To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 021cfc1b authored by Kunshan Wang's avatar Kunshan Wang
Browse files

Swapped the SimpleTests and SimpleSumTest file names.

parent 544b3598
......@@ -13,119 +13,50 @@ import uvm.refimpl.mem.TypeSizes.Word
import ch.qos.logback.classic.Level._
import uvm.refimpl.UvmBundleTesterBase
class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
class UvmInterpreterSimpleSumTest extends UvmBundleTesterBase {
setLogLevels(
ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.itpr" -> DEBUG)
"uvm.refimpl.itpr" -> INFO)
preloadBundles("tests/uvm-refimpl-test/primitives.uir",
"tests/uvm-refimpl-test/simple-tests.uir")
"tests/uvm-refimpl-test/simple-sum.uir")
"Factorial functions" should "work" in {
"Simple sum" should "work" in {
val ca = microVM.newClientAgent()
val func = ca.putFunction("@test_fac")
val from = 1L
val to = 1000000L
val expectedSum = (from + to) * (to - from + 1L) / 2L
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val Seq(r1, r2, r3) = ca.dumpKeepalives(st, 0)
val hFrom = ca.putInt("@i64", from)
val hTo = ca.putInt("@i64", to)
r1.vb.asInt shouldEqual 3628800
r2.vb.asInt shouldEqual 3628800
r3.vb.asInt shouldEqual 3628800
val func = ca.putFunction("@simplesum")
TrapRebindPassVoid(st)
}
ca.close()
}
"Fibonacci functions" should "work" in {
val ca = microVM.newClientAgent()
val func = ca.putFunction("@test_fib")
val watch = true
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@fibonacci_mat_v1.watch" => {
if (watch) {
val vhs = ca.dumpKeepalives(st, 0)
val vs = vhs.map(_.vb.asInt)
println("watch " + vs)
}
TrapRebindPassVoid(st)
}
case "@test_fib_v1.checktrap" => {
val Seq(r1, r2) = ca.dumpKeepalives(st, 0)
r1.vb.asInt shouldEqual 55
r2.vb.asInt shouldEqual 55
var t1: Long = 0L
var t2: Long = 0L
testFunc(ca, func, Seq(hFrom, hTo)) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@simplesum_v1.starttrap" => {
t1 = System.currentTimeMillis()
TrapRebindPassVoid(st)
}
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
}
"Coroutine test" should "work" in {
val ca = microVM.newClientAgent()
case "@simplesum_v1.exittrap" => {
t2 = System.currentTimeMillis()
val func = ca.putFunction("@test_coroutine")
val Seq(sum) = ca.dumpKeepalives(st, 0)
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@test_coroutine_v1.trap_body" => {
val Seq(v) = ca.dumpKeepalives(st, 0)
println(v.vb.asSInt(64))
TrapRebindPassVoid(st)
}
case "@test_coroutine_v1.trap_exit" => {
val Seq(exc) = ca.dumpKeepalives(st, 0)
val hsi = ca.putGlobal("@StopIteration")
val hrsi = ca.load(MemoryOrder.NOT_ATOMIC, hsi)
exc.vb.asRef shouldEqual hrsi.vb.asRef
sum.vb.asSInt(64) shouldBe expectedSum
TrapRebindPassVoid(st)
}
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
}
"Multi-threading test" should "work" in {
val ca = microVM.newClientAgent()
val func = ca.putFunction("@test_multithreading")
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@test_multithreading_v1.trap_result" => {
val Seq(v) = ca.dumpKeepalives(st, 0)
v.vb.asSInt(64) shouldEqual 4950
TrapRebindPassVoid(st)
}
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
val timeDiff = t2 - t1
printf("Time: %d ms".format(timeDiff))
}
}
\ No newline at end of file
......@@ -13,50 +13,119 @@ import uvm.refimpl.mem.TypeSizes.Word
import ch.qos.logback.classic.Level._
import uvm.refimpl.UvmBundleTesterBase
class UvmInterpreterSimpleSumTest extends UvmBundleTesterBase {
class UvmInterpreterSimpleTests extends UvmBundleTesterBase {
setLogLevels(
ROOT_LOGGER_NAME -> INFO,
"uvm.refimpl.itpr" -> INFO)
"uvm.refimpl.itpr" -> DEBUG)
preloadBundles("tests/uvm-refimpl-test/primitives.uir",
"tests/uvm-refimpl-test/simple-sum.uir")
"tests/uvm-refimpl-test/simple-tests.uir")
"Simple sum" should "work" in {
"Factorial functions" should "work" in {
val ca = microVM.newClientAgent()
val from = 1L
val to = 1000000L
val expectedSum = (from + to) * (to - from + 1L) / 2L
val func = ca.putFunction("@test_fac")
val hFrom = ca.putInt("@i64", from)
val hTo = ca.putInt("@i64", to)
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val Seq(r1, r2, r3) = ca.dumpKeepalives(st, 0)
val func = ca.putFunction("@simplesum")
r1.vb.asInt shouldEqual 3628800
r2.vb.asInt shouldEqual 3628800
r3.vb.asInt shouldEqual 3628800
var t1: Long = 0L
var t2: Long = 0L
TrapRebindPassVoid(st)
}
ca.close()
}
"Fibonacci functions" should "work" in {
val ca = microVM.newClientAgent()
val func = ca.putFunction("@test_fib")
val watch = true
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@fibonacci_mat_v1.watch" => {
if (watch) {
val vhs = ca.dumpKeepalives(st, 0)
val vs = vhs.map(_.vb.asInt)
println("watch " + vs)
}
TrapRebindPassVoid(st)
}
case "@test_fib_v1.checktrap" => {
val Seq(r1, r2) = ca.dumpKeepalives(st, 0)
r1.vb.asInt shouldEqual 55
r2.vb.asInt shouldEqual 55
testFunc(ca, func, Seq(hFrom, hTo)) { (ca, th, st, wp) =>
nameOf(ca.currentInstruction(st, 0)) match {
case "@simplesum_v1.starttrap" => {
t1 = System.currentTimeMillis()
TrapRebindPassVoid(st)
}
case "@simplesum_v1.exittrap" => {
t2 = System.currentTimeMillis()
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
}
"Coroutine test" should "work" in {
val ca = microVM.newClientAgent()
val Seq(sum) = ca.dumpKeepalives(st, 0)
val func = ca.putFunction("@test_coroutine")
sum.vb.asSInt(64) shouldBe expectedSum
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@test_coroutine_v1.trap_body" => {
val Seq(v) = ca.dumpKeepalives(st, 0)
println(v.vb.asSInt(64))
TrapRebindPassVoid(st)
}
case "@test_coroutine_v1.trap_exit" => {
val Seq(exc) = ca.dumpKeepalives(st, 0)
val hsi = ca.putGlobal("@StopIteration")
val hrsi = ca.load(MemoryOrder.NOT_ATOMIC, hsi)
exc.vb.asRef shouldEqual hrsi.vb.asRef
TrapRebindPassVoid(st)
}
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
}
"Multi-threading test" should "work" in {
val ca = microVM.newClientAgent()
val func = ca.putFunction("@test_multithreading")
val timeDiff = t2 - t1
printf("Time: %d ms".format(timeDiff))
testFunc(ca, func, Seq()) { (ca, th, st, wp) =>
val trapName = nameOf(ca.currentInstruction(st, 0))
trapName match {
case "@test_multithreading_v1.trap_result" => {
val Seq(v) = ca.dumpKeepalives(st, 0)
v.vb.asSInt(64) shouldEqual 4950
TrapRebindPassVoid(st)
}
case _ => fail("Should not hit " + trapName)
}
}
ca.close()
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment