Internals/Tests: Cleanup some missing dev coverage items

This commit is contained in:
Wilson Snyder 2025-10-11 20:58:03 -04:00
parent 71941cc673
commit eae1e5bdf2
17 changed files with 47 additions and 39 deletions

View File

@ -642,7 +642,6 @@ FASTCOV_OPT += --exclude-br-lines-starting-with
FASTCOV_OPT += BROKEN_BASE_RTN
FASTCOV_OPT += BROKEN_RTN
FASTCOV_OPT += NUM_ASSERT
FASTCOV_OPT += NUM_ASSERT
FASTCOV_OPT += SELF_CHECK
FASTCOV_OPT += UASSERT
FASTCOV_OPT += UINFO

View File

@ -658,10 +658,6 @@ public:
return names[m_e];
}
bool trueKnown() const { return m_e == BU_TRUE; }
bool trueUnknown() const { return m_e == BU_TRUE || m_e == BU_UNKNOWN; }
bool falseKnown() const { return m_e == BU_FALSE; }
bool falseUnknown() const { return m_e == BU_FALSE || m_e == BU_UNKNOWN; }
bool unknown() const { return m_e == BU_UNKNOWN; }
void setTrueOrFalse(bool flag) { m_e = flag ? BU_TRUE : BU_FALSE; }
};
constexpr bool operator==(const VBoolOrUnknown& lhs, const VBoolOrUnknown& rhs) {
@ -1769,7 +1765,6 @@ public:
|| m_e == SUPPLY1 || m_e == TRIOR || m_e == TRIAND);
}
bool isWor() const { return (m_e == TRIOR); }
bool isWand() const { return (m_e == TRIAND); }
bool isWiredNet() const { return (m_e == TRIOR || m_e == TRIAND); }
bool isContAssignable() const { // In Verilog, always ok in SystemVerilog
return (m_e == SUPPLY0 || m_e == SUPPLY1 || m_e == WIRE || m_e == WREAL || m_e == TRIWIRE

View File

@ -2128,7 +2128,6 @@ public:
bool isSignal() const { return varType().isSignal(); }
bool isNet() const { return varType().isNet(); }
bool isWor() const { return varType().isWor(); }
bool isWand() const { return varType().isWand(); }
bool isWiredNet() const { return varType().isWiredNet(); }
bool isTemp() const { return varType().isTemp(); }
bool isToggleCoverable() const {

View File

@ -522,9 +522,8 @@ private:
constexpr int P_RD = 0;
constexpr int P_WR = 1;
if (pipe(fd_stdin) != 0 || pipe(fd_stdout) != 0) {
v3fatal("--pipe-filter: Can't pipe: " << std::strerror(errno));
}
if (VL_UNCOVERABLE(pipe(fd_stdin) != 0 || pipe(fd_stdout) != 0))
v3fatal("--pipe-filter: Can't pipe: " << std::strerror(errno)); // LCOV_EXCL_LINE
if (fd_stdin[P_RD] <= 2 || fd_stdin[P_WR] <= 2 || fd_stdout[P_RD] <= 2
|| fd_stdout[P_WR] <= 2) {
// We'd have to rearrange all of the FD usages in this case.
@ -535,7 +534,8 @@ private:
UINFO(1, "--pipe-filter: /bin/sh -c " << command);
const pid_t pid = fork();
if (pid < 0) v3fatal("--pipe-filter: fork failed: " << std::strerror(errno));
if (VL_UNCOVERABLE(pid < 0))
v3fatal("--pipe-filter: fork failed: " << std::strerror(errno)); // LCOV_EXCL_LINE
if (pid == 0) { // Child
UINFO(6, "In child");
close(fd_stdin[P_WR]);

View File

@ -70,7 +70,6 @@ public:
std::abort(); // LCOV_EXCL_LINE
}
}
bool lockConfig() VL_MT_SAFE { return m_lockConfig; }
bool enable() VL_MT_SAFE { return m_enable; }
};

View File

@ -277,11 +277,11 @@ void V3Number::create(const char* sourcep) {
break;
}
case '_': break;
default: {
default: { // LCOV_EXCL_START
// Likely impossible as parser prevents hitting it
v3error("Illegal character in decimal constant: " << *cp); // LCOV_EXCL_LINE
v3error("Illegal character in decimal constant: " << *cp);
break;
}
} // LCOV_EXCL_STOP
}
}
obit = width();
@ -357,18 +357,18 @@ void V3Number::create(const char* sourcep) {
case 'x': setBit(obit++,'x'); setBit(obit++,'x'); setBit(obit++,'x'); setBit(obit++,'x'); break;
// clang-format on
case '_': break;
default:
default: // LCOV_EXCL_START
// Likely impossible as parser prevents hitting it
v3error("Illegal character in hex constant: " << *cp); // LCOV_EXCL_LINE
v3error("Illegal character in hex constant: " << *cp);
break;
}
} // LCOV_EXCL_STOP
break;
}
default:
default: // LCOV_EXCL_START
// Likely impossible as parser prevents hitting it
v3error("Illegal base character: " << base); // LCOV_EXCL_LINE
v3error("Illegal base character: " << base);
break;
}
} // LCOV_EXCL_STOP
}
}

