From: Zbigniew Jędrzejewski-Szmek Date: Wed, 1 Jun 2022 22:38:14 +0000 (+0200) Subject: tests: drop pointless checks for root X-Git-Tag: v252-rc1~878^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1fdcda8765b0f3c059e90b152c13c9797bc9814;p=thirdparty%2Fsystemd.git tests: drop pointless checks for root Testing the error paths is very important. If we are not root, we should try and get a failure, which we should report nicely and mark the test as skipped. After those checks are removed, this is what seems to happen. This way we can see what will happen e.g. in the user manager when we try to perform some bpf ops. --- diff --git a/src/test/test-bpf-firewall.c b/src/test/test-bpf-firewall.c index 8f4b4850734..3b99c5aaecb 100644 --- a/src/test/test-bpf-firewall.c +++ b/src/test/test-bpf-firewall.c @@ -61,9 +61,6 @@ int main(int argc, char *argv[]) { r = bpf_program_add_instructions(p, exit_insn, ELEMENTSOF(exit_insn)); assert_se(r == 0); - if (getuid() != 0) - return log_tests_skipped("not running as root"); - r = bpf_firewall_supported(); if (r == BPF_FIREWALL_UNSUPPORTED) return log_tests_skipped("BPF firewalling not supported"); diff --git a/src/test/test-bpf-lsm.c b/src/test/test-bpf-lsm.c index 630d60dbf53..9709053d0af 100644 --- a/src/test/test-bpf-lsm.c +++ b/src/test/test-bpf-lsm.c @@ -68,9 +68,6 @@ int main(int argc, char *argv[]) { test_setup_logging(LOG_DEBUG); - if (getuid() != 0) - return log_tests_skipped("not running as root"); - assert_se(getrlimit(RLIMIT_MEMLOCK, &rl) >= 0); rl.rlim_cur = rl.rlim_max = MAX(rl.rlim_max, CAN_MEMLOCK_SIZE); (void) setrlimit_closest(RLIMIT_MEMLOCK, &rl); diff --git a/src/test/test-socket-bind.c b/src/test/test-socket-bind.c index 59d8cc965b0..fd1fc7a26b6 100644 --- a/src/test/test-socket-bind.c +++ b/src/test/test-socket-bind.c @@ -110,9 +110,6 @@ int main(int argc, char *argv[]) { if (detect_container() > 0) return log_tests_skipped("test-bpf fails inside LXC and Docker containers: https://github.com/systemd/systemd/issues/9666"); - if (getuid() != 0) - return log_tests_skipped("not running as root"); - assert_se(getrlimit(RLIMIT_MEMLOCK, &rl) >= 0); rl.rlim_cur = rl.rlim_max = MAX(rl.rlim_max, CAN_MEMLOCK_SIZE); (void) setrlimit_closest(RLIMIT_MEMLOCK, &rl);