Tests: Move per-command expect= to instead check logfiles

This commit is contained in:
Wilson Snyder 2024-09-19 18:53:22 -04:00
parent f63168a5b5
commit 1543b202b2
33 changed files with 117 additions and 147 deletions

View File

@ -2350,11 +2350,6 @@ check_finished
string ``*-* All Finished *-*`` being printed on standard output. This is string ``*-* All Finished *-*`` being printed on standard output. This is
the normal way for successful tests to finish. the normal way for successful tests to finish.
expect
A quoted list of strings or regular expression to be matched in the
output. See `Hints On Writing Tests` for more detail on how this argument
should be used.
fails fails
True to indicate this step is expected to fail. Tests that are expected True to indicate this step is expected to fail. Tests that are expected
to fail generally have _bad in their filename. to fail generally have _bad in their filename.

View File

@ -432,8 +432,7 @@ class Runner:
else: else:
error_msg = test.errors if test.errors else test.errors_keep_going error_msg = test.errors if test.errors else test.errors_keep_going
test.oprint("FAILED: " + error_msg) test.oprint("FAILED: " + error_msg)
j = " -j" if Args.jobs else "" makecmd = VtOs.getenv_def('VERILATOR_MAKE', os.environ['MAKE']) + " &&"
makecmd = VtOs.getenv_def('VERILATOR_MAKE', os.environ['MAKE']) + j + " &&"
upperdir = 'test_regress/' if re.search(r'test_regress', os.getcwd()) else '' upperdir = 'test_regress/' if re.search(r'test_regress', os.getcwd()) else ''
self.fail_msgs.append("\t#" + test.soprint("%Error: " + error_msg) + "\t\t" + makecmd + self.fail_msgs.append("\t#" + test.soprint("%Error: " + error_msg) + "\t\t" + makecmd +
" " + upperdir + test.py_filename + " " + upperdir + test.py_filename +
@ -763,6 +762,7 @@ class VlTest:
self.coverage_filename = self.obj_dir + "/coverage.dat" self.coverage_filename = self.obj_dir + "/coverage.dat"
self.golden_filename = re.sub(r'\.py$', '.out', self.py_filename) self.golden_filename = re.sub(r'\.py$', '.out', self.py_filename)
self.main_filename = self.obj_dir + "/" + self.vm_prefix + "__main.cpp" self.main_filename = self.obj_dir + "/" + self.vm_prefix + "__main.cpp"
self.compile_log_filename = self.obj_dir + "/vlt_compile.log"
self.run_log_filename = self.obj_dir + "/vlt_sim.log" self.run_log_filename = self.obj_dir + "/vlt_sim.log"
self.stats = self.obj_dir + "/V" + self.name + "__stats.txt" self.stats = self.obj_dir + "/V" + self.name + "__stats.txt"
self.top_filename = re.sub(r'\.py$', '', self.py_filename) + '.' + self.v_suffix self.top_filename = re.sub(r'\.py$', '', self.py_filename) + '.' + self.v_suffix
@ -1055,7 +1055,6 @@ class VlTest:
def compile(self, **kwargs) -> None: def compile(self, **kwargs) -> None:
"""Run simulation compiler. Arguments similar to run(); default arguments are from self""" """Run simulation compiler. Arguments similar to run(); default arguments are from self"""
param = { param = {
'expect': None,
'expect_filename': None, 'expect_filename': None,
'fails': False, 'fails': False,
'make_flags': [], 'make_flags': [],
@ -1234,7 +1233,6 @@ class VlTest:
self.run(logfile=self.obj_dir + "/vlt_compile.log", self.run(logfile=self.obj_dir + "/vlt_compile.log",
fails=param['fails'], fails=param['fails'],
tee=param['tee'], tee=param['tee'],
expect=param['expect'],
expect_filename=param['expect_filename'], expect_filename=param['expect_filename'],
verilator_run=True, verilator_run=True,
cmd=vlt_cmd) cmd=vlt_cmd)
@ -1251,7 +1249,6 @@ class VlTest:
logfile=self.obj_dir + "/vlt_cmake.log", logfile=self.obj_dir + "/vlt_cmake.log",
fails=param['fails'], fails=param['fails'],
tee=param['tee'], tee=param['tee'],
expect=param['expect'],
expect_filename=param['expect_filename'], expect_filename=param['expect_filename'],
verilator_run=True, verilator_run=True,
cmd=[ cmd=[
@ -1326,7 +1323,6 @@ class VlTest:
'entering': False, 'entering': False,
'check_finished': False, 'check_finished': False,
'executable': None, 'executable': None,
'expect': None,
'expect_filename': None, 'expect_filename': None,
'fails': False, 'fails': False,
'run_env': '', 'run_env': '',
@ -1363,7 +1359,6 @@ class VlTest:
' '.join(param['all_run_flags']), ' '.join(param['all_run_flags']),
], ],
*param, *param,
expect=param['atsim_run_expect'], # non-verilator expect isn't the same
expect_filename=param['atsim_run_expect_filename'], expect_filename=param['atsim_run_expect_filename'],
) )
elif param['ghdl']: elif param['ghdl']:
@ -1376,7 +1371,6 @@ class VlTest:
' '.join(param['all_run_flags']), ' '.join(param['all_run_flags']),
], ],
*param, *param,
expect=param['ghdl_run_expect'], # non-verilator expect isn't the same
expect_filename=param['ghdl_run_expect_filename'], expect_filename=param['ghdl_run_expect_filename'],
) )
elif param['iv']: elif param['iv']:
@ -1393,7 +1387,6 @@ class VlTest:
fails=param['fails'], fails=param['fails'],
cmd=cmd, cmd=cmd,
*param, *param,
expect=param['iv_run_expect'], # non-verilator expect isn't the same
expect_filename=param['iv_run_expect_filename'], expect_filename=param['iv_run_expect_filename'],
) )
elif param['ms']: elif param['ms']:
@ -1409,7 +1402,6 @@ class VlTest:
(" top") (" top")
], ],
*param, *param,
expect=param['ms_run_expect'], # non-verilator expect isn't the same
expect_filename=param['ms_expect_filename'], expect_filename=param['ms_expect_filename'],
) )
elif param['nc']: elif param['nc']:
@ -1422,7 +1414,6 @@ class VlTest:
' '.join(param['all_run_flags']), ' '.join(param['all_run_flags']),
], ],
*param, *param,
expect=param['nc_run_expect'], # non-verilator expect isn't the same
expect_filename=param['nc_run_expect_filename'], expect_filename=param['nc_run_expect_filename'],
) )
elif param['vcs']: elif param['vcs']:
@ -1436,7 +1427,6 @@ class VlTest:
' '.join(param['all_run_flags']), ' '.join(param['all_run_flags']),
], ],
*param, *param,
expect=param['vcs_run_expect'], # non-verilator expect isn't the same
expect_filename=param['vcs_run_expect_filename'], expect_filename=param['vcs_run_expect_filename'],
) )
elif param['xrun']: elif param['xrun']:
@ -1455,7 +1445,6 @@ class VlTest:
param['top_filename'], param['top_filename'],
], ],
*param, *param,
expect=param['xrun_run_expect'], # non-verilator expect isn't the same
expect_filename=param['xrun_run_expect_filename'], expect_filename=param['xrun_run_expect_filename'],
) )
elif param['xsim']: elif param['xsim']:
@ -1468,7 +1457,6 @@ class VlTest:
' '.join(param['all_run_flags']), (" " + self.name + ".top") ' '.join(param['all_run_flags']), (" " + self.name + ".top")
], ],
*param, *param,
expect=param['xsim_run_expect'], # non-verilator expect isn't the same
expect_filename=param['xsim_expect_filename'], expect_filename=param['xsim_expect_filename'],
) )
elif param['vlt_all']: elif param['vlt_all']:
@ -1489,7 +1477,6 @@ class VlTest:
aslr_off=param['aslr_off'], # Disable address space layour randomization aslr_off=param['aslr_off'], # Disable address space layour randomization
check_finished=param['check_finished'], # Check for All Finished check_finished=param['check_finished'], # Check for All Finished
entering=param['entering'], # Print entering directory information entering=param['entering'], # Print entering directory information
expect=param['expect'],
expect_filename=param['expect_filename'], expect_filename=param['expect_filename'],
fails=param['fails'], fails=param['fails'],
logfile=param.get('logfile', self.obj_dir + "/vlt_sim.log"), logfile=param.get('logfile', self.obj_dir + "/vlt_sim.log"),
@ -1634,7 +1621,6 @@ class VlTest:
aslr_off=False, # Disable address space layour randomization aslr_off=False, # Disable address space layour randomization
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=None, # Regexp to expect in output
expect_filename=None, # Filename that should match logfile expect_filename=None, # Filename that should match logfile
fails=False, # Command should fail fails=False, # Command should fail
logfile=None, # Filename to write putput to logfile=None, # Filename to write putput to
@ -1741,12 +1727,12 @@ class VlTest:
return False return False
# Read the log file a couple of times to allow for NFS delays # Read the log file a couple of times to allow for NFS delays
if check_finished or expect: if check_finished:
for tryn in range(self.tries() - 1, -1, -1): for tryn in range(self.tries() - 1, -1, -1):
if tryn != self.tries() - 1: if tryn != self.tries() - 1:
time.sleep(1) time.sleep(1)
moretry = tryn != 0 moretry = tryn != 0
if self._run_log_try(cmd, logfile, check_finished, moretry, expect): if not self._run_log_try(logfile, check_finished, moretry):
break break
if expect_filename: if expect_filename:
self.files_identical(logfile, expect_filename, is_logfile=True) self.files_identical(logfile, expect_filename, is_logfile=True)
@ -1754,8 +1740,8 @@ class VlTest:
return True return True
def _run_log_try(self, cmd: str, logfile: str, check_finished: bool, moretry: bool, def _run_log_try(self, logfile: str, check_finished: bool, moretry: bool) -> bool:
expect) -> None: # If moretry, then return true to try again
with open(logfile, 'r', encoding='latin-1', newline='\n') as fh: with open(logfile, 'r', encoding='latin-1', newline='\n') as fh:
if not fh and moretry: if not fh and moretry:
return True return True
@ -1766,31 +1752,6 @@ class VlTest:
if moretry: if moretry:
return True return True
self.error("Missing '*-* All Finished *-*'") self.error("Missing '*-* All Finished *-*'")
if expect:
# Strip debugging comments
# See also files_identical
wholefile = re.sub(r'^- [^\n]+\n', '', wholefile)
wholefile = re.sub(r'^- [a-z.0-9]+:\d+:[^\n]+\n', '', wholefile)
wholefile = re.sub(r'^dot [^\n]+\n', '', wholefile)
wholefile = re.sub(r'^==[0-9]+== [^\n]+\n', '', wholefile) # Valgrind
# Compare
quoted = (re.escape(expect) or self._try_regex(wholefile, expect) == 1
or re.search(expect, wholefile))
ok = (wholefile == expect or self._try_regex(wholefile, expect) == 1
or re.search(quoted, wholefile))
if not ok:
#print("**BAD " + self.name + " " + logfile + " MT " + moretry + " " + try)
if moretry:
return True
self.error("Miscompares in output from " + cmd[0])
if ok < 1:
self.error("Might be error in regexp format")
print("GOT:")
print(wholefile)
print("ENDGOT")
print("EXPECT:")
print(expect)
print("ENDEXPECT")
return False return False
@ -2170,6 +2131,7 @@ class VlTest:
break break
def _files_identical_try(self, fn1: str, fn2: str, is_logfile: bool, moretry: bool) -> bool: def _files_identical_try(self, fn1: str, fn2: str, is_logfile: bool, moretry: bool) -> bool:
# If moretry, then return true to try again
try: try:
f1 = open( # pylint: disable=consider-using-with f1 = open( # pylint: disable=consider-using-with
fn1, 'r', encoding='latin-1', newline='\n') fn1, 'r', encoding='latin-1', newline='\n')
@ -2187,20 +2149,21 @@ class VlTest:
self.copy_if_golden(fn1, fn2) self.copy_if_golden(fn1, fn2)
self.error("Files_identical file does not exist: " + fn2) self.error("Files_identical file does not exist: " + fn2)
return True return True
ok = self._files_identical_reader(f1, again = self._files_identical_reader(f1,
f2, f2,
fn1=fn1, fn1=fn1,
fn2=fn2, fn2=fn2,
is_logfile=is_logfile, is_logfile=is_logfile,
moretry=moretry) moretry=moretry)
if f1: if f1:
f1.close() f1.close()
if f2: if f2:
f2.close() f2.close()
return ok return again
def _files_identical_reader(self, f1, f2, fn1: str, fn2: str, is_logfile: bool, def _files_identical_reader(self, f1, f2, fn1: str, fn2: str, is_logfile: bool,
moretry: bool) -> None: moretry: bool) -> None:
# If moretry, then return true to try again
l1s = f1.readlines() l1s = f1.readlines()
l2s = f2.readlines() if f2 else [] l2s = f2.readlines() if f2 else []
# print(" rawGOT="+pformat(l1s)+"\n rawEXP="+pformat(l2s)) # print(" rawGOT="+pformat(l1s)+"\n rawEXP="+pformat(l2s))
@ -2270,7 +2233,7 @@ class VlTest:
file=sys.stderr) file=sys.stderr)
return False return False
return True return False # Good
def files_identical_sorted(self, fn1: str, fn2: str, is_logfile=False) -> None: def files_identical_sorted(self, fn1: str, fn2: str, is_logfile=False) -> None:
"""Test if two files, after sorting both, have identical contents""" """Test if two files, after sorting both, have identical contents"""