View File

@ -1322,7 +1322,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
m_debugLevel[optp] = std::atoi(valp);
});
DECL_OPTION("-debug-abort", CbCall, []() {
V3Error::vlAbort();
V3Error::vlAbort(); // LCOV_EXCL_LINE
}).undocumented(); // See also --debug-sigseg
DECL_OPTION("-debug-check", OnOff, &m_debugCheck);
DECL_OPTION("-debug-collision", OnOff, &m_debugCollision).undocumented();

View File

@ -223,7 +223,6 @@ public:
// CONFIG STATIC METHODS
// Length at which to start hashing, 0=disable
static void maxLength(size_t flag) { s_maxLength = flag; }
static size_t maxLength() { return s_maxLength; }
static string dehash(const string& in);
};

View File

@ -225,6 +225,8 @@ class TraceVisitor final : public VNVisitor {
}
}
}
if (dumpLevel() || debug() >= 9)
dupFinder.dumpFile(v3Global.debugFilename("trace") + ".hash", false);
}
void graphSimplify(bool initial) {

View File

@ -8322,10 +8322,8 @@ class WidthVisitor final : public VNVisitor {
void replaceWithSFormat(AstMethodCall* nodep, const string& format) {
// For string.itoa and similar, replace with SFormatF
const AstArg* argp = VN_CAST(nodep->pinsp(), Arg);
if (!argp) {
nodep->v3error("Argument needed for string." + nodep->prettyName() + " method");
return;
}
UASSERT_OBJ(argp, nodep,
"Argument needed for string method, call methodOkArguments before here");
AstNodeVarRef* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef);
AstNode* const newp = new AstAssign{
nodep->fileline(), fromp,

View File

@ -67,7 +67,9 @@ static double lexParseDouble(FileLine* fl, const char* textp, size_t length) {
const string text = std::string{textp, length};
bool success = false;
const double d = VString::parseDouble(text, &success);
if (!success) fl->v3error("Syntax error parsing real: '" << textp << "'");
// Below never fails, instead can't lex the number
if (VL_UNCOVERABLE(!success))
fl->v3error("Syntax error parsing real: '" << textp << "'"); // LCOV_EXCL_LINE
return d;
}

View File

@ -14,7 +14,10 @@ test.scenarios("vlt")
test.lint(
# We also have dump-tree turned on, so hit a lot of AstNode*::dump() functions
# Likewise XML
v_flags=["--lint-only --dumpi-tree 9 --dumpi-V3EmitV 9 --debug-emitv --timing"])
v_flags=[
"--lint-only --timing",
"--dumpi-tree 9 --dumpi-V3EmitV 9 --debug-emitv" # Dev coverage of the V3EmitV code
])
output_vs = test.glob_some(test.obj_dir + "/" + test.vm_prefix + "_*_width.tree.v")

View File

@ -16,22 +16,19 @@ Outputs = {}
Suppressed = {}
for s in [
# Cannot hit, and comment as to why
# Instead of adding here, consider adding a LCOV_EXCL_LINE/START/STOP to the sources on the message
' exited with ', # Is hit; driver.py filters out
' loading non-variable', # Instead 'storing to parameter' or syntax error
'--pipe-filter: Can\'t pipe: ', # Can't test
'--pipe-filter: fork failed: ', # Can't test
'Assigned pin is neither input nor output', # Instead earlier error
'Define missing argument \'', # Instead get Define passed too many arguments
'Define or directive not defined: `', # Instead V3ParseImp will warn
'Enum ranges must be integral, per spec', # Hard to hit
'Expecting define formal arguments. Found: ', # Instead define syntax error
'Syntax error parsing real: \'', # Instead can't lex the number
'Syntax error: Range \':\', \'+:\' etc are not allowed in the instance ', # Instead get syntax error
'dynamic new() not expected in this context (expected under an assign)', # Instead get syntax error
# Not yet analyzed
'--pipe-filter protocol error, unexpected: ',
'--pipe-filter returned bad status',
'Argument needed for string.',
'Array initialization has too few elements, need element ',
'Assignment pattern with no members',
'Can\'t find varpin scope of ',
@ -110,6 +107,8 @@ def read_messages():
with open(filename, 'r', encoding="utf8") as fh:
lineno = 0
read_next = None
excl = False
excl_next = False
for origline in fh:
line = origline
@ -118,6 +117,12 @@ def read_messages():
continue
if re.match(r'^\s*/\*', line):
continue
excl = excl_next
if 'LCOV_EXCL_START' in line:
excl = True
excl_next = True
if 'LCOV_EXCL_STOP' in line:
excl_next = False # Reenables coverage on next line, not this one
if re.search(r'\b(v3error|v3warn|v3fatal|BBUNSUP)\b\($', line):
if 'LCOV_EXCL_LINE' not in line:
read_next = True
@ -131,6 +136,8 @@ def read_messages():
read_next = False
if 'LCOV_EXCL_LINE' in line:
continue
if excl:
continue
if "\\" in line: # \" messes up next part
continue
m = re.search(r'"([^"]*)"', line)

View File

@ -55,7 +55,7 @@ module sub (input clk, input [31:0] i, output [31:0] z);
assign z = z_tmp;
always @(posedge z_tmp == 32'b11) begin
$display("%m z_tmp[0]: %d", z_tmp);
$display("%m z_tmp[0]: %0d", z_tmp);
end
endmodule

View File

@ -82,12 +82,13 @@ def check_gcc_flags(filename):
if not test.make_version or float(test.make_version) < 4.1:
test.skip("Test requires GNU Make version >= 4.1")
test.compile(v_flags2=["--trace-vcd",
test.compile(v_flags2=["--exe",
"--trace-vcd",
"--output-split 1",
"--output-groups 2",
"--output-split-cfuncs 1",
"--exe",
"--stats",
"--dumpi-V3EmitMk 9", # Dev coverage of the V3EmitMk debug printer
"../" + test.main_filename],
verilator_make_gmake=False) # yapf:disable

View File

@ -20,7 +20,8 @@ test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --getenv FOOBARTEST
test.file_grep(test.compile_log_filename, r'gotit')
for var in [
'MAKE', 'PERL', 'PYTHON3', 'SYSTEMC', 'SYSTEMC_ARCH', 'SYSTEMC_LIBDIR', 'VERILATOR_ROOT'
'MAKE', 'PERL', 'PYTHON3', 'SYSTEMC', 'SYSTEMC_ARCH', 'SYSTEMC_INCLUDE', 'SYSTEMC_LIBDIR',
'VERILATOR_ROOT'
]:
test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator", "--getenv", var],
logfile=test.obj_dir + "/simx.log",

View File

@ -11,7 +11,10 @@ import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=['--trace-vcd --binary'])
test.compile(verilator_flags2=[
'--trace-vcd --binary',
'--dumpi-V3Trace 9' # Dev coverage of the V3DumpFinder debug code
])
test.execute()