Tests: Refactor to create test.root variable. No test change.

This commit is contained in:
Wilson Snyder 2025-09-14 08:43:52 -04:00
parent b455f9b591
commit a2b6aca288
43 changed files with 147 additions and 228 deletions

View File

@ -618,6 +618,7 @@ class VlTest:
self.py_filename = py_filename # Name of .py file to get setup from
self.running_id = running_id
self.scenario = scenario
self.root = '..' # Relative path to git root (above test_regress)
self._force_pass = False
self._have_solver_called = False

View File

@ -12,8 +12,6 @@ import vltest_bootstrap
test.scenarios('dist')
test.rerunnable = False
root = ".."
def have_clang_check():
cmd = 'python3 -c "from clang.cindex import Index; index = Index.create(); print(\\"Clang imported\\")";'
@ -27,21 +25,21 @@ def have_clang_check():
if 'VERILATOR_TEST_NO_ATTRIBUTES' in os.environ:
test.skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES")
if not os.path.exists(root + "/src/obj_dbg/compile_commands.json"):
if not os.path.exists(test.root + "/src/obj_dbg/compile_commands.json"):
test.skip("compile_commands.json not found. Please install 'bear > 3.0' and rebuild Verilator")
if not have_clang_check():
test.skip("No libclang installed")
# some of the files are only used in Verilation
# and are only in "include" folder
srcfiles = test.glob_some(root + "/include/*.cpp")
srcfiles = test.glob_some(test.root + "/include/*.cpp")
srcfiles_str = " ".join(srcfiles)
clang_args = "-I" + root + "/include/ -I" + root + "/include/vltstd/ -fcoroutines-ts"
clang_args = "-I" + test.root + "/include/ -I" + test.root + "/include/vltstd/ -fcoroutines-ts"
test.run(logfile=test.run_log_filename,
tee=True,
cmd=["python3", root + "/nodist/clang_check_attributes",
"--verilator-root=" + root,
cmd=["python3", test.root + "/nodist/clang_check_attributes",
"--verilator-root=" + test.root,
"--cxxflags='" + clang_args + "'",
srcfiles_str]) # yapf:disable

View File

@ -12,8 +12,6 @@ import vltest_bootstrap
test.scenarios('dist')
test.rerunnable = False
root = ".."
def have_clang_check():
cmd = 'python3 -c "from clang.cindex import Index; index = Index.create(); print(\\"Clang imported\\")";'
@ -27,24 +25,25 @@ def have_clang_check():
if 'VERILATOR_TEST_NO_ATTRIBUTES' in os.environ:
test.skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES")
if not os.path.exists(root + "/src/obj_dbg/compile_commands.json"):
if not os.path.exists(test.root + "/src/obj_dbg/compile_commands.json"):
test.skip("compile_commands.json not found. Please install 'bear > 3.0' and rebuild Verilator")
if not have_clang_check():
test.skip("No libclang installed")
# some of the files are only used in Verilation
# and are only in "include" folder
srcfiles = test.glob_some(root + "/src/*.cpp") + test.glob_some(root +
"/src/obj_dbg/V3Const__gen.cpp")
srcfiles = test.glob_some(test.root +
"/src/*.cpp") + test.glob_some(test.root +
"/src/obj_dbg/V3Const__gen.cpp")
srcfiles = [f for f in srcfiles if re.search(r'\/(V3Const|Vlc\w*|\w*_test|\w*_sc|\w*.yy).cpp$', f)]
srcfiles_str = " ".join(srcfiles)
test.run(logfile=test.run_log_filename,
tee=True,
cmd=["python3", root + "/nodist/clang_check_attributes",
"--verilator-root=" + root,
"--compilation-root=" + root + "/src/obj_dbg",
"--compile-commands-dir=" + root + "/src/obj_dbg",
cmd=["python3", test.root + "/nodist/clang_check_attributes",
"--verilator-root=" + test.root,
"--compilation-root=" + test.root + "/src/obj_dbg",
"--compile-commands-dir=" + test.root + "/src/obj_dbg",
srcfiles_str]) # yapf:disable
test.file_grep(test.run_log_filename, r'Number of functions reported unsafe: +(\d+)', 0)

View File

@ -13,12 +13,10 @@ test.scenarios('dist')
test.clean_command = '/bin/rm -rf ../examples/*/build ../examples/*/obj*'
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
examples = sorted(test.glob_some(root + "/examples/*"))
examples = sorted(test.glob_some(test.root + "/examples/*"))
for example in examples:
test.run(cmd=[os.environ["MAKE"], "-C", example])

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('simulator')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.compile(verilator_flags2=['--assert'],
@ -23,35 +21,35 @@ test.compile(verilator_flags2=['--assert'],
expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_USERWARN_faulty.rst",
out_filename=test.root + "/docs/gen/ex_USERWARN_faulty.rst",
regexp=r'\$warn.*User')
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_USERERROR_faulty.rst",
out_filename=test.root + "/docs/gen/ex_USERERROR_faulty.rst",
regexp=r'\$error.*User')
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_USERINFO_faulty.rst",
out_filename=test.root + "/docs/gen/ex_USERINFO_faulty.rst",
regexp=r'\$info.*User')
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_USERFATAL_faulty.rst",
out_filename=test.root + "/docs/gen/ex_USERFATAL_faulty.rst",
regexp=r'\$fatal.*User')
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_USERWARN_msg.rst",
out_filename=test.root + "/docs/gen/ex_USERWARN_msg.rst",
regexp=r'USERWARN:.* User')
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_USERERROR_msg.rst",
out_filename=test.root + "/docs/gen/ex_USERERROR_msg.rst",
regexp=r'USERERROR:.* User')
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_USERINFO_msg.rst",
out_filename=test.root + "/docs/gen/ex_USERINFO_msg.rst",
regexp=r'-Info:.* User')
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_USERFATAL_msg.rst",
out_filename=test.root + "/docs/gen/ex_USERFATAL_msg.rst",
regexp=r'USERFATAL:.* User')
test.passes()