View File

@ -21,7 +21,7 @@ test.compile(v_flags2=[
test.execute(fails=test.vlt_all) test.execute(fails=test.vlt_all)
test.file_grep(test.obj_dir + "/vlt_compile.log", 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"')
test.passes() test.passes()

View File

@ -12,6 +12,8 @@ import vltest_bootstrap
test.scenarios('vlt') test.scenarios('vlt')
test.top_filename = "t_EXAMPLE.v" test.top_filename = "t_EXAMPLE.v"
test.lint(verilator_flags2=["--debug-exit-parse"], expect='--debug-exit-parse') test.lint(verilator_flags2=["--debug-exit-parse"])
test.file_grep(test.compile_log_filename, r'--debug-exit-parse')
test.passes() test.passes()

View File

@ -14,9 +14,9 @@ test.scenarios('vlt')
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"], test.lint(verilator_flags2=["--debug-fatalsrc"], fails=test.vlt_all)
fails=test.vlt_all,
expect="""%Error: Internal Error: .*: --debug-fatal-src test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
.* See the manual .*""") test.file_grep(test.compile_log_filename, r'See the manual')
test.passes() test.passes()

View File

@ -16,11 +16,10 @@ 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"], test.lint(verilator_flags2=["--lint-only --debug --gdbbt --debug-fatalsrc"], fails=True)
fails=True,
expect="""%Error: Internal Error: .*: --debug-fatal-src test.file_grep(test.compile_log_filename, r'%Error: Internal Error: .*: --debug-fatal-src')
.*See the manual .* test.file_grep(test.compile_log_filename, r'See the manual')
.*in V3Options::.* test.file_grep(test.compile_log_filename, r'in V3Options::')
.*%Error: Command Failed.*""")
test.passes() test.passes()

View File

@ -16,10 +16,10 @@ 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(v_flags=["--debug-sigsegv"], test.lint(v_flags=["--debug-sigsegv"], fails=True, sanitize=0)
fails=True,
sanitize=0, test.file_grep(test.compile_log_filename,
expect="""%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt r'%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt')
%Error: Command Failed.*""") test.file_grep(test.compile_log_filename, r'Command Failed')
test.passes() test.passes()

View File

@ -17,10 +17,9 @@ 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=test.vlt_all)
expect=""".*
Program received signal SIGSEGV, Segmentation fault. test.file_grep(test.compile_log_filename, r'Program received signal SIGSEGV')
.*in V3Options::.* test.file_grep(test.compile_log_filename, r'in V3Options::')
.*%Error: Command Failed.*""")
test.passes() test.passes()

