Tests: Add driver.py --driver-clean

This commit is contained in:
Wilson Snyder 2025-03-27 18:33:18 -04:00
parent 8965401d10
commit d26d62a176
3 changed files with 26 additions and 12 deletions

View File

@ -109,22 +109,22 @@ elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then
ccache -z
case $TESTS in
dist-vlt-0)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=0/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=0/4
;;
dist-vlt-1)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=1/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=1/4
;;
dist-vlt-2)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=2/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=2/4
;;
dist-vlt-3)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt $sanitize" DRIVER_HASHSET=--hashset=3/4
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean $sanitize" DRIVER_HASHSET=--hashset=3/4
;;
vltmt-0)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt" DRIVER_HASHSET=--hashset=0/2
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt --driver-clean" DRIVER_HASHSET=--hashset=0/2
;;
vltmt-1)
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt" DRIVER_HASHSET=--hashset=1/2
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--vltmt --driver-clean" DRIVER_HASHSET=--hashset=1/2
;;
coverage-all)
nodist/code_coverage --stages 1-

View File

@ -2046,6 +2046,11 @@ driver.py Non-Scenario Arguments
Same as ``verilator --debugi level``: Set Verilator internal debugging
level globally to the specified debug level (1-10).
--driver-clean
After a test passes, remove the generated objects. Reduces storage
requirements, but may result in longer runtime if the tests are run
again.
--dump-tree
Same as ``verilator --dump-tree``: Enable Verilator writing .tree debug
files with dumping level 3, which dumps the standard critical stages.
@ -2079,6 +2084,9 @@ driver.py Non-Scenario Arguments
Run number of parallel tests, or 0 to determine the count based on the
number of cores installed.
--obj-suffix <name>
Append the argument to the name of the ``test_regress/obj_`` directories.
--quiet
Suppress all output except for failures and progress messages every 15
seconds. Intended for use only in automated regressions. See also

View File

@ -442,6 +442,8 @@ class Runner:
test._read_status()
if test.ok:
self.ok_cnt += 1
if Args.driver_clean:
test.clean()
elif test._quit:
pass
elif test._scenario_off and not test.errors:
@ -951,14 +953,17 @@ class VlTest:
#----------------------------------------------------------------------
# Methods invoked by tests
def clean(self) -> None:
"""Called on a rerun to cleanup files."""
def clean(self, for_rerun=False) -> None:
"""Called on a --driver-clean or rerun to cleanup files."""
if self.clean_command:
os.system(self.clean_command)
# Prevents false-failures when switching compilers
# Remove old results to force hard rebuild
os.system('/bin/rm -rf ' + self.obj_dir + '__fail1')
os.system('/bin/mv ' + self.obj_dir + ' ' + self.obj_dir + '__fail1')
if for_rerun:
# Prevents false-failures when switching compilers
# Remove old results to force hard rebuild
os.system('/bin/mv ' + self.obj_dir + ' ' + self.obj_dir + '__fail1')
else:
os.system('/bin/rm -rf ' + self.obj_dir)
def clean_objs(self) -> None:
os.system("/bin/rm -rf " + ' '.join(glob.glob(self.obj_dir + "/*")))
@ -2715,7 +2720,7 @@ def run_them() -> None:
for ftest in orig_runner.fail_tests:
# Reschedule test
if ftest.rerunnable:
ftest.clean()
ftest.clean(for_rerun=True)
runner.one_test(py_filename=ftest.py_filename,
scenario=ftest.scenario,
rerun_skipping=not ftest.rerunnable)
@ -2776,6 +2781,7 @@ if __name__ == '__main__':
parser.add_argument('--benchmark', action='store', help='enable benchmarking')
parser.add_argument('--debug', action='store_const', const=9, help='enable debug')
# --debugi: see _parameter()
parser.add_argument('--driver-clean', action='store_true', help='clean after test passes')
parser.add_argument('--fail-max',
action='store',
default=None,