ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Jan Synacek 2ec3b0
From 32a4ce451c3aa579d768005decd5342ba319a0e7 Mon Sep 17 00:00:00 2001
Jan Synacek 2ec3b0
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Jan Synacek 2ec3b0
Date: Tue, 1 Dec 2015 22:35:16 -0500
Jan Synacek 2ec3b0
Subject: [PATCH 1/4] tests: turn check if manager cannot be intialized into
Jan Synacek 2ec3b0
 macro
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
We need to check the same thing in multiple tests. Use a shared
Jan Synacek 2ec3b0
macro to make it easier to update the list of errnos.
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
Change the errno code for "unitialized cgroup fs" for ENOMEDIUM.
Jan Synacek 2ec3b0
Exec format error looks like something more serious.
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
This fixes test-execute invocation in mock.
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
(cherry picked from commit 8b3aa503c171acdb9ec63484a8c50e2680d31e79)
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
Resolves: #1286249
Jan Synacek 2ec3b0
---
Jan Synacek 2ec3b0
 src/basic/cgroup-util.c                |  2 +-
Jan Synacek 2ec3b0
 src/libsystemd/sd-bus/test-bus-creds.c |  2 +-
Jan Synacek 2ec3b0
 src/test/test-engine.c                 |  3 ++-
Jan Synacek 2ec3b0
 src/test/test-execute.c                |  3 ++-
Jan Synacek 2ec3b0
 src/test/test-helper.h                 | 12 ++++++++++++
Jan Synacek 2ec3b0
 src/test/test-path.c                   |  3 ++-
Jan Synacek 2ec3b0
 src/test/test-sched-prio.c             |  3 ++-
Jan Synacek 2ec3b0
 7 files changed, 22 insertions(+), 6 deletions(-)
Jan Synacek 2ec3b0
Jan Synacek 2ec3b0
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
Jan Synacek 2ec3b0
index f7fc2c2..263c726 100644
Jan Synacek 2ec3b0
--- a/src/basic/cgroup-util.c
Jan Synacek 2ec3b0
+++ b/src/basic/cgroup-util.c
Jan Synacek 2ec3b0
@@ -2130,7 +2130,7 @@ int cg_unified(void) {
Jan Synacek 2ec3b0
         else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
Jan Synacek 2ec3b0
                 unified_cache = false;
Jan Synacek 2ec3b0
         else
Jan Synacek 2ec3b0
-                return -ENOEXEC;
Jan Synacek 2ec3b0
+                return -ENOMEDIUM;
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
         return unified_cache;
Jan Synacek 2ec3b0
 }