View File

@ -12,9 +12,10 @@ import vltest_bootstrap
test.scenarios('vlt') test.scenarios('vlt')
test.compile(v_flags2=["--generate-key"], test.compile(v_flags2=["--generate-key"],
expect=r'VL-KEY',
verilator_make_gmake=False, verilator_make_gmake=False,
make_top_shell=False, make_top_shell=False,
make_main=False) make_main=False)
test.file_grep(test.compile_log_filename, r'VL-KEY')
test.passes() test.passes()

View File

@ -14,10 +14,11 @@ test.scenarios('vlt')
test.setenv('FOOBARTEST', "gotit") test.setenv('FOOBARTEST', "gotit")
test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --getenv FOOBARTEST"], test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --getenv FOOBARTEST"],
expect=r'gotit', logfile=test.compile_log_filename,
logfile=test.obj_dir + "/simx.log",
verilator_run=True) verilator_run=True)
test.file_grep(test.compile_log_filename, r'gotit')
for var in [ for var in [
'MAKE', 'PERL', 'PYTHON3', 'SYSTEMC', 'SYSTEMC_ARCH', 'SYSTEMC_LIBDIR', 'VERILATOR_ROOT' 'MAKE', 'PERL', 'PYTHON3', 'SYSTEMC', 'SYSTEMC_ARCH', 'SYSTEMC_LIBDIR', 'VERILATOR_ROOT'
]: ]:

