tests: add ioperm.test

* 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.
diff --git a/tests/.gitignore b/tests/.gitignore
index af1de08..c2bc5ad 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -66,6 +66,7 @@
 getxxid
 inet-cmsg
 ioctl
+ioperm
 ip_mreq
 ipc_msg
 ipc_msgbuf
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6234711..047ac60 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -118,6 +118,7 @@
 	getxxid \
 	inet-cmsg \
 	ioctl \
+	ioperm \
 	ip_mreq \
 	ipc_msg \
 	ipc_msgbuf \
@@ -351,6 +352,7 @@
 	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..114c01e
--- /dev/null
+++ b/tests/ioperm.c
@@ -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
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