mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
tests: turn check if manager cannot be intialized into macro
We need to check the same thing in multiple tests. Use a shared macro to make it easier to update the list of errnos. Change the errno code for "unitialized cgroup fs" for ENOMEDIUM. Exec format error looks like something more serious. This fixes test-execute invocation in mock.
This commit is contained in:
parent
ade61d3b48
commit
8b3aa503c1
@ -2135,7 +2135,7 @@ int cg_unified(void) {
|
||||
else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
|
||||
unified_cache = false;
|
||||
else
|
||||
return -ENOEXEC;
|
||||
return -ENOMEDIUM;
|
||||
|
||||
return unified_cache;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ static int get_cgroup_root(char **ret) {
|
||||
|
||||
if (!arg_machine) {
|
||||
r = cg_get_root_path(ret);
|
||||
if (r == -ENOEXEC)
|
||||
if (r == -ENOMEDIUM)
|
||||
return log_error_errno(r, "Failed to get root control group path: No cgroup filesystem mounted on /sys/fs/cgroup");
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to get root control group path: %m");
|
||||
|
@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
|
||||
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
|
||||
int r;
|
||||
|
||||
if (cg_unified() == -ENOEXEC) {
|
||||
if (cg_unified() == -ENOMEDIUM) {
|
||||
puts("Skipping test: /sys/fs/cgroup/ not available");
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "bus-util.h"
|
||||
#include "manager.h"
|
||||
#include "test-helper.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error err = SD_BUS_ERROR_NULL;
|
||||
@ -38,7 +39,7 @@ int main(int argc, char *argv[]) {
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(TEST_DIR) >= 0);
|
||||
r = manager_new(MANAGER_USER, true, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
printf("Skipping test: manager_new: %s", strerror(-r));
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "mkdir.h"
|
||||
#include "path-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "test-helper.h"
|
||||
#include "unit.h"
|
||||
#include "util.h"
|
||||
|
||||
@ -296,7 +297,7 @@ int main(int argc, char *argv[]) {
|
||||
assert_se(unsetenv("VAR3") == 0);
|
||||
|
||||
r = manager_new(MANAGER_USER, true, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
printf("Skipping test: manager_new: %s", strerror(-r));
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -23,9 +23,21 @@
|
||||
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
#define TEST_REQ_RUNNING_SYSTEMD(x) \
|
||||
if (sd_booted() > 0) { \
|
||||
x; \
|
||||
} else { \
|
||||
printf("systemd not booted skipping '%s'\n", #x); \
|
||||
}
|
||||
|
||||
#define MANAGER_SKIP_TEST(r) \
|
||||
IN_SET(r, \
|
||||
-EPERM, \
|
||||
-EACCES, \
|
||||
-EADDRINUSE, \
|
||||
-EHOSTDOWN, \
|
||||
-ENOENT, \
|
||||
-ENOMEDIUM /* cannot determine cgroup */ \
|
||||
)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "test-helper.h"
|
||||
#include "unit.h"
|
||||
#include "util.h"
|
||||
|
||||
@ -44,7 +45,7 @@ static int setup_test(Manager **m) {
|
||||
assert_se(m);
|
||||
|
||||
r = manager_new(MANAGER_USER, true, &tmp);
|
||||
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
printf("Skipping test: manager_new: %s", strerror(-r));
|
||||
return -EXIT_TEST_SKIP;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "macro.h"
|
||||
#include "manager.h"
|
||||
#include "test-helper.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Manager *m = NULL;
|
||||
@ -35,7 +36,7 @@ int main(int argc, char *argv[]) {
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(TEST_DIR) >= 0);
|
||||
r = manager_new(MANAGER_USER, true, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
|
||||
if (MANAGER_SKIP_TEST(r)) {
|
||||
printf("Skipping test: manager_new: %s", strerror(-r));
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user