View File

@ -11,8 +11,8 @@ import vltest_bootstrap
test.scenarios('vlt') test.scenarios('vlt')
test.lint(verilator_flags2=["--instr-count-dpi -1"], test.lint(verilator_flags2=["--instr-count-dpi -1"], fails=True)
fails=True,
expect="%Error: --instr-count-dpi must be non-negative: -1") test.file_grep(test.compile_log_filename, "%Error: --instr-count-dpi must be non-negative: -1")
test.passes() test.passes()

View File

@ -16,7 +16,7 @@ test.top_filename = "t/t_file_does_not_exist.v"
# "Command Failed" line # "Command Failed" line
test.compile(v_flags2=["--quiet-exit"], fails=True) test.compile(v_flags2=["--quiet-exit"], fails=True)
test.file_grep_not(test.obj_dir + "/vlt_compile.log", r'Exiting due to') test.file_grep_not(test.compile_log_filename, r'Exiting due to')
test.file_grep_not(test.obj_dir + "/vlt_compile.log", r'Command Failed') test.file_grep_not(test.compile_log_filename, r'Command Failed')
test.passes() test.passes()

View File

@ -15,6 +15,6 @@ test.compile(verilator_flags2=['--quiet-stats'],
verilator_make_gcc=False, verilator_make_gcc=False,
logfile=test.run_log_filename) logfile=test.run_log_filename)
test.file_grep_not(test.obj_dir + '/vlt_compile.log', r'V e r i l a t') test.file_grep_not(test.compile_log_filename, r'V e r i l a t')
test.passes() test.passes()

