diff options
Diffstat (limited to 'src/test/scala/firrtlTests/DriverSpec.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/DriverSpec.scala | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala index 4e1add39..9cbeb6f9 100644 --- a/src/test/scala/firrtlTests/DriverSpec.scala +++ b/src/test/scala/firrtlTests/DriverSpec.scala @@ -66,7 +66,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities val firrtlOptions = optionsManager.firrtlOptions val inputFileName = optionsManager.getBuildFileName("fir", firrtlOptions.inputFileNameOverride) inputFileName should be ("./cat.fir") - val outputFileName = optionsManager.getBuildFileName("v", firrtlOptions.outputFileNameOverride) + val outputFileName = firrtlOptions.getTargetFile(optionsManager) outputFileName should be ("./cat.v") } "input and output file names can be overridden, overrides do not use targetDir" in { @@ -79,7 +79,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities val firrtlOptions = optionsManager.firrtlOptions val inputFileName = optionsManager.getBuildFileName("fir", firrtlOptions.inputFileNameOverride) inputFileName should be ("./bob.fir") - val outputFileName = optionsManager.getBuildFileName("v", firrtlOptions.outputFileNameOverride) + val outputFileName = firrtlOptions.getTargetFile(optionsManager) outputFileName should be ("carol.v") } "various annotations can be created from command line, currently:" - { @@ -142,26 +142,31 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities annotationsTestFile.delete() } - val input = - """ - |circuit Dummy : - | module Dummy : - | input x : UInt<1> - | output y : UInt<1> - | y <= x - """.stripMargin - - "Driver produces files with different names depending on the compiler" - { - "compiler changes the default name of the output file" in { - + "Circuits are emitted on properly" - { + val input = + """|circuit Top : + | module Top : + | output foo : UInt<32> + | inst c of Child + | inst e of External + | foo <= tail(add(c.foo, e.foo), 1) + | module Child : + | output foo : UInt<32> + | inst e of External + | foo <= e.foo + | extmodule External : + | output foo : UInt<32> + """.stripMargin + + "To a single file with file extension depending on the compiler by default" in { Seq( - "low" -> "./Dummy.lo.fir", - "high" -> "./Dummy.hi.fir", - "middle" -> "./Dummy.mid.fir", - "verilog" -> "./Dummy.v" + "low" -> "./Top.lo.fir", + "high" -> "./Top.hi.fir", + "middle" -> "./Top.mid.fir", + "verilog" -> "./Top.v" ).foreach { case (compilerName, expectedOutputFileName) => val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = CommonOptions(topName = "Dummy") + commonOptions = CommonOptions(topName = "Top") firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input), compilerName = compilerName) } @@ -172,8 +177,33 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities file.delete() } } + "To a single file per module if OneFilePerModule is specified" in { + Seq( + "low" -> Seq("./Top.lo.fir", "./Child.lo.fir"), + "high" -> Seq("./Top.hi.fir", "./Child.hi.fir"), + "middle" -> Seq("./Top.mid.fir", "./Child.mid.fir"), + "verilog" -> Seq("./Top.v", "./Child.v") + ).foreach { case (compilerName, expectedOutputFileNames) => + println(s"$compilerName -> $expectedOutputFileNames") + val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions { + commonOptions = CommonOptions(topName = "Top") + firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input), + compilerName = compilerName, + emitOneFilePerModule = true) + } + + firrtl.Driver.execute(manager) + + for (name <- expectedOutputFileNames) { + val file = new File(name) + file.exists() should be (true) + file.delete() + } + } + } } + "Directory deleter is handy for cleaning up after tests" - { "for example making a directory tree, and deleting it looks like" in { FileUtils.makeDirectory("dog/fox/wolf") |
