aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/FirrtlSpec.scala
diff options
context:
space:
mode:
authorjackkoenig2016-09-22 18:53:02 -0700
committerJack Koenig2016-10-26 15:15:37 -0700
commitd7bf4656f27de63474eec018c689e5b28e3472d8 (patch)
treecf597b9be0a78222bda1fd73b427ebe2a23ba5c0 /src/test/scala/firrtlTests/FirrtlSpec.scala
parentd344f4400ad5e9c71c97229e33660bbe067260a0 (diff)
Improve integration test API and add support for Verilog resources
Change integration tests to be classes that extend abstract classes. This allows them to be run in parallel. Also expand API to support Verilog resources in integration tests.
Diffstat (limited to 'src/test/scala/firrtlTests/FirrtlSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/FirrtlSpec.scala41
1 files changed, 38 insertions, 3 deletions
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