]> granicus.if.org Git - strace/commitdiff
tests: add readlink.test and readlinkat.test
authorGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Fri, 14 Aug 2015 15:49:27 +0000 (17:49 +0200)
committerGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Sat, 15 Aug 2015 00:21:22 +0000 (02:21 +0200)
* 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
tests/Makefile.am
tests/readlink.awk [new file with mode: 0644]
tests/readlink.c [new file with mode: 0644]
tests/readlink.test [new file with mode: 0755]
tests/readlinkat.awk [new file with mode: 0644]
tests/readlinkat.c [new file with mode: 0644]
tests/readlinkat.test [new file with mode: 0755]

index 6d8e3183f72f7c320ac3dc5f916b4fae81c390d3..d58e73552292858c84660e2d4cd987b1ddaa68c3 100644 (file)
@@ -24,6 +24,8 @@ oldselect
 pc
 pipe
 ppoll
+readlink
+readlinkat
 sched_xetattr
 scm_rights
 seccomp
index 45b34ab59fdbbb495dbafe8c5e779e01cb93b126..6b299d11403b89c4551d0c74f1e5a80d3a056b63 100644 (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 \
diff --git a/tests/readlink.awk b/tests/readlink.awk
new file mode 100644 (file)
index 0000000..7b74250
--- /dev/null
@@ -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 (file)
index 0000000..b31c891
--- /dev/null
@@ -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
+}
diff --git a/tests/readlink.test b/tests/readlink.test
new file mode 100755 (executable)
index 0000000..1578859
--- /dev/null
@@ -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 (file)
index 0000000..5611b43
--- /dev/null
@@ -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 (file)
index 0000000..a075d70
--- /dev/null
@@ -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
+}
diff --git a/tests/readlinkat.test b/tests/readlinkat.test
new file mode 100755 (executable)
index 0000000..9ae46a9
--- /dev/null
@@ -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