GenerateTopSpec get rid of Console.withOut

This commit is contained in:
chick
2021-08-10 18:04:49 -07:00
parent 08eba27126
commit b2cee7ccb8
2 changed files with 39 additions and 91 deletions

View File

@@ -7,25 +7,25 @@ import firrtl.FileUtils
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import java.io.{ByteArrayOutputStream, File, PrintStream, PrintWriter}
import java.io.{File, PrintWriter}
class GenerateTopSpec extends AnyFreeSpec with Matchers {
"Generate top and harness" - {
"should include the following transforms" in {
val targetDir = "test_run_dir/generate_top_and_harness"
val transformListName = s"$targetDir/ExampleModuleNeesResetInvertTransforms.log"
FileUtils.makeDirectory(targetDir)
(new ChiselStage).emitChirrtl(new ExampleModuleNeedsResetInverted, Array("--target-dir", targetDir))
val buffer = new ByteArrayOutputStream()
Console.withOut(new PrintStream(buffer)) {
GenerateTopAndHarness.main(
Array(
"-i", s"$targetDir/ExampleModuleNeedsResetInverted.fir",
"-ll", "info"
)
GenerateTopAndHarness.main(
Array(
"-i", s"$targetDir/ExampleModuleNeedsResetInverted.fir",
"-ll", "info",
"--log-file", transformListName
)
}
val output = buffer.toString
)
val output = FileUtils.getText(transformListName)
output should include("barstools.tapeout.transforms.AddSuffixToModuleNames")
output should include("barstools.tapeout.transforms.ConvertToExtMod")
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 logOutputName = s"$targetDir/top_spec_output.log"
FileUtils.makeDirectory(targetDir)
val input = FileUtils.getLinesResource("/BlackBoxFloatTester.fir")
@@ -44,34 +45,32 @@ class GenerateTopSpec extends AnyFreeSpec with Matchers {
println(s"""Resource: ${input.mkString("\n")}""")
// val buffer = new ByteArrayOutputStream()
// Console.withOut(new PrintStream(buffer)) {
GenerateTopAndHarness.main(
Array(
"--target-dir", "test_run_dir/generate_top_spec",
"-i", s"$targetDir/BlackBoxFloatTester.fir",
"-o",
"chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.v",
"-tho", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.v",
"-i", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.fir",
"--syn-top", "UnitTestSuite",
"--harness-top", "TestHarness",
"-faf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.anno.json",
"-tsaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.anno.json",
"-tdf", "firrtl_black_box_resource_files.top.f",
"-tsf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.fir",
"-thaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.anno.json",
"-hdf", "firrtl_black_box_resource_files.harness.f",
"-thf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.fir",
"--infer-rw",
"--repl-seq-mem", "-c:TestHarness:-o:chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.mems.conf",
"-thconf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.mems.conf",
"-td", "test_run_dir/from-ci",
"-ll", "info"
)
GenerateTopAndHarness.main(
Array(
"--target-dir", "test_run_dir/generate_top_spec",
"-i", s"$targetDir/BlackBoxFloatTester.fir",
"-o", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.v",
"-tho", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.v",
"-i", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.fir",
"--syn-top", "UnitTestSuite",
"--harness-top", "TestHarness",
"-faf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.anno.json",
"-tsaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.anno.json",
"-tdf", "firrtl_black_box_resource_files.top.f",
"-tsf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.fir",
"-thaof", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.anno.json",
"-hdf", "firrtl_black_box_resource_files.harness.f",
"-thf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.fir",
"--infer-rw",
"--repl-seq-mem", "-c:TestHarness:-o:chipyard.unittest.TestHarness.IceNetUnitTestConfig.top.mems.conf",
"-thconf", "chipyard.unittest.TestHarness.IceNetUnitTestConfig.harness.mems.conf",
"-td", "test_run_dir/from-ci",
"-ll", "info",
"--log-file", logOutputName
)
}
// val output = buffer.toString
// println(output)
)
val output = FileUtils.getText(logOutputName)
println(output)
}
}

View File

@@ -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)
// }
//}