]> granicus.if.org Git - strace/commitdiff
tests: add link.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Wed, 11 May 2016 07:07:28 +0000 (15:07 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 11 May 2016 12:26:00 +0000 (12:26 +0000)
* tests/link.c: New file.
* tests/link.test: New test.
* tests/.gitignore: Add link.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add link.test.

tests/.gitignore
tests/Makefile.am
tests/link.c [new file with mode: 0644]
tests/link.test [new file with mode: 0755]

index fbcc8baf479446b18539982eea8d7bc71583b8d8..acf92c8b8f128b3b71639aacd9efe055ef366fd3 100644 (file)
@@ -103,6 +103,7 @@ ksysent.h
 lchown
 lchown32
 libtests.a
+link
 linkat
 llseek
 lseek
index 00cf8270920043610a748742a7398b50c91f8de1..34616d4e1255c6173bdbea020678cea4f5f284dc 100644 (file)
@@ -156,6 +156,7 @@ check_PROGRAMS = \
        ksysent \
        lchown \
        lchown32 \
+       link \
        linkat \
        llseek \
        lseek \
@@ -438,6 +439,7 @@ DECODER_TESTS = \
        kill.test \
        lchown.test \
        lchown32.test \
+       link.test \
        linkat.test \
        llseek.test \
        lseek.test \
diff --git a/tests/link.c b/tests/link.c
new file mode 100644 (file)
index 0000000..4b84e41
--- /dev/null
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_link
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       static const char sample_1[] = "link_sample_old";
+       static const char sample_2[] = "link_sample_new";
+
+       long rc = syscall(__NR_link, sample_1, sample_2);
+       printf("link(\"%s\", \"%s\") = %ld %s (%m)\n",
+              sample_1, sample_2, rc, errno2name());
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_link")
+
+#endif
diff --git a/tests/link.test b/tests/link.test
new file mode 100755 (executable)
index 0000000..cfa2b0c
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check link syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff