Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Fix to support verilator tests in chisel3 that use MFC to generate unittests #2594

Open
wants to merge 2 commits into
base: master-deprecated
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/main/scala/firrtl/util/BackendCompilationUtilities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -176,7 +187,11 @@ 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
Comment on lines +190 to 197
Copy link
Contributor

@jackkoenig jackkoenig Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than hardcoding the assertion message, can you instead make this:

  1. Do the same thing that the stdout check does and allow the user to specify the assertion message
  2. Make the return value below do the right thing even without providing Assertion failed? it's already looking for non-zero exit codes, are MFC tests that have assertion failures not returning non-zero?

Expand Down