]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: Don't make rootfs read-only if we're collecting coverage
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 3 Dec 2024 14:08:11 +0000 (15:08 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 4 Dec 2024 13:04:24 +0000 (14:04 +0100)
The test needs to be able to write coverage data to the rootfs so don't
make / read-only.

src/test/test-execute.c

index 95ccf5490de50e8d159c4da9a58b5db5f1fde22c..de575ec1e6d7616f50f96523f18cdcfdd1b851d3 100644 (file)
@@ -1448,8 +1448,10 @@ static int prepare_ns(const char *process_name) {
                 _cleanup_free_ char *unit_dir = NULL, *build_dir = NULL, *build_dir_mount = NULL;
                 int ret;
 
-                /* Make "/" read-only. */
-                ASSERT_OK(mount_nofollow_verbose(LOG_DEBUG, NULL, "/", NULL, MS_BIND|MS_REMOUNT|MS_RDONLY, NULL));
+                const char *coverage = getenv("COVERAGE_BUILD_DIR");
+                if (!coverage)
+                        /* Make "/" read-only. */
+                        ASSERT_OK(mount_nofollow_verbose(LOG_DEBUG, NULL, "/", NULL, MS_BIND|MS_REMOUNT|MS_RDONLY, NULL));
 
                 /* Creating a new user namespace in the above means all MS_SHARED mounts become MS_SLAVE.
                  * Let's put them back to MS_SHARED here, since that's what we want as defaults. (This will