tests: add helper to unify skipping a test and exiting

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-09-13 13:34:12 +02:00
parent c1cd674357
commit 317bb217d3
34 changed files with 128 additions and 178 deletions

View File

@ -173,7 +173,6 @@ int main(int argc, char *argv[]) {
}
return 0;
#else
log_info("No compression feature is enabled, skipping tests.");
return EXIT_TEST_SKIP;
return log_tests_skipped("No compression feature is enabled");
#endif
}

View File

@ -15,9 +15,9 @@
#include "parse-util.h"
#include "rm-rf.h"
#include "util.h"
#include "tests.h"
/* This program tests skipping around in a multi-file journal.
*/
/* This program tests skipping around in a multi-file journal. */
static bool arg_keep = false;
@ -277,10 +277,8 @@ int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
if (access("/etc/machine-id", F_OK) != 0)
return log_tests_skipped("/etc/machine-id not found");
arg_keep = argc > 1;

View File

@ -12,6 +12,7 @@
#include "macro.h"
#include "parse-util.h"
#include "rm-rf.h"
#include "tests.h"
#include "util.h"
#define N_ENTRIES 200
@ -67,10 +68,8 @@ int main(int argc, char *argv[]) {
dual_timestamp previous_ts = DUAL_TIMESTAMP_NULL;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
if (access("/etc/machine-id", F_OK) != 0)
return log_tests_skipped("/etc/machine-id not found");
log_set_max_level(LOG_DEBUG);

View File

@ -10,6 +10,7 @@
#include "log.h"
#include "rm-rf.h"
#include "terminal-util.h"
#include "tests.h"
#include "util.h"
#define N_ENTRIES 6000
@ -61,10 +62,8 @@ int main(int argc, char *argv[]) {
uint64_t p;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
if (access("/etc/machine-id", F_OK) != 0)
return log_tests_skipped("/etc/machine-id not found");
log_set_max_level(LOG_DEBUG);

View File

@ -8,6 +8,7 @@
#include "journal-vacuum.h"
#include "log.h"
#include "rm-rf.h"
#include "tests.h"
static bool arg_keep = false;
@ -239,10 +240,8 @@ int main(int argc, char *argv[]) {
arg_keep = argc > 1;
/* journal_file_open requires a valid machine id */
if (access("/etc/machine-id", F_OK) != 0) {
log_info("/etc/machine-id not found, skipping tests.");
return EXIT_TEST_SKIP;
}
if (access("/etc/machine-id", F_OK) != 0)
return log_tests_skipped("/etc/machine-id not found");
test_non_empty();
test_empty();

View File

@ -9,6 +9,7 @@
#include "sd-event.h"
#include "dhcp-server-internal.h"
#include "tests.h"
static void test_pool(struct in_addr *address, unsigned size, int ret) {
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
@ -235,10 +236,8 @@ int main(int argc, char *argv[]) {
assert_se(sd_event_new(&e) >= 0);
r = test_basic(e);
if (r != 0) {
log_notice("%s: skipping tests.", program_invocation_short_name);
return EXIT_TEST_SKIP;
}
if (r != 0)
return log_tests_skipped("cannot start dhcp server");
test_message_handler();
test_client_id_hash();

View File

@ -16,6 +16,7 @@
#include "format-util.h"
#include "log.h"
#include "macro.h"
#include "tests.h"
#include "util.h"
static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
@ -510,10 +511,8 @@ int main(int argc, char *argv[]) {
int q, r;
r = server_init(&bus);
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
if (r < 0)
return log_tests_skipped("Failed to connect to bus");
log_info("Initialized...");

View File

@ -8,6 +8,7 @@
#include "bus-message.h"
#include "bus-util.h"
#include "refcnt.h"
#include "tests.h"
static void test_bus_new(void) {
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
@ -59,17 +60,13 @@ static void test_bus_new_signal(void) {
}
int main(int argc, char **argv) {
int r;
log_parse_environment();
log_open();
test_bus_new();
r = test_bus_open();
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
if (test_bus_open() < 0)
return log_tests_skipped("Failed to connect to bus");
test_bus_new_method_call();
test_bus_new_signal();

View File

@ -5,6 +5,7 @@
#include "bus-dump.h"
#include "bus-util.h"
#include "cgroup-util.h"
#include "tests.h"
int main(int argc, char *argv[]) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@ -14,10 +15,8 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
if (cg_unified_flush() == -ENOMEDIUM) {
log_info("Skipping test: /sys/fs/cgroup/ not available");
return EXIT_TEST_SKIP;
}
if (cg_unified_flush() == -ENOMEDIUM)
return log_tests_skipped("/sys/fs/cgroup/ not available");
r = sd_bus_creds_new_from_pid(&creds, 0, _SD_BUS_CREDS_ALL);
log_full_errno(r < 0 ? LOG_ERR : LOG_DEBUG, r, "sd_bus_creds_new_from_pid: %m");

View File

@ -21,6 +21,7 @@
#include "fd-util.h"
#include "hexdecoct.h"
#include "log.h"
#include "tests.h"
#include "util.h"
static void test_bus_path_encode_unique(void) {
@ -121,10 +122,8 @@ int main(int argc, char *argv[]) {
uint64_t u64;
r = sd_bus_default_user(&bus);
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
if (r < 0)
return log_tests_skipped("Failed to connect to bus");
r = sd_bus_message_new_method_call(bus, &m, "foobar.waldo", "/", "foobar.waldo", "Piep");
assert_se(r >= 0);

View File

@ -6,6 +6,7 @@
#include "bus-util.h"
#include "log.h"
#include "macro.h"
#include "tests.h"
static bool mask[32];
@ -78,10 +79,8 @@ int main(int argc, char *argv[]) {
int r;
r = sd_bus_open_user(&bus);
if (r < 0) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
if (r < 0)
return log_tests_skipped("Failed to connect to bus");
assert_se(match_add(slots, &root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar.x',", 1) >= 0);
assert_se(match_add(slots, &root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar.x',", 2) >= 0);

View File

@ -6,6 +6,7 @@
#include "sd-bus.h"
#include "macro.h"
#include "tests.h"
static bool track_cb_called_x = false;
static bool track_cb_called_y = false;
@ -51,10 +52,8 @@ int main(int argc, char *argv[]) {
assert_se(r >= 0);
r = sd_bus_open_user(&a);
if (IN_SET(r, -ECONNREFUSED, -ENOENT)) {
log_info("Failed to connect to bus, skipping tests.");
return EXIT_TEST_SKIP;
}
if (IN_SET(r, -ECONNREFUSED, -ENOENT))
return log_tests_skipped("Failed to connect to bus");
assert_se(r >= 0);
r = sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL);

View File

@ -10,6 +10,7 @@
#include "network-internal.h"
#include "networkd-manager.h"
#include "string-util.h"
#include "tests.h"
static void test_deserialize_in_addr(void) {
_cleanup_free_ struct in_addr *addresses = NULL;
@ -231,10 +232,9 @@ int main(void) {
assert_se(manager_new(&manager) >= 0);
r = test_load_config(manager);
if (r == -EPERM) {
log_info_errno(r, "Skipping tests: %m");
return EXIT_TEST_SKIP;
}
if (r == -EPERM)
return log_tests_skipped("Cannot load configuration");
assert_se(r == 0);
assert_se(sd_device_new_from_syspath(&loopback, "/sys/class/net/lo") >= 0);
assert_se(loopback);

View File

@ -9,6 +9,7 @@
#include "alloc-util.h"
#include "env-util.h"
#include "fileio.h"
#include "log.h"
#include "path-util.h"
#include "strv.h"
#include "tests.h"
@ -89,3 +90,9 @@ bool slow_tests_enabled(void) {
log_warning_errno(r, "Cannot parse $SYSTEMD_SLOW_TESTS, ignoring.");
return SYSTEMD_SLOW_TESTS_DEFAULT;
}
int log_tests_skipped(const char *message) {
log_notice("%s: %s, skipping tests.",
program_invocation_short_name, message);
return EXIT_TEST_SKIP;
}

View File

@ -5,3 +5,4 @@ char* setup_fake_runtime_dir(void);
const char* get_testdata_dir(void);
const char* get_catalog_dir(void);
bool slow_tests_enabled(void);
int log_tests_skipped(const char *message);

View File

@ -2,6 +2,7 @@
#include "architecture.h"
#include "log.h"
#include "tests.h"
#include "util.h"
#include "virt.h"
@ -17,10 +18,8 @@ int main(int argc, char *argv[]) {
assert_se(architecture_from_string(architecture_to_string(1)) == 1);
v = detect_virtualization();
if (IN_SET(v, -EPERM, -EACCES)) {
log_info_errno(v, "Skipping tests: %m");
return EXIT_TEST_SKIP;
}
if (IN_SET(v, -EPERM, -EACCES))
return log_tests_skipped("Cannot detect virtualization");
assert_se(v >= 0);

View File

@ -424,11 +424,8 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
if (!slow_tests_enabled()) {
log_notice("%s: slow tests are disabled, exiting.",
program_invocation_short_name);
return EXIT_TEST_SKIP;
}
if (!slow_tests_enabled())
return log_tests_skipped("slow tests are disabled");
test_barrier_sync();
test_barrier_wait_next();

View File

@ -4,6 +4,7 @@
#include "boot-timestamps.h"
#include "efivars.h"
#include "log.h"
#include "tests.h"
#include "util.h"
static int test_acpi_fpdt(void) {
@ -91,10 +92,8 @@ int main(int argc, char* argv[]) {
r = test_boot_timestamps();
assert(r >= 0);
bool any = p > 0 || q > 0 || r > 0;
if (!any)
log_notice("%s: access to firmware variable not possible, skipping tests.",
program_invocation_short_name);
if (p == 0 && q == 0 && r == 0)
return log_tests_skipped("access to firmware variables not possible");
return any ? EXIT_SUCCESS : EXIT_TEST_SKIP;
return EXIT_SUCCESS;
}

View File

@ -33,10 +33,8 @@ int main(int argc, char *argv[]) {
log_open();
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice("cgroupfs not available, skipping tests");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
assert_se(set_unit_path(get_testdata_dir()) >= 0);
assert_se(runtime_dir = setup_fake_runtime_dir());
@ -47,16 +45,12 @@ int main(int argc, char *argv[]) {
r = bpf_program_add_instructions(p, exit_insn, ELEMENTSOF(exit_insn));
assert(r == 0);
if (getuid() != 0) {
log_notice("Not running as root, skipping kernel related tests.");
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
return log_tests_skipped("not running as root");
r = bpf_firewall_supported();
if (r == BPF_FIREWALL_UNSUPPORTED) {
log_notice("BPF firewalling not supported, skipping");
return EXIT_TEST_SKIP;
}
if (r == BPF_FIREWALL_UNSUPPORTED)
return log_tests_skipped("BPF firewalling not supported");
assert_se(r > 0);
if (r == BPF_FIREWALL_SUPPORTED_WITH_MULTI)
@ -110,10 +104,8 @@ int main(int argc, char *argv[]) {
unit_dump(u, stdout, NULL);
r = bpf_firewall_compile(u);
if (IN_SET(r, -ENOTTY, -ENOSYS, -EPERM)) {
log_info_errno(r, "Kernel doesn't support the necessary bpf bits, or masked out via seccomp? Skipping tests: %m");
return EXIT_TEST_SKIP;
}
if (IN_SET(r, -ENOTTY, -ENOSYS, -EPERM))
return log_tests_skipped("Kernel doesn't support the necessary bpf bits (masked out via seccomp?)");
assert_se(r >= 0);
assert(u->ip_bpf_ingress);

View File

@ -14,6 +14,7 @@
#include "fileio.h"
#include "macro.h"
#include "parse-util.h"
#include "tests.h"
#include "util.h"
static uid_t test_uid = -1;
@ -217,7 +218,6 @@ static void test_set_ambient_caps(void) {
}
int main(int argc, char *argv[]) {
int r;
bool run_ambient;
test_last_cap_file();
@ -228,16 +228,11 @@ int main(int argc, char *argv[]) {
log_info("have ambient caps: %s", yes_no(ambient_capabilities_supported()));
if (getuid() != 0) {
log_notice("%s: not root, skipping tests.", program_invocation_short_name);
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
return log_tests_skipped("not running as root");
r = setup_tests(&run_ambient);
if (r < 0) {
log_notice("%s: skipping tests.", program_invocation_short_name);
return EXIT_TEST_SKIP;
}
if (setup_tests(&run_ambient) < 0)
return log_tests_skipped("setup failed");
show_capabilities();

View File

@ -17,19 +17,18 @@ static int test_cgroup_mask(void) {
int r;
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
puts("Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
/* Prepare the manager. */
assert_se(set_unit_path(get_testdata_dir()) >= 0);
assert_se(runtime_dir = setup_fake_runtime_dir());
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
if (IN_SET(r, -EPERM, -EACCES)) {
puts("manager_new: Permission denied. Skipping test.");
return EXIT_TEST_SKIP;
log_error_errno(r, "manager_new: %m");
return log_tests_skipped("cannot create manager");
}
assert_se(r >= 0);
/* Turn off all kinds of default accouning, so that we can
@ -117,13 +116,13 @@ static void test_cg_mask_to_string(void) {
}
int main(int argc, char* argv[]) {
int rc = 0;
int rc = EXIT_SUCCESS;
log_parse_environment();
log_open();
TEST_REQ_RUNNING_SYSTEMD(rc = test_cgroup_mask());
test_cg_mask_to_string();
TEST_REQ_RUNNING_SYSTEMD(rc = test_cgroup_mask());
return rc;
}

View File

@ -23,10 +23,8 @@ int main(int argc, char *argv[]) {
log_open();
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice_errno(r, "Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
/* prepare the test */
assert_se(set_unit_path(get_testdata_dir()) >= 0);

View File

@ -733,16 +733,12 @@ int main(int argc, char *argv[]) {
(void) unsetenv("SHELL");
/* It is needed otherwise cgroup creation fails */
if (getuid() != 0) {
puts("Skipping test: not root");
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
return log_tests_skipped("not root");
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
puts("Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
assert_se(runtime_dir = setup_fake_runtime_dir());
test_execute_path = path_join(NULL, get_testdata_dir(), "test-execute");

View File

@ -7,6 +7,7 @@
#include "log.h"
#include "string-util.h"
#include "khash.h"
#include "tests.h"
int main(int argc, char *argv[]) {
_cleanup_(khash_unrefp) khash *h = NULL, *copy = NULL;
@ -20,10 +21,8 @@ int main(int argc, char *argv[]) {
r = khash_supported();
assert_se(r >= 0);
if (r == 0) {
puts("khash not supported on this kernel, skipping");
return EXIT_TEST_SKIP;
}
if (r == 0)
return log_tests_skipped("khash not supported on this kernel");
assert_se(khash_new(&h, "foobar") == -EOPNOTSUPP); /* undefined hash function */

View File

@ -2,6 +2,7 @@
#include "clean-ipc.h"
#include "user-util.h"
#include "tests.h"
#include "util.h"
int main(int argc, char *argv[]) {
@ -10,11 +11,11 @@ int main(int argc, char *argv[]) {
const char* name = argv[1] ?: NOBODY_USER_NAME;
r = get_user_creds(&name, &uid, NULL, NULL, NULL, 0);
if (r == -ESRCH)
return log_tests_skipped("Failed to resolve user");
if (r < 0) {
log_full_errno(r == -ESRCH ? LOG_NOTICE : LOG_ERR,
r, "Failed to resolve \"%s\"%s: %m", name,
r == -ESRCH ? ", skipping tests" : "");
return r == -ESRCH ? EXIT_TEST_SKIP : EXIT_FAILURE;
log_error_errno(r, "Failed to resolve \"%s\": %m", name);
return EXIT_FAILURE;
}
r = clean_ipc_by_uid(uid);

View File

@ -7,6 +7,7 @@
#include "namespace.h"
#include "process-util.h"
#include "string-util.h"
#include "tests.h"
#include "util.h"
static void test_tmpdir(const char *id, const char *A, const char *B) {
@ -46,16 +47,14 @@ static void test_tmpdir(const char *id, const char *A, const char *B) {
assert_se(rmdir(b) >= 0);
}
static void test_netns(void) {
static int test_netns(void) {
_cleanup_close_pair_ int s[2] = { -1, -1 };
pid_t pid1, pid2, pid3;
int r, n = 0;
siginfo_t si;
if (geteuid() > 0) {
log_info("Skipping test: not root");
exit(EXIT_TEST_SKIP);
}
if (geteuid() > 0)
return log_tests_skipped("not root");
assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, s) >= 0);
@ -102,6 +101,7 @@ static void test_netns(void) {
n += si.si_status;
assert_se(n == 1);
return EXIT_SUCCESS;
}
int main(int argc, char *argv[]) {
@ -128,7 +128,5 @@ int main(int argc, char *argv[]) {
test_tmpdir("sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device", z, zz);
test_netns();
return 0;
return test_netns();
}

View File

@ -10,6 +10,7 @@
#include "macro.h"
#include "module-util.h"
#include "tests.h"
#include "util.h"
static int load_module(const char *mod_name) {
@ -57,10 +58,8 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
return EXIT_TEST_SKIP;
}
if (getuid() != 0) {
log_info("Skipping tests: not root");
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
return log_tests_skipped("not root");
/* IPIP tunnel */
assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0) >= 0);

View File

@ -33,15 +33,13 @@ static int setup_test(Manager **m) {
assert_se(m);
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice_errno(r, "Skipping test: cgroupfs not available");
return -EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &tmp);
if (MANAGER_SKIP_TEST(r)) {
log_notice_errno(r, "Skipping test: manager_new: %m");
return -EXIT_TEST_SKIP;
return EXIT_TEST_SKIP;
}
assert_se(r >= 0);
assert_se(manager_startup(tmp, NULL, NULL) >= 0);
@ -266,8 +264,8 @@ int main(int argc, char *argv[]) {
/* We create a clean environment for each test */
r = setup_test(&m);
if (r < 0)
return -r;
if (r != 0)
return r;
(*test)(m);

View File

@ -20,10 +20,8 @@ int main(int argc, char *argv[]) {
int r;
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice_errno(r, "Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
/* prepare the test */
assert_se(set_unit_path(get_testdata_dir()) >= 0);

View File

@ -2,12 +2,14 @@
#include <sys/mman.h>
#if HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
#endif
#include "fd-util.h"
#include "sigbus.h"
#include "tests.h"
#include "util.h"
#if HAVE_VALGRIND_VALGRIND_H
#include <valgrind/valgrind.h>
#endif
int main(int argc, char *argv[]) {
_cleanup_close_ int fd = -1;
@ -15,17 +17,14 @@ int main(int argc, char *argv[]) {
void *addr = NULL;
uint8_t *p;
#ifdef __SANITIZE_ADDRESS__
return log_tests_skipped("address-sanitizer is enabled");
#endif
#if HAVE_VALGRIND_VALGRIND_H
if (RUNNING_ON_VALGRIND) {
puts("This test cannot run on valgrind, skipping tests.");
return EXIT_TEST_SKIP;
}
if (RUNNING_ON_VALGRIND)
return log_tests_skipped("This test cannot run on valgrind");
#endif
#ifdef __SANITIZE_ADDRESS__
puts("Address sanitization is enabled, skipping tests.");
return EXIT_TEST_SKIP;
#endif
sigbus_install();
assert_se(sigbus_pop(&addr) == 0);

View File

@ -8,6 +8,7 @@
#include "log.h"
#include "sleep-config.h"
#include "strv.h"
#include "tests.h"
#include "util.h"
static void test_parse_sleep_config(void) {
@ -26,10 +27,8 @@ static int test_fiemap(const char *path) {
if (fd < 0)
return log_error_errno(errno, "failed to open %s: %m", path);
r = read_fiemap(fd, &fiemap);
if (r == -EOPNOTSUPP) {
log_info("Skipping test, not supported");
exit(EXIT_TEST_SKIP);
}
if (r == -EOPNOTSUPP)
exit(log_tests_skipped("Not supported"));
if (r < 0)
return log_error_errno(r, "Unable to read extent map for '%s': %m", path);
log_info("extent map information for %s:", path);

View File

@ -900,10 +900,8 @@ int main(int argc, char *argv[]) {
log_open();
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice_errno(r, "Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@ -815,10 +815,8 @@ int main(int argc, char* argv[]) {
log_open();
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice_errno(r, "Skipping test: cgroupfs not available");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
assert_se(runtime_dir = setup_fake_runtime_dir());

View File

@ -17,16 +17,11 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
if (getuid() != 0) {
log_notice("Not running as root, skipping kernel related tests.");
return EXIT_TEST_SKIP;
}
if (getuid() != 0)
return log_tests_skipped("not root");
r = enter_cgroup_subroot();
if (r == -ENOMEDIUM) {
log_notice("cgroupfs not available, skipping tests");
return EXIT_TEST_SKIP;
}
if (r == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
assert_se(set_unit_path(get_testdata_dir()) >= 0);
assert_se(runtime_dir = setup_fake_runtime_dir());