meson: Still build libshared even if libmount is disabled (#39871)
Currently, if the libmount feature is disabled, we don't build libshared and as a result skip building every other executable as well. Among other things, this makes our nodeps CI builds kind of pointless since hardly any code will be compiled. Let's improve on the situation by making libmount properly optional in libshared. Then, we only skip building the executables that actually need libmount.
This commit is contained in:
@@ -349,6 +349,7 @@ executables += [
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-libmount.c'),
|
||||
'conditions' : ['HAVE_LIBMOUNT'],
|
||||
'dependencies' : [
|
||||
libmount_cflags,
|
||||
threads,
|
||||
@@ -368,6 +369,7 @@ executables += [
|
||||
},
|
||||
test_template + {
|
||||
'sources' : files('test-mount-util.c'),
|
||||
'conditions' : ['HAVE_LIBMOUNT'],
|
||||
'dependencies' : libmount_cflags,
|
||||
},
|
||||
test_template + {
|
||||
|
||||
@@ -54,7 +54,7 @@ static int run(int argc, char **argv) {
|
||||
ASSERT_DLOPEN(dlopen_libblkid, HAVE_BLKID);
|
||||
ASSERT_DLOPEN(dlopen_libfido2, HAVE_LIBFIDO2);
|
||||
ASSERT_DLOPEN(dlopen_libkmod, HAVE_KMOD);
|
||||
ASSERT_DLOPEN(dlopen_libmount, true);
|
||||
ASSERT_DLOPEN(dlopen_libmount, HAVE_LIBMOUNT);
|
||||
ASSERT_DLOPEN(dlopen_libpam, HAVE_PAM);
|
||||
ASSERT_DLOPEN(dlopen_libseccomp, HAVE_SECCOMP);
|
||||
ASSERT_DLOPEN(dlopen_libselinux, HAVE_SELINUX);
|
||||
|
||||
@@ -1612,7 +1612,7 @@ static int intro(void) {
|
||||
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
|
||||
return log_tests_skipped("not privileged");
|
||||
|
||||
if (running_in_chroot() > 0)
|
||||
if (running_in_chroot() != 0)
|
||||
return log_tests_skipped("running in chroot");
|
||||
|
||||
if (enter_cgroup_subroot(NULL) == -ENOMEDIUM)
|
||||
|
||||
@@ -240,7 +240,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
|
||||
return log_tests_skipped("not running privileged");
|
||||
|
||||
if (detect_container() > 0 || running_in_chroot() > 0)
|
||||
if (detect_container() != 0 || running_in_chroot() != 0)
|
||||
return log_tests_skipped("Test not supported in a container/chroot, requires udev/uevent notifications");
|
||||
|
||||
assert_se(loop_device_make(fd, O_RDWR, 0, UINT64_MAX, 0, LO_FLAGS_PARTSCAN, LOCK_EX, &loop) >= 0);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#define CHECK_PRIV \
|
||||
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) \
|
||||
return (void) log_tests_skipped("Not privileged"); \
|
||||
if (running_in_chroot() > 0) \
|
||||
if (running_in_chroot() != 0) \
|
||||
return (void) log_tests_skipped("running in chroot");
|
||||
|
||||
TEST(mount_option_mangle) {
|
||||
|
||||
@@ -457,7 +457,7 @@ static int intro(void) {
|
||||
/* let's move into our own mount namespace with all propagation from the host turned off, so
|
||||
* that /proc/self/mountinfo is static and constant for the whole time our test runs. */
|
||||
|
||||
if (running_in_chroot() > 0) {
|
||||
if (running_in_chroot() != 0) {
|
||||
/* We cannot remount file system with MS_PRIVATE when running in chroot. */
|
||||
log_notice("Running in chroot, proceeding in originating mount namespace.");
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -47,9 +47,9 @@ TEST(rereadpt) {
|
||||
|
||||
if (detect_container() > 0)
|
||||
return (void) log_tests_skipped("test not available in container");
|
||||
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
|
||||
if (have_effective_cap(CAP_SYS_ADMIN) <= 0)
|
||||
return (void) log_tests_skipped("test requires privileges");
|
||||
if (running_in_chroot() > 0)
|
||||
if (running_in_chroot() != 0)
|
||||
return (void) log_tests_skipped("test not available in chroot()");
|
||||
|
||||
_cleanup_free_ char *sfdisk_path = NULL;
|
||||
@@ -97,11 +97,12 @@ TEST(rereadpt) {
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
|
||||
_cleanup_close_ int pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
ASSERT_OK_ERRNO(pfd);
|
||||
_cleanup_close_ int pfd = -EBADF;
|
||||
ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
|
||||
uint64_t size;
|
||||
ASSERT_OK(blockdev_get_device_size(pfd, &size));
|
||||
ASSERT_EQ(size, 20U*1024U*1024U);
|
||||
pfd = safe_close(pfd);
|
||||
|
||||
/* No change */
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
@@ -122,11 +123,14 @@ TEST(rereadpt) {
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
|
||||
ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
|
||||
ASSERT_OK(blockdev_get_device_size(pfd, &size));
|
||||
ASSERT_EQ(size, 30U*1024U*1024U);
|
||||
pfd = safe_close(pfd);
|
||||
|
||||
/* No change */
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
ASSERT_OK_ERRNO(pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
|
||||
|
||||
/* Move */
|
||||
log_notice("MOVING BY 50M");
|
||||
@@ -137,19 +141,19 @@ TEST(rereadpt) {
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
ASSERT_ERROR(reread_partition_table_fd(loop->fd, /* flags= */ 0), EBUSY);
|
||||
pfd = safe_close(pfd);
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
|
||||
safe_close(pfd);
|
||||
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
|
||||
pfd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
ASSERT_OK_ERRNO(pfd);
|
||||
pfd = ASSERT_OK_ERRNO(open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
|
||||
ASSERT_OK(blockdev_get_device_size(pfd, &size));
|
||||
ASSERT_EQ(size, 15U*1024U*1024U);
|
||||
pfd = safe_close(pfd);
|
||||
|
||||
/* No change */
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
pfd = ASSERT_OK_ERRNO(open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY));
|
||||
|
||||
/* Remove */
|
||||
log_notice("REMOVING");
|
||||
@@ -159,9 +163,9 @@ TEST(rereadpt) {
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
ASSERT_ERROR(reread_partition_table_fd(loop->fd, /* flags= */ 0), EBUSY);
|
||||
pfd = safe_close(pfd);
|
||||
|
||||
ASSERT_OK_ZERO_ERRNO(access(p, F_OK));
|
||||
pfd = safe_close(pfd);
|
||||
ASSERT_OK(reread_partition_table_fd(loop->fd, /* flags= */ 0));
|
||||
ASSERT_ERROR_ERRNO(access(p, F_OK), ENOENT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user