@@ -7,10 +7,12 @@ import be.ugent.topl.mio.debugger.Debugger
77import org.junit.jupiter.api.DisplayName
88import org.junit.jupiter.api.Nested
99import org.junit.jupiter.api.Test
10+ import org.junit.jupiter.api.extension.ExtensionContext
1011import org.junit.jupiter.params.ParameterizedTest
11- import org.junit.jupiter.params.provider.CsvSource
12- import org.junit.jupiter.params.provider.ValueSource
12+ import org.junit.jupiter.params.provider.*
1313import java.io.File
14+ import java.util.stream.Stream
15+ import kotlin.random.Random
1416import kotlin.test.assertEquals
1517import kotlin.test.assertNotNull
1618
@@ -26,6 +28,7 @@ class ConcolicTests : DebuggerTestBase() {
2628 private fun makeWat (content : String ): String {
2729 return " (module\n " +
2830 " (import \" env\" \" chip_analog_read\" (func \$ chip_analog_read (param i32) (result i32)))\n " +
31+ " (memory \$ memory 1)" +
2932 " (func \$ main (local i32)\n " +
3033 content +
3134 " )\n (export \" main\" (func \$ main)))"
@@ -103,6 +106,33 @@ class ConcolicTests : DebuggerTestBase() {
103106 assertEquals(2 ,result.paths.size)
104107 }
105108
109+ class MemoryAddressProvider : ArgumentsProvider {
110+ override fun provideArguments (context : ExtensionContext ? ): Stream <out Arguments ?> =
111+ (1 .. 10 ).map { Arguments .of(Random .nextInt(65536 - 4 )) }.stream()
112+ }
113+
114+ @ParameterizedTest(name = " Test wat if 2 paths with memory [address={0}]" )
115+ @ArgumentsSource(MemoryAddressProvider ::class )
116+ fun `Test wat if 2 paths memory` (address : Int ) {
117+ // val address = Random.nextInt(65536 - 4)
118+ val watString = makeWat($$"""
119+ i32.const $$address ;; Memory address
120+ i32.const 0 ;; Arg for analog_read
121+ call $chip_analog_read
122+ i32.store
123+
124+ i32.const $$address
125+ i32.load
126+ i32.const 10
127+ i32.lt_s
128+ if
129+ nop
130+ end
131+ """ .trimIndent())
132+ val result = getPathsFromWat(watString)
133+ assertEquals(2 , result.paths.size)
134+ }
135+
106136 @Test
107137 fun `Test wat if 3 paths` () {
108138 val watString = makeWat($$"""
0 commit comments