Set up testing infrastructure ("make test")

This commit is contained in:
Robert Xiao
2023-05-05 16:24:45 -07:00
parent 4b471e16e9
commit 66c8965f96
14 changed files with 151 additions and 19 deletions

View File

@@ -0,0 +1,39 @@
package tests;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
public class TestSamples {
private final ByteArrayOutputStream outContent =
new ByteArrayOutputStream();
private final PrintStream originalOut = System.out;
@Before
public void setUpStreams() {
outContent.reset();
System.setOut(new PrintStream(outContent));
}
@After
public void restoreStreams() {
System.setOut(originalOut);
}
@Test
public void testArm() {
samples.Sample_arm.test_arm();
assertEquals("testArm",
"Emulate ARM code\n" +
">>> Tracing basic block at 0x10000, block size = 0x8\n" +
">>> Tracing instruction at 0x10000, instruction size = 0x4\n" +
">>> Emulation done. Below is the CPU context\n" +
">>> R0 = 0x37\n" +
">>> R1 = 0x3456\n",
outContent.toString());
}
}