test-loop-block: conditionalize things on HAVE_BLKID correctly
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user