View File

@ -14,6 +14,6 @@ test.top_filename = "t/t_flag_quiet_stats.v"
test.compile(verilator_flags2=['--quiet'], verilator_make_gcc=False, logfile=test.run_log_filename) test.compile(verilator_flags2=['--quiet'], verilator_make_gcc=False, logfile=test.run_log_filename)
test.file_grep_not(test.obj_dir + '/vlt_compile.log', r'V e r i l a t') test.file_grep_not(test.compile_log_filename, r'V e r i l a t')
test.passes() test.passes()

View File

@ -16,6 +16,6 @@ test.compile(verilator_flags2=['--quiet --no-quiet-stats'],
verilator_make_gcc=False, verilator_make_gcc=False,
logfile=test.run_log_filename) logfile=test.run_log_filename)
test.file_grep(test.obj_dir + '/vlt_compile.log', r'V e r i l a t') test.file_grep(test.compile_log_filename, r'V e r i l a t')
test.passes() test.passes()

View File

@ -13,21 +13,19 @@ test.scenarios('vlt')
if test.have_coroutines: if test.have_coroutines:
test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported COROUTINES"], test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported COROUTINES"],
expect="""1
""",
logfile=test.obj_dir + "/vlt_coroutines.log", logfile=test.obj_dir + "/vlt_coroutines.log",
expect_filename="t/t_flag_supported_1.out",
verilator_run=True) verilator_run=True)
if test.have_sc: if test.have_sc:
test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported SYSTEMC"], test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported SYSTEMC"],
expect="""1
""",
logfile=test.obj_dir + "/vlt_systemc.log", logfile=test.obj_dir + "/vlt_systemc.log",
expect_filename="t/t_flag_supported_1.out",
verilator_run=True) verilator_run=True)
test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported DOES_NOT_EXIST"], test.run(cmd=[os.environ["VERILATOR_ROOT"] + "/bin/verilator --get-supported DOES_NOT_EXIST"],
expect='',
logfile=test.obj_dir + "/vlt_does_not_exist.log", logfile=test.obj_dir + "/vlt_does_not_exist.log",
expect_filename="t/t_flag_supported_empty.out",
verilator_run=True) verilator_run=True)
test.passes() test.passes()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@

