Tests: Strictly test exit codes (no unexpected core dumps)
This commit is contained in:
parent
542ffcca60
commit
3a039df351
|
|
@ -258,8 +258,8 @@ sub run {
|
||||||
warn "%Error: Command Failed $command\n";
|
warn "%Error: Command Failed $command\n";
|
||||||
}
|
}
|
||||||
exit $! if $!; # errno
|
exit $! if $!; # errno
|
||||||
exit $? >> 8 if $? >> 8; # child exit status
|
exit $? >> 8 if $? >> 8; # pass along child exit code
|
||||||
exit 255; # last resort
|
exit 128 + ($status & 127); # last resort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1724,7 +1724,7 @@ class VlTest:
|
||||||
check_finished=False, # Check for All Finished
|
check_finished=False, # Check for All Finished
|
||||||
entering=None, # Print entering directory information
|
entering=None, # Print entering directory information
|
||||||
expect_filename=None, # Filename that should match logfile
|
expect_filename=None, # Filename that should match logfile
|
||||||
fails=False, # Command should fail
|
fails=False, # True: normal 1 exit code, 'any': any exit code
|
||||||
logfile=None, # Filename to write putput to
|
logfile=None, # Filename to write putput to
|
||||||
tee=True,
|
tee=True,
|
||||||
verilator_run=False) -> str: # Move gcov data to parallel area
|
verilator_run=False) -> str: # Move gcov data to parallel area
|
||||||
|
|
@ -1812,9 +1812,12 @@ class VlTest:
|
||||||
-8, # SIGFPA
|
-8, # SIGFPA
|
||||||
-11)): # SIGSEGV
|
-11)): # SIGSEGV
|
||||||
self.error("Exec failed with core dump")
|
self.error("Exec failed with core dump")
|
||||||
status = 10
|
status = 128 + (-rc) # So is "normal" shell 0-255 status
|
||||||
|
elif rc >= 256:
|
||||||
|
# waitpid returns status << 8; subprocess otherwise; handle both
|
||||||
|
status = int(rc / 256) # So is shell $?-like
|
||||||
elif rc:
|
elif rc:
|
||||||
status = 10
|
status = rc
|
||||||
else:
|
else:
|
||||||
status = 0
|
status = 0
|
||||||
|
|
||||||
|
|
@ -1829,8 +1832,21 @@ class VlTest:
|
||||||
# Strip ANSI escape sequences
|
# Strip ANSI escape sequences
|
||||||
firstline = re.sub(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])', '', firstline)
|
firstline = re.sub(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])', '', firstline)
|
||||||
self.error("Exec of " + self._error_cmd_simplify(cmd) + " failed: " + firstline)
|
self.error("Exec of " + self._error_cmd_simplify(cmd) + " failed: " + firstline)
|
||||||
|
|
||||||
if fails and status:
|
if fails and status:
|
||||||
print("(Exec expected to fail, and did.)")
|
if not verilator_run:
|
||||||
|
print("(Exec failed, matching expected fail)")
|
||||||
|
elif fails == 'any':
|
||||||
|
print("(Exec failed, matching expected 'any' exit code fail)")
|
||||||
|
elif fails is True:
|
||||||
|
if status == 1:
|
||||||
|
print("(Exec failed, matching expected 'True' exit code 1 fail)")
|
||||||
|
else:
|
||||||
|
self.error("Exec of " + self._error_cmd_simplify(cmd) +
|
||||||
|
" failed with exit code " + str(status) +
|
||||||
|
", but expected 'True' exit code 1 fail")
|
||||||
|
else: # Future: support numeric exit code?
|
||||||
|
self.error("fails=" + str(fails) + " is not legal value")
|
||||||
if fails and not status:
|
if fails and not status:
|
||||||
self.error("Exec of " + self._error_cmd_simplify(cmd) + " ok, but expected to fail")
|
self.error("Exec of " + self._error_cmd_simplify(cmd) + " ok, but expected to fail")
|
||||||
if self.errors or self._skips:
|
if self.errors or self._skips:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import vltest_bootstrap
|
import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('simulator')
|
test.scenarios('simulator_st')
|
||||||
test.top_filename = "t/t_assert_elab.v"
|
test.top_filename = "t/t_assert_elab.v"
|
||||||
|
|
||||||
test.unlink_ok(test.obj_dir + "/t_assert_elab_bad.log")
|
test.unlink_ok(test.obj_dir + "/t_assert_elab_bad.log")
|
||||||
|
|
@ -19,8 +19,6 @@ test.compile(v_flags2=[
|
||||||
],
|
],
|
||||||
fails=True)
|
fails=True)
|
||||||
|
|
||||||
test.execute(fails=test.vlt_all)
|
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename,
|
test.file_grep(test.compile_log_filename,
|
||||||
r'%Warning-USERFATAL: "Parameter 5 is invalid...string and constant both work"')
|
r'%Warning-USERFATAL: "Parameter 5 is invalid...string and constant both work"')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
||||||
if not test.have_gdb:
|
if not test.have_gdb:
|
||||||
test.skip("No gdb installed")
|
test.skip("No gdb installed")
|
||||||
|
|
||||||
test.lint(verilator_flags2=["--debug-fatalsrc"], fails=test.vlt_all)
|
test.lint(verilator_flags2=["--debug-fatalsrc"], fails='any')
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
|
test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
|
||||||
test.file_grep(test.compile_log_filename, r'See the manual')
|
test.file_grep(test.compile_log_filename, r'See the manual')
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
||||||
if not test.have_gdb:
|
if not test.have_gdb:
|
||||||
test.skip("No gdb installed")
|
test.skip("No gdb installed")
|
||||||
|
|
||||||
test.lint(verilator_flags2=["--lint-only --debug --gdbbt --debug-fatalsrc"], fails=True)
|
test.lint(verilator_flags2=["--lint-only --debug --gdbbt --debug-fatalsrc"], fails='any')
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
|
test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
|
||||||
test.file_grep(test.compile_log_filename, r'See the manual')
|
test.file_grep(test.compile_log_filename, r'See the manual')
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ test.scenarios('vlt')
|
||||||
test.setenv("ASAN_OPTIONS", "handle_segv=0")
|
test.setenv("ASAN_OPTIONS", "handle_segv=0")
|
||||||
test.leak_check_disable()
|
test.leak_check_disable()
|
||||||
|
|
||||||
test.lint(v_flags=["--debug-sigsegv"], fails=True, sanitize=0)
|
test.lint(v_flags=["--debug-sigsegv"], fails='any', sanitize=0)
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename,
|
test.file_grep(test.compile_log_filename,
|
||||||
r'%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt')
|
r'%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt')
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ if not test.have_gdb:
|
||||||
|
|
||||||
test.lint(verilator_flags2=["--lint-only --debug --gdbbt --debug-sigsegv"],
|
test.lint(verilator_flags2=["--lint-only --debug --gdbbt --debug-sigsegv"],
|
||||||
sanitize=0,
|
sanitize=0,
|
||||||
fails=test.vlt_all)
|
fails='any')
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename, r'Program received signal SIGSEGV')
|
test.file_grep(test.compile_log_filename, r'Program received signal SIGSEGV')
|
||||||
test.file_grep(test.compile_log_filename, r'in V3Options::')
|
test.file_grep(test.compile_log_filename, r'in V3Options::')
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ test.compile(
|
||||||
],
|
],
|
||||||
# Recursive make breaks the golden compare
|
# Recursive make breaks the golden compare
|
||||||
#expect_filename = test.golden_filename
|
#expect_filename = test.golden_filename
|
||||||
fails=True)
|
fails='any') # make returns exit code 2
|
||||||
|
|
||||||
test.passes()
|
test.passes()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue