]> granicus.if.org Git - strace/commitdiff
tests: add ioperm.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Tue, 19 Apr 2016 07:38:32 +0000 (15:38 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 20 Apr 2016 01:08:13 +0000 (01:08 +0000)
* tests/ioperm.c: New file.
* tests/ioperm.test: New test.
* tests/.gitignore: Add ioperm.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add ioperm.test.

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

index af1de088ed92099d9dfae03b910b1a0bf7ee1718..c2bc5addfe546076120aab2f7c9247114ba7109b 100644 (file)
@@ -66,6 +66,7 @@ getrusage
 getxxid
 inet-cmsg
 ioctl
+ioperm
 ip_mreq
 ipc_msg
 ipc_msgbuf
index 6234711e559c6b44e88ac16e31d645014210f47b..047ac608fd6a1a45ba13750cf1dc94688c89a678 100644 (file)
@@ -118,6 +118,7 @@ check_PROGRAMS = \
        getxxid \
        inet-cmsg \
        ioctl \
+       ioperm \
        ip_mreq \
        ipc_msg \
        ipc_msgbuf \
@@ -351,6 +352,7 @@ DECODER_TESTS = \
        getxxid.test \
        inet-cmsg.test \
        ioctl.test \
+       ioperm.test \
        ip_mreq.test \
        ipc_msg.test \
        ipc_msgbuf.test \
diff --git a/tests/ioperm.c b/tests/ioperm.c
new file mode 100644 (file)
index 0000000..114c01e
--- /dev/null
@@ -0,0 +1,40 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_ioperm
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       const unsigned long port = (unsigned long) 0xdeafbeefffffffff;
+       long rc = syscall(__NR_ioperm, port, 1, 0);
+       const char *error_text;
+       switch (errno) {
+               case EIO:
+                       error_text = "EIO";
+                       break;
+               case ENOSYS:
+                       error_text = "ENOSYS";
+                       break;
+               case EPERM:
+                       error_text = "EPERM";
+                       break;
+               default:
+                       error_text = "EINVAL";
+       }
+       printf("ioperm(%#lx, %#lx, %d) = %ld %s (%m)\n",
+              port, 1UL, 0, rc, error_text);
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_ioperm")
+
+#endif
diff --git a/tests/ioperm.test b/tests/ioperm.test
new file mode 100755 (executable)
index 0000000..8c1c1cc
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check ioperm syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a27