View File

@ -14,15 +14,13 @@ import os
test.scenarios('vlt_all')
test.sim_time = 2000000
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
# Read expected source lines hit
expectedLines = set()
with open(root + "/src/V3DfgBreakCycles.cpp", 'r', encoding="utf8") as fd:
with open(test.root + "/src/V3DfgBreakCycles.cpp", 'r', encoding="utf8") as fd:
for lineno, line in enumerate(fd, 1):
line = line.split("//")[0]
if re.match(r'^[^#]*SET_RESULT', line):

View File

@ -12,9 +12,7 @@ import vltest_bootstrap
test.scenarios('vlt_all')
test.sim_time = 2000000
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
# Read optimizations

View File

@ -12,9 +12,7 @@ import vltest_bootstrap
test.scenarios('vlt_all')
test.sim_time = 2000000
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
# Generate the equivalence checks and declaration boilerplate

View File

@ -12,9 +12,7 @@ import vltest_bootstrap
test.scenarios('vlt_all')
test.sim_time = 2000000
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
# Generate the equivalence checks and declaration boilerplate

View File

@ -12,8 +12,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
def have_clang_check():
cmd = 'python3 -c "from clang.cindex import Index; index = Index.create(); print(\\"Clang imported\\")";'
@ -27,15 +25,15 @@ def have_clang_check():
if 'VERILATOR_TEST_NO_ATTRIBUTES' in os.environ:
test.skip("Skipping due to VERILATOR_TEST_NO_ATTRIBUTES")
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
if not have_clang_check():
test.skip("No libclang installed")
aroot = os.path.abspath(root)
aroot = os.path.abspath(test.root)
ccjson_file = test.obj_dir + "/compile_commands.json"
aroot_dir = os.path.abspath(root)
aroot_dir = os.path.abspath(test.root)
srcs_dir = os.path.abspath("./t/t_dist_attributes")
common_args = [
"clang++", "-std=c++14", "-I" + aroot_dir + "/include", "-I" + aroot_dir + "/src", "-c"

View File

@ -11,13 +11,11 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
### Must trim output before and after our file list
cmd = "cd " + root + " && git ls-files --exclude-standard"
cmd = "cd " + test.root + " && git ls-files --exclude-standard"
files = test.run_capture(cmd)
if test.verbose:
print("ST " + files)
@ -29,7 +27,7 @@ for filename in files.split():
continue
if "test_regress/t/uvm/dpi/" in filename: # Standard file - can't change it
continue
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename):
continue
with open(filename, 'r', encoding='latin-1') as fh:

