Cleanup quotes

This commit is contained in:
Jordan Carlin 2024-12-17 21:49:11 -08:00
parent 51c3d59605
commit 32b62e9d0c
No known key found for this signature in database
3 changed files with 32 additions and 33 deletions

View File

@ -13,15 +13,15 @@ from multiprocessing import Pool, TimeoutError as MPTimeoutError
TIMEOUT_DUR = 60 # 1` minute TIMEOUT_DUR = 60 # 1` minute
class bcolors: class bcolors:
HEADER = '\033[95m' HEADER = "\033[95m"
OKBLUE = '\033[94m' OKBLUE = "\033[94m"
OKCYAN = '\033[96m' OKCYAN = "\033[96m"
OKGREEN = '\033[92m' OKGREEN = "\033[92m"
WARNING = '\033[93m' WARNING = "\033[93m"
FAIL = '\033[91m' FAIL = "\033[91m"
ENDC = '\033[0m' ENDC = "\033[0m"
BOLD = '\033[1m' BOLD = "\033[1m"
UNDERLINE = '\033[4m' UNDERLINE = "\033[4m"
def search_log_for_mismatches(logfile): def search_log_for_mismatches(logfile):
"""Search through the given log file for text, returning True if it is found or False if it is not""" """Search through the given log file for text, returning True if it is found or False if it is not"""
@ -34,16 +34,16 @@ def search_log_for_mismatches(logfile):
def run_test_case(elf): def run_test_case(elf):
"""Run the given test case, and return 0 if the test suceeds and 1 if it fails""" """Run the given test case, and return 0 if the test suceeds and 1 if it fails"""
WALLY = os.environ.get('WALLY') WALLY = os.environ.get("WALLY")
fields = elf.rsplit('/', 3) fields = elf.rsplit("/", 3)
if fields[2] == "ref": if fields[2] == "ref":
shortelf = fields[1] + "_" + fields[3] shortelf = fields[1] + "_" + fields[3]
else: else:
shortelf = fields[2] + "_" + fields[3] shortelf = fields[2] + "_" + fields[3]
# shortelf = fields[1] + "_" + fields[2] # shortelf = fields[1] + "_" + fields[2]
logfile = WALLY + "/sim/" + args.sim + "/logs/" + shortelf + ".log" logfile = WALLY + "/sim/" + args.sim + "/logs/" + shortelf + ".log"
cmd = "wsim " + args.config + " " + shortelf + " --elf " + elf + " --sim " + args.sim + " --lockstep > " + logfile # add coveerage flags if necessary cmd = "wsim " + args.config + " " + shortelf + " --elf " + elf + " --sim " + args.sim + " --lockstep > " + logfile # add coveerage flags if necessary
# print("cmd = " + cmd) # print("cmd = " + cmd)
os.system(cmd) os.system(cmd)
if search_log_for_mismatches(logfile): if search_log_for_mismatches(logfile):
print(f"{bcolors.OKGREEN}{cmd}: Success{bcolors.ENDC}") print(f"{bcolors.OKGREEN}{cmd}: Success{bcolors.ENDC}")
@ -78,26 +78,25 @@ if os.path.isdir(args.dir):
DirectorMode = 1 DirectorMode = 1
for dirpath, dirnames, filenames in os.walk(os.path.abspath(args.dir)): for dirpath, dirnames, filenames in os.walk(os.path.abspath(args.dir)):
for file in filenames: for file in filenames:
if (file.endswith("elf") and not file.endswith(args.exclude)): if file.endswith("elf") and not file.endswith(args.exclude):
ElfList.append(os.path.join(dirpath, file)) ElfList.append(os.path.join(dirpath, file))
else: else:
print(args.dir + " is not a directory") print(args.dir + " is not a directory")
sys.exit(1) sys.exit(1)
#print(ElfList)
# spawn parallel wsim jobs for each ELF file # spawn parallel wsim jobs for each ELF file
ImperasDVLicenseCount = 8 ImperasDVLicenseCount = 8
with Pool(processes=min(len(ElfList),multiprocessing.cpu_count(), ImperasDVLicenseCount)) as pool: with Pool(processes=min(len(ElfList), multiprocessing.cpu_count(), ImperasDVLicenseCount)) as pool:
num_fail = 0 num_fail = 0
results = {} results = {}
for elf in ElfList: for elf in ElfList:
results[elf] = pool.apply_async(run_test_case,(elf,)) results[elf] = pool.apply_async(run_test_case, (elf,))
for (elf,result) in results.items(): for elf, result in results.items():
try: try:
num_fail+=result.get(timeout=TIMEOUT_DUR) num_fail += result.get(timeout=TIMEOUT_DUR)
except MPTimeoutError: except MPTimeoutError:
num_fail+=1 num_fail += 1
print(f"{bcolors.FAIL}{elf}: Timeout - runtime exceeded {TIMEOUT_DUR} seconds{bcolors.ENDC}") print(f"{bcolors.FAIL}{elf}: Timeout - runtime exceeded {TIMEOUT_DUR} seconds{bcolors.ENDC}")
if num_fail == 0: if num_fail == 0:

