From 2e069fcc0df056d69d10bde4003da62413899cce Mon Sep 17 00:00:00 2001 From: Fei Jie Date: Tue, 19 Apr 2016 15:38:32 +0800 Subject: [PATCH] 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. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/ioperm.c | 40 ++++++++++++++++++++++++++++++++++++++++ tests/ioperm.test | 6 ++++++ 4 files changed, 49 insertions(+) create mode 100644 tests/ioperm.c create mode 100755 tests/ioperm.test diff --git a/tests/.gitignore b/tests/.gitignore index af1de088..c2bc5add 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -66,6 +66,7 @@ getrusage getxxid inet-cmsg ioctl +ioperm ip_mreq ipc_msg ipc_msgbuf diff --git a/tests/Makefile.am b/tests/Makefile.am index 6234711e..047ac608 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..114c01e7 --- /dev/null +++ b/tests/ioperm.c @@ -0,0 +1,40 @@ +#include "tests.h" +#include + +#ifdef __NR_ioperm + +# include +# include +# include + +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 00000000..8c1c1cc7 --- /dev/null +++ b/tests/ioperm.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# Check ioperm syscall decoding. + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a27 -- 2.50.1