Added --buildroot option to run a full Linux boot and search 'buildroot_uart.out' for login prompt

This commit is contained in:
slmnemo 2024-04-16 17:27:25 -07:00
parent 554f818a8c
commit 48a2028891

View File

@ -12,7 +12,6 @@
################################## ##################################
import sys,os,shutil import sys,os,shutil
import multiprocessing import multiprocessing
#import os
from collections import namedtuple from collections import namedtuple
from multiprocessing import Pool, TimeoutError from multiprocessing import Pool, TimeoutError
@ -24,7 +23,7 @@ from multiprocessing import Pool, TimeoutError
# The element consists of the configuration name, a list of test suites to run, # The element consists of the configuration name, a list of test suites to run,
# optionally a string to pass to the simulator, and optionally a nonstandard grep string to check for success # optionally a string to pass to the simulator, and optionally a nonstandard grep string to check for success
INSTR_LIMIT = 1000000 # multiple of 100000; 4M is interesting because it gets into the kernel and enabling VM INSTR_LIMIT = 4000000 # multiple of 100000; Set to 0 to run simulation until timeout or Wally Hostname:
tests = [ tests = [
["rv32e", ["arch32e"]], ["rv32e", ["arch32e"]],
["rv32i", ["arch32i"]], ["rv32i", ["arch32i"]],
@ -38,6 +37,11 @@ tests = [
["buildroot", ["buildroot"], [f"+INSTR_LIMIT={INSTR_LIMIT}"], str(INSTR_LIMIT)+" instructions"] ["buildroot", ["buildroot"], [f"+INSTR_LIMIT={INSTR_LIMIT}"], str(INSTR_LIMIT)+" instructions"]
] ]
# Separate test for full buildroot run
tests_buildroot = [["buildroot", ["buildroot"], [f"+INSTR_LIMIT=600000000"], "WallyHostName login:", os.environ.get('WALLY')+"/sim/questa/logs/buildroot_uart.out"]]
# Separate out floating-point tests for RV64 to speed up coverage # Separate out floating-point tests for RV64 to speed up coverage
tests64gc_nofp = [ tests64gc_nofp = [
["rv64gc", ["coverage64gc", "arch64i", "arch64priv", "arch64c", "arch64m", ["rv64gc", ["coverage64gc", "arch64i", "arch64priv", "arch64c", "arch64m",
@ -176,7 +180,7 @@ bpredtests = [
# Data Types & Functions # Data Types & Functions
################################## ##################################
TestCase = namedtuple("TestCase", ['name', 'variant', 'cmd', 'grepstr']) TestCase = namedtuple("TestCase", ['name', 'variant', 'cmd', 'grepstr', 'logfile', 'overwrite'])
# name: the name of this test configuration (used in printing human-readable # name: the name of this test configuration (used in printing human-readable
# output and picking logfile names) # output and picking logfile names)
# cmd: the command to run to test (should include the logfile as '{}', and # cmd: the command to run to test (should include the logfile as '{}', and
@ -184,6 +188,7 @@ TestCase = namedtuple("TestCase", ['name', 'variant', 'cmd', 'grepstr'])
# grepstr: the string to grep through the log file for. The test succeeds iff # grepstr: the string to grep through the log file for. The test succeeds iff
# grep finds that string in the logfile (is used by grep, so it may # grep finds that string in the logfile (is used by grep, so it may
# be any pattern grep accepts, see `man 1 grep` for more info). # be any pattern grep accepts, see `man 1 grep` for more info).
# logfile: the string corresponding to the log file for the test. autogenerated
class bcolors: class bcolors:
HEADER = '\033[95m' HEADER = '\033[95m'
@ -210,11 +215,19 @@ def addTests(tests, sim):
gs = "All tests ran without failures" gs = "All tests ran without failures"
cmdPrefix="wsim --sim " + sim + " " + config cmdPrefix="wsim --sim " + sim + " " + config
for t in suites: for t in suites:
if (len(test) >= 5):
logfile = test[4]
overwrite = 0
else:
logfile = WALLY + "/sim/"+sim+"/logs/"+config+"_"+t+".log"
overwrite = 1
tc = TestCase( tc = TestCase(
name=t, name=t,
variant=config, variant=config,
cmd=cmdPrefix + " " + t + args, cmd=cmdPrefix + " " + t + args,
grepstr=gs) grepstr=gs,
logfile = logfile,
overwrite = overwrite)
configs.append(tc) configs.append(tc)
def search_log_for_text(text, logfile): def search_log_for_text(text, logfile):
@ -225,14 +238,17 @@ def search_log_for_text(text, logfile):
def run_test_case(config): def run_test_case(config):
"""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"""
logname = WALLY + "/sim/questa/logs/"+config.variant+"_"+config.name+".log" ### *** fix hardwiring to questa log logname = config.logfile
WALLY = os.environ.get('WALLY')
#cmd = config.cmd + " > " + logname #cmd = config.cmd + " > " + logname
if ("lint-wally" in config.cmd): if ("lint-wally" in config.cmd):
cmd = config.cmd + " | tee " + logname cmd = config.cmd + " | tee " + logname
elif (config.overwrite == 0): ### TODO: Fix hardcoding for logs/buildroot_buildroot.log
cmd = config.cmd + f" > {WALLY}/sim/questa/logs/buildroot_buildroot.log"
else: else:
cmd = config.cmd + " > " + logname cmd = config.cmd + " > " + logname
os.chdir(regressionDir) os.chdir(regressionDir)
# print(" run_test_case invoking %s" % cmd) # print(" run_test_case invoking %s" % cmd)
os.system(cmd) os.system(cmd)
if search_log_for_text(config.grepstr, logname): if search_log_for_text(config.grepstr, logname):
print(f"{bcolors.OKGREEN}%s_%s: Success{bcolors.ENDC}" % (config.variant, config.name)) print(f"{bcolors.OKGREEN}%s_%s: Success{bcolors.ENDC}" % (config.variant, config.name))
@ -258,6 +274,7 @@ coverage = '--coverage' in sys.argv
fp = '--fp' in sys.argv fp = '--fp' in sys.argv
nightly = '--nightly' in sys.argv nightly = '--nightly' in sys.argv
testfloat = '--testfloat' in sys.argv testfloat = '--testfloat' in sys.argv
buildroot = '--buildroot' in sys.argv
if (nightly): if (nightly):
nightMode = "--nightly"; nightMode = "--nightly";
@ -278,15 +295,21 @@ configs = [
name="lints", name="lints",
variant="all", variant="all",
cmd="lint-wally " + nightMode, cmd="lint-wally " + nightMode,
grepstr="lints run with no errors or warnings" grepstr="lints run with no errors or warnings",
logfile = WALLY + "/sim/questa/logs/all_lints.log",
overwrite = 1
) )
] ]
if (buildroot):
for sim in sims:
addTests(tests_buildroot, sim)
if (coverage): # only run RV64GC tests on Questa in coverage mode if (coverage): # only run RV64GC tests on Questa in coverage mode
addTests(tests64gc_nofp, "questa") addTests(tests64gc_nofp, "questa")
if (fp): if (fp):
addTests(tests64gc_fp, "questa") addTests(tests64gc_fp, "questa")
else: elif not buildroot:
for sim in sims: for sim in sims:
addTests(tests, sim) addTests(tests, sim)
addTests(tests64gc_nofp, sim) addTests(tests64gc_nofp, sim)
@ -309,7 +332,9 @@ if (testfloat):
name=test, name=test,
variant=config, variant=config,
cmd="wsim --tb testbench_fp " + config + " " + test, cmd="wsim --tb testbench_fp " + config + " " + test,
grepstr="All Tests completed with 0 errors") grepstr="All Tests completed with 0 errors",
logfile = WALLY + "/sim/questa/logs/"+config+"_"+test+".log",
overwrite = 1)
configs.append(tc) configs.append(tc)
@ -352,7 +377,9 @@ if (testfloat):
name=test, name=test,
variant=config, variant=config,
cmd="wsim --tb testbench_fp --sim questa " + config + " " + test, cmd="wsim --tb testbench_fp --sim questa " + config + " " + test,
grepstr="All Tests completed with 0 errors") grepstr="All Tests completed with 0 errors",
logfile = WALLY + "/sim/questa/logs/"+config+"_"+test+".log",
overwrite = 1)
configs.append(tc) configs.append(tc)
@ -374,7 +401,7 @@ def main():
TIMEOUT_DUR = 30*7200 # seconds TIMEOUT_DUR = 30*7200 # seconds
#configs.append(getBuildrootTC(boot=True)) #configs.append(getBuildrootTC(boot=True))
elif '--buildroot' in sys.argv: elif '--buildroot' in sys.argv:
TIMEOUT_DUR = 30*7200 # seconds TIMEOUT_DUR = 60*7200 # 5 days to run
#configs=[getBuildrootTC(boot=True)] #configs=[getBuildrootTC(boot=True)]
elif '--coverage' in sys.argv: elif '--coverage' in sys.argv:
TIMEOUT_DUR = 20*60 # seconds TIMEOUT_DUR = 20*60 # seconds