Jan Synacek 2ec3b0
diff --git a/src/libsystemd/sd-bus/test-bus-creds.c b/src/libsystemd/sd-bus/test-bus-creds.c
Jan Synacek 2ec3b0
index bd0101a..de337bb 100644
Jan Synacek 2ec3b0
--- a/src/libsystemd/sd-bus/test-bus-creds.c
Jan Synacek 2ec3b0
+++ b/src/libsystemd/sd-bus/test-bus-creds.c
Jan Synacek 2ec3b0
@@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
Jan Synacek 2ec3b0
         int r;
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
-        if (cg_unified() == -ENOEXEC) {
Jan Synacek 2ec3b0
+        if (cg_unified() == -ENOMEDIUM) {
Jan Synacek 2ec3b0
                 puts("Skipping test: /sys/fs/cgroup/ not available");
Jan Synacek 2ec3b0
                 return EXIT_TEST_SKIP;
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
Jan Synacek 2ec3b0
index 4f14c58..f09df43 100644
Jan Synacek 2ec3b0
--- a/src/test/test-engine.c
Jan Synacek 2ec3b0
+++ b/src/test/test-engine.c
Jan Synacek 2ec3b0
@@ -25,6 +25,7 @@
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
 #include "bus-util.h"
Jan Synacek 2ec3b0
 #include "manager.h"
Jan Synacek 2ec3b0
+#include "test-helper.h"
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
 int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         _cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
Jan Synacek 2ec3b0
@@ -38,7 +39,7 @@ int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         /* prepare the test */
Jan Synacek 2ec3b0
         assert_se(set_unit_path(TEST_DIR) >= 0);
Jan Synacek 2ec3b0
         r = manager_new(MANAGER_USER, true, &m);
Jan Synacek 2ec3b0
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
Jan Synacek 2ec3b0
+        if (MANAGER_SKIP_TEST(r)) {
Jan Synacek 2ec3b0
                 printf("Skipping test: manager_new: %s", strerror(-r));
Jan Synacek 2ec3b0
                 return EXIT_TEST_SKIP;
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
Jan Synacek 2ec3b0
index 03ec0fc..1ab10fb 100644
Jan Synacek 2ec3b0
--- a/src/test/test-execute.c
Jan Synacek 2ec3b0
+++ b/src/test/test-execute.c
Jan Synacek 2ec3b0
@@ -29,6 +29,7 @@
Jan Synacek 2ec3b0
 #include "mkdir.h"
Jan Synacek 2ec3b0
 #include "path-util.h"
Jan Synacek 2ec3b0
 #include "rm-rf.h"
Jan Synacek 2ec3b0
+#include "test-helper.h"
Jan Synacek 2ec3b0
 #include "unit.h"
Jan Synacek 2ec3b0
 #include "util.h"
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
@@ -296,7 +297,7 @@ int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         assert_se(unsetenv("VAR3") == 0);
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
         r = manager_new(MANAGER_USER, true, &m);
Jan Synacek 2ec3b0
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT)) {
Jan Synacek 2ec3b0
+        if (MANAGER_SKIP_TEST(r)) {
Jan Synacek 2ec3b0
                 printf("Skipping test: manager_new: %s", strerror(-r));
Jan Synacek 2ec3b0
                 return EXIT_TEST_SKIP;
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
diff --git a/src/test/test-helper.h b/src/test/test-helper.h
Jan Synacek 2ec3b0
index f75dd33..c0f6a91 100644
Jan Synacek 2ec3b0
--- a/src/test/test-helper.h
Jan Synacek 2ec3b0
+++ b/src/test/test-helper.h
Jan Synacek 2ec3b0
@@ -23,9 +23,21 @@
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
 #include "sd-daemon.h"
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
+#include "macro.h"
Jan Synacek 2ec3b0
+
Jan Synacek 2ec3b0
 #define TEST_REQ_RUNNING_SYSTEMD(x)                                 \
Jan Synacek 2ec3b0
         if (sd_booted() > 0) {                                      \
Jan Synacek 2ec3b0
                 x;                                                  \
Jan Synacek 2ec3b0
         } else {                                                    \
Jan Synacek 2ec3b0
                 printf("systemd not booted skipping '%s'\n", #x);   \
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
+
Jan Synacek 2ec3b0
+#define MANAGER_SKIP_TEST(r)                                    \
Jan Synacek 2ec3b0
+        IN_SET(r,                                               \
Jan Synacek 2ec3b0
+               -EPERM,                                          \
Jan Synacek 2ec3b0
+               -EACCES,                                         \
Jan Synacek 2ec3b0
+               -EADDRINUSE,                                     \
Jan Synacek 2ec3b0
+               -EHOSTDOWN,                                      \
Jan Synacek 2ec3b0
+               -ENOENT,                                         \
Jan Synacek 2ec3b0
+               -ENOMEDIUM /* cannot determine cgroup */         \
Jan Synacek 2ec3b0
+               )
Jan Synacek 2ec3b0
diff --git a/src/test/test-path.c b/src/test/test-path.c
Jan Synacek 2ec3b0
index 8302bdd..6e6a72d 100644
Jan Synacek 2ec3b0
--- a/src/test/test-path.c
Jan Synacek 2ec3b0
+++ b/src/test/test-path.c
Jan Synacek 2ec3b0
@@ -29,6 +29,7 @@
Jan Synacek 2ec3b0
 #include "rm-rf.h"
Jan Synacek 2ec3b0
 #include "string-util.h"
Jan Synacek 2ec3b0
 #include "strv.h"
Jan Synacek 2ec3b0
+#include "test-helper.h"
Jan Synacek 2ec3b0
 #include "unit.h"
Jan Synacek 2ec3b0
 #include "util.h"
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
@@ -44,7 +45,7 @@ static int setup_test(Manager **m) {
Jan Synacek 2ec3b0
         assert_se(m);
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
         r = manager_new(MANAGER_USER, true, &tmp);
Jan Synacek 2ec3b0
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
Jan Synacek 2ec3b0
+        if (MANAGER_SKIP_TEST(r)) {
Jan Synacek 2ec3b0
                 printf("Skipping test: manager_new: %s", strerror(-r));
Jan Synacek 2ec3b0
                 return -EXIT_TEST_SKIP;
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
Jan Synacek 2ec3b0
index 8396ae6..7958a6c 100644
Jan Synacek 2ec3b0
--- a/src/test/test-sched-prio.c
Jan Synacek 2ec3b0
+++ b/src/test/test-sched-prio.c
Jan Synacek 2ec3b0
@@ -23,6 +23,7 @@
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
 #include "macro.h"
Jan Synacek 2ec3b0
 #include "manager.h"
Jan Synacek 2ec3b0
+#include "test-helper.h"
Jan Synacek 2ec3b0
 
Jan Synacek 2ec3b0
 int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         Manager *m = NULL;
Jan Synacek 2ec3b0
@@ -35,7 +36,7 @@ int main(int argc, char *argv[]) {
Jan Synacek 2ec3b0
         /* prepare the test */
Jan Synacek 2ec3b0
         assert_se(set_unit_path(TEST_DIR) >= 0);
Jan Synacek 2ec3b0
         r = manager_new(MANAGER_USER, true, &m);
Jan Synacek 2ec3b0
-        if (IN_SET(r, -EPERM, -EACCES, -EADDRINUSE, -EHOSTDOWN, -ENOENT, -ENOEXEC)) {
Jan Synacek 2ec3b0
+        if (MANAGER_SKIP_TEST(r)) {
Jan Synacek 2ec3b0
                 printf("Skipping test: manager_new: %s", strerror(-r));
Jan Synacek 2ec3b0
                 return EXIT_TEST_SKIP;
Jan Synacek 2ec3b0
         }
Jan Synacek 2ec3b0
-- 
Jan Synacek 2ec3b0
2.5.0
Jan Synacek 2ec3b0