Skip to content

Commit b6fc524

Browse files
committed
test: set ReadWritePaths=$BUILD_DIR when running w/ coverage
otherwise units using `DynamicUser=yes` won't be able to write the coverage stats (currently affecting TEST-20-MAINPIDGAMES). `DynamicUser=yes` implies `ProtectSystem=strict` and `ProtectHome=read-only` and can't be overridden hence we need to utilize `ReadWritePaths=` to work around that.
1 parent f3376ee commit b6fc524

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/test-functions

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,11 +1163,13 @@ install_systemd() {
11631163
mkdir "$initdir/etc/systemd/system/user@.service.d/"
11641164
echo -e "[Service]\nPassEnvironment=SYSTEMD_UNIT_PATH\n" >"$initdir/etc/systemd/system/user@.service.d/override.conf"
11651165

1166-
# When built with gcov, disable ProtectSystem= and ProtectHome in the test
1167-
# images, since it prevents gcov to write the coverage reports (*.gcda files)
1166+
# When built with gcov, disable ProtectSystem= and ProtectHome= in the test
1167+
# images, since it prevents gcov to write the coverage reports (*.gcda
1168+
# files). Similarly, set ReadWritePaths= to the $BUIL_DIR in the test image
1169+
# to make the coverage work with units utilizing DynamicUser=yes.
11681170
if get_bool "$IS_BUILT_WITH_COVERAGE"; then
11691171
mkdir -p "$initdir/etc/systemd/system/service.d/"
1170-
echo -e "[Service]\nProtectSystem=no\nProtectHome=no\n" >"$initdir/etc/systemd/system/service.d/gcov-override.conf"
1172+
echo -e "[Service]\nProtectSystem=no\nProtectHome=no\nReadWritePaths=${BUILD_DIR:?}\n" >"$initdir/etc/systemd/system/service.d/gcov-override.conf"
11711173
fi
11721174

11731175
# If we're built with -Dportabled=false, tests with systemd-analyze

0 commit comments

Comments
 (0)