@@ -25,17 +25,20 @@ load("//rules/opentitan:toolchain.bzl", "LOCALTOOLS_TOOLCHAIN")
25
25
_TEST_SCRIPT = """#!/bin/bash
26
26
set -e
27
27
28
+ mutable_otp="otp_img.raw"
29
+ mutable_flash="flash_img.bin"
30
+
28
31
cleanup() {{
29
- rm -f { mutable_otp} { mutable_flash}
32
+ rm -f "$ mutable_otp" "$ mutable_flash"
30
33
rm -f qemu-monitor qemu.log
31
34
}}
32
35
trap cleanup EXIT
33
36
34
37
# QEMU requires mutable flash and OTP files but Bazel only provides RO
35
38
# 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"
37
40
if [ ! -z {flash} ]; then
38
- cp {flash} { mutable_flash} && chmod +w { mutable_flash}
41
+ cp {flash} "$ mutable_flash" && chmod +w "$ mutable_flash"
39
42
fi
40
43
41
44
# QEMU disconnects from `stdout` when it daemonizes so we need to stream
@@ -358,8 +361,7 @@ def _test_dispatch(ctx, exec_env, firmware):
358
361
test_harness , data_labels , data_files , param , action_param = common_test_setup (ctx , exec_env , firmware )
359
362
360
363
# 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.
363
365
if "assemble" in param :
364
366
assemble = param .get ("assemble" )
365
367
assemble = recursive_format (assemble , action_param )
@@ -371,12 +373,14 @@ def _test_dispatch(ctx, exec_env, firmware):
371
373
data_files = data_files ,
372
374
opentitantool = exec_env ._opentitantool ,
373
375
)
374
- param ["firmware" ] = image .short_path
375
- action_param ["firmware" ] = image .path
376
376
data_files .append (image )
377
377
else :
378
378
image = firmware .signed_bin or firmware .default
379
379
380
+ # Replace the firmware param with the newly assembled image.
381
+ param ["firmware" ] = image .short_path
382
+ action_param ["firmware" ] = image .path
383
+
380
384
data_files += [exec_env .qemu ]
381
385
382
386
# Add arguments to pass directly to QEMU.
@@ -410,7 +414,6 @@ def _test_dispatch(ctx, exec_env, firmware):
410
414
data_files += [otp_image ]
411
415
qemu_args += ["-drive" , "if=pflash,file=otp_img.raw,format=raw" ]
412
416
test_script_fmt |= {
413
- "mutable_otp" : "otp_img.raw" ,
414
417
"otp" : otp_image .short_path ,
415
418
}
416
419
0 commit comments