]> granicus.if.org Git - strace/commitdiff
tests: add sethostname.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Thu, 31 Mar 2016 08:06:49 +0000 (16:06 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Apr 2016 23:34:33 +0000 (23:34 +0000)
* tests/sethostname.c: New file.
* tests/sethostname.test: New test.
* tests/.gitignore: Add sethostname.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add sethostname.test.

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

index 92ab696f9ab896e48efe587193826b97c4a6a5c6..b709f4999774efe00609f33b6599810162dfb895 100644 (file)
@@ -118,6 +118,7 @@ select
 sendfile
 sendfile64
 set_ptracer_any
+sethostname
 sigaction
 sigaltstack
 signalfd
index 29d787394ddf4b2a3afffc15dce2b6035172a2a6..98be3a49d5ac3fd5d5e31705a4ee6f931a1b7c14 100644 (file)
@@ -167,6 +167,7 @@ check_PROGRAMS = \
        sendfile \
        sendfile64 \
        set_ptracer_any \
+       sethostname \
        sigaction \
        sigaltstack \
        signalfd \
@@ -343,6 +344,7 @@ DECODER_TESTS = \
        select.test \
        sendfile.test \
        sendfile64.test \
+       sethostname.test \
        sigaction.test \
        sigaltstack.test \
        signalfd.test \
diff --git a/tests/sethostname.c b/tests/sethostname.c
new file mode 100644 (file)
index 0000000..8d98cb6
--- /dev/null
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_sethostname
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       const char *hostname = NULL;
+       int rc = syscall(__NR_sethostname, hostname, 63);
+       const char *errno_text;
+       switch (errno) {
+               case ENOSYS:
+                       errno_text = "ENOSYS";
+                       break;
+               case EPERM:
+                       errno_text = "EPERM";
+                       break;
+               default:
+                       errno_text = "EFAULT";
+       }
+       printf("sethostname(NULL, %d) = %d %s (%m)\n",
+              63, rc, errno_text);
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_sethostname")
+
+#endif
diff --git a/tests/sethostname.test b/tests/sethostname.test
new file mode 100755 (executable)
index 0000000..78f8c58
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check sethostname syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a22