View File

@ -11,6 +11,8 @@ import vltest_bootstrap
test.scenarios('dist') test.scenarios('dist')
n = 0
for prog in [ for prog in [
# See also t_flag_help.py # See also t_flag_help.py
os.environ["VERILATOR_ROOT"] + "/bin/verilator", os.environ["VERILATOR_ROOT"] + "/bin/verilator",
@ -19,24 +21,22 @@ for prog in [
#os.environ["VERILATOR_ROOT"] + "/bin/verilator_gantt", #os.environ["VERILATOR_ROOT"] + "/bin/verilator_gantt",
#os.environ["VERILATOR_ROOT"] + "/bin/verilator_profcfunc", #os.environ["VERILATOR_ROOT"] + "/bin/verilator_profcfunc",
]: ]:
n += 1
log_filename = test.obj_dir + "/vlt_" + str(n) + ".log"
test.run(fails=False, test.run(fails=False,
cmd=["perl", prog, "--version"], cmd=["perl", prog, "--version"],
tee=test.verbose, tee=test.verbose,
logfile=test.obj_dir + "/t_help.log", logfile=log_filename,
expect=r'^Verilator',
verilator_run=True) verilator_run=True)
test.file_grep(log_filename, r'Verilator')
n += 1
log_filename = test.obj_dir + "/vlt_" + str(n) + ".log"
test.run(fails=False, test.run(fails=False,
cmd=["perl", prog, "-V"], cmd=["perl", prog, "-V"],
tee=test.verbose, tee=test.verbose,
logfile=test.obj_dir + "/t_help.log", logfile=log_filename,
expect=r'^Verilator',
verilator_run=True)
test.run(fails=False,
cmd=["perl", prog, "-V"],
logfile=test.obj_dir + "/t_help.log",
expect=r'^Verilator',
verilator_run=True) verilator_run=True)
test.file_grep(log_filename, r'Verilator')
test.passes() test.passes()

View File

@ -13,8 +13,9 @@ test.scenarios('simulator')
test.compile() test.compile()
test.execute(expect="""[10] hello test.execute()
[20] world
""") test.file_grep(test.run_log_filename, r"\[10\] hello")
test.file_grep(test.run_log_filename, r"\[20\] world")
test.passes() test.passes()

View File

@ -30,6 +30,7 @@ if test.vlt_all:
test.file_grep(out_filename, test.file_grep(out_filename,
r'{"type":"MODULE","name":"l5__P2",.*"loc":"f,83:[^"]*",.*"origName":"l5"') r'{"type":"MODULE","name":"l5__P2",.*"loc":"f,83:[^"]*",.*"origName":"l5"')
test.execute(expect=r"\] (%m|.*t\.ps): Clocked", ) test.execute()
test.file_grep(test.run_log_filename, r"\] (%m|.*t\.ps): Clocked")
test.passes() test.passes()

View File

@ -53,6 +53,7 @@ if test.vlt_all:
check_relative_refs("l5__P1", True) check_relative_refs("l5__P1", True)
check_relative_refs("l5__P2", True) check_relative_refs("l5__P2", True)
test.execute(expect=r"\] (%m|.*t\.ps): Clocked") test.execute()
test.file_grep(test.run_log_filename, r"\] (%m|.*t\.ps): Clocked")
test.passes() test.passes()

View File

@ -32,6 +32,7 @@ if test.vlt_all:
r'{"type":"VAR","name":"t.u.u1.u0.z0",.*"loc":"f,70:[^"]*",.*"origName":"z0",.*"dtypeName":"logic"' r'{"type":"VAR","name":"t.u.u1.u0.z0",.*"loc":"f,70:[^"]*",.*"origName":"z0",.*"dtypeName":"logic"'
) )
test.execute(expect=r"\] (%m|.*t\.ps): Clocked\n") test.execute()
test.file_grep(test.run_log_filename, r"\] (%m|.*t\.ps): Clocked")
test.passes() test.passes()

