[PATCH 2/4] tests: add iopl.test

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


* tests/iopl.c: New file.
* tests/iopl.test: New test.
* tests/.gitignore: Add iopl.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add iopl.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/iopl.c      | 36 ++++++++++++++++++++++++++++++++++++
 tests/iopl.test   |  6 ++++++
 4 files changed, 45 insertions(+)
 create mode 100644 tests/iopl.c
 create mode 100755 tests/iopl.test

diff --git a/tests/.gitignore b/tests/.gitignore
index bf9cf57..31e39b4 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -65,6 +65,7 @@ getxxid
 inet-cmsg
 ioctl
 ioperm
+iopl
 ip_mreq
 ipc_msg
 ipc_msgbuf
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2878dc2..44bc44b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -117,6 +117,7 @@ check_PROGRAMS = \
 	inet-cmsg \
 	ioctl \
 	ioperm \
+	iopl \
 	ip_mreq \
 	ipc_msg \
 	ipc_msgbuf \
@@ -329,6 +330,7 @@ DECODER_TESTS = \
 	inet-cmsg.test \
 	ioctl.test \
 	ioperm.test \
+	iopl.test \
 	ip_mreq.test \
 	ipc_msg.test \
 	ipc_msgbuf.test \
diff --git a/tests/iopl.c b/tests/iopl.c
new file mode 100644
index 0000000..5fc658a
--- /dev/null
+++ b/tests/iopl.c
@@ -0,0 +1,36 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_iopl
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/io.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	int rc = syscall(__NR_iopl, 4);
+	const char *error_text;
+	switch (errno) {
+		case ENOSYS:
+			error_text = "ENOSYS";
+			break;
+		case EPERM:
+			error_text = "EPERM";
+			break;
+		default:
+			error_text = "EINVAL";
+	}
+	printf("iopl(4) = %d %s (%m)\n", rc, error_text);
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_iopl")
+
+#endif
diff --git a/tests/iopl.test b/tests/iopl.test
new file mode 100755
index 0000000..d0b5b11
--- /dev/null
+++ b/tests/iopl.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check iopl syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a8
-- 
1.8.3.1







More information about the Strace-devel mailing list