[PATCH 1/4] tests: add ioperm.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Apr 19 07:38:32 UTC 2016


* 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  |  1 +
 tests/Makefile.am |  2 ++
 tests/ioperm.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 tests/ioperm.test |  6 ++++++
 4 files changed, 50 insertions(+)
 create mode 100644 tests/ioperm.c
 create mode 100755 tests/ioperm.test

diff --git a/tests/.gitignore b/tests/.gitignore
index f3ee629..bf9cf57 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -64,6 +64,7 @@ getrusage
 getxxid
 inet-cmsg
 ioctl
+ioperm
 ip_mreq
 ipc_msg
 ipc_msgbuf
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e9cd625..2878dc2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -116,6 +116,7 @@ check_PROGRAMS = \
 	getxxid \
 	inet-cmsg \
 	ioctl \
+	ioperm \
 	ip_mreq \
 	ipc_msg \
 	ipc_msgbuf \
@@ -327,6 +328,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
index 0000000..a57372d
--- /dev/null
+++ b/tests/ioperm.c
@@ -0,0 +1,41 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_ioperm
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/io.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	const unsigned long port = (unsigned long) 0xdeafbeefffffffff;
+	int 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) = %d %s (%m)\n",
+	       port, (unsigned long) 1, 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
index 0000000..8c1c1cc
--- /dev/null
+++ b/tests/ioperm.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check ioperm syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a27
-- 
1.8.3.1







More information about the Strace-devel mailing list