View File

@ -33,6 +33,7 @@ if test.vlt_all:
r'{"type":"VAR","name":"u.u0.u1.u0.u0.z",.*"loc":"f,83:[^"]*",.*"origName":"z",.*,"isSigPublic":true,.*dtypeName":"logic",.*"isSigUserRdPublic":true,.*"isSigUserRWPublic":true' r'{"type":"VAR","name":"u.u0.u1.u0.u0.z",.*"loc":"f,83:[^"]*",.*"origName":"z",.*,"isSigPublic":true,.*dtypeName":"logic",.*"isSigUserRdPublic":true,.*"isSigUserRWPublic":true'
) )
test.execute(expect=r"\] (%m|.*t\.ps): Clocked") test.execute()
test.file_grep(test.run_log_filename, r"\] (%m|.*t\.ps): Clocked")
test.passes() test.passes()

View File

@ -13,9 +13,9 @@ test.scenarios('simulator')
test.compile() test.compile()
test.execute( test.execute()
# Make sure we get the finish statement called
expect=r"""\*-\* All Finished \*-\* # Make sure we get the finish statement called
Goodbye world, at cycle \d+.*""") test.file_grep(test.run_log_filename, r'Goodbye world, at cycle \d')
test.passes() test.passes()

View File

@ -11,12 +11,13 @@ import vltest_bootstrap
test.scenarios('simulator') test.scenarios('simulator')
test.compile( test.compile(fails=test.vlt_all)
fails=test.vlt_all,
# Used to be %Error: t/t_order_wireloop.v:\d+: Wire inputs its own output, creating circular logic .wire x=x. # Used to be %Error: t/t_order_wireloop.v:\d+: Wire inputs its own output, creating circular logic .wire x=x.
# However we no longer gate optimize this # However we no longer gate optimize this
# Can't use expect_filename here as unstable output # Can't use expect_filename here as unstable output
expect= test.file_grep(
test.compile_log_filename,
r"%Warning-UNOPTFLAT: t/t_order_wireloop.v:\d+:\d+: Signal unoptimizable: Circular combinational logic: \'bar\'" r"%Warning-UNOPTFLAT: t/t_order_wireloop.v:\d+:\d+: Signal unoptimizable: Circular combinational logic: \'bar\'"
) )

View File

@ -12,8 +12,9 @@ import vltest_bootstrap
test.scenarios('vlt') test.scenarios('vlt')
test.top_filename = "t/t_pipe_filter.v" test.top_filename = "t/t_pipe_filter.v"
test.lint(verilator_flags2=['-E --pipe-filter \'python3 t/t_pipe_exit_bad_pf.pf\' '], test.lint(verilator_flags2=['-E --pipe-filter \'python3 t/t_pipe_exit_bad_pf.pf\' '], fails=True)
fails=True,
expect=r'%Error: t_pipe_exit_bad_pf.pf: Intentional bad exit status....*') test.file_grep(test.compile_log_filename,
r'%Error: t_pipe_exit_bad_pf.pf: Intentional bad exit status....*')
test.passes() test.passes()