View File

@ -16,7 +16,7 @@ import os
import sys import sys
# Global variable # Global variable
WALLY = os.environ.get('WALLY') WALLY = os.environ.get("WALLY")
def parseArgs(): def parseArgs():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -41,13 +41,13 @@ def validateArgs(args):
if not args.testsuite and not args.elf: if not args.testsuite and not args.elf:
print("Error: Missing test suite or ELF file") print("Error: Missing test suite or ELF file")
sys.exit(1) sys.exit(1)
if any([args.lockstep, args.lockstepverbose, args.fcov]) and not (args.testsuite.endswith('.elf') or args.elf) and args.testsuite != "buildroot": if any([args.lockstep, args.lockstepverbose, args.fcov]) and not (args.testsuite.endswith(".elf") or args.elf) and args.testsuite != "buildroot":
print(f"Invalid Options. Cannot run a testsuite, {args.testsuite} with lockstep or fcov. Must run a single elf or buildroot.") print(f"Invalid Options. Cannot run a testsuite, {args.testsuite} with lockstep or fcov. Must run a single elf or buildroot.")
sys.exit(1) sys.exit(1)
elif any([args.gui, args.ccov, args.fcov, args.lockstep, args.lockstepverbose]) and args.sim not in ["questa", "vcs"]: elif any([args.gui, args.ccov, args.fcov, args.lockstep, args.lockstepverbose]) and args.sim not in ["questa", "vcs"]:
print("Option only supported for Questa and VCS") print("Option only supported for Questa and VCS")
sys.exit(1) sys.exit(1)
elif (args.tb == "testbench_fp" and args.sim != "questa"): elif args.tb == "testbench_fp" and args.sim != "questa":
print("Error: testbench_fp presently only supported by Questa, not VCS or Verilator, because of a touchy testbench") print("Error: testbench_fp presently only supported by Questa, not VCS or Verilator, because of a touchy testbench")
sys.exit(1) sys.exit(1)
@ -58,19 +58,19 @@ def elfFileCheck(args):
elif args.elf: elif args.elf:
print(f"ELF file not found: {args.elf}") print(f"ELF file not found: {args.elf}")
sys.exit(1) sys.exit(1)
elif args.testsuite.endswith('.elf'): # No --elf argument; check if testsuite has a .elf extension and use that instead elif args.testsuite.endswith(".elf"): # No --elf argument; check if testsuite has a .elf extension and use that instead
if os.path.isfile(args.testsuite): if os.path.isfile(args.testsuite):
ElfFile = f"+ElfFile={os.path.abspath(args.testsuite)}" ElfFile = f"+ElfFile={os.path.abspath(args.testsuite)}"
# extract the elf name from the path to be the test suite # extract the elf name from the path to be the test suite
fields = args.testsuite.rsplit('/', 3) fields = args.testsuite.rsplit("/", 3)
# if the name is just ref.elf in a deep path (riscv-arch-test/wally-riscv-arch-test), then use the directory name as the test suite to make it unique; otherwise work directory will have duplicates. # if the name is just ref.elf in a deep path (riscv-arch-test/wally-riscv-arch-test), then use the directory name as the test suite to make it unique; otherwise work directory will have duplicates.
if len(fields) > 3: if len(fields) > 3:
if fields[2] == "ref": if fields[2] == "ref":
args.testsuite = f"{fields[1]}_{fields[3]}" args.testsuite = f"{fields[1]}_{fields[3]}"
else: else:
args.testsuite = f"{fields[2]}_{fields[3]}" args.testsuite = f"{fields[2]}_{fields[3]}"
elif '/' in args.testsuite: elif "/" in args.testsuite:
args.testsuite=args.testsuite.rsplit('/', 1)[1] # strip off path if present args.testsuite = args.testsuite.rsplit("/", 1)[1] # strip off path if present
else: else:
print(f"ELF file not found: {args.testsuite}") print(f"ELF file not found: {args.testsuite}")
sys.exit(1) sys.exit(1)

