Skip to content

Commit fb5e4ee

Browse files
committed
[cov,e2e] Enable code coverage collection in e2e tests
This change updates the orchestrator end-to-end tests to support code coverage collection. Change-Id: I40f041a245fa7a3e14177aa62514d9f529521c35 Signed-off-by: Yi-Hsuan Deng <[email protected]>
1 parent bda3b62 commit fb5e4ee

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

sw/host/provisioning/ft_lib/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ pub fn run_ft_personalize(
667667
response
668668
.stats
669669
.log_elapsed_time("second-bootstrap-done", second_t0);
670+
671+
#[cfg(feature = "ot_coverage_enabled")]
672+
let _ = UartConsole::wait_for_coverage(spi_console, Duration::from_secs(10));
673+
670674
Ok(())
671675
}
672676

sw/host/provisioning/orchestrator/tests/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ sh_test(
149149
":orchestrator_{}_zip".format(fpga),
150150
"@python3",
151151
cfg["orchestrator_cfg"],
152+
cfg["owner_fw"],
153+
cfg["rom_ext"],
154+
"//sw/host/provisioning/orchestrator/src:data_dependencies",
155+
"//util/coverage/collect_cc_coverage",
152156
],
153157
env = {
154158
"PYTHON": "$(location @python3//:python3)",
155159
"SKU_CONFIG_PATH": "$(location {})".format(cfg["orchestrator_cfg"]),
160+
"COLLECT_CC_COVERAGE": "$(location //util/coverage/collect_cc_coverage)",
161+
"CC_CODE_COVERAGE_SCRIPT": "", # Disable built-in cc coverage
156162
"FPGA": "{}".format(fpga),
157163
},
158164
tags = [

sw/host/provisioning/orchestrator/tests/e2e.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,28 @@ cp sw/host/provisioning/orchestrator/src/orchestrator.zip $TEST_TMPDIR
1414

1515
ORCHESTRATOR_PATH=$TEST_TMPDIR/orchestrator.zip
1616

17-
# This script is run by a Bazel sh_test rule, which sets RUNFILES_DIR to point
18-
# at the test's runfiles. However, if RUNFILES_DIR is set, orchestrator.zip will
19-
# inherit its value instead of setting it to the proper directory. This breaks
20-
# runfile resolution, so we unset this variable here.
21-
unset RUNFILES_DIR
17+
(
18+
# This script is run by a Bazel sh_test rule, which sets RUNFILES_DIR to point
19+
# at the test's runfiles. However, if RUNFILES_DIR is set, orchestrator.zip will
20+
# inherit its value instead of setting it to the proper directory. This breaks
21+
# runfile resolution, so we unset this variable here.
22+
unset RUNFILES_DIR
2223

23-
# Run tool. The path to the --sku-config parameter is relative to the
24-
# runfiles-dir.
25-
$PYTHON ${ORCHESTRATOR_PATH} \
26-
--sku-config=${SKU_CONFIG_PATH} \
27-
--test-unlock-token="0x11111111_11111111_11111111_11111111" \
28-
--test-exit-token="0x22222222_22222222_22222222_22222222" \
29-
--fpga=${FPGA} \
30-
--non-interactive \
31-
"$@" \
32-
--db-path=$TEST_TMPDIR/registry.sqlite
24+
# Run tool. The path to the --sku-config parameter is relative to the
25+
# runfiles-dir.
26+
$PYTHON ${ORCHESTRATOR_PATH} \
27+
--sku-config=${SKU_CONFIG_PATH} \
28+
--test-unlock-token="0x11111111_11111111_11111111_11111111" \
29+
--test-exit-token="0x22222222_22222222_22222222_22222222" \
30+
--fpga=${FPGA} \
31+
--non-interactive \
32+
"$@" \
33+
--db-path=$TEST_TMPDIR/registry.sqlite
34+
)
35+
36+
# Post-process the coverage profile if coverage mode is enabled.
37+
if [[ "$COVERAGE" == "1" ]]; then
38+
export COLLECT_CC_COVERAGE="$PWD/$COLLECT_CC_COVERAGE"
39+
cd "$ROOT"
40+
"$COLLECT_CC_COVERAGE"
41+
fi

0 commit comments

Comments
 (0)