tests: add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test
JingPiao Chen
chenjingpiao at foxmail.com
Thu Nov 17 13:17:27 UTC 2016
From 8995d87f0c27d40d574f032bf483f6ae2b5f7375 Mon Sep 17 00:00:00 2001
From: JingPiao Chen <chenjingpiao at foxmail.com>
Date: Thu, 17 Nov 2016 21:15:51 +0800
Subject: [PATCH] tests: add prctl-name.test, prctl-pdeathsig.test and
prctl-tsc.test
* tests/prctl-name.c:New file.
* tests/prctl-name.test: Likewise.
* tests/prctl-pdeathsig.c:Likewise.
* tests/prctl-pdeathsig.test: Likewise.
* tests/prctl-tsc.c: Likewise.
* tests/prctl-tsc.test: Likewise
* tests/.gitignore: Add prctl-name, prctl-pdeathsig and prctl-tsc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test
---
tests/.gitignore | 3 +++
tests/Makefile.am | 6 +++++
tests/prctl-name.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
tests/prctl-name.test | 6 +++++
tests/prctl-pdeathsig.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
tests/prctl-pdeathsig.test | 6 +++++
tests/prctl-tsc.c | 60 +++++++++++++++++++++++++++++++++++++++++++
tests/prctl-tsc.test | 6 +++++
8 files changed, 211 insertions(+)
create mode 100644 tests/prctl-name.c
create mode 100755 tests/prctl-name.test
create mode 100644 tests/prctl-pdeathsig.c
create mode 100755 tests/prctl-pdeathsig.test
create mode 100644 tests/prctl-tsc.c
create mode 100755 tests/prctl-tsc.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 6fc3cd1..8497dfa 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -207,8 +207,11 @@ pkey_free
pkey_mprotect
poll
ppoll
+prctl-name
+prctl-pdeathsig
prctl-seccomp-filter-v
prctl-seccomp-strict
+prctl-tsc
pread64-pwrite64
preadv
preadv-pwritev
diff --git a/tests/Makefile.am b/tests/Makefile.am
index df5ddb2..744ed25 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -265,8 +265,11 @@ check_PROGRAMS = \
pkey_mprotect \
poll \
ppoll \
+ prctl-name \
+ prctl-pdeathsig \
prctl-seccomp-filter-v \
prctl-seccomp-strict \
+ prctl-tsc \
pread64-pwrite64 \
preadv \
preadv-pwritev \
@@ -637,8 +640,11 @@ DECODER_TESTS = \
pkey_mprotect.test \
poll.test \
ppoll.test \
+ prctl-name.test \
+ prctl-pdeathsig.test \
prctl-seccomp-filter-v.test \
prctl-seccomp-strict.test \
+ prctl-tsc.test \
pread64-pwrite64.test \
preadv-pwritev.test \
preadv2-pwritev2.test \
diff --git a/tests/prctl-name.c b/tests/prctl-name.c
new file mode 100644
index 0000000..a508969
--- /dev/null
+++ b/tests/prctl-name.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao at foxmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef HAVE_PRCTL
+# include <sys/prctl.h>
+#endif
+
+#if defined HAVE_PRCTL && defined PR_GET_NAME && defined PR_SET_NAME
+
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ char setname[16] = "test-set-name";
+ char getname[16];
+ long rc;
+
+ rc = syscall(__NR_prctl, PR_SET_NAME, setname);
+ printf("prctl(PR_SET_NAME, \"%s\\0\\0\\0\") = %s\n",
+ setname, sprintrc(rc));
+
+ rc = syscall(__NR_prctl, PR_GET_NAME, getname);
+ printf("prctl(PR_GET_NAME, \"%s\") = %s\n",
+ getname, sprintrc(rc));
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_NAME && PR_SET_NAME")
+
+#endif
diff --git a/tests/prctl-name.test b/tests/prctl-name.test
new file mode 100755
index 0000000..fae18b3
--- /dev/null
+++ b/tests/prctl-name.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check prctl PR_GET_NAME PR_SET_NAME decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a42 -e trace=prctl
diff --git a/tests/prctl-pdeathsig.c b/tests/prctl-pdeathsig.c
new file mode 100644
index 0000000..db2e7b3
--- /dev/null
+++ b/tests/prctl-pdeathsig.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao at foxmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef HAVE_PRCTL
+# include <sys/prctl.h>
+#endif
+
+#if defined HAVE_PRCTL && defined PR_GET_PDEATHSIG && defined PR_SET_PDEATHSIG
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/signal.h>
+
+int
+main(void)
+{
+ int pdeathsig;
+ long rc;
+
+ rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, SIGINT);
+ printf("prctl(PR_SET_PDEATHSIG, SIGINT) = %s\n", sprintrc(rc));
+
+ rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, &pdeathsig);
+ printf("prctl(PR_GET_PDEATHSIG, [SIGINT]) = %s\n", sprintrc(rc));
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_PDEATHSIG && PR_SET_PDEATHSIG")
+
+#endif
diff --git a/tests/prctl-pdeathsig.test b/tests/prctl-pdeathsig.test
new file mode 100755
index 0000000..5e0be13
--- /dev/null
+++ b/tests/prctl-pdeathsig.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check prctl PR_GET_PDEATHSIG PR_SET_PDEATHSIG decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a34 -e trace=prctl
diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c
new file mode 100644
index 0000000..ea8bf61
--- /dev/null
+++ b/tests/prctl-tsc.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao at foxmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <asm/unistd.h>
+
+#ifdef HAVE_PRCTL
+# include <sys/prctl.h>
+#endif
+
+#if defined HAVE_PRCTL && defined PR_GET_TSC && defined PR_SET_TSC
+
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ int tsc;
+ long rc;
+
+ rc = syscall(__NR_prctl, PR_SET_TSC, PR_TSC_SIGSEGV);
+ printf("prctl(PR_SET_TSC, PR_TSC_SIGSEGV) = %s\n", sprintrc(rc));
+
+ rc = syscall(__NR_prctl, PR_GET_TSC, &tsc);
+ printf("prctl(PR_GET_TSC, [PR_TSC_SIGSEGV]) = %s\n", sprintrc(rc));
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("HAVE_PRCTL && PR_GET_TSC && PR_SET_TSC")
+
+#endif
diff --git a/tests/prctl-tsc.test b/tests/prctl-tsc.test
new file mode 100755
index 0000000..c6fe65f
--- /dev/null
+++ b/tests/prctl-tsc.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check prctl PR_GET_TSC PR_SET_TSC decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a36 -e trace=prctl
--
2.7.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20161117/31817615/attachment.html>
More information about the Strace-devel
mailing list