mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-25 06:03:40 +03:00
test: skip various tests if namespacing is not available
Apparently on Debian LXC/AppArmor doesn't allow namespacing to container payloads. Deal with it. Fixes: #9700
This commit is contained in:
parent
a4bc3c1d25
commit
5f00dc4df6
@ -28,7 +28,7 @@
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
|
||||
static bool can_unshare = true;
|
||||
static bool can_unshare;
|
||||
|
||||
typedef void (*test_function_t)(Manager *m);
|
||||
|
||||
@ -760,6 +760,8 @@ int main(int argc, char *argv[]) {
|
||||
(void) unsetenv("LOGNAME");
|
||||
(void) unsetenv("SHELL");
|
||||
|
||||
can_unshare = have_namespaces();
|
||||
|
||||
/* It is needed otherwise cgroup creation fails */
|
||||
if (getuid() != 0)
|
||||
return log_tests_skipped("not root");
|
||||
|
@ -111,6 +111,11 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
if (!have_namespaces()) {
|
||||
log_tests_skipped("Don't have namespace support");
|
||||
return EXIT_TEST_SKIP;
|
||||
}
|
||||
|
||||
assert_se(sd_id128_get_boot(&bid) >= 0);
|
||||
sd_id128_to_string(bid, boot_id);
|
||||
|
||||
|
@ -186,6 +186,11 @@ static void test_get_process_cmdline_harder(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!have_namespaces()) {
|
||||
log_notice("Testing without namespaces, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
#if HAVE_VALGRIND_VALGRIND_H
|
||||
/* valgrind patches open(/proc//cmdline)
|
||||
* so, test_get_process_cmdline_harder fails always
|
||||
|
@ -178,6 +178,11 @@ static void test_restrict_namespace(void) {
|
||||
unsigned long ul;
|
||||
pid_t pid;
|
||||
|
||||
if (!have_namespaces()) {
|
||||
log_notice("Testing without namespaces, skipping %s", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
log_info("/* %s */", __func__);
|
||||
|
||||
assert_se(namespace_flags_to_string(0, &s) == 0 && streq(s, ""));
|
||||
|
Loading…
x
Reference in New Issue
Block a user