diff options
author | Tim Newsome <tim@sifive.com> | 2020-06-25 15:34:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 15:34:08 -0700 |
commit | 944704e224e534d5371fe6da246552c7f7fe831a (patch) | |
tree | e8f6e64c2b8f0f4779ae7ef0e44285b28e12b6ea /debug/testlib.py | |
parent | fbe74f48e16be28a2b360e8a9e845b01d9e4b167 (diff) | |
download | riscv-tests-944704e224e534d5371fe6da246552c7f7fe831a.zip riscv-tests-944704e224e534d5371fe6da246552c7f7fe831a.tar.gz riscv-tests-944704e224e534d5371fe6da246552c7f7fe831a.tar.bz2 |
Create a more sophisticated vector test (#284)
* WIP
* WIP
* Vector test seems to work well with spike.
* Check a0 in case the program didn't work right.
* Return not applicable if compile doesn't support V
Diffstat (limited to 'debug/testlib.py')
-rw-r--r-- | debug/testlib.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/debug/testlib.py b/debug/testlib.py index bd83d56..e003fdc 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -29,8 +29,18 @@ def find_file(path): return relpath return None +class CompileError(Exception): + def __init__(self, stdout, stderr): + self.stdout = stdout + self.stderr = stderr + +gcc_cmd = None def compile(args): # pylint: disable=redefined-builtin - cmd = ["riscv64-unknown-elf-gcc", "-g"] + if gcc_cmd: + cmd = [gcc_cmd] + else: + cmd = ["riscv64-unknown-elf-gcc"] + cmd.append("-g") for arg in args: found = find_file(arg) if found: @@ -43,10 +53,10 @@ def compile(args): # pylint: disable=redefined-builtin stderr=subprocess.PIPE) stdout, stderr = process.communicate() if process.returncode: - print(stdout, end=" ") - print(stderr, end=" ") + print(stdout.decode('ascii'), end=" ") + print(stderr.decode('ascii'), end=" ") header("") - raise Exception("Compile failed!") + raise CompileError(stdout, stderr) class Spike: # pylint: disable=too-many-instance-attributes @@ -666,10 +676,15 @@ class Gdb: self.select_child(child) self.interrupt() - def x(self, address, size='w'): - output = self.command("x/%s %s" % (size, address)) - value = int(output.split(':')[1].strip(), 0) - return value + def x(self, address, size='w', count=1): + output = self.command("x/%d%s %s" % (count, size, address)) + values = [] + for line in output.splitlines(): + for value in line.split(':')[1].strip().split(): + values.append(int(value, 0)) + if len(values) == 1: + return values[0] + return values def p_raw(self, obj): output = self.command("p %s" % obj) @@ -806,6 +821,8 @@ def run_all_tests(module, target, parsed): global gdb_cmd # pylint: disable=global-statement gdb_cmd = parsed.gdb + global gcc_cmd # pylint: disable=global-statement + gcc_cmd = parsed.gcc examine_added = False for hart in target.harts: @@ -889,6 +906,8 @@ def add_test_run_options(parser): help="Print out a list of tests, and exit immediately.") parser.add_argument("test", nargs='*', help="Run only tests that are named here.") + parser.add_argument("--gcc", + help="The command to use to start gcc.") parser.add_argument("--gdb", help="The command to use to start gdb.") parser.add_argument("--misaval", |