From 8ef543929a561318de1d249562a7013208b7fd7d Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 16 Jul 2015 09:09:11 +0000 Subject: [PATCH] tests/uid.test: adopt for alpha Make the test work on alpha that has getxuid syscall instead of getuid. * tests/uid.awk (BEGIN): Update getuid regexp to match both getuid and getxuid syscalls. * tests/uid.c (main): Allow __NR_getxuid as an alternative to __NR_getuid. * tests/uid.test: If getuid syscall is not available, probe for getxuid syscall. --- tests/uid.awk | 2 +- tests/uid.c | 5 ++++- tests/uid.test | 12 +++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/uid.awk b/tests/uid.awk index 6f07b44f..b79aa79f 100644 --- a/tests/uid.awk +++ b/tests/uid.awk @@ -1,6 +1,6 @@ BEGIN { r_uint = "(0|[1-9][0-9]*)" - regexp = "^getuid" suffix "\\(\\)[[:space:]]+= " r_uint "$" + regexp = "^getx?uid" suffix "\\(\\)[[:space:]]+= " r_uint "$" expected = "getuid" fail = 0 } diff --git a/tests/uid.c b/tests/uid.c index 28f548bd..f316d805 100644 --- a/tests/uid.c +++ b/tests/uid.c @@ -9,7 +9,7 @@ int main(void) { -#if defined(__NR_getuid) \ +#if (defined __NR_getuid || defined __NR_getxuid) \ && defined(__NR_setuid) \ && defined(__NR_getresuid) \ && defined(__NR_setreuid) \ @@ -20,6 +20,9 @@ main(void) int size; int *list = 0; +#ifndef __NR_getuid +# define __NR_getuid __NR_getxuid +#endif uid = syscall(__NR_getuid); assert(syscall(__NR_setuid, uid) == 0); { diff --git a/tests/uid.test b/tests/uid.test index 7bbcca7b..e214272d 100755 --- a/tests/uid.test +++ b/tests/uid.test @@ -9,7 +9,17 @@ w="${uid_t_size-}" run_prog ./uid$s$w -syscalls="getuid$s,setuid$s,getresuid$s,setreuid$s,setresuid$s,fchown$s,getgroups$s" +syscalls= +for n in "getuid$s" "getxuid$s"; do + if $STRACE -e "$n" -h > /dev/null; then + syscalls="$n" + break + fi +done +test -n "$syscalls" || + fail_ "neither getuid$s nor getxuid$s is supported on this architecture" + +syscalls="$syscalls,setuid$s,getresuid$s,setreuid$s,setresuid$s,fchown$s,getgroups$s" run_strace -e trace="$syscalls" $args AWK=gawk