View File

@ -11,8 +11,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
Contributors = {'github action': True}
Authors = {}
@ -27,7 +25,7 @@ def read_contributors(filename):
def read_user():
cmd = "cd " + root + " && git diff-index --quiet HEAD --"
cmd = "cd " + test.root + " && git diff-index --quiet HEAD --"
changes = test.run_capture(cmd, check=False)
changes = changes.rstrip()
if changes == "":
@ -51,7 +49,7 @@ def read_authors():
def check():
read_contributors(root + "/docs/CONTRIBUTORS")
read_contributors(test.root + "/docs/CONTRIBUTORS")
read_user()
read_authors()
for author in sorted(Authors.keys()):
@ -80,7 +78,7 @@ def check():
if 'VERILATOR_TEST_NO_CONTRIBUTORS' in os.environ:
test.skip("Skipping due to VERILATOR_TEST_NO_CONTRIBUTORS")
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
check()

View File

@ -51,16 +51,14 @@ EXEMPT_FILES_LIST = """
verilator.pc.in
"""
root = ".."
Exempt_Files_List_Re = list(map(re.escape, EXEMPT_FILES_LIST.split()))
Exempt_Files_List_Re = '^(' + '|'.join(Exempt_Files_List_Re) + ")"
# pprint(Exempt_Files_List_Re)
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
cmd = "cd " + root + " && git ls-files --exclude-standard"
cmd = "cd " + test.root + " && git ls-files --exclude-standard"
out = test.run_capture(cmd)
year = datetime.datetime.now().year
@ -75,7 +73,7 @@ for filename in out.split():
files[filename] = True
for filename in files:
open_filename = os.path.join(root, filename)
open_filename = os.path.join(test.root, filename)
if not os.path.exists(open_filename):
continue
with open(open_filename, 'r', encoding="utf8") as fh:

View File

@ -11,11 +11,9 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
def get_source_files(root):
git_files = test.run_capture("cd " + root + " && git ls-files")
def get_source_files():
git_files = test.run_capture("cd " + test.root + " && git ls-files")
if test.verbose:
print("MF " + git_files)
files = {}
@ -48,13 +46,13 @@ def check_pattern(filename, contents, pattern, not_pattern, message):
buffer = "\n"
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
files = get_source_files(root)
files = get_source_files()
for filename in sorted(files.keys()):
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename): # git file might be deleted but not yet staged
continue
if not re.search(r'\.(h|c|cpp)(\.in)?$', filename):

View File

@ -11,11 +11,9 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
def get_source_files(root):
git_files = test.run_capture("cd " + root + " && git ls-files")
def get_source_files():
git_files = test.run_capture("cd " + test.root + " && git ls-files")
if test.verbose:
print("MF " + git_files)
files = {}
@ -100,14 +98,14 @@ def _option_sort_key(opt):
#####
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
### Must trim output before and after our file list
files = get_source_files(root)
files = get_source_files()
for filename in sorted(files.keys()):
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename): # git file might be deleted but not yet staged
continue
if not re.search(r'\.rst$', filename):

View File