View File

@ -11,9 +11,9 @@ import vltest_bootstrap
test.scenarios('vlt') test.scenarios('vlt')
test.lint( test.lint(fails=True)
fails=True,
# EOF result varies with Bison version, so can't use .out # EOF result varies with Bison version, so can't use .out
expect=r'define or other nested inclusion') test.file_grep(test.compile_log_filename, r'define or other nested inclusion')
test.passes() test.passes()

View File

@ -14,14 +14,16 @@ test.scenarios('vlt_all')
test.compile() test.compile()
test.execute(all_run_flags=["+verilator+debug +verilator+debugi+9 +verilator+rand+reset+1"], test.execute(all_run_flags=["+verilator+debug +verilator+debugi+9 +verilator+rand+reset+1"],
expect=r'.*Verilated::debug is on.*') logfile=test.obj_dir + "/vlt_1.log")
test.file_grep(test.obj_dir + "/vlt_1.log", r'Verilated::debug is on')
test.execute(all_run_flags=["+verilator+help"], test.execute(all_run_flags=["+verilator+help"], fails=True, logfile=test.obj_dir + "/vlt_2.log")
fails=True, test.file_grep(test.obj_dir + "/vlt_2.log", r"For help, please see 'verilator --help'")
expect=r".*For help, please see 'verilator --help'.*")
test.execute(all_run_flags=["+verilator+V"], fails=True, expect=r'.*Version:.*') test.execute(all_run_flags=["+verilator+V"], fails=True, logfile=test.obj_dir + "/vlt_3.log")
test.file_grep(test.obj_dir + "/vlt_3.log", r'Version:')
test.execute(all_run_flags=["+verilator+version"], fails=True, expect=r'.*Version:.*') test.execute(all_run_flags=["+verilator+version"], fails=True, logfile=test.obj_dir + "/vlt_4.log")
test.file_grep(test.obj_dir + "/vlt_4.log", r'Version:')
test.passes() test.passes()

View File

@ -16,6 +16,6 @@ test.compile(verilator_flags2=['--cc --debug-nondeterminism --no-skip-identical'
test.execute() test.execute()
test.file_grep(test.obj_dir + "/vlt_compile.log", r'Hash of shape') test.file_grep(test.compile_log_filename, r'Hash of shape')
test.passes() test.passes()

View File

@ -12,10 +12,10 @@ import vltest_bootstrap
test.scenarios('simulator') test.scenarios('simulator')
# Should convert the first always into combo and detect cycle # Should convert the first always into combo and detect cycle
test.compile( test.compile(fails=True, verilator_flags2=["--timing"])
fails=True,
verilator_flags2=["--timing"], test.file_grep(
expect= test.compile_log_filename,
r'%Warning-UNOPTFLAT: t/t_timing_fork_comb.v:\d+:\d+: Signal unoptimizable: Circular combinational logic:' r'%Warning-UNOPTFLAT: t/t_timing_fork_comb.v:\d+:\d+: Signal unoptimizable: Circular combinational logic:'
) )

View File

@ -11,10 +11,9 @@ import vltest_bootstrap
test.scenarios('linter') test.scenarios('linter')
test.lint( test.lint(verilator_flags2=["--lint-only --bbox-unsup"], fails=test.vlt_all)
verilator_flags2=["--lint-only --bbox-unsup"],
fails=test.vlt_all, # Cannot use .out, get "$end" or "end of file" depending on bison version
# Cannot use .out, get "$end" or "end of file" depending on bison version test.file_grep(test.compile_log_filename, r"EOF in 'table'")
expect=r"EOF in 'table'")
test.passes() test.passes()

View File

@ -43,6 +43,8 @@ gen(test.top_filename)
test.compile() test.compile()
test.execute(expect=hi) test.execute()
test.file_grep(test.run_log_filename, hi)
test.passes() test.passes()