aboutsummaryrefslogtreecommitdiff
path: root/debug/targets.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2022-06-23 08:08:19 -0700
committerGitHub <noreply@github.com>2022-06-23 08:08:19 -0700
commitfc38747b2dba58c7c80edd99e965c57a373cf294 (patch)
tree2df4215b16c6485dcdd1e2165d1de6674c9d5600 /debug/targets.py
parent8567faa64561f504c1e9a70ffec74ac1a9f2091b (diff)
downloadriscv-tests-fc38747b2dba58c7c80edd99e965c57a373cf294.zip
riscv-tests-fc38747b2dba58c7c80edd99e965c57a373cf294.tar.gz
riscv-tests-fc38747b2dba58c7c80edd99e965c57a373cf294.tar.bz2
Another pylint upgrade. (#398)
* Another pylint upgrade. Lots of format string changes, which are more readable. More files to come... * Satisfy pylint for two more files.
Diffstat (limited to 'debug/targets.py')
-rw-r--r--debug/targets.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/debug/targets.py b/debug/targets.py
index 727a882..504a550 100644
--- a/debug/targets.py
+++ b/debug/targets.py
@@ -143,7 +143,7 @@ class Target:
self.name = type(self).__name__
# Default OpenOCD config file to <name>.cfg
if not self.openocd_config_path:
- self.openocd_config_path = "%s.cfg" % self.name
+ self.openocd_config_path = f"{self.name}.cfg"
self.openocd_config_path = os.path.join(self.directory,
self.openocd_config_path)
for i, hart in enumerate(self.harts):
@@ -151,10 +151,10 @@ class Target:
if not hasattr(hart, 'id'):
hart.id = i
if not hart.name:
- hart.name = "%s-%d" % (self.name, i)
+ hart.name = f"{self.name}-{i}"
# Default link script to <name>.lds
if not hart.link_script_path:
- hart.link_script_path = "%s.lds" % self.name
+ hart.link_script_path = f"{self.name}.lds"
hart.link_script_path = os.path.join(self.directory,
hart.link_script_path)
@@ -169,11 +169,12 @@ class Target:
freertos=test.freertos())
def do_compile(self, hart, *sources):
- binary_name = "%s_%s-%x" % (
- self.name,
- os.path.basename(os.path.splitext(sources[0])[0]),
- hart.misa)
+ binary_name = (
+ self.name + "_" +
+ os.path.basename(os.path.splitext(sources[0])[0]) + "-" +
+ f"{hart.misa:x}")
if Target.isolate:
+ # pylint: disable-next=consider-using-with
self.temporary_binary = tempfile.NamedTemporaryFile(
prefix=binary_name + "_")
binary_name = self.temporary_binary.name
@@ -181,12 +182,12 @@ class Target:
args = list(sources) + [
"programs/entry.S", "programs/init.c",
- "-DNHARTS=%d" % len(self.harts),
+ f"-DNHARTS={len(self.harts)}",
"-I", "../env",
"-T", hart.link_script_path,
"-nostartfiles",
"-mcmodel=medany",
- "-DXLEN=%d" % hart.xlen,
+ f"-DXLEN={hart.xlen}",
"-o", binary_name]
if hart.extensionSupported('e'):
@@ -194,17 +195,17 @@ class Target:
args.append("-mabi=ilp32e")
args.append("-DRV32E")
else:
- march = "rv%dima" % hart.xlen
+ march = f"rv{hart.xlen}ima"
for letter in "fdc":
if hart.extensionSupported(letter):
march += letter
if hart.extensionSupported("v") and self.compiler_supports_v:
march += "v"
- args.append("-march=%s" % march)
+ args.append(f"-march={march}")
if hart.xlen == 32:
args.append("-mabi=ilp32")
else:
- args.append("-mabi=lp%d" % hart.xlen)
+ args.append(f"-mabi=lp{hart.xlen}")
testlib.compile(args)
return binary_name
@@ -221,8 +222,8 @@ class Target:
r"ISA extension `(\w)'", e.stderr.decode())
if m and m.group(1) in "v":
extension = m.group(1)
- print("Disabling extension %r because the "
- "compiler doesn't support it." % extension)
+ print(f"Disabling extension {extension!r} because the "
+ "compiler doesn't support it.")
self.compiler_supports_v = False
else:
raise
@@ -260,18 +261,18 @@ def target(parsed):
definition = getattr(module, name)
if isinstance(definition, type) and issubclass(definition, Target):
found.append(definition)
- assert len(found) == 1, "%s does not define exactly one subclass of " \
- "targets.Target" % parsed.target
+ assert len(found) == 1, (f"{parsed.target} does not define exactly one "
+ "subclass of targets.Target")
t = found[0](parsed.target, parsed)
- assert t.harts, "%s doesn't have any harts defined!" % t.name
+ assert t.harts, f"{t.name} doesn't have any harts defined!"
if parsed.xlen > 0:
for h in t.harts:
if h.xlen == 0:
h.xlen = parsed.xlen
elif h.xlen != parsed.xlen:
- raise Exception("The target hart specified an XLEN of %d, but "\
- "the command line specified an XLEN of %d. They must "\
- "match." % (h.xlen, parsed.xlen))
+ raise Exception("The target hart specified an XLEN of "
+ f"{h.xlen}, but the command line specified an XLEN of "
+ f"{parsed.xlen}. They must match.")
return t