From: Yu Watanabe Date: Tue, 15 Jun 2021 10:19:46 +0000 (+0900) Subject: test: fix syscall existence check X-Git-Tag: v249-rc1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=742240562308880cf4c3bbbc47ca428a3e0a5478;p=thirdparty%2Fsystemd.git test: fix syscall existence check Follow-up for 0643eb47a0418dc90d33853089dc9bc6ad63b0ca. This also drops errnously introduced hashmap_put() in the commit. --- diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c index 6c19c891475..023c4b6e0e5 100644 --- a/src/test/test-seccomp.c +++ b/src/test/test-seccomp.c @@ -805,10 +805,18 @@ static void test_load_syscall_filter_set_raw(void) { assert_se(s = hashmap_new(NULL)); #if defined __NR_access && __NR_access >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(-1)) >= 0); -#else + log_debug("has access()"); +#endif +#if defined __NR_faccessat && __NR_faccessat >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(-1)) >= 0); + log_debug("has faccessat()"); +#endif +#if defined __NR_faccessat2 && __NR_faccessat2 >= 0 + assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat2 + 1), INT_TO_PTR(-1)) >= 0); + log_debug("has faccessat2()"); #endif + assert_se(!hashmap_isempty(s)); assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUCLEAN), true) >= 0); assert_se(access("/", F_OK) < 0); @@ -816,14 +824,16 @@ static void test_load_syscall_filter_set_raw(void) { assert_se(poll(NULL, 0, 0) == 0); - s = hashmap_free(s); - - assert_se(s = hashmap_new(NULL)); + hashmap_clear(s); #if defined __NR_access && __NR_access >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(EILSEQ)) >= 0); -#else +#endif +#if defined __NR_faccessat && __NR_faccessat >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(EILSEQ)) >= 0); #endif +#if defined __NR_faccessat2 && __NR_faccessat2 >= 0 + assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat2 + 1), INT_TO_PTR(EILSEQ)) >= 0); +#endif assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUCLEAN), true) >= 0); @@ -832,15 +842,21 @@ static void test_load_syscall_filter_set_raw(void) { assert_se(poll(NULL, 0, 0) == 0); - s = hashmap_free(s); - - assert_se(s = hashmap_new(NULL)); + hashmap_clear(s); #if defined __NR_poll && __NR_poll >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(-1)) >= 0); -#elif defined __NR_ppoll + log_debug("has poll()"); +#endif +#if defined __NR_ppoll && __NR_ppoll >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(-1)) >= 0); + log_debug("has ppoll()"); +#endif +#if defined __NR_ppoll_time64 && __NR_ppoll_time64 >= 0 + assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll_time64 + 1), INT_TO_PTR(-1)) >= 0); + log_debug("has ppoll_time64()"); #endif + assert_se(!hashmap_isempty(s)); assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUNATCH), true) >= 0); assert_se(access("/", F_OK) < 0); @@ -849,15 +865,16 @@ static void test_load_syscall_filter_set_raw(void) { assert_se(poll(NULL, 0, 0) < 0); assert_se(errno == EUNATCH); - s = hashmap_free(s); - - assert_se(s = hashmap_new(NULL)); + hashmap_clear(s); #if defined __NR_poll && __NR_poll >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(EILSEQ)) >= 0); -#elif defined __NR_ppoll - assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(-1)) >= 0); +#endif +#if defined __NR_ppoll && __NR_ppoll >= 0 assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(EILSEQ)) >= 0); #endif +#if defined __NR_ppoll_time64 && __NR_ppoll_time64 >= 0 + assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll_time64 + 1), INT_TO_PTR(EILSEQ)) >= 0); +#endif assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUNATCH), true) >= 0);