]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: set `ReadWritePaths=$BUILD_DIR` when running w/ coverage
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 14 Feb 2022 19:19:51 +0000 (20:19 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 14 Feb 2022 21:59:33 +0000 (21:59 +0000)
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.

test/test-functions

index 2c13baab048369e27a8537b37488d14b5fc80bb4..dbd6371622a5ad79658c19e2b22bca389bae7adf 100644 (file)
@@ -1163,11 +1163,13 @@ install_systemd() {
     mkdir "$initdir/etc/systemd/system/user@.service.d/"
     echo -e "[Service]\nPassEnvironment=SYSTEMD_UNIT_PATH\n" >"$initdir/etc/systemd/system/user@.service.d/override.conf"
 
-    # When built with gcov, disable ProtectSystem= and ProtectHome in the test
-    # images, since it prevents gcov to write the coverage reports (*.gcda files)
+    # When built with gcov, disable ProtectSystem= and ProtectHome= in the test
+    # images, since it prevents gcov to write the coverage reports (*.gcda
+    # files). Similarly, set ReadWritePaths= to the $BUIL_DIR in the test image
+    # to make the coverage work with units utilizing DynamicUser=yes.
     if get_bool "$IS_BUILT_WITH_COVERAGE"; then
         mkdir -p "$initdir/etc/systemd/system/service.d/"
-        echo -e "[Service]\nProtectSystem=no\nProtectHome=no\n" >"$initdir/etc/systemd/system/service.d/gcov-override.conf"
+        echo -e "[Service]\nProtectSystem=no\nProtectHome=no\nReadWritePaths=${BUILD_DIR:?}\n" >"$initdir/etc/systemd/system/service.d/gcov-override.conf"
     fi
 
     # If we're built with -Dportabled=false, tests with systemd-analyze