summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-11-26 09:31:10 +0900
committerGitHub <noreply@github.com>2020-11-26 09:31:10 +0900
commit35ad7113dba4cf27d9f557e1ff309fb5891e060b (patch)
tree5d7966fa82b3160acdb7f357283dac036f34faf2 /src
parent7a1fe27f81dace11a25a0573dc170d86d1f92023 (diff)
parenta0dfd10a3d8091007c94cef2d341a84d46095787 (diff)
downloadsystemd-35ad7113dba4cf27d9f557e1ff309fb5891e060b.tar.gz
Merge pull request #17709 from yuwata/test-seccomp-skip
test: skip several tests in test-seccomp when running under valgrind or ASAN
Diffstat (limited to 'src')
-rw-r--r--src/test/test-seccomp.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
index 853b0ef3b9..2b5e4cf23a 100644
--- a/src/test/test-seccomp.c
+++ b/src/test/test-seccomp.c
@@ -10,6 +10,9 @@
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
+#if HAVE_VALGRIND_VALGRIND_H
+#include <valgrind/valgrind.h>
+#endif
#include "alloc-util.h"
#include "fd-util.h"
@@ -115,6 +118,21 @@ static void test_filter_sets(void) {
for (unsigned i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
pid_t pid;
+#if HAVE_VALGRIND_VALGRIND_H
+ if (RUNNING_ON_VALGRIND && IN_SET(i, SYSCALL_FILTER_SET_DEFAULT, SYSCALL_FILTER_SET_BASIC_IO, SYSCALL_FILTER_SET_SIGNAL)) {
+ /* valgrind at least requires rt_sigprocmask(), read(), write(). */
+ log_info("Running on valgrind, skipping %s", syscall_filter_sets[i].name);
+ continue;
+ }
+#endif
+#if HAS_FEATURE_ADDRESS_SANITIZER
+ if (IN_SET(i, SYSCALL_FILTER_SET_DEFAULT, SYSCALL_FILTER_SET_BASIC_IO, SYSCALL_FILTER_SET_SIGNAL)) {
+ /* ASAN at least requires sigaltstack(), read(), write(). */
+ log_info("Running on address sanitizer, skipping %s", syscall_filter_sets[i].name);
+ continue;
+ }
+#endif
+
log_info("Testing %s", syscall_filter_sets[i].name);
pid = fork();
@@ -323,6 +341,13 @@ static void test_protect_sysctl(void) {
assert_se(seccomp_protect_sysctl() >= 0);
+#if HAVE_VALGRIND_VALGRIND_H
+ if (RUNNING_ON_VALGRIND) {
+ log_info("Running on valgrind, skipping syscall/EPERM test");
+ _exit(EXIT_SUCCESS);
+ }
+#endif
+
#if defined __NR__sysctl && __NR__sysctl >= 0
assert_se(syscall(__NR__sysctl, 0, 0, 0) < 0);
assert_se(errno == EPERM);
@@ -525,6 +550,16 @@ static void test_memory_deny_write_execute_mmap(void) {
log_notice("Not root, skipping %s", __func__);
return;
}
+#if HAVE_VALGRIND_VALGRIND_H
+ if (RUNNING_ON_VALGRIND) {
+ log_notice("Running on valgrind, skipping %s", __func__);
+ return;
+ }
+#endif
+#if HAS_FEATURE_ADDRESS_SANITIZER
+ log_notice("Running on address sanitizer, skipping %s", __func__);
+ return;
+#endif
pid = fork();
assert_se(pid >= 0);
@@ -585,6 +620,16 @@ static void test_memory_deny_write_execute_shmat(void) {
log_notice("Not root, skipping %s", __func__);
return;
}
+#if HAVE_VALGRIND_VALGRIND_H
+ if (RUNNING_ON_VALGRIND) {
+ log_notice("Running on valgrind, skipping %s", __func__);
+ return;
+ }
+#endif
+#if HAS_FEATURE_ADDRESS_SANITIZER
+ log_notice("Running on address sanitizer, skipping %s", __func__);
+ return;
+#endif
shmid = shmget(IPC_PRIVATE, page_size(), 0);
assert_se(shmid >= 0);