test_setup_logging(LOG_DEBUG);
- if (cg_unified() == -ENOMEDIUM)
+ if (IN_SET(cg_unified(), -ENOMEDIUM, -ENOENT))
return log_tests_skipped("/sys/fs/cgroup/ not available");
r = sd_bus_creds_new_from_pid(&creds, 0, _SD_BUS_CREDS_ALL);
#include "device-private.h"
#include "device-util.h"
#include "macro.h"
+#include "mountpoint-util.h"
#include "path-util.h"
#include "stat-util.h"
#include "string-util.h"
if (getuid() != 0)
return log_tests_skipped("not root");
+ if (path_is_mount_point("/sys", NULL, 0) <= 0)
+ return log_tests_skipped("/sys is not mounted");
+
if (path_is_read_only_fs("/sys") > 0)
return log_tests_skipped("Running in container");
#include "sd-device.h"
#include "device-util.h"
+#include "tests.h"
#define handle_error_errno(error, msg) \
({ \
int r;
r = sd_device_new_from_syspath(&loopback, "/sys/class/net/lo");
+ if (r == -ENODEV)
+ return log_tests_skipped("Loopback device not found");
if (r < 0)
return handle_error_errno(r, "Failed to create loopback device object");
#include "errno-util.h"
#include "fd-util.h"
#include "hashmap.h"
+#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "path-util.h"
#include "rm-rf.h"
}
}
-DEFINE_TEST_MAIN(LOG_INFO);
+static int intro(void) {
+ if (path_is_mount_point("/sys", NULL, 0) <= 0)
+ return log_tests_skipped("/sys is not mounted");
+
+ return EXIT_SUCCESS;
+}
+
+DEFINE_TEST_MAIN_WITH_INTRO(LOG_INFO, intro);
#include "format-util.h"
#include "log.h"
#include "missing_syscall.h"
+#include "mountpoint-util.h"
#include "process-util.h"
#include "string-util.h"
#include "strv.h"
}
static int intro(void) {
+ if (IN_SET(cg_unified(), -ENOENT, -ENOMEDIUM))
+ return log_tests_skipped("cgroupfs is not mounted");
+
log_info("/* Information printed is from the live system */");
return EXIT_SUCCESS;
}
#include <stdlib.h>
#include "libudev.h"
+#include "tests.h"
#define handle_error_errno(error, msg) \
({ \
int r;
loopback = udev_device_new_from_syspath(NULL, "/sys/class/net/lo");
- if (!loopback)
+ if (!loopback) {
+ if (errno == ENODEV)
+ return log_tests_skipped_errno(errno, "Loopback device not found");
+
return handle_error_errno(errno, "Failed to create loopback device object");
+ }
entry = udev_device_get_properties_list_entry(loopback);
udev_list_entry_foreach(e, entry)
#include "fd-util.h"
#include "fs-util.h"
#include "log.h"
+#include "mountpoint-util.h"
#include "namespace-util.h"
#include "path-util.h"
#include "process-util.h"
log_warning_errno(r, "Couldn't allocate a scope unit for this test, proceeding without.");
r = cg_pid_get_path(NULL, 0, &cgroup_root);
- if (r == -ENOMEDIUM)
+ if (IN_SET(r, -ENOMEDIUM, -ENOENT))
return log_warning_errno(r, "cg_pid_get_path(NULL, 0, ...) failed: %m");
assert(r >= 0);
},
test_template + {
'sources' : files('../libsystemd/sd-device/test-sd-device-thread.c'),
- 'link_with' : libsystemd,
+ 'link_with' : [
+ libbasic,
+ libsystemd,
+ ],
'dependencies' : threads,
},
test_template + {
'sources' : files('../libudev/test-udev-device-thread.c'),
- 'link_with' : libudev,
+ 'link_with' : [
+ libbasic,
+ libudev,
+ ],
'dependencies' : threads,
},
test_template + {
int all, hybrid, systemd, r;
r = cg_unified();
- if (r == -ENOMEDIUM) {
+ if (IN_SET(r, -ENOENT, -ENOMEDIUM)) {
log_tests_skipped("cgroup not mounted");
return;
}
int i, r;
r = cg_get_keyed_attribute("cpu", "/init.scope", "no_such_file", STRV_MAKE("no_such_attr"), &val);
- if (r == -ENOMEDIUM || ERRNO_IS_PRIVILEGE(r)) {
+ if (IN_SET(r, -ENOMEDIUM, -ENOENT) || ERRNO_IS_PRIVILEGE(r)) {
log_info_errno(r, "Skipping most of %s, /sys/fs/cgroup not accessible: %m", __func__);
return;
}
int r;
r = cg_unified_cached(false);
- if (r == -ENOMEDIUM) {
- log_tests_skipped("cgroup not mounted");
+ if (IN_SET(r, -ENOMEDIUM, -ENOENT)) {
+ log_tests_skipped("cgroupfs is not mounted");
return;
}
assert_se(r >= 0);
int r;
r = cg_unified();
- if (r == -ENOMEDIUM) {
- log_tests_skipped("cgroup not mounted");
+ if (IN_SET(r, -ENOMEDIUM, -ENOENT)) {
+ log_tests_skipped("cgroupfs is not mounted");
return;
}
assert_se(r >= 0);
int r;
r = cg_unified();
- if (r == -ENOMEDIUM) {
- log_tests_skipped("cgroup not mounted");
+ if (IN_SET(r, -ENOMEDIUM, -ENOENT)) {
+ log_tests_skipped("cgroupfs is not mounted");
return;
}
assert_se(r >= 0);
assert_se(path_is_mount_point("/proc/1/", NULL, AT_SYMLINK_FOLLOW) == 0);
assert_se(path_is_mount_point("/proc/1/", NULL, 0) == 0);
- assert_se(path_is_mount_point("/sys", NULL, AT_SYMLINK_FOLLOW) > 0);
- assert_se(path_is_mount_point("/sys", NULL, 0) > 0);
- assert_se(path_is_mount_point("/sys/", NULL, AT_SYMLINK_FOLLOW) > 0);
- assert_se(path_is_mount_point("/sys/", NULL, 0) > 0);
+ assert_se(path_is_mount_point("/dev", NULL, AT_SYMLINK_FOLLOW) > 0);
+ assert_se(path_is_mount_point("/dev", NULL, 0) > 0);
+ assert_se(path_is_mount_point("/dev/", NULL, AT_SYMLINK_FOLLOW) > 0);
+ assert_se(path_is_mount_point("/dev/", NULL, 0) > 0);
/* we'll create a hierarchy of different kinds of dir/file/link
* layouts:
if (getuid() != 0)
return log_tests_skipped("not root");
r = enter_cgroup_subroot(NULL);
- if (r == -ENOMEDIUM)
+ if (r < 0)
return log_tests_skipped("cgroupfs not available");
_cleanup_free_ char *unit_dir = NULL;
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "mountpoint-util.h"
#include "string-util.h"
#include "tests.h"
#include "udev-format.h"
test_udev_resolve_subsys_kernel_one("[net/lo]/address", true, 0, "00:00:00:00:00:00");
}
-DEFINE_TEST_MAIN(LOG_DEBUG);
+static int intro(void) {
+ if (path_is_mount_point("/sys", NULL, 0) <= 0)
+ return log_tests_skipped("/sys is not mounted");
+
+ return EXIT_SUCCESS;
+}
+
+DEFINE_TEST_MAIN_WITH_INTRO(LOG_DEBUG, intro);
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "mountpoint-util.h"
#include "path-util.h"
#include "signal-util.h"
#include "strv.h"
int main(int argc, char *argv[]) {
_cleanup_free_ char *self = NULL;
+ if (path_is_mount_point("/sys", NULL, 0) <= 0)
+ return log_tests_skipped("/sys is not mounted");
+
if (argc > 1) {
if (streq(argv[1], "test1"))
test1();