diff --git a/include/verilated.cpp b/include/verilated.cpp index 052315a41..cc1464901 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -3603,16 +3603,14 @@ void VerilatedContextImp::commandArgVl(const std::string& arg) { // and the run can be reproduced by passing +verilator+seed+. if (u64 == 0) u64 = pickRandomSeed(); randSeed(static_cast(u64)); - } else if (0 - == std::strncmp(arg.c_str(), "+verilator+vpi+", - std::strlen("+verilator+vpi+"))) { + } else if (commandArgVlString(arg, "+verilator+vpi+", str)) { // With --vpi the generated --main (vl_load_vpi_libs) consumes this, so accept // it silently here. Without --vpi there is no loader, so warn it is ignored. #if !VM_VPI VL_WARN_MT( "COMMAND_LINE", 0, "", ("+verilator+vpi+ ignored: simulation was not compiled with --vpi '" + arg + "'") - .c_str()); + .c_str()); // LCOV_EXCL_LINE (gcov zeroes this wrapped continuation line) #endif } else if (arg == "+verilator+V") { VerilatedImp::versionDump(); // Someday more info too diff --git a/test_regress/t/t_flag_main_vpi.py b/test_regress/t/t_flag_main_vpi.py index 2ccadc844..3702f58f5 100755 --- a/test_regress/t/t_flag_main_vpi.py +++ b/test_regress/t/t_flag_main_vpi.py @@ -32,7 +32,12 @@ else: # Run the generated binary; load the VPI library via the +verilator+vpi+ plusarg. # The VPI library's output (observed 'count' reaching MAX_TICKS, then end-of-sim) is # checked against the golden .out file. -test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so"], +# Also pass a non-VPI plusarg (skipped by the loader's prefix check) and a bare +# +verilator+vpi+ with an empty payload (skipped by the empty-arg check), so both +# loader-skip branches are exercised alongside the real library load. +test.execute(all_run_flags=[ + "+othertest", "+verilator+vpi+", "+verilator+vpi+" + test.obj_dir + "/libvpi.so" +], check_finished=True, expect_filename=test.golden_filename)