Merge branch 'master' of https://github.com/PeterAaser/TDT4255_EX2
This commit is contained in:
commit
2e37f0b8d7
17 changed files with 478 additions and 260 deletions
|
@ -19,7 +19,7 @@ import LogParser._
|
|||
|
||||
object Manifest {
|
||||
|
||||
val singleTest = "forward2.s"
|
||||
val singleTest = "addi.s"
|
||||
|
||||
val nopPadded = false
|
||||
|
||||
|
@ -96,3 +96,30 @@ class AllTests extends FlatSpec with Matchers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Not tested at all
|
||||
*/
|
||||
class AllTestsWindows extends FlatSpec with Matchers {
|
||||
it should "just werk" in {
|
||||
val werks = getAllWindowsTestNames.filterNot(_ == "convolution.s").map{testname =>
|
||||
say(s"testing $testname")
|
||||
val opts = Manifest.allTestOptions(testname)
|
||||
(testname, TestRunner.run(opts))
|
||||
}
|
||||
if(werks.foldLeft(true)(_ && _._2))
|
||||
say(Console.GREEN + "All tests successful!" + Console.RESET)
|
||||
else {
|
||||
val success = werks.map(x => if(x._2) 1 else 0).sum
|
||||
val total = werks.size
|
||||
say(s"$success/$total tests successful")
|
||||
werks.foreach{ case(name, success) =>
|
||||
val msg = if(success) Console.GREEN + s"$name successful" + Console.RESET
|
||||
else Console.RED + s"$name failed" + Console.RESET
|
||||
say(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ case class TestOptions(
|
|||
printVMtrace : Boolean,
|
||||
printVMfinal : Boolean,
|
||||
printMergedTrace : Boolean,
|
||||
printBinary : Boolean,
|
||||
nopPadded : Boolean,
|
||||
breakPoints : List[Int], // Not implemented
|
||||
testName : String,
|
||||
|
@ -35,7 +36,8 @@ case class TestResult(
|
|||
program : String,
|
||||
vmTrace : String,
|
||||
vmFinal : String,
|
||||
sideBySide : String
|
||||
sideBySide : String,
|
||||
binary : String
|
||||
)
|
||||
|
||||
object TestRunner {
|
||||
|
@ -50,7 +52,8 @@ object TestRunner {
|
|||
binary.toList.sortBy(_._1.value).map(_._2),
|
||||
program.settings,
|
||||
finalVM.pc,
|
||||
testOptions.maxSteps)
|
||||
testOptions.maxSteps,
|
||||
testOptions.testName)
|
||||
} yield {
|
||||
val traces = mergeTraces(trace, chiselTrace).map(x => printMergedTraces((x), program))
|
||||
|
||||
|
@ -58,6 +61,7 @@ object TestRunner {
|
|||
val vmTraceString = printVMtrace(trace, program)
|
||||
val vmFinalState = finalVM.regs.show
|
||||
val traceString = printLogSideBySide(trace, chiselTrace, program)
|
||||
val binaryString = printBinary(binary)
|
||||
|
||||
val regError = compareRegs(trace, chiselTrace)
|
||||
val memError = compareMem(trace, chiselTrace)
|
||||
|
@ -68,7 +72,8 @@ object TestRunner {
|
|||
programString,
|
||||
vmTraceString,
|
||||
vmFinalState.toString,
|
||||
traceString)
|
||||
traceString,
|
||||
binaryString)
|
||||
}
|
||||
|
||||
testResults.left.foreach{ error =>
|
||||
|
@ -78,15 +83,16 @@ object TestRunner {
|
|||
testResults.map{ testResults =>
|
||||
val successful = List(testResults.regError, testResults.memError).flatten.headOption.map(_ => false).getOrElse(true)
|
||||
if(successful)
|
||||
say(s"${testOptions.testName} succesful")
|
||||
sayGreen(s"${testOptions.testName} succesful")
|
||||
else
|
||||
say(s"${testOptions.testName} failed")
|
||||
sayRed(s"${testOptions.testName} failed")
|
||||
|
||||
if(testOptions.printIfSuccessful && successful){
|
||||
if(testOptions.printParsedProgram) say(testResults.program)
|
||||
if(testOptions.printVMtrace) say(testResults.vmTrace)
|
||||
if(testOptions.printVMfinal) say(testResults.vmFinal)
|
||||
if(testOptions.printMergedTrace) say(testResults.sideBySide)
|
||||
if(testOptions.printBinary) say(testResults.binary)
|
||||
}
|
||||
else{
|
||||
if(testOptions.printErrors){
|
||||
|
@ -97,6 +103,7 @@ object TestRunner {
|
|||
if(testOptions.printVMtrace) say(testResults.vmTrace)
|
||||
if(testOptions.printVMfinal) say(testResults.vmFinal)
|
||||
if(testOptions.printMergedTrace) say(testResults.sideBySide)
|
||||
if(testOptions.printBinary) say(testResults.binary)
|
||||
}
|
||||
successful
|
||||
}.toOption.getOrElse(false)
|
||||
|
|
|
@ -159,12 +159,18 @@ object ChiselTestRunner {
|
|||
binary : List[Int],
|
||||
settings : List[TestSetting],
|
||||
terminalAddress : Addr,
|
||||
maxSteps : Int): Either[String, (Option[String], List[CircuitTrace])] = {
|
||||
maxSteps : Int,
|
||||
testName : String): Either[String, (Option[String], List[CircuitTrace])] = {
|
||||
|
||||
var sideEffectExtravaganza: Option[(Option[String], List[CircuitTrace])] = None
|
||||
|
||||
val error: Either[String, Boolean] = scala.util.Try {
|
||||
chisel3.iotesters.Driver(() => new Tile(), "treadle") { c =>
|
||||
chisel3.iotesters.Driver.execute(Array(
|
||||
"--generate-vcd-output", "on",
|
||||
"--backend-name", "treadle",
|
||||
"--target-dir", "waveforms",
|
||||
"--top-name", testName
|
||||
), () => new Tile) { c =>
|
||||
new PeekPokeTester(c) {
|
||||
val testRunner = new ChiselTestRunner(
|
||||
binary,
|
||||
|
|
|
@ -61,7 +61,10 @@ object fileUtils {
|
|||
def getAllTests: List[File] = getListOfFilesRecursive(getTestDir.getPath)
|
||||
.filter( f => f.getPath.endsWith(".s") )
|
||||
|
||||
def getAllTestNames: List[String] = getAllTests.map(_.toString.split("/").takeRight(1).mkString)
|
||||
def getAllTestNames: List[String] = getAllTests.map(_.toString.split("/").takeRight(1).mkString)
|
||||
|
||||
// Not tested.
|
||||
def getAllWindowsTestNames: List[String] = getAllTests.map(_.toString.split("\\\\").takeRight(1).mkString)
|
||||
|
||||
def clearTestResults = {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue