tests: add linkat.test

* 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.
diff --git a/tests/.gitignore b/tests/.gitignore
index c856bff..85a3491 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -65,6 +65,7 @@
 ksysent
 ksysent.h
 libtests.a
+linkat
 llseek
 lseek
 lstat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ebdf71..e03b619 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,6 +114,7 @@
 	ipc_sem \
 	ipc_shm \
 	ksysent \
+	linkat \
 	llseek \
 	lseek \
 	lstat \
@@ -306,6 +307,7 @@
 	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
index 0000000..6a1a52e
--- /dev/null
+++ b/tests/linkat.c
@@ -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
index 0000000..5627de7
--- /dev/null
+++ b/tests/linkat.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check linkat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff