]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-loop-block: conditionalize things on HAVE_BLKID correctly
authorLennart Poettering <lennart@poettering.net>
Wed, 6 Apr 2022 09:57:13 +0000 (11:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Apr 2022 16:56:38 +0000 (18:56 +0200)
src/test/test-loop-block.c

index 35a981bcce383662cd5b0298cea4b03244f6b083..2f3c3745e2031fc9990304ea5ce29363e6b0cfe1 100644 (file)
@@ -27,6 +27,7 @@ static unsigned arg_n_threads = 5;
 static unsigned arg_n_iterations = 3;
 static usec_t arg_timeout = 0;
 
+#if HAVE_BLKID
 static usec_t end = 0;
 
 static void* thread_func(void *ptr) {
@@ -100,6 +101,7 @@ static void* thread_func(void *ptr) {
 
         return NULL;
 }
+#endif
 
 static bool have_root_gpt_type(void) {
 #ifdef GPT_ROOT_NATIVE
@@ -114,9 +116,6 @@ static int run(int argc, char *argv[]) {
         _cleanup_(pclosep) FILE *sfdisk = NULL;
         _cleanup_(loop_device_unrefp) LoopDevice *loop = NULL;
         _cleanup_close_ int fd = -1;
-        _cleanup_(dissected_image_unrefp) DissectedImage *dissected = NULL;
-        _cleanup_(umount_and_rmdir_and_freep) char *mounted = NULL;
-        sd_id128_t id;
         int r;
 
         test_setup_logging(LOG_DEBUG);
@@ -149,8 +148,6 @@ static int run(int argc, char *argv[]) {
         if (argc >= 5)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Too many arguments (expected 3 at max).");
 
-        pthread_t threads[arg_n_threads];
-
         if (!have_root_gpt_type()) {
                 log_tests_skipped("No root partition GPT defined for this architecture, exiting.");
                 return EXIT_TEST_SKIP;
@@ -217,6 +214,13 @@ static int run(int argc, char *argv[]) {
         sfdisk = NULL;
 
         assert_se(loop_device_make(fd, O_RDWR, 0, UINT64_MAX, LO_FLAGS_PARTSCAN, &loop) >= 0);
+
+#if HAVE_BLKID
+        _cleanup_(dissected_image_unrefp) DissectedImage *dissected = NULL;
+        _cleanup_(umount_and_rmdir_and_freep) char *mounted = NULL;
+        pthread_t threads[arg_n_threads];
+        sd_id128_t id;
+
         assert_se(dissect_image(loop->fd, NULL, NULL, loop->diskseq, loop->uevent_seqnum_not_before, loop->timestamp_not_before, 0, &dissected) >= 0);
 
         assert_se(dissected->partitions[PARTITION_ESP].found);
@@ -279,6 +283,9 @@ static int run(int argc, char *argv[]) {
                 }
 
         log_notice("Threads are all terminated now.");
+#else
+        log_notice("Cutting test short, since we do not have libblkid.");
+#endif
 
         return 0;
 }