From ff19ac4b44959b6ba3d11ce951a3217101f5c95a Mon Sep 17 00:00:00 2001 From: chick Date: Thu, 19 Jan 2023 13:01:18 -0800 Subject: [PATCH 1/2] Fix to support verilator tests in chisel3 that use MFC to generate code for `executeExpecting*` API --- .../util/BackendCompilationUtilities.scala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/scala/firrtl/util/BackendCompilationUtilities.scala b/src/main/scala/firrtl/util/BackendCompilationUtilities.scala index a687cb28a6..f6d393b44a 100644 --- a/src/main/scala/firrtl/util/BackendCompilationUtilities.scala +++ b/src/main/scala/firrtl/util/BackendCompilationUtilities.scala @@ -163,6 +163,17 @@ object BackendCompilationUtilities extends LazyLogging { def cppToExe(prefix: String, dir: File): ProcessBuilder = Seq("make", "-C", dir.toString, "-j", "-f", s"V$prefix.mk", s"V$prefix") + /** Check for failed unit test using verilator + * Failure determined by + * - supplied assertion message on stdout + * - "Assertion failed" on stderr + * - exit code not equal to 0 or 134 + * + * @param prefix program to be run after adding capital "./V" to the front + * @param dir working directory for program execution + * @param assertionMsg message to look for on stdout + * @return true + */ def executeExpectingFailure( prefix: String, dir: File, @@ -176,7 +187,10 @@ object BackendCompilationUtilities extends LazyLogging { triggered = triggered || (assertionMessageSupplied && line.contains(assertionMsg)) logger.info(line) }, - logger.warn(_) + stderrLine => { + triggered = triggered || stderrLine.contains("Assertion failed") || (assertionMessageSupplied && stderrLine.contains(assertionMsg)) + logger.warn(stderrLine) + } ) // Fail if a line contained an assertion or if we get a non-zero exit code // or, we get a SIGABRT (assertion failure) and we didn't provide a specific assertion message From b4c3a06a7813a60cfd024613330cf28c7c364566 Mon Sep 17 00:00:00 2001 From: chick Date: Thu, 19 Jan 2023 13:19:43 -0800 Subject: [PATCH 2/2] scalafmt --- src/main/scala/firrtl/util/BackendCompilationUtilities.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/firrtl/util/BackendCompilationUtilities.scala b/src/main/scala/firrtl/util/BackendCompilationUtilities.scala index f6d393b44a..dcf3985e85 100644 --- a/src/main/scala/firrtl/util/BackendCompilationUtilities.scala +++ b/src/main/scala/firrtl/util/BackendCompilationUtilities.scala @@ -188,7 +188,8 @@ object BackendCompilationUtilities extends LazyLogging { logger.info(line) }, stderrLine => { - triggered = triggered || stderrLine.contains("Assertion failed") || (assertionMessageSupplied && stderrLine.contains(assertionMsg)) + triggered = triggered || stderrLine + .contains("Assertion failed") || (assertionMessageSupplied && stderrLine.contains(assertionMsg)) logger.warn(stderrLine) } )