@ -11,8 +11,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
Waivers = [
'+verilator+prof+threads+file+', # Deprecated
'+verilator+prof+threads+start+', # Deprecated
@ -25,9 +23,9 @@ Waivers = [
]
def get_summary_opts(root):
def get_summary_opts():
args = {}
for filename in test.glob_some(root + "/bin/*"):
for filename in test.glob_some(test.root + "/bin/*"):
with open(filename, "r", encoding="latin-1") as fh:
on = False
lineno = 0
@ -53,9 +51,9 @@ def get_summary_opts(root):
return args
def get_docs_opts(root):
def get_docs_opts():
args = {}
for filename in test.glob_some(root + "/docs/guide/*.rst"):
for filename in test.glob_some(test.root + "/docs/guide/*.rst"):
with open(filename, "r", encoding="latin-1") as fh:
lineno = 0
for line in fh:
@ -91,11 +89,11 @@ def alt_names(opt):
return opts
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
sums = get_summary_opts(root)
docs = get_docs_opts(root)
sums = get_summary_opts()
docs = get_docs_opts()
both = {}
both.update(sums)

View File

@ -11,8 +11,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
Waivers = [
'Internal',
'Unsupported',
@ -23,9 +21,9 @@ src_filename = "src/V3Error.h"
doc_filename = "docs/guide/warnings.rst"
def get_src_warns(root):
def get_src_warns():
args = {}
for filename in test.glob_some(root + "/" + src_filename):
for filename in test.glob_some(test.root + "/" + src_filename):
with open(filename, "r", encoding="latin-1") as fh:
state = 0
lineno = 0
@ -49,9 +47,9 @@ def get_src_warns(root):
return args
def get_docs_warns(root):
def get_docs_warns():
args = {}
for filename in test.glob_some(root + "/" + doc_filename):
for filename in test.glob_some(test.root + "/" + doc_filename):
with open(filename, "r", encoding="latin-1") as fh:
lineno = 0
last_opt = None
@ -77,11 +75,11 @@ def opt_clean(opt):
return opt
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
srcs = get_src_warns(root)
docs = get_docs_warns(root)
srcs = get_src_warns()
docs = get_docs_warns()
if len(srcs) < 10:
test.error(src_filename + ": Too few warnings found; parse error?")
if len(docs) < 10:

View File

@ -11,14 +11,12 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
# Check all error messages match our standard format
# This assumes .out files cover all important errors
def formats():
files = root + "/test_regress/t/*.out"
files = test.root + "/test_regress/t/*.out"
warns = {}
lnmatch = 0
for filename in test.glob_some(files):
@ -67,7 +65,7 @@ def formats():
test.error_keep_going(warns[filename])
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
formats()

View File

@ -11,13 +11,11 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
### Must trim output before and after our file list
files = test.run_capture("cd " + root + " && git ls-files --exclude-standard")
files = test.run_capture("cd " + test.root + " && git ls-files --exclude-standard")
if test.verbose:
print("ST " + files)
@ -28,7 +26,7 @@ regex = r'(FIX[M]E|BO[Z]O)'
for filename in files.split():
if re.search(regex, filename):
names[filename] = True
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename):
continue
wholefile = test.file_contents(filename)

View File

@ -12,11 +12,9 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
def get_source_files(root):
git_files = test.run_capture("cd " + root + " && git ls-files")
def get_source_files():
git_files = test.run_capture("cd " + test.root + " && git ls-files")
if test.verbose:
print("MF " + git_files)
files = {}
@ -27,14 +25,14 @@ def get_source_files(root):
return files
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
### Must trim output before and after our file list
files = get_source_files(root)
files = get_source_files()
for filename in sorted(files.keys()):
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename): # git file might be deleted but not yet staged
continue
if not re.search(r'include.*verilated.*\.[ch].*$', filename):

View File

