mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
tests: use log_tests_skipped more, use shorter form
Also change order to handle errors before 0 in one case.
This commit is contained in:
@@ -44,10 +44,8 @@ TEST(cg_create) {
|
||||
int r;
|
||||
|
||||
r = cg_unified_cached(false);
|
||||
if (IN_SET(r, -ENOMEDIUM, -ENOENT)) {
|
||||
log_tests_skipped("cgroupfs is not mounted");
|
||||
return;
|
||||
}
|
||||
if (IN_SET(r, -ENOMEDIUM, -ENOENT))
|
||||
return (void) log_tests_skipped("cgroupfs is not mounted");
|
||||
ASSERT_OK(r);
|
||||
|
||||
_cleanup_free_ char *here = NULL;
|
||||
@@ -122,14 +120,10 @@ TEST(id) {
|
||||
int r;
|
||||
|
||||
r = cg_all_unified();
|
||||
if (r == 0) {
|
||||
log_tests_skipped("skipping cgroupid test, not running in unified mode");
|
||||
return;
|
||||
}
|
||||
if (IN_SET(r, -ENOMEDIUM, -ENOENT)) {
|
||||
log_tests_skipped("cgroupfs is not mounted");
|
||||
return;
|
||||
}
|
||||
if (IN_SET(r, -ENOMEDIUM, -ENOENT))
|
||||
return (void) log_tests_skipped("cgroupfs is not mounted");
|
||||
if (r == 0)
|
||||
return (void) log_tests_skipped("skipping cgroupid test, not running in unified mode");
|
||||
ASSERT_OK_POSITIVE(r);
|
||||
|
||||
fd = cg_path_open(SYSTEMD_CGROUP_CONTROLLER, "/");
|
||||
|
||||
@@ -184,8 +184,7 @@ TEST(touch_file) {
|
||||
r = touch_file(a, false, test_mtime, test_uid, test_gid, 0640);
|
||||
if (r < 0) {
|
||||
assert_se(IN_SET(r, -EINVAL, -ENOSYS, -ENOTTY, -EPERM));
|
||||
log_tests_skipped_errno(errno, "touch_file() not possible");
|
||||
return;
|
||||
return (void) log_tests_skipped_errno(errno, "touch_file() not possible");
|
||||
}
|
||||
|
||||
assert_se(lstat(a, &st) >= 0);
|
||||
|
||||
@@ -201,10 +201,8 @@ TEST(real_pressure) {
|
||||
pid_t pid;
|
||||
|
||||
r = sd_bus_open_system(&bus);
|
||||
if (r < 0) {
|
||||
log_notice_errno(r, "Can't connect to system bus, skipping test: %m");
|
||||
return;
|
||||
}
|
||||
if (r < 0)
|
||||
return (void) log_tests_skipped_errno(r, "can't connect to system bus");
|
||||
|
||||
assert_se(bus_wait_for_jobs_new(bus, &w) >= 0);
|
||||
|
||||
@@ -218,10 +216,8 @@ TEST(real_pressure) {
|
||||
assert_se(sd_bus_message_append(m, "a(sa(sv))", 0) >= 0);
|
||||
|
||||
r = sd_bus_call(bus, m, 0, &error, &reply);
|
||||
if (r < 0) {
|
||||
log_notice_errno(r, "Can't issue transient unit call, skipping test: %m");
|
||||
return;
|
||||
}
|
||||
if (r < 0)
|
||||
return (void) log_tests_skipped_errno(r, "can't issue transient unit call");
|
||||
|
||||
assert_se(sd_bus_message_read(reply, "o", &object) >= 0);
|
||||
|
||||
@@ -250,10 +246,8 @@ TEST(real_pressure) {
|
||||
};
|
||||
|
||||
r = sd_event_add_memory_pressure(e, &es, real_pressure_callback, &context);
|
||||
if (r < 0) {
|
||||
log_notice_errno(r, "Can't allocate memory pressure fd, skipping test: %m");
|
||||
return;
|
||||
}
|
||||
if (r < 0)
|
||||
return (void) log_tests_skipped_errno(r, "can't allocate memory pressure fd");
|
||||
|
||||
assert_se(sd_event_source_set_description(es, "real pressure event source") >= 0);
|
||||
assert_se(sd_event_source_set_memory_pressure_type(es, "some") == 0);
|
||||
@@ -272,10 +266,8 @@ TEST(real_pressure) {
|
||||
assert_se(sd_bus_get_property_trivial(bus, "org.freedesktop.systemd1", uo, "org.freedesktop.systemd1.Scope", "MemoryCurrent", &error, 't', &mcurrent) >= 0);
|
||||
|
||||
printf("current: %" PRIu64 "\n", mcurrent);
|
||||
if (mcurrent == UINT64_MAX) {
|
||||
log_notice_errno(r, "Memory accounting not available, skipping test: %m");
|
||||
return;
|
||||
}
|
||||
if (mcurrent == UINT64_MAX)
|
||||
return (void) log_tests_skipped_errno(r, "memory accounting not available");
|
||||
|
||||
m = sd_bus_message_unref(m);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user