summaryrefslogtreecommitdiff
path: root/src/test/test-execute.c
diff options
context:
space:
mode:
authorDongsu Park <dongsu@endocode.com>2016-10-25 14:51:01 +0200
committerEvgeny Vereshchagin <evvers@ya.ru>2016-10-25 13:27:45 +0000
commit6086d2daf370426259299e6ff9316ae51238969a (patch)
treeb77e0d5af777f5d19a8d551ba1a2b8b714517262 /src/test/test-execute.c
parentf70ebf1ce3b35d56917605a1696d7eaba4990f11 (diff)
test: skip exec tests when inaccessible dir is unavailable
In case of running test-execute on systems with systemd < v232, several tests like privatedevices or protectkernelmodules fail because /run/systemd/inaccessible/ doesn't exist. In these cases, we should skip tests to avoid unnecessary errors. See also https://github.com/systemd/systemd/pull/4243#issuecomment-253665566
Diffstat (limited to 'src/test/test-execute.c')
-rw-r--r--src/test/test-execute.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 404421a2b8..c369098500 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -70,6 +70,24 @@ static void check(Manager *m, Unit *unit, int status_expected, int code_expected
assert_se(service->main_exec_status.code == code_expected);
}
+static bool is_inaccessible_available(void) {
+ char *p;
+
+ FOREACH_STRING(p,
+ "/run/systemd/inaccessible/reg",
+ "/run/systemd/inaccessible/dir",
+ "/run/systemd/inaccessible/chr",
+ "/run/systemd/inaccessible/blk",
+ "/run/systemd/inaccessible/fifo",
+ "/run/systemd/inaccessible/sock"
+ ) {
+ if (access(p, F_OK) < 0)
+ return false;
+ }
+
+ return true;
+}
+
static void test(Manager *m, const char *unit_name, int status_expected, int code_expected) {
Unit *unit;
@@ -129,6 +147,11 @@ static void test_exec_privatedevices(Manager *m) {
log_notice("testing in container, skipping private device tests");
return;
}
+ if (!is_inaccessible_available()) {
+ log_notice("testing without inaccessible, skipping private device tests");
+ return;
+ }
+
test(m, "exec-privatedevices-yes.service", 0, CLD_EXITED);
test(m, "exec-privatedevices-no.service", 0, CLD_EXITED);
}
@@ -138,6 +161,11 @@ static void test_exec_privatedevices_capabilities(Manager *m) {
log_notice("testing in container, skipping private device tests");
return;
}
+ if (!is_inaccessible_available()) {
+ log_notice("testing without inaccessible, skipping private device tests");
+ return;
+ }
+
test(m, "exec-privatedevices-yes-capability-mknod.service", 0, CLD_EXITED);
test(m, "exec-privatedevices-no-capability-mknod.service", 0, CLD_EXITED);
test(m, "exec-privatedevices-yes-capability-sys-rawio.service", 0, CLD_EXITED);
@@ -149,6 +177,10 @@ static void test_exec_protectkernelmodules(Manager *m) {
log_notice("testing in container, skipping protectkernelmodules tests");
return;
}
+ if (!is_inaccessible_available()) {
+ log_notice("testing without inaccessible, skipping protectkernelmodules tests");
+ return;
+ }
test(m, "exec-protectkernelmodules-no-capabilities.service", 0, CLD_EXITED);
test(m, "exec-protectkernelmodules-yes-capabilities.service", 0, CLD_EXITED);