mirror of
https://github.com/systemd/systemd.git
synced 2025-03-14 04:58:28 +03:00
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
This commit is contained in:
parent
f70ebf1ce3
commit
6086d2daf3
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user