aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/ChirrtlSpec.scala7
-rw-r--r--src/test/scala/firrtlTests/ExpandWhensSpec.scala6
-rw-r--r--src/test/scala/firrtlTests/FeatureSpec.scala7
-rw-r--r--src/test/scala/firrtlTests/FirrtlSpec.scala41
-rw-r--r--src/test/scala/firrtlTests/IntegrationSpec.scala29
-rw-r--r--src/test/scala/firrtlTests/LegalizeSpec.scala7
6 files changed, 52 insertions, 45 deletions
diff --git a/src/test/scala/firrtlTests/ChirrtlSpec.scala b/src/test/scala/firrtlTests/ChirrtlSpec.scala
index a24cd9fa..04f66d08 100644
--- a/src/test/scala/firrtlTests/ChirrtlSpec.scala
+++ b/src/test/scala/firrtlTests/ChirrtlSpec.scala
@@ -93,8 +93,7 @@ class ChirrtlSpec extends FirrtlFlatSpec {
}
}
}
-
- it should "compile and run" in {
- runFirrtlTest("ChirrtlMems", "/features")
- }
}
+
+class ChirrtlMemsExecutionTest extends ExecutionTest("ChirrtlMems", "/features")
+
diff --git a/src/test/scala/firrtlTests/ExpandWhensSpec.scala b/src/test/scala/firrtlTests/ExpandWhensSpec.scala
index 82809dc8..8bbecaeb 100644
--- a/src/test/scala/firrtlTests/ExpandWhensSpec.scala
+++ b/src/test/scala/firrtlTests/ExpandWhensSpec.scala
@@ -47,9 +47,6 @@ class ExpandWhensSpec extends FirrtlFlatSpec {
l.contains(notExpected) should be (false)
}
}
- "Expand Whens" should "compile and run" in {
- runFirrtlTest("ExpandWhens", "/passes/ExpandWhens")
- }
"Expand Whens" should "not emit INVALID" in {
val passes = Seq(
ToWorkingIR,
@@ -80,3 +77,6 @@ class ExpandWhensSpec extends FirrtlFlatSpec {
executeTest(input, check, passes)
}
}
+
+class ExpandWhensExecutionTest extends ExecutionTest("ExpandWhens", "/passes/ExpandWhens")
+
diff --git a/src/test/scala/firrtlTests/FeatureSpec.scala b/src/test/scala/firrtlTests/FeatureSpec.scala
index 2a2179db..0a474b72 100644
--- a/src/test/scala/firrtlTests/FeatureSpec.scala
+++ b/src/test/scala/firrtlTests/FeatureSpec.scala
@@ -30,10 +30,5 @@ package firrtlTests
import org.scalatest._
// Miscellaneous Feature Checks
-class FeatureSpec extends FirrtlPropSpec {
-
- property("Nested SubAccesses should be supported!") {
- runFirrtlTest("NestedSubAccessTester", "/features")
- }
-}
+class NestedSubAccessExecutionTest extends ExecutionTest("NestedSubAccessTester", "/features")
diff --git a/src/test/scala/firrtlTests/FirrtlSpec.scala b/src/test/scala/firrtlTests/FirrtlSpec.scala
index 682aadee..f491b0f5 100644
--- a/src/test/scala/firrtlTests/FirrtlSpec.scala
+++ b/src/test/scala/firrtlTests/FirrtlSpec.scala
@@ -132,6 +132,12 @@ trait BackendCompilationUtilities {
trait FirrtlRunners extends BackendCompilationUtilities {
lazy val cppHarness = new File(s"/top.cpp")
+ /** Compile a Firrtl file
+ *
+ * @param prefix is the name of the Firrtl file without path or file extension
+ * @param srcDir directory where all Resources for this test are located
+ * @param annotations Optional Firrtl annotations
+ */
def compileFirrtlTest(
prefix: String,
srcDir: String,
@@ -147,15 +153,30 @@ trait FirrtlRunners extends BackendCompilationUtilities {
annotations)
testDir
}
+ /** Execute a Firrtl Test
+ *
+ * @param prefix is the name of the Firrtl file without path or file extension
+ * @param srcDir directory where all Resources for this test are located
+ * @param verilogPrefixes names of option Verilog resources without path or file extension
+ * @param annotations Optional Firrtl annotations
+ */
def runFirrtlTest(
prefix: String,
srcDir: String,
+ verilogPrefixes: Seq[String] = Seq.empty,
annotations: AnnotationMap = new AnnotationMap(Seq.empty)) = {
val testDir = compileFirrtlTest(prefix, srcDir, annotations)
val harness = new File(testDir, s"top.cpp")
copyResourceToFile(cppHarness.toString, harness)
- verilogToCpp(prefix, testDir, Seq(), harness).!
+ // Note file copying side effect
+ val verilogFiles = verilogPrefixes map { vprefix =>
+ val file = new File(testDir, s"$vprefix.v")
+ copyResourceToFile(s"$srcDir/$vprefix.v", file)
+ file
+ }
+
+ verilogToCpp(prefix, testDir, verilogFiles, harness).!
cppToExe(prefix, testDir).!
assert(executeExpectingSuccess(prefix, testDir))
}
@@ -171,7 +192,21 @@ trait FirrtlMatchers {
}
}
-class FirrtlPropSpec extends PropSpec with PropertyChecks with FirrtlRunners with LazyLogging
+abstract class FirrtlPropSpec extends PropSpec with PropertyChecks with FirrtlRunners with LazyLogging
+
+abstract class FirrtlFlatSpec extends FlatSpec with Matchers with FirrtlRunners with FirrtlMatchers with LazyLogging
+
+/** Super class for execution driven Firrtl tests */
+abstract class ExecutionTest(name: String, dir: String, vFiles: Seq[String] = Seq.empty) extends FirrtlPropSpec {
+ property(s"$name should execute correctly") {
+ runFirrtlTest(name, dir, vFiles)
+ }
+}
+/** Super class for compilation driven Firrtl tests */
+abstract class CompilationTest(name: String, dir: String) extends FirrtlPropSpec {
+ property(s"$name should compile correctly") {
+ compileFirrtlTest(name, dir)
+ }
+}
-class FirrtlFlatSpec extends FlatSpec with Matchers with FirrtlRunners with FirrtlMatchers with LazyLogging
diff --git a/src/test/scala/firrtlTests/IntegrationSpec.scala b/src/test/scala/firrtlTests/IntegrationSpec.scala
index e99a6e36..dd456589 100644
--- a/src/test/scala/firrtlTests/IntegrationSpec.scala
+++ b/src/test/scala/firrtlTests/IntegrationSpec.scala
@@ -30,28 +30,11 @@ package firrtlTests
import org.scalatest._
import org.scalatest.prop._
-class IntegrationSpec extends FirrtlPropSpec {
+class GCDExecutionTest extends ExecutionTest("GCDTester", "/integration")
+class RightShiftExecutionTest extends ExecutionTest("RightShiftTester", "/integration")
+class MemExecutionTest extends ExecutionTest("MemTester", "/integration")
- case class Test(name: String, dir: String)
+class RocketCompilationTest extends CompilationTest("rocket", "/regress")
+class RocketFirrtlCompilationTest extends CompilationTest("rocket-firrtl", "/regress")
+class BOOMRobCompilationTest extends CompilationTest("Rob", "/regress")
- val runTests = Seq(Test("GCDTester", "/integration"),
- Test("RightShiftTester", "/integration"),
- Test("MemTester", "/integration"))
-
-
- runTests foreach { test =>
- property(s"${test.name} should execute correctly") {
- runFirrtlTest(test.name, test.dir)
- }
- }
-
- val compileTests = Seq(Test("rocket", "/regress"),
- Test("rocket-firrtl", "/regress"),
- Test("Rob", "/regress"))
-
- compileTests foreach { test =>
- property(s"${test.name} should compile to Verilog") {
- compileFirrtlTest(test.name, test.dir)
- }
- }
-}
diff --git a/src/test/scala/firrtlTests/LegalizeSpec.scala b/src/test/scala/firrtlTests/LegalizeSpec.scala
index 781f93d7..7caa2efe 100644
--- a/src/test/scala/firrtlTests/LegalizeSpec.scala
+++ b/src/test/scala/firrtlTests/LegalizeSpec.scala
@@ -29,10 +29,5 @@ package firrtlTests
import firrtl._
-class LegalizeSpec extends FirrtlFlatSpec {
- behavior of "Legalize"
+class LegalizeExecutionTest extends ExecutionTest("Legalize", "/passes/Legalize")
- it should "compile and run" in {
- runFirrtlTest("Legalize", "/passes/Legalize")
- }
-}