From 3af6aabe52d73caa6861511da44f23931f4f038b Mon Sep 17 00:00:00 2001 From: Gleb Fotengauer-Malinovskiy Date: Fri, 14 Aug 2015 17:49:27 +0200 Subject: [PATCH] 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. --- tests/.gitignore | 2 ++ tests/Makefile.am | 6 ++++++ tests/readlink.awk | 10 ++++++++++ tests/readlink.c | 17 +++++++++++++++++ tests/readlink.test | 16 ++++++++++++++++ tests/readlinkat.awk | 10 ++++++++++ tests/readlinkat.c | 18 ++++++++++++++++++ tests/readlinkat.test | 16 ++++++++++++++++ 8 files changed, 95 insertions(+) create mode 100644 tests/readlink.awk create mode 100644 tests/readlink.c create mode 100755 tests/readlink.test create mode 100644 tests/readlinkat.awk create mode 100644 tests/readlinkat.c create mode 100755 tests/readlinkat.test diff --git a/tests/.gitignore b/tests/.gitignore index 6d8e3183..d58e7355 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -24,6 +24,8 @@ oldselect pc pipe ppoll +readlink +readlinkat sched_xetattr scm_rights seccomp diff --git a/tests/Makefile.am b/tests/Makefile.am index 45b34ab5..6b299d11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/readlink.awk b/tests/readlink.awk new file mode 100644 index 00000000..7b74250f --- /dev/null +++ b/tests/readlink.awk @@ -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" diff --git a/tests/readlink.c b/tests/readlink.c new file mode 100644 index 00000000..b31c8913 --- /dev/null +++ b/tests/readlink.c @@ -0,0 +1,17 @@ +#include +#include + +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 +} diff --git a/tests/readlink.test b/tests/readlink.test new file mode 100755 index 00000000..15788599 --- /dev/null +++ b/tests/readlink.test @@ -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 diff --git a/tests/readlinkat.awk b/tests/readlinkat.awk new file mode 100644 index 00000000..5611b430 --- /dev/null +++ b/tests/readlinkat.awk @@ -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" diff --git a/tests/readlinkat.c b/tests/readlinkat.c new file mode 100644 index 00000000..a075d703 --- /dev/null +++ b/tests/readlinkat.c @@ -0,0 +1,18 @@ +#include +#include +#include + +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 +} diff --git a/tests/readlinkat.test b/tests/readlinkat.test new file mode 100755 index 00000000..9ae46a98 --- /dev/null +++ b/tests/readlinkat.test @@ -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 -- 2.40.0