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.
This commit is contained in:
Дмитрий Левин 2015-07-16 09:09:11 +00:00
parent 14278620c9
commit 8ef543929a
3 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,6 @@
BEGIN { BEGIN {
r_uint = "(0|[1-9][0-9]*)" r_uint = "(0|[1-9][0-9]*)"
regexp = "^getuid" suffix "\\(\\)[[:space:]]+= " r_uint "$" regexp = "^getx?uid" suffix "\\(\\)[[:space:]]+= " r_uint "$"
expected = "getuid" expected = "getuid"
fail = 0 fail = 0
} }

View File

@ -9,7 +9,7 @@
int int
main(void) main(void)
{ {
#if defined(__NR_getuid) \ #if (defined __NR_getuid || defined __NR_getxuid) \
&& defined(__NR_setuid) \ && defined(__NR_setuid) \
&& defined(__NR_getresuid) \ && defined(__NR_getresuid) \
&& defined(__NR_setreuid) \ && defined(__NR_setreuid) \
@ -20,6 +20,9 @@ main(void)
int size; int size;
int *list = 0; int *list = 0;
#ifndef __NR_getuid
# define __NR_getuid __NR_getxuid
#endif
uid = syscall(__NR_getuid); uid = syscall(__NR_getuid);
assert(syscall(__NR_setuid, uid) == 0); assert(syscall(__NR_setuid, uid) == 0);
{ {

View File

@ -9,7 +9,17 @@ w="${uid_t_size-}"
run_prog ./uid$s$w 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 run_strace -e trace="$syscalls" $args
AWK=gawk AWK=gawk