tests: add readlink.test and readlinkat.test

* tests/readlink.c: New file.
* tests/readlink.awk: Likewise.
* tests/readlinkat.c: Likewise.
* tests/readlinkat.awk: Likewise.
* tests/readlink.test: New test.
* tests/readlinkat.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add readlink and readlinkat.
(TESTS): Add readlink.test and readlinkat.test.
(EXTRA_DIST): Add readlink.awk and readlinkat.awk.
* tests/.gitignore: Add readlink and readlinkat.
This commit is contained in:
Gleb Fotengauer-Malinovskiy 2015-08-14 17:49:27 +02:00
parent 525eed33fa
commit 3af6aabe52
8 changed files with 95 additions and 0 deletions

2
tests/.gitignore vendored
View File

@ -24,6 +24,8 @@ oldselect
pc
pipe
ppoll
readlink
readlinkat
sched_xetattr
scm_rights
seccomp

View File

@ -35,6 +35,8 @@ check_PROGRAMS = \
pc \
pipe \
ppoll \
readlink \
readlinkat \
sched_xetattr \
scm_rights \
seccomp \
@ -87,6 +89,8 @@ TESTS = \
ipc_msg.test \
ipc_shm.test \
ipc_sem.test \
readlink.test \
readlinkat.test \
sched_xetattr.test \
scm_rights-fd.test \
seccomp.test \
@ -159,6 +163,8 @@ EXTRA_DIST = init.sh run.sh match.awk \
pipe.expected \
ppoll.expected \
ppoll-v.expected \
readlink.awk \
readlinkat.awk \
restart_syscall.expected \
restart_syscall_unknown.expected \
select.awk \

10
tests/readlink.awk Normal file
View File

@ -0,0 +1,10 @@
BEGIN {
pathname = "\\\\x72\\\\x65\\\\x61\\\\x64\\\\x6c\\\\x69\\\\x6e\\\\x6b\\\\x2e\\\\x6c\\\\x69\\\\x6e\\\\x6b"
buf = "\\\\x72\\\\x65\\\\x61"
r[1] = "^readlink\\(\"" pathname "\", \"" buf "\"\\.\\.\\., 31\\) += 10"
r[2] = "^\\+\\+\\+ exited with 0 \\+\\+\\+$"
lines = 2
fail = 0
}
@include "match.awk"

17
tests/readlink.c Normal file
View File

@ -0,0 +1,17 @@
#include <unistd.h>
#include <sys/syscall.h>
int
main(void)
{
#ifdef __NR_readlink
char buf[31];
if (syscall(__NR_readlink, "readlink.link", buf, sizeof(buf)) != 10)
return 77;
return 0;
#else
return 77;
#endif
}

16
tests/readlink.test Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# Check readlink syscall decoding.
. "${srcdir=.}/init.sh"
ln -sf readlink.c readlink.link ||
framework_skip_ 'failed to create a symlink'
run_prog
run_strace -e readlink -xx -s3 $args
match_awk
rm -f readlink.link
exit 0

10
tests/readlinkat.awk Normal file
View File

@ -0,0 +1,10 @@
BEGIN {
pathname = "\\\\x72\\\\x65\\\\x61\\\\x64\\\\x6c\\\\x69\\\\x6e\\\\x6b\\\\x61\\\\x74\\\\x2e\\\\x6c\\\\x69\\\\x6e\\\\x6b"
buf = "\\\\x72\\\\x65\\\\x61"
r[1] = "^readlinkat\\(AT_FDCWD, \"" pathname "\", \"" buf "\"\\.\\.\\., 31\\) += 12"
r[2] = "^\\+\\+\\+ exited with 0 \\+\\+\\+$"
lines = 2
fail = 0
}
@include "match.awk"

18
tests/readlinkat.c Normal file
View File

@ -0,0 +1,18 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/syscall.h>
int
main(void)
{
#ifdef __NR_readlinkat
char buf[31];
if (syscall(__NR_readlinkat, AT_FDCWD, "readlinkat.link", buf, sizeof(buf)) != 12)
return 77;
return 0;
#else
return 77;
#endif
}

16
tests/readlinkat.test Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# Check readlinkat syscall decoding.
. "${srcdir=.}/init.sh"
ln -sf readlinkat.c readlinkat.link ||
framework_skip_ 'failed to create a symlink'
run_prog
run_strace -e readlinkat -xx -s3 $args
match_awk
rm -f readlinkat.link
exit 0