From d8f95ba4bf13ef96af9e22265b29aad33d391f77 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 15 Jul 2019 17:11:27 +0000 Subject: [PATCH] tests: fix build and run on alpha with fresh kernel headers Fix tests on alpha with Linux kernel headers containing commits v5.1-rc1~160^2~3^2~12 and v5.1-rc1~160^2~3^2~1. * tests/getegid.c: Include "scno.h". (main): Use sprintrc. * tests/geteuid.c: Likewise. * tests/getppid.c: Likewise. * tests/getgid.c [__NR_getgid == __NR_getxgid]: Skip. * tests/getuid.c [__NR_getuid == __NR_getxuid]: Skip. * tests/getpid.c [__NR_getpid == __NR_getxpid]: Skip. * tests/umount2.c (__NR_umount2): Remove. (TEST_SYSCALL_NR): New macro. (main): Use it instead of __NR_umount2. * tests/ksysent.sed: Remove new __NR_get[gup]id aliases to traditional __NR_getx[gup]id names (on alpha). Prioritize __NR_umount over __NR_umount2, __NR_osf_shmat over __NR_shmat. * NEWS: Mention these fixes. --- NEWS | 3 +++ tests/getegid.c | 3 ++- tests/geteuid.c | 3 ++- tests/getgid.c | 2 +- tests/getpid.c | 2 +- tests/getppid.c | 3 ++- tests/getuid.c | 2 +- tests/ksysent.sed | 11 +++++++++++ tests/umount2.c | 5 +++-- 9 files changed, 26 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 7b40cf7d..27a012c7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ Noteworthy changes in release ?.? (????-??-??) ============================================== +* Bug fixes + * Fixed tests on alpha with Linux kernel headers 5.1+. + Noteworthy changes in release 5.2 (2019-07-12) ============================================== diff --git a/tests/getegid.c b/tests/getegid.c index 2e0754b7..89fc15c5 100644 --- a/tests/getegid.c +++ b/tests/getegid.c @@ -7,6 +7,7 @@ #include "tests.h" #include +#include "scno.h" #ifdef __NR_getegid @@ -16,7 +17,7 @@ int main(void) { - printf("getegid() = %ld\n", syscall(__NR_getegid)); + printf("getegid() = %s\n", sprintrc(syscall(__NR_getegid))); return 0; } diff --git a/tests/geteuid.c b/tests/geteuid.c index 430df1c6..ff0c2edb 100644 --- a/tests/geteuid.c +++ b/tests/geteuid.c @@ -7,6 +7,7 @@ #include "tests.h" #include +#include "scno.h" #ifdef __NR_geteuid @@ -16,7 +17,7 @@ int main(void) { - printf("geteuid() = %ld\n", syscall(__NR_geteuid)); + printf("geteuid() = %s\n", sprintrc(syscall(__NR_geteuid))); return 0; } diff --git a/tests/getgid.c b/tests/getgid.c index 1bd70502..c407ec1f 100644 --- a/tests/getgid.c +++ b/tests/getgid.c @@ -8,7 +8,7 @@ #include "tests.h" #include -#ifdef __NR_getgid +#if defined __NR_getgid && (!defined __NR_getxgid || __NR_getxgid != __NR_getgid) # include # include diff --git a/tests/getpid.c b/tests/getpid.c index 5e88e052..7af628c0 100644 --- a/tests/getpid.c +++ b/tests/getpid.c @@ -8,7 +8,7 @@ #include "tests.h" #include -#ifdef __NR_getpid +#if defined __NR_getpid && (!defined __NR_getxpid || __NR_getxpid != __NR_getpid) # include # include diff --git a/tests/getppid.c b/tests/getppid.c index 718d0691..974ff536 100644 --- a/tests/getppid.c +++ b/tests/getppid.c @@ -7,6 +7,7 @@ #include "tests.h" #include +#include "scno.h" #ifdef __NR_getppid @@ -16,7 +17,7 @@ int main(void) { - printf("getppid() = %ld\n", syscall(__NR_getppid)); + printf("getppid() = %s\n", sprintrc(syscall(__NR_getppid))); puts("+++ exited with 0 +++"); return 0; } diff --git a/tests/getuid.c b/tests/getuid.c index 56f6c902..3691ced0 100644 --- a/tests/getuid.c +++ b/tests/getuid.c @@ -8,7 +8,7 @@ #include "tests.h" #include -#ifdef __NR_getuid +#if defined __NR_getuid && (!defined __NR_getxuid || __NR_getxuid != __NR_getuid) # include # include diff --git a/tests/ksysent.sed b/tests/ksysent.sed index c35ba22f..88f0a52a 100644 --- a/tests/ksysent.sed +++ b/tests/ksysent.sed @@ -8,6 +8,9 @@ # should not have been exported at all /#define[[:space:]]+__NR_(sys_epoll_|arch_specific_syscall|arm_sync_file_range|syscalls|syscall_count|syscall_max|available|reserved|unused)/d +# remove new aliases to traditional names on alpha +/#define[[:space:]]+__NR_get[gup]id[[:space:]]+__NR_getx[gup]id$/d + # should not have been named this way s/__NR_(arm|xtensa)_fadvise64_64/__NR_fadvise64_64/ @@ -17,4 +20,12 @@ s/__NR_madvise1/__NR_madvise/ s/__NR_paccept/__NR_accept4/ # generate + +# prioritize __NR_umount over __NR_umount2 +s/#define[[:space:]]+__NR_(umount)2([[:space:]].*)?$/#if defined __NR_\12 \&\& (!defined __NR_\1 || __NR_\1 != __NR_\12)\n[__NR_\12 \& 0xffff] = "\12",\n#endif/p + +# prioritize __NR_osf_shmat over __NR_shmat +s/#define[[:space:]]+__NR_(shmat)([[:space:]].*)?$/#if defined __NR_\1 \&\& (!defined __NR_osf_\1 || __NR_osf_\1 != __NR_\1)\n[__NR_\1 \& 0xffff] = "\1",\n#endif/p + +# generic s/#define[[:space:]]+__NR_([a-z_][^[:space:]]+)([[:space:]].*)?$/#ifdef __NR_\1\n[__NR_\1 \& 0xffff] = "\1",\n#endif/p diff --git a/tests/umount2.c b/tests/umount2.c index d313d597..2d07e11e 100644 --- a/tests/umount2.c +++ b/tests/umount2.c @@ -13,9 +13,10 @@ #include #if defined __NR_umount2 && (!defined __NR_umount || __NR_umount2 != __NR_umount) +# define TEST_SYSCALL_NR __NR_umount2 # define TEST_SYSCALL_STR "umount2" #else -# define __NR_umount2 __NR_umount +# define TEST_SYSCALL_NR __NR_umount # define TEST_SYSCALL_STR "umount" #endif @@ -25,7 +26,7 @@ main(void) static const char sample[] = "umount2.sample"; if (mkdir(sample, 0700)) perror_msg_and_fail("mkdir: %s", sample); - (void) syscall(__NR_umount2, sample, 31); + (void) syscall(TEST_SYSCALL_NR, sample, 31); printf("%s(\"%s\", MNT_FORCE|MNT_DETACH|MNT_EXPIRE|UMOUNT_NOFOLLOW|0x10)" " = -1 EINVAL (%m)\n", TEST_SYSCALL_STR, sample); if (rmdir(sample)) -- 2.40.0