Skip to content

Commit c83a4c5

Browse files
committed
[bazel] update firmware param for non-assembled images
Signed-off-by: James Wainwright <[email protected]>
1 parent 2653018 commit c83a4c5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

rules/opentitan/qemu.bzl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ load("//rules/opentitan:toolchain.bzl", "LOCALTOOLS_TOOLCHAIN")
2525
_TEST_SCRIPT = """#!/bin/bash
2626
set -e
2727
28+
mutable_otp="otp_img.raw"
29+
mutable_flash="flash_img.bin"
30+
2831
cleanup() {{
29-
rm -f {mutable_otp} {mutable_flash}
32+
rm -f "$mutable_otp" "$mutable_flash"
3033
rm -f qemu-monitor qemu.log
3134
}}
3235
trap cleanup EXIT
3336
3437
# QEMU requires mutable flash and OTP files but Bazel only provides RO
3538
# files so we have to create copies unique to this test run.
36-
cp {otp} {mutable_otp} && chmod +w {mutable_otp}
39+
cp {otp} "$mutable_otp" && chmod +w "$mutable_otp"
3740
if [ ! -z {flash} ]; then
38-
cp {flash} {mutable_flash} && chmod +w {mutable_flash}
41+
cp {flash} "$mutable_flash" && chmod +w "$mutable_flash"
3942
fi
4043
4144
# QEMU disconnects from `stdout` when it daemonizes so we need to stream
@@ -358,8 +361,7 @@ def _test_dispatch(ctx, exec_env, firmware):
358361
test_harness, data_labels, data_files, param, action_param = common_test_setup(ctx, exec_env, firmware)
359362

360363
# If the test requested an assembled image, then use opentitantool to
361-
# assemble the image. Replace the firmware param with the newly assembled
362-
# image.
364+
# assemble the image.
363365
if "assemble" in param:
364366
assemble = param.get("assemble")
365367
assemble = recursive_format(assemble, action_param)
@@ -371,12 +373,14 @@ def _test_dispatch(ctx, exec_env, firmware):
371373
data_files = data_files,
372374
opentitantool = exec_env._opentitantool,
373375
)
374-
param["firmware"] = image.short_path
375-
action_param["firmware"] = image.path
376376
data_files.append(image)
377377
else:
378378
image = firmware.signed_bin or firmware.default
379379

380+
# Replace the firmware param with the newly assembled image.
381+
param["firmware"] = image.short_path
382+
action_param["firmware"] = image.path
383+
380384
data_files += [exec_env.qemu]
381385

382386
# Add arguments to pass directly to QEMU.
@@ -410,7 +414,6 @@ def _test_dispatch(ctx, exec_env, firmware):
410414
data_files += [otp_image]
411415
qemu_args += ["-drive", "if=pflash,file=otp_img.raw,format=raw"]
412416
test_script_fmt |= {
413-
"mutable_otp": "otp_img.raw",
414417
"otp": otp_image.short_path,
415418
}
416419

0 commit comments

Comments
 (0)