GenerateTopSpec get rid of Console.withOut
This commit is contained in:
@@ -7,25 +7,25 @@ import firrtl.FileUtils
|
|||||||
import org.scalatest.freespec.AnyFreeSpec
|
import org.scalatest.freespec.AnyFreeSpec
|
||||||
import org.scalatest.matchers.should.Matchers
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
|
||||||
import java.io.{ByteArrayOutputStream, File, PrintStream, PrintWriter}
|
import java.io.{File, PrintWriter}
|
||||||
|
|
||||||
class GenerateTopSpec extends AnyFreeSpec with Matchers {
|
class GenerateTopSpec extends AnyFreeSpec with Matchers {
|
||||||
"Generate top and harness" - {
|
"Generate top and harness" - {
|
||||||
"should include the following transforms" in {
|
"should include the following transforms" in {
|
||||||
val targetDir = "test_run_dir/generate_top_and_harness"
|
val targetDir = "test_run_dir/generate_top_and_harness"
|
||||||
|
val transformListName = s"$targetDir/ExampleModuleNeesResetInvertTransforms.log"
|
||||||
FileUtils.makeDirectory(targetDir)
|
FileUtils.makeDirectory(targetDir)
|
||||||
(new ChiselStage).emitChirrtl(new ExampleModuleNeedsResetInverted, Array("--target-dir", targetDir))
|
(new ChiselStage).emitChirrtl(new ExampleModuleNeedsResetInverted, Array("--target-dir", targetDir))
|
||||||
|
|
||||||
val buffer = new ByteArrayOutputStream()
|
GenerateTopAndHarness.main(
|
||||||
Console.withOut(new PrintStream(buffer)) {
|
Array(
|
||||||
GenerateTopAndHarness.main(
|
"-i", s"$targetDir/ExampleModuleNeedsResetInverted.fir",
|
||||||
Array(
|
"-ll", "info",
|
||||||
"-i", s"$targetDir/ExampleModuleNeedsResetInverted.fir",
|
"--log-file", transformListName
|
||||||
"-ll", "info"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
val output = buffer.toString
|
|
||||||
|
val output = FileUtils.getText(transformListName)
|
||||||
output should include("barstools.tapeout.transforms.AddSuffixToModuleNames")
|
output should include("barstools.tapeout.transforms.AddSuffixToModuleNames")
|
||||||
output should include("barstools.tapeout.transforms.ConvertToExtMod")
|
output should include("barstools.tapeout.transforms.ConvertToExtMod")
|
||||||
output should include("barstools.tapeout.transforms.RemoveUnusedModules")
|
output should include("barstools.tapeout.transforms.RemoveUnusedModules")
|
||||||
@@ -33,8 +33,9 @@ class GenerateTopSpec extends AnyFreeSpec with Matchers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"generate harness should " ignore {
|
"generate harness should be generated" ignore {
|
||||||
val targetDir = "test_run_dir/generate_top_spec"
|
val targetDir = "test_run_dir/generate_top_spec"
|
||||||
|
val logOutputName = s"$targetDir/top_spec_output.log"
|
||||||
FileUtils.makeDirectory(targetDir)
|
FileUtils.makeDirectory(targetDir)
|
||||||
|
|
||||||
val input = FileUtils.getLinesResource("/BlackBoxFloatTester.fir")
|
val input = FileUtils.getLinesResource("/BlackBoxFloatTester.fir")
|
||||||
@@ -44,34 +45,32 @@ class GenerateTopSpec extends AnyFreeSpec with Matchers {
|
|||||||
|
|
||||||
println(s"""Resource: ${input.mkString("\n")}""")
|
println(s"""Resource: ${input.mkString("\n")}""")
|
||||||
|
|
||||||
|
GenerateTopAndHarness.main(
|
||||||
// val buffer = new ByteArrayOutputStream()
|
Array(
|
||||||
// Console.withOut(new PrintStream(buffer)) {
|
"--target-dir", "test_run_dir/generate_top_spec",
|
||||||
GenerateTopAndHarness.main(
|
"-i", s"$targetDir/BlackBoxFloatTester.fir",
|
||||||
Array(
|
"-o", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.v",
|
||||||
"--target-dir", "test_run_dir/generate_top_spec",
|
"-tho", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.v",
|
||||||
"-i", s"$targetDir/BlackBoxFloatTester.fir",
|
"-i", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.fir",
|
||||||
"-o",
|
"--syn-top", "UnitTestSuite",
|
||||||
"chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.v",
|
"--harness-top", "TestHarness",
|
||||||
"-tho", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.v",
|
"-faf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.anno.json",
|
||||||
"-i", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.fir",
|
"-tsaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.anno.json",
|
||||||
"--syn-top", "UnitTestSuite",
|
"-tdf", "firrtl_black_box_resource_files.top.f",
|
||||||
"--harness-top", "TestHarness",
|
"-tsf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.fir",
|
||||||
"-faf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.anno.json",
|
"-thaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.anno.json",
|
||||||
"-tsaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.anno.json",
|
"-hdf", "firrtl_black_box_resource_files.harness.f",
|
||||||
"-tdf", "firrtl_black_box_resource_files.top.f",
|
"-thf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.fir",
|
||||||
"-tsf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.fir",
|
"--infer-rw",
|
||||||
"-thaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.anno.json",
|
"--repl-seq-mem", "-c:TestHarness:-o:chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.mems.conf",
|
||||||
"-hdf", "firrtl_black_box_resource_files.harness.f",
|
"-thconf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.mems.conf",
|
||||||
"-thf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.fir",
|
"-td", "test_run_dir/from-ci",
|
||||||
"--infer-rw",
|
"-ll", "info",
|
||||||
"--repl-seq-mem", "-c:TestHarness:-o:chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.mems.conf",
|
"--log-file", logOutputName
|
||||||
"-thconf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.mems.conf",
|
|
||||||
"-td", "test_run_dir/from-ci",
|
|
||||||
"-ll", "info"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
// val output = buffer.toString
|
|
||||||
// println(output)
|
val output = FileUtils.getText(logOutputName)
|
||||||
|
println(output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
//// SPDX-License-Identifier: Apache-2.0
|
|
||||||
//
|
|
||||||
//package barstools.tapeout.transforms
|
|
||||||
//
|
|
||||||
//import firrtl.AnnotationSeq
|
|
||||||
//import firrtl.options.{Shell, Stage, StageMain}
|
|
||||||
//import firrtl.stage.{FirrtlCli, FirrtlStage}
|
|
||||||
//import logger.Logger.OutputCaptor
|
|
||||||
//import logger.{LazyLogging, LogLevel, Logger}
|
|
||||||
//import org.scalatest.freespec.AnyFreeSpec
|
|
||||||
//
|
|
||||||
//import java.io.{ByteArrayOutputStream, PrintStream}
|
|
||||||
//
|
|
||||||
//class NoFileStage extends Stage {
|
|
||||||
// override val shell: Shell = new Shell(applicationName = "tapeout") with FirrtlCli
|
|
||||||
//
|
|
||||||
// override def run(annotations: AnnotationSeq): AnnotationSeq = {
|
|
||||||
// Logger.makeScope(annotations) {
|
|
||||||
// val annos = new FirrtlStage().execute(Array.empty, annotations)
|
|
||||||
// }
|
|
||||||
// annotations
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//class NoFileGenerator(annotationSeq: AnnotationSeq) extends LazyLogging {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//object NoFileGenerator extends StageMain(new NoFileStage)
|
|
||||||
//
|
|
||||||
//class NoFileProblem extends AnyFreeSpec {
|
|
||||||
// // "should fail in a way that discloses missing file" - {
|
|
||||||
// // (new NoFileStage).execute(Array("-i", "jackalope"), Seq.empty)
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// "should fail in a way that discloses missing file with output capture" in {
|
|
||||||
// val buffer = new ByteArrayOutputStream()
|
|
||||||
// Console.withOut(new PrintStream(buffer)) {
|
|
||||||
// NoFileGenerator.main(Array("-i", "jackalope", "-ll", "info"))
|
|
||||||
// }
|
|
||||||
// println(buffer.toString)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// "don't uses Console.withOut" in {
|
|
||||||
// val captor = new OutputCaptor
|
|
||||||
// Logger.setOutput(captor.printStream)
|
|
||||||
// Logger.setLevel(getClass.getName, LogLevel.Info)
|
|
||||||
// NoFileGenerator.main(Array("-i", "jackalope", "-ll", "info"))
|
|
||||||
// println(captor.getOutputAsString)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
Reference in New Issue
Block a user