summaryrefslogtreecommitdiff
path: root/src/test/test-loop-block.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-04-06 11:57:13 +0200
committerLennart Poettering <lennart@poettering.net>2022-04-07 18:56:38 +0200
commite745ddb16f7910402f30e26cb1133a1e886c9742 (patch)
tree8ee5314edd68b2220c84f8ccd10f4b2d882e5529 /src/test/test-loop-block.c
parentd4dd3689fa7a791c7b3198debab25b290668da52 (diff)
downloadsystemd-e745ddb16f7910402f30e26cb1133a1e886c9742.tar.gz
test-loop-block: conditionalize things on HAVE_BLKID correctly
Diffstat (limited to 'src/test/test-loop-block.c')
-rw-r--r--src/test/test-loop-block.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/test/test-loop-block.c b/src/test/test-loop-block.c
index 35a981bcce..2f3c3745e2 100644
--- a/src/test/test-loop-block.c
+++ b/src/test/test-loop-block.c
@@ -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;
}