View File

@ -12,7 +12,7 @@ import subprocess
import sys import sys
# Global variables # Global variables
WALLY = os.environ.get('WALLY') WALLY = os.environ.get("WALLY")
simdir = f"{WALLY}/sim/vcs" simdir = f"{WALLY}/sim/vcs"
cfgdir = f"{WALLY}/config" cfgdir = f"{WALLY}/config"
srcdir = f"{WALLY}/src" srcdir = f"{WALLY}/src"
@ -21,7 +21,7 @@ logdir = f"{simdir}/logs"
# run a Linux command and return the result as a string in a form that VCS can use # run a Linux command and return the result as a string in a form that VCS can use
def runFindCommand(cmd): def runFindCommand(cmd):
res = subprocess.check_output(cmd, shell=True, ) res = subprocess.check_output(cmd, shell=True)
res = str(res) res = str(res)
res = res.replace("\\n", " ") # replace newline with space res = res.replace("\\n", " ") # replace newline with space
res = res.replace("'", "") # strip off quotation marks res = res.replace("'", "") # strip off quotation marks
@ -55,7 +55,7 @@ def generateFileList(testbench):
rtlsrc_files = runFindCommand(rtlsrc_cmd) rtlsrc_files = runFindCommand(rtlsrc_cmd)
tbcommon_cmd = f'find {tbdir}/common -name "*.sv"' tbcommon_cmd = f'find {tbdir}/common -name "*.sv"'
tbcommon_files = runFindCommand(tbcommon_cmd) tbcommon_files = runFindCommand(tbcommon_cmd)
tb_file = f'{tbdir}/{testbench}.sv' tb_file = f"{tbdir}/{testbench}.sv"
return f"{tb_file} {rtlsrc_files} {tbcommon_files}" return f"{tb_file} {rtlsrc_files} {tbcommon_files}"
def processArgs(wkdir, args): def processArgs(wkdir, args):
@ -89,7 +89,7 @@ def setupParamOverrides(wkdir, args):
return f" -parameters {wkdir}/param_overrides.txt " return f" -parameters {wkdir}/param_overrides.txt "
def setupCommands(wkdir, rtlFiles, compileOptions, simvOptions, args): def setupCommands(wkdir, rtlFiles, compileOptions, simvOptions, args):
includePath=f"+incdir+{cfgdir}/{args.config} +incdir+{cfgdir}/deriv/{args.config} +incdir+{cfgdir}/shared +incdir+$WALLY/tests +incdir+{tbdir} +incdir+{srcdir}" includePath = f"+incdir+{cfgdir}/{args.config} +incdir+{cfgdir}/deriv/{args.config} +incdir+{cfgdir}/shared +incdir+$WALLY/tests +incdir+{tbdir} +incdir+{srcdir}"
vcsStandardFlags = "+lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU,noSTASKW_CO,noSTASKW_CO1,noSTASKW_RMCOF -suppress +warn -sverilog +vc -Mupdate -line -full64 -lca -ntb_opts sensitive_dyn" vcsStandardFlags = "+lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU,noSTASKW_CO,noSTASKW_CO1,noSTASKW_RMCOF -suppress +warn -sverilog +vc -Mupdate -line -full64 -lca -ntb_opts sensitive_dyn"
vcsCMD = f"vcs {vcsStandardFlags} -top {args.tb} {compileOptions} -Mdir={wkdir} {includePath} {srcdir}/cvw.sv {rtlFiles} -o {wkdir}/sim_out -work {wkdir} -Mlib={wkdir} -l {logdir}/{args.config}_{args.testsuite}.log" vcsCMD = f"vcs {vcsStandardFlags} -top {args.tb} {compileOptions} -Mdir={wkdir} {includePath} {srcdir}/cvw.sv {rtlFiles} -o {wkdir}/sim_out -work {wkdir} -Mlib={wkdir} -l {logdir}/{args.config}_{args.testsuite}.log"
simvCMD = f"{wkdir}/sim_out +TEST={args.testsuite} {args.args} -no_save {simvOptions}" simvCMD = f"{wkdir}/sim_out +TEST={args.testsuite} {args.args} -no_save {simvOptions}"