@ -11,13 +11,11 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.run(cmd=[
"cd " + root + "/src/obj_dbg && " + os.environ['MAKE'] +
"cd " + test.root + "/src/obj_dbg && " + os.environ['MAKE'] +
" -j 4 -k -f ../Makefile_obj VL_NOOPT=1 header_cc"
],
check_finished=False)

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
cwd = os.getcwd()
@ -24,8 +22,9 @@ test.run(cmd=["rm -rf " + destdir + " && mkdir -p " + destdir], check_finished=F
# Install into temp area
print("Install...")
test.run(cmd=["cd " + root + " && " + os.environ["MAKE"] + " DESTDIR=" + destdir + " install-all"],
check_finished=False)
test.run(
cmd=["cd " + test.root + " && " + os.environ["MAKE"] + " DESTDIR=" + destdir + " install-all"],
check_finished=False)
# Check we can run a test
# Unfortunately the prefix was hardcoded in the exec at a different place,
@ -34,8 +33,9 @@ test.run(cmd=["cd " + root + " && " + os.environ["MAKE"] + " DESTDIR=" + destdir
# Uninstall
print("Uninstall...\n")
test.run(cmd=["cd " + root + " && " + os.environ["MAKE"] + " DESTDIR=" + destdir + " uninstall"],
check_finished=False)
test.run(
cmd=["cd " + test.root + " && " + os.environ["MAKE"] + " DESTDIR=" + destdir + " uninstall"],
check_finished=False)
# Check empty
files = []

View File

@ -11,13 +11,11 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if 'VERILATOR_TEST_NO_LINT_PY' in os.environ:
test.skip("Skipping due to VERILATOR_TEST_NO_LINT_PY")
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.run(cmd=["cd " + root + " && " + os.environ["MAKE"] + " lint-py"])
test.run(cmd=["cd " + test.root + " && " + os.environ["MAKE"] + " lint-py"])
test.passes()

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
for pl in sorted(glob.glob(root + "/test_regress/t/*.pl")):
for pl in sorted(glob.glob(test.root + "/test_regress/t/*.pl")):
if 'bootstrap.pl' in pl:
continue
py = re.sub(r'\.pl', '.py', pl)

View File

@ -11,8 +11,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
def line_filename(line):
m = re.search(r'^([^:]+)', line)
@ -21,7 +19,7 @@ def line_filename(line):
def printfll():
files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c* test_regress/t/*.c* test_regress/t/*.h"
cmd = "cd " + root + " && fgrep -n ll " + files + " | sort"
cmd = "cd " + test.root + " && fgrep -n ll " + files + " | sort"
grep = test.run_capture(cmd, check=False)
names = {}
for line in grep.splitlines():
@ -37,7 +35,7 @@ def printfll():
def cstr():
files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c* test_regress/t/*.c* test_regress/t/*.h"
cmd = "cd " + root + " && grep -n -P 'c_str|begin|end' " + files + " | sort"
cmd = "cd " + test.root + " && grep -n -P 'c_str|begin|end' " + files + " | sort"
grep = test.run_capture(cmd, check=False)
names = {}
for line in grep.splitlines():
@ -54,7 +52,7 @@ def cstr():
def vsnprintf():
# Note do not do test_regress, as VPI files need to compile without verilatedos.h
files = "src/*.c* src/*.h include/*.c* include/*.h examples/*/*.c*"
cmd = "cd " + root + " && grep -n -P '(snprintf|vsnprintf)' " + files + " | sort"
cmd = "cd " + test.root + " && grep -n -P '(snprintf|vsnprintf)' " + files + " | sort"
grep = test.run_capture(cmd, check=False)
names = {}
for line in grep.splitlines():
@ -70,7 +68,7 @@ def vsnprintf():
def final():
# Note do not do test_regress, as VPI files need to compile without verilatedos.h
files = "src/*.c* src/*.h include/*.c* include/*.h"
cmd = "cd " + root + " && grep -n -P '(class|struct)' " + files + " | sort"
cmd = "cd " + test.root + " && grep -n -P '(class|struct)' " + files + " | sort"
grep = test.run_capture(cmd, check=False)
names = {}
for line in grep.splitlines():
@ -89,7 +87,7 @@ def final():
' '.join(sorted(names.keys())))
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
printfll()

View File

@ -11,16 +11,14 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
### Must trim output before and after our file list
warns = {}
summary = None
status = test.run_capture("cd " + root + " && git ls-files -o --exclude-standard")
status = test.run_capture("cd " + test.root + " && git ls-files -o --exclude-standard")
if test.verbose:
print("-ST " + status)

View File

@ -11,8 +11,6 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
Messages = {}
Outputs = {}
Suppressed = {}
@ -114,7 +112,7 @@ for s in [
def read_messages():
for filename in test.glob_some(root + "/src/*"):
for filename in test.glob_some(test.root + "/src/*"):
if not os.path.isfile(filename):
continue
with open(filename, 'r', encoding="utf8") as fh:
@ -156,9 +154,9 @@ def read_messages():
def read_outputs():
for filename in (test.glob_some(root + "/test_regress/t/*.py") +
test.glob_some(root + "/test_regress/t/*.out") +
test.glob_some(root + "/docs/gen/*.rst")):
for filename in (test.glob_some(test.root + "/test_regress/t/*.py") +
test.glob_some(test.root + "/test_regress/t/*.out") +
test.glob_some(test.root + "/docs/gen/*.rst")):
if "t_dist_warn_coverage" in filename: # Avoid our own suppressions
continue
with open(filename, 'r', encoding="latin-1") as fh:
@ -224,7 +222,7 @@ def check():
print()
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
check()

View File

@ -11,13 +11,11 @@ import vltest_bootstrap
test.scenarios('dist')
root = ".."
Tabs_Exempt_Re = r'(\.out$)|(/gtkwave)|(Makefile)|(\.mk$)|(\.mk\.in$)|test_regress/t/t_preproc\.v|install-sh'
def get_source_files(root):
git_files = test.run_capture("cd " + root + " && git ls-files")
def get_source_files():
git_files = test.run_capture("cd " + test.root + " && git ls-files")
if test.verbose:
print("MF " + git_files)
files = {}
@ -28,17 +26,15 @@ def get_source_files(root):
return files
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
root = ".."
files = get_source_files(root)
files = get_source_files()
warns = {}
fcount = 0
for filename in sorted(files.keys()):
filename = os.path.join(root, filename)
filename = os.path.join(test.root, filename)
if not os.path.exists(filename): # git file might be deleted but not yet staged
continue
contents = test.file_contents(filename)

View File

@ -12,19 +12,17 @@ import vltest_bootstrap
test.scenarios('linter')
test.top_filename = 't/t_event_control_star_never.v'
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(verilator_flags2=['--timing'], fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_ALWNEVER_faulty.rst",
out_filename=test.root + "/docs/gen/ex_ALWNEVER_faulty.rst",
lines="9-9")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_ALWNEVER_msg.rst",
out_filename=test.root + "/docs/gen/ex_ALWNEVER_msg.rst",
lines="1-1")
test.passes()

View File

@ -12,18 +12,16 @@ import vltest_bootstrap
test.scenarios('vlt')
test.top_filename = "t/t_lint_assigneqexpr.v"
root = ".."
test.lint(verilator_flags2=['-Wall -Wno-DECLFILENAME'],
fails=True,
expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_ASSIGNEQEXPR_faulty.rst",
out_filename=test.root + "/docs/gen/ex_ASSIGNEQEXPR_faulty.rst",
lines="26-29")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_ASSIGNEQEXPR_msg.rst",
out_filename=test.root + "/docs/gen/ex_ASSIGNEQEXPR_msg.rst",
lines="7-8")
test.passes()

View File

@ -11,19 +11,17 @@ import vltest_bootstrap
test.scenarios('vlt')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_BADVLTPRAGMA_faulty.rst",
out_filename=test.root + "/docs/gen/ex_BADVLTPRAGMA_faulty.rst",
lines="7")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_BADVLTPRAGMA_msg.rst",
out_filename=test.root + "/docs/gen/ex_BADVLTPRAGMA_msg.rst",
lines="1-3")
test.passes()

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('vlt')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.compile(verilator_flags2=["--prof-cfuncs"])
@ -21,11 +19,11 @@ test.compile(verilator_flags2=["--prof-cfuncs"])
test.execute(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_DIDNOTCONVERGE_faulty.rst",
out_filename=test.root + "/docs/gen/ex_DIDNOTCONVERGE_faulty.rst",
lines="16-17")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_DIDNOTCONVERGE_msg.rst",
out_filename=test.root + "/docs/gen/ex_DIDNOTCONVERGE_msg.rst",
lines="1-2")
test.passes()

