def find_file(path):
for directory in (os.getcwd(), os.path.dirname(__file__)):
fullpath = os.path.join(directory, path)
- if os.path.exists(fullpath):
- return fullpath
+ relpath = os.path.relpath(fullpath)
+ if len(relpath) >= len(fullpath):
+ relpath = fullpath
+ if os.path.exists(relpath):
+ return relpath
return None
def compile(args, xlen=32): # pylint: disable=redefined-builtin
if with_jtag_gdb:
cmd += ['--rbb-port', '0']
os.environ['REMOTE_BITBANG_HOST'] = 'localhost'
- self.infinite_loop = harts[0].compile(
+ self.infinite_loop = target.compile(harts[0],
"programs/checksum.c", "programs/tiny-malloc.c",
"programs/infinite_loop.S", "-DDEFINE_MALLOC", "-DDEFINE_FREE")
cmd.append(self.infinite_loop)
print "OpenOCD Temporary Log File: %s" % logname
def __init__(self, server_cmd=None, config=None, debug=False, timeout=60):
+ self.timeout = timeout
+
if server_cmd:
cmd = shlex.split(server_cmd)
else:
if not messaged and time.time() - start > 1:
messaged = True
print "Waiting for OpenOCD to start..."
- if (time.time() - start) > timeout:
+ if (time.time() - start) > self.timeout:
raise Exception("ERROR: Timed out waiting for OpenOCD to "
"listen for gdb")
return process
raise CannotAccess(int(m.group(1), 0))
return output.split('=')[-1].strip()
- def p(self, obj):
- output = self.command("p/x %s" % obj)
+ def parse_string(self, text):
+ text = text.strip()
+ if text.startswith("{") and text.endswith("}"):
+ inner = text[1:-1]
+ return [self.parse_string(t) for t in inner.split(", ")]
+ elif text.startswith('"') and text.endswith('"'):
+ return text[1:-1]
+ else:
+ return int(text, 0)
+
+ def p(self, obj, fmt="/x"):
+ output = self.command("p%s %s" % (fmt, obj))
m = re.search("Cannot access memory at address (0x[0-9a-f]+)", output)
if m:
raise CannotAccess(int(m.group(1), 0))
- value = int(output.split('=')[-1].strip(), 0)
- return value
+ rhs = output.split('=')[-1]
+ return self.parse_string(rhs)
def p_string(self, obj):
output = self.command("p %s" % obj)
self.hart = hart
else:
self.hart = random.choice(target.harts)
+ self.hart = target.harts[-1] #<<<
self.server = None
self.target_process = None
self.binary = None
if compile_args not in BaseTest.compiled:
# pylint: disable=star-args
BaseTest.compiled[compile_args] = \
- self.hart.compile(*compile_args)
+ self.target.compile(self.hart, *compile_args)
self.binary = BaseTest.compiled.get(compile_args)
def classSetup(self):