2021-01-25 16:28:43 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
##################################
|
|
|
|
#
|
|
|
|
# regression-wally.py
|
|
|
|
# David_Harris@Hmc.edu 25 January 2021
|
2021-05-04 22:58:23 +00:00
|
|
|
# Modified by Jarred Allen <jaallen@g.hmc.edu>
|
2021-01-25 16:28:43 +00:00
|
|
|
#
|
2021-05-04 22:58:23 +00:00
|
|
|
# Run a regression with multiple configurations in parallel and exit with
|
|
|
|
# non-zero status code if an error happened, as well as printing human-readable
|
|
|
|
# output.
|
2021-01-25 16:28:43 +00:00
|
|
|
#
|
|
|
|
##################################
|
2021-10-23 20:17:30 +00:00
|
|
|
import sys
|
2021-01-25 16:28:43 +00:00
|
|
|
|
2021-04-22 17:29:55 +00:00
|
|
|
from collections import namedtuple
|
2021-05-04 22:58:23 +00:00
|
|
|
TestCase = namedtuple("TestCase", ['name', 'cmd', 'grepstr'])
|
|
|
|
# name: the name of this test configuration (used in printing human-readable
|
|
|
|
# output and picking logfile names)
|
|
|
|
# cmd: the command to run to test (should include the logfile as '{}', and
|
|
|
|
# the command needs to write to that file)
|
|
|
|
# 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
|
|
|
|
# be any pattern grep accepts, see `man 1 grep` for more info).
|
2021-04-22 17:29:55 +00:00
|
|
|
|
2021-05-04 22:58:23 +00:00
|
|
|
# edit this list to add more test cases
|
2021-04-22 17:29:55 +00:00
|
|
|
configs = [
|
2021-05-04 22:58:23 +00:00
|
|
|
TestCase(
|
2021-05-03 21:32:05 +00:00
|
|
|
name="lints",
|
2021-10-23 13:15:26 +00:00
|
|
|
cmd="./lint-wally &> {}",
|
2021-05-03 21:32:05 +00:00
|
|
|
grepstr="All lints run with no errors or warnings"
|
2021-10-23 20:17:30 +00:00
|
|
|
)
|
2021-04-22 17:29:55 +00:00
|
|
|
]
|
2021-10-23 20:17:30 +00:00
|
|
|
def getBuildrootTC(short):
|
|
|
|
INSTR_LIMIT = 100000 # multiple of 100000
|
2021-11-19 20:52:11 +00:00
|
|
|
MAX_EXPECTED = 182000000
|
2021-10-23 20:17:30 +00:00
|
|
|
if short:
|
2021-10-25 19:25:32 +00:00
|
|
|
BRcmd="vsim > {} -c <<!\ndo wally-buildroot-batch.do "+str(INSTR_LIMIT)+" 1 0\n!"
|
2021-10-23 20:17:30 +00:00
|
|
|
BRgrepstr=str(INSTR_LIMIT)+" instructions"
|
|
|
|
else:
|
2021-10-25 19:25:32 +00:00
|
|
|
BRcmd="vsim > {} -c <<!\ndo wally-buildroot-batch.do 0 1 0\n!"
|
2021-10-23 20:17:30 +00:00
|
|
|
BRgrepstr=str(MAX_EXPECTED)+" instructions"
|
|
|
|
return TestCase(name="buildroot",cmd=BRcmd,grepstr=BRgrepstr)
|
2021-01-25 16:28:43 +00:00
|
|
|
|
2021-11-21 03:42:53 +00:00
|
|
|
tc = TestCase(
|
|
|
|
name="buildroot-checkpoint",
|
|
|
|
cmd="vsim > {} -c <<!\ndo wally-buildroot-batch.do 400100000 400000001 400000000\n!",
|
|
|
|
grepstr="400100000 instructions")
|
|
|
|
configs.append(tc)
|
|
|
|
|
2021-11-01 15:48:46 +00:00
|
|
|
tests64 = ["wally64i", "arch64i", "arch64priv", "arch64c", "arch64m", "imperas64i", "imperas64p", "imperas64mmu", "imperas64f", "imperas64d", "imperas64m", "imperas64a", "imperas64c"] #, "testsBP64"]
|
2021-10-10 22:07:51 +00:00
|
|
|
for test in tests64:
|
|
|
|
tc = TestCase(
|
|
|
|
name=test,
|
|
|
|
cmd="vsim > {} -c <<!\ndo wally-pipelined-batch.do rv64g "+test+"\n!",
|
|
|
|
grepstr="All tests ran without failures")
|
|
|
|
configs.append(tc)
|
2021-10-27 17:37:35 +00:00
|
|
|
#tests32 = ["arch32i", "arch32priv", "arch32c", "arch32m", "arch32f", "imperas32i", "imperas32p", "imperas32mmu", "imperas32f", "imperas32m", "imperas32a", "imperas32c"]
|
2021-11-01 20:17:49 +00:00
|
|
|
tests32 = ["wally32i", "arch32i", "arch32priv", "arch32c", "arch32m", "imperas32i", "imperas32p", "imperas32mmu", "imperas32f", "imperas32m", "imperas32a", "imperas32c"]
|
2021-10-10 22:07:51 +00:00
|
|
|
for test in tests32:
|
|
|
|
tc = TestCase(
|
|
|
|
name=test,
|
|
|
|
cmd="vsim > {} -c <<!\ndo wally-pipelined-batch.do rv32g "+test+"\n!",
|
|
|
|
grepstr="All tests ran without failures")
|
|
|
|
configs.append(tc)
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-17 22:44:47 +00:00
|
|
|
import os
|
|
|
|
from multiprocessing import Pool, TimeoutError
|
2021-01-25 16:28:43 +00:00
|
|
|
|
2021-02-02 22:20:45 +00:00
|
|
|
def search_log_for_text(text, logfile):
|
|
|
|
"""Search through the given log file for text, returning True if it is found or False if it is not"""
|
|
|
|
grepcmd = "grep -e '%s' '%s' > /dev/null" % (text, logfile)
|
|
|
|
return os.system(grepcmd) == 0
|
|
|
|
|
2021-05-17 22:44:47 +00:00
|
|
|
def run_test_case(config):
|
2021-05-04 22:58:23 +00:00
|
|
|
"""Run the given test case, and return 0 if the test suceeds and 1 if it fails"""
|
2021-10-10 22:07:51 +00:00
|
|
|
logname = "logs/wally_"+config.name+".log"
|
2021-05-17 22:44:47 +00:00
|
|
|
cmd = config.cmd.format(logname)
|
2021-03-05 20:20:32 +00:00
|
|
|
print(cmd)
|
2021-02-02 22:05:35 +00:00
|
|
|
os.system(cmd)
|
2021-05-17 22:44:47 +00:00
|
|
|
if search_log_for_text(config.grepstr, logname):
|
|
|
|
print("%s: Success" % config.name)
|
2021-04-22 17:29:55 +00:00
|
|
|
return 0
|
|
|
|
else:
|
2021-05-17 22:44:47 +00:00
|
|
|
print("%s: Failures detected in output" % config.name)
|
|
|
|
print(" Check %s" % logname)
|
2021-04-22 17:29:55 +00:00
|
|
|
return 1
|
2021-02-02 22:20:45 +00:00
|
|
|
|
2021-05-04 22:58:23 +00:00
|
|
|
def main():
|
|
|
|
"""Run the tests and count the failures"""
|
|
|
|
# Scale the number of concurrent processes to the number of test cases, but
|
2021-10-10 22:07:51 +00:00
|
|
|
# max out at a limited number of concurrent processes to not overwhelm the system
|
2021-10-23 20:17:30 +00:00
|
|
|
|
|
|
|
if '-all' in sys.argv:
|
2021-12-06 22:13:58 +00:00
|
|
|
TIMEOUT_DUR = 20*3600 # seconds
|
2021-10-23 20:17:30 +00:00
|
|
|
configs.append(getBuildrootTC(short=False))
|
2021-12-06 22:13:58 +00:00
|
|
|
elif '-buildroot' in sys.argv:
|
|
|
|
TIMEOUT_DUR = 20*3600 # seconds
|
|
|
|
configs=[getBuildrootTC(short=False)]
|
2021-10-23 20:17:30 +00:00
|
|
|
else:
|
2021-12-06 22:13:58 +00:00
|
|
|
TIMEOUT_DUR = 5*60 # seconds
|
2021-10-23 20:17:30 +00:00
|
|
|
configs.append(getBuildrootTC(short=True))
|
|
|
|
print(configs)
|
|
|
|
|
2021-05-06 16:56:57 +00:00
|
|
|
try:
|
2021-10-10 22:07:51 +00:00
|
|
|
os.mkdir("logs")
|
2021-05-06 16:56:57 +00:00
|
|
|
except:
|
|
|
|
pass
|
2021-10-10 22:07:51 +00:00
|
|
|
with Pool(processes=min(len(configs),25)) as pool:
|
2021-05-17 22:44:47 +00:00
|
|
|
num_fail = 0
|
|
|
|
results = {}
|
|
|
|
for config in configs:
|
|
|
|
results[config] = pool.apply_async(run_test_case,(config,))
|
|
|
|
for (config,result) in results.items():
|
|
|
|
try:
|
|
|
|
num_fail+=result.get(timeout=TIMEOUT_DUR)
|
|
|
|
except TimeoutError:
|
|
|
|
num_fail+=1
|
|
|
|
print("%s: Timeout - runtime exceeded %d seconds" % (config.name, TIMEOUT_DUR))
|
|
|
|
|
2021-05-04 22:58:23 +00:00
|
|
|
# Count the number of failures
|
|
|
|
if num_fail:
|
|
|
|
print("Regression failed with %s failed configurations" % num_fail)
|
|
|
|
# Remind the user to try `make allclean`, since it may be needed if test
|
|
|
|
# cases have changed
|
|
|
|
print("Reminder: have you run `make allclean`?")
|
|
|
|
else:
|
|
|
|
print("SUCCESS! All tests ran without failures")
|
|
|
|
return num_fail
|
2021-01-25 16:28:43 +00:00
|
|
|
|
2021-05-04 22:58:23 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
exit(main())
|