]> granicus.if.org Git - strace/commitdiff
tests: add linkat.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Wed, 6 Apr 2016 06:18:48 +0000 (14:18 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Apr 2016 06:18:48 +0000 (06:18 +0000)
* tests/linkat.c: New file.
* tests/linkat.test: New test.
* tests/.gitignore: Add linkat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add linkat.test.

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

index c856bffc31590bdf7b39df9448be3b775ab901af..85a3491608ce8be3e51112f06af292de17d866c8 100644 (file)
@@ -65,6 +65,7 @@ ipc_shm
 ksysent
 ksysent.h
 libtests.a
+linkat
 llseek
 lseek
 lstat
index 0ebdf71cb7f7157c1500eb2cfa56d447b49c61a6..e03b6197d8570a8b11a2dba957da5356fdd83b50 100644 (file)
@@ -114,6 +114,7 @@ check_PROGRAMS = \
        ipc_sem \
        ipc_shm \
        ksysent \
+       linkat \
        llseek \
        lseek \
        lstat \
@@ -306,6 +307,7 @@ DECODER_TESTS = \
        ipc_msgbuf.test \
        ipc_sem.test \
        ipc_shm.test \
+       linkat.test \
        llseek.test \
        lseek.test \
        lstat.test \
diff --git a/tests/linkat.c b/tests/linkat.c
new file mode 100644 (file)
index 0000000..6a1a52e
--- /dev/null
@@ -0,0 +1,31 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_linkat
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       static const char sample_1[] = "linkat_sample_old";
+       static const char sample_2[] = "linkat_sample_new";
+       const long fd_old = (long) 0xdeadbeefffffffff;
+       const long fd_new = (long) 0xdeadbeeffffffffe;
+
+       int rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0);
+       printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %d %s (%m)\n",
+              (int) fd_old, sample_1, (int) fd_new, sample_2, rc,
+              errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_linkat")
+
+#endif
diff --git a/tests/linkat.test b/tests/linkat.test
new file mode 100755 (executable)
index 0000000..5627de7
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check linkat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff