Internals: Cleanup branch coverage. No functional change.

This commit is contained in:
Wilson Snyder 2020-07-10 19:17:21 -04:00
parent f8a67b2fe8
commit dced49a804
4 changed files with 40 additions and 40 deletions

View File

@ -220,20 +220,19 @@ private:
} }
static void selftest() VL_MT_SAFE { static void selftest() VL_MT_SAFE {
// Little selftest // Little selftest
#define VL_CST_CHECK(got, exp) \ #define SELF_CHECK(got, exp) \
do { \ do { \
if ((got) != (exp)) VL_FATAL_MT(__FILE__, __LINE__, "", "%Error: selftest\n"); \ if ((got) != (exp)) VL_FATAL_MT(__FILE__, __LINE__, "", "%Error: selftest\n"); \
} while (0) } while (0)
SELF_CHECK(combineHier("a.b.c", "a.b.c"), "a.b.c");
VL_CST_CHECK(combineHier("a.b.c", "a.b.c"), "a.b.c"); SELF_CHECK(combineHier("a.b.c", "a.b"), "a.b*");
VL_CST_CHECK(combineHier("a.b.c", "a.b"), "a.b*"); SELF_CHECK(combineHier("a.x.c", "a.y.c"), "a.*.c");
VL_CST_CHECK(combineHier("a.x.c", "a.y.c"), "a.*.c"); SELF_CHECK(combineHier("a.z.z.z.c", "a.b.c"), "a.*.c");
VL_CST_CHECK(combineHier("a.z.z.z.c", "a.b.c"), "a.*.c"); SELF_CHECK(combineHier("z", "a"), "*");
VL_CST_CHECK(combineHier("z", "a"), "*"); SELF_CHECK(combineHier("q.a", "q.b"), "q.*");
VL_CST_CHECK(combineHier("q.a", "q.b"), "q.*"); SELF_CHECK(combineHier("q.za", "q.zb"), "q.z*");
VL_CST_CHECK(combineHier("q.za", "q.zb"), "q.z*"); SELF_CHECK(combineHier("1.2.3.a", "9.8.7.a"), "*.a");
VL_CST_CHECK(combineHier("1.2.3.a", "9.8.7.a"), "*.a"); #undef SELF_CHECK
#undef VL_CST_CHECK
} }
void clearGuts() VL_REQUIRES(m_mutex) { void clearGuts() VL_REQUIRES(m_mutex) {
for (ItemList::const_iterator it = m_items.begin(); it != m_items.end(); ++it) { for (ItemList::const_iterator it = m_items.begin(); it != m_items.end(); ++it) {

View File

@ -129,7 +129,7 @@ void VerilatedSave::open(const char* filenamep) VL_MT_UNSAFE_ONE {
// cppcheck-suppress duplicateExpression // cppcheck-suppress duplicateExpression
m_fd = ::open(filenamep, m_fd = ::open(filenamep,
O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666); O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE | O_NONBLOCK | O_CLOEXEC, 0666);
if (m_fd < 0) { if (VL_UNLIKELY(m_fd < 0)) {
// User code can check isOpen() // User code can check isOpen()
m_isOpen = false; m_isOpen = false;
return; return;
@ -151,7 +151,7 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE {
} else { } else {
// cppcheck-suppress duplicateExpression // cppcheck-suppress duplicateExpression
m_fd = ::open(filenamep, O_CREAT | O_RDONLY | O_LARGEFILE | O_CLOEXEC, 0666); m_fd = ::open(filenamep, O_CREAT | O_RDONLY | O_LARGEFILE | O_CLOEXEC, 0666);
if (m_fd < 0) { if (VL_UNLIKELY(m_fd < 0)) {
// User code can check isOpen() // User code can check isOpen()
m_isOpen = false; m_isOpen = false;
return; return;

View File

@ -964,52 +964,52 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE {
return names[(vpiVal <= vpiIsProtected) ? vpiVal : 0]; return names[(vpiVal <= vpiIsProtected) ? vpiVal : 0];
} }
#define CHECK_RESULT_CSTR(got, exp) \ #define SELF_CHECK_RESULT_CSTR(got, exp) \
if (0 != strcmp((got), (exp))) { \ if (0 != strcmp((got), (exp))) { \
std::string msg \ std::string msg \
= std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \ = std::string("%Error: ") + "GOT = '" + got + "'" + " EXP = '" + exp + "'"; \
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \
} }
#define CHECK_ENUM_STR(fn, enum) \ #define SELF_CHECK_ENUM_STR(fn, enum) \
do { \ do { \
const char* strVal = VerilatedVpiError::fn(enum); \ const char* strVal = VerilatedVpiError::fn(enum); \
CHECK_RESULT_CSTR(strVal, #enum); \ SELF_CHECK_RESULT_CSTR(strVal, #enum); \
} while (0) } while (0)
void VerilatedVpi::selfTest() VL_MT_UNSAFE_ONE { VerilatedVpiError::selfTest(); } void VerilatedVpi::selfTest() VL_MT_UNSAFE_ONE { VerilatedVpiError::selfTest(); }
void VerilatedVpiError::selfTest() VL_MT_UNSAFE_ONE { void VerilatedVpiError::selfTest() VL_MT_UNSAFE_ONE {
VerilatedVpiImp::assertOneCheck(); VerilatedVpiImp::assertOneCheck();
CHECK_ENUM_STR(strFromVpiVal, vpiBinStrVal); SELF_CHECK_ENUM_STR(strFromVpiVal, vpiBinStrVal);
CHECK_ENUM_STR(strFromVpiVal, vpiRawFourStateVal); SELF_CHECK_ENUM_STR(strFromVpiVal, vpiRawFourStateVal);
CHECK_ENUM_STR(strFromVpiObjType, vpiAlways); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiAlways);
CHECK_ENUM_STR(strFromVpiObjType, vpiWhile); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiWhile);
CHECK_ENUM_STR(strFromVpiObjType, vpiAttribute); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiAttribute);
CHECK_ENUM_STR(strFromVpiObjType, vpiUdpArray); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiUdpArray);
CHECK_ENUM_STR(strFromVpiObjType, vpiContAssignBit); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiContAssignBit);
CHECK_ENUM_STR(strFromVpiObjType, vpiGenVar); SELF_CHECK_ENUM_STR(strFromVpiObjType, vpiGenVar);
CHECK_ENUM_STR(strFromVpiMethod, vpiCondition); SELF_CHECK_ENUM_STR(strFromVpiMethod, vpiCondition);
CHECK_ENUM_STR(strFromVpiMethod, vpiStmt); SELF_CHECK_ENUM_STR(strFromVpiMethod, vpiStmt);
CHECK_ENUM_STR(strFromVpiCallbackReason, cbValueChange); SELF_CHECK_ENUM_STR(strFromVpiCallbackReason, cbValueChange);
CHECK_ENUM_STR(strFromVpiCallbackReason, cbAtEndOfSimTime); SELF_CHECK_ENUM_STR(strFromVpiCallbackReason, cbAtEndOfSimTime);
CHECK_ENUM_STR(strFromVpiProp, vpiType); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiType);
CHECK_ENUM_STR(strFromVpiProp, vpiProtected); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiProtected);
CHECK_ENUM_STR(strFromVpiProp, vpiDirection); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiDirection);
CHECK_ENUM_STR(strFromVpiProp, vpiTermIndex); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiTermIndex);
CHECK_ENUM_STR(strFromVpiProp, vpiConstType); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiConstType);
CHECK_ENUM_STR(strFromVpiProp, vpiAutomatic); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiAutomatic);
CHECK_ENUM_STR(strFromVpiProp, vpiOffset); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiOffset);
CHECK_ENUM_STR(strFromVpiProp, vpiStop); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiStop);
CHECK_ENUM_STR(strFromVpiProp, vpiIsProtected); SELF_CHECK_ENUM_STR(strFromVpiProp, vpiIsProtected);
} }
#undef CHECK_ENUM_STR #undef SELF_CHECK_ENUM_STR
#undef CHECK_RESULT_CSTR #undef SELF_CHECK_RESULT_CSTR
//====================================================================== //======================================================================
// callback related // callback related

View File

@ -53,6 +53,7 @@ exclude_line_regexp(qr/(\bv3fatalSrc\b
|\bUINFO\b)/x); |\bUINFO\b)/x);
# Exclude for branch coverage only # Exclude for branch coverage only
exclude_branch_regexp(qr/(\bdebug\(\))/x); exclude_branch_regexp(qr/(\bdebug\(\)
|\bSELF_CHECK)/x);
1; 1;