View File

@ -12,9 +12,7 @@ import vltest_bootstrap
test.scenarios('vlt')
test.top_filename = "t/t_lint_didnotconverge_bad.v"
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.compile(make_flags=['CPPFLAGS_ADD=-UVL_DEBUG'])
@ -22,7 +20,7 @@ test.compile(make_flags=['CPPFLAGS_ADD=-UVL_DEBUG'])
test.execute(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_DIDNOTCONVERGE_nodbg_msg.rst",
out_filename=test.root + "/docs/gen/ex_DIDNOTCONVERGE_nodbg_msg.rst",
lines="1")
test.passes()

View File

@ -11,19 +11,17 @@ import vltest_bootstrap
test.scenarios('linter')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_MULTIDRIVEN_faulty.rst",
out_filename=test.root + "/docs/gen/ex_MULTIDRIVEN_faulty.rst",
lines="31-36")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_MULTIDRIVEN_msg.rst",
out_filename=test.root + "/docs/gen/ex_MULTIDRIVEN_msg.rst",
lines="10,11,14")
test.passes()

View File

@ -12,19 +12,17 @@ import vltest_bootstrap
test.scenarios('linter')
test.top_filename = 't/t_lint_paramnodefault.v'
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_PARAMNODEFAULT_faulty.rst",
out_filename=test.root + "/docs/gen/ex_PARAMNODEFAULT_faulty.rst",
lines="7-8")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_PARAMNODEFAULT_msg.rst",
out_filename=test.root + "/docs/gen/ex_PARAMNODEFAULT_msg.rst",
lines="1-3")
test.passes()

