]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-loop-block: also test dissection without ADD/PIN of partition block devices
authorLennart Poettering <lennart@poettering.net>
Thu, 1 Dec 2022 16:16:18 +0000 (17:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Dec 2022 21:07:36 +0000 (22:07 +0100)
Let's extend the test further, and try the codepaths where we do not
pin/add the partition block devices (i.e. which is the codepaths we use
when running without privs)

src/test/test-loop-block.c

index 200cf2ba0331cf59c14d20f53da3e9df97a6bf40..01db8b092ec0b85fd7ba657609a3b1dcd0c5b4ca 100644 (file)
@@ -255,6 +255,14 @@ static int run(int argc, char *argv[]) {
         assert_se(make_filesystem(dissected->partitions[PARTITION_HOME].node, "ext4", "home", NULL, id, true) >= 0);
 
         dissected = dissected_image_unref(dissected);
+
+        /* Try to read once, without pinning or adding partitions, i.e. by only accessing the whole block
+         * device. */
+        assert_se(dissect_loop_device(loop, NULL, NULL, 0, &dissected) >= 0);
+        verify_dissected_image_harder(dissected);
+        dissected = dissected_image_unref(dissected);
+
+        /* Now go via the loopback device after all, but this time add/pin, because now we want to mount it. */
         assert_se(dissect_loop_device(loop, NULL, NULL, DISSECT_IMAGE_ADD_PARTITION_DEVICES|DISSECT_IMAGE_PIN_PARTITION_DEVICES, &dissected) >= 0);
         verify_dissected_image_harder(dissected);