From 7a158a18f85d9b45561b7abb40b77002b8df1220 Mon Sep 17 00:00:00 2001 From: Fei Jie Date: Wed, 6 Apr 2016 14:18:48 +0800 Subject: [PATCH] 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. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/linkat.c | 31 +++++++++++++++++++++++++++++++ tests/linkat.test | 6 ++++++ 4 files changed, 40 insertions(+) create mode 100644 tests/linkat.c create mode 100755 tests/linkat.test diff --git a/tests/.gitignore b/tests/.gitignore index c856bffc..85a34916 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -65,6 +65,7 @@ ipc_shm ksysent ksysent.h libtests.a +linkat llseek lseek lstat diff --git a/tests/Makefile.am b/tests/Makefile.am index 0ebdf71c..e03b6197 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..6a1a52e6 --- /dev/null +++ b/tests/linkat.c @@ -0,0 +1,31 @@ +#include "tests.h" +#include + +#ifdef __NR_linkat + +# include +# include +# include + +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 00000000..5627de7f --- /dev/null +++ b/tests/linkat.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check linkat syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -- 2.40.0