View File

@ -11,19 +11,17 @@ import vltest_bootstrap
test.scenarios('linter')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_PINMISSING_faulty.rst",
out_filename=test.root + "/docs/gen/ex_PINMISSING_faulty.rst",
lines="7-12")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_PINMISSING_msg.rst",
out_filename=test.root + "/docs/gen/ex_PINMISSING_msg.rst",
lines="1-1")
test.passes()

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('vlt')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(verilator_flags2=['-Wall -Wno-DECLFILENAME'],
@ -21,15 +19,15 @@ test.lint(verilator_flags2=['-Wall -Wno-DECLFILENAME'],
expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_PROCASSINIT_faulty.rst",
out_filename=test.root + "/docs/gen/ex_PROCASSINIT_faulty.rst",
lines="26-32")
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_PROCASSINIT_fixed.rst",
out_filename=test.root + "/docs/gen/ex_PROCASSINIT_fixed.rst",
lines="36-45")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_PROCASSINIT_msg.rst",
out_filename=test.root + "/docs/gen/ex_PROCASSINIT_msg.rst",
lines="1-9")
test.passes()

View File

@ -11,19 +11,17 @@ import vltest_bootstrap
test.scenarios('vlt')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(verilator_flags2=["--no-timing"], fails=True, expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_STMTDLY_faulty.rst",
out_filename=test.root + "/docs/gen/ex_STMTDLY_faulty.rst",
lines="10")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_STMTDLY_msg.rst",
out_filename=test.root + "/docs/gen/ex_STMTDLY_msg.rst",
lines="1")
test.passes()

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('linter')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(verilator_flags2=["--lint-only"],
@ -21,16 +19,16 @@ test.lint(verilator_flags2=["--lint-only"],
expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_WIDTHEXPAND_1_faulty.rst",
out_filename=test.root + "/docs/gen/ex_WIDTHEXPAND_1_faulty.rst",
lines="8-10")
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_WIDTHEXPAND_1_msg.rst",
out_filename=test.root + "/docs/gen/ex_WIDTHEXPAND_1_msg.rst",
lineno_adjust=-7,
regexp=r'Warning-WIDTH')
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_WIDTHEXPAND_1_fixed.rst",
out_filename=test.root + "/docs/gen/ex_WIDTHEXPAND_1_fixed.rst",
lines="18")
test.passes()

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('linter')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.lint(verilator_flags2=["--lint-only -Wwarn-VARHIDDEN"],
@ -21,11 +19,11 @@ test.lint(verilator_flags2=["--lint-only -Wwarn-VARHIDDEN"],
expect_filename=test.golden_filename)
test.extract(in_filename=test.top_filename,
out_filename=root + "/docs/gen/ex_VARHIDDEN_faulty.rst",
out_filename=test.root + "/docs/gen/ex_VARHIDDEN_faulty.rst",
regexp=r'(module t|integer|endmodule)')
test.extract(in_filename=test.golden_filename,
out_filename=root + "/docs/gen/ex_VARHIDDEN_msg.rst",
out_filename=test.root + "/docs/gen/ex_VARHIDDEN_msg.rst",
lineno_adjust=-6,
regexp=r'(var_bad_hide)')

View File

@ -11,9 +11,7 @@ import vltest_bootstrap
test.scenarios('vltmt')
root = ".."
if not os.path.exists(root + "/.git"):
if not os.path.exists(test.root + "/.git"):
test.skip("Not in a git repository")
test.compile(
@ -22,7 +20,7 @@ test.compile(
"--cc", "--coverage-toggle --coverage-line --coverage-user",
"--trace-vcd --vpi ", "--trace-threads 1",
("--timing" if test.have_coroutines else "--no-timing -Wno-STMTDLY"), "--prof-exec",
"--prof-pgo", root + "/include/verilated_save.cpp"
"--prof-pgo", test.root + "/include/verilated_save.cpp"
],
threads=2)
@ -30,7 +28,8 @@ test.execute(
all_run_flags=[" +verilator+prof+exec+file+/dev/null", " +verilator+prof+vlt+file+/dev/null"])
hit = {}
for filename in (test.glob_some(root + "/include/*.cpp") + test.glob_some(root + "/include/*.h")):
for filename in (test.glob_some(test.root + "/include/*.cpp") +
test.glob_some(test.root + "/include/*.h")):
filename = os.path.basename(filename)
if test.verbose:
print("NEED: " + filename)

View File

@ -12,13 +12,11 @@ import vltest_bootstrap
test.scenarios('vlt')
test.top_filename = "t/t_verilated_all.v"
root = ".."
test.compile(
# Can't use --coverage and --savable together, so cheat and compile inline
verilator_flags2=[
"--cc --coverage-toggle --coverage-line --coverage-user --trace-vcd --prof-exec --prof-pgo --vpi "
+ root + "/include/verilated_save.cpp",
+ test.root + "/include/verilated_save.cpp",
("--timing" if test.have_coroutines else "--no-timing -Wno-STMTDLY")
],
make_flags=['DRIVER_STD=newest'])

View File

@ -12,13 +12,11 @@ import vltest_bootstrap
test.scenarios('vltmt')
test.top_filename = "t/t_verilated_all.v"
root = ".."
test.compile(
# Can't use --coverage and --savable together, so cheat and compile inline
verilator_flags2=[
"--cc --coverage-toggle --coverage-line --coverage-user --trace-vcd --vpi",
root + "/include/verilated_save.cpp",
test.root + "/include/verilated_save.cpp",
("--timing" if test.have_coroutines else "--no-timing -Wno-STMTDLY")
],
threads=1)