]> granicus.if.org Git - strace/commitdiff
tests: add prctl-pdeathsig.test and prctl-tsc.test
authorJingPiao Chen <chenjingpiao@foxmail.com>
Thu, 17 Nov 2016 13:15:51 +0000 (21:15 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 30 Nov 2016 23:40:30 +0000 (23:40 +0000)
* tests/prctl-pdeathsig.c: New file.
* tests/prctl-tsc.c: Likewise.
* tests/prctl-pdeathsig.test: New test.
* tests/prctl-tsc.test: Likewise.
* tests/.gitignore: Add prctl-pdeathsig and prctl-tsc.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add prctl-pdeathsig.test and prctl-tsc.test.

tests/.gitignore
tests/Makefile.am
tests/prctl-pdeathsig.c [new file with mode: 0644]
tests/prctl-pdeathsig.test [new file with mode: 0755]
tests/prctl-tsc.c [new file with mode: 0644]
tests/prctl-tsc.test [new file with mode: 0755]

index ce714a47c244f7ee2957c66b1d7c980ee4bf7564..0d7ec86403f49a7cbb342829c724b8f256d21d71 100644 (file)
@@ -210,8 +210,10 @@ pkey_mprotect
 poll
 ppoll
 prctl-name
+prctl-pdeathsig
 prctl-seccomp-filter-v
 prctl-seccomp-strict
+prctl-tsc
 pread64-pwrite64
 preadv
 preadv-pwritev
index ab43e2a65ac659be17ad41908aea40e2e161be24..0cc94e922e5fb72bf3b9a360c738d42d1ebb1715 100644 (file)
@@ -269,8 +269,10 @@ check_PROGRAMS = \
        poll \
        ppoll \
        prctl-name \
+       prctl-pdeathsig \
        prctl-seccomp-filter-v \
        prctl-seccomp-strict \
+       prctl-tsc \
        pread64-pwrite64 \
        preadv \
        preadv-pwritev \
@@ -648,8 +650,10 @@ DECODER_TESTS = \
        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-pdeathsig.c b/tests/prctl-pdeathsig.c
new file mode 100644 (file)
index 0000000..2052677
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao@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>
+#include <linux/prctl.h>
+
+#if defined __NR_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;
+
+       if ((rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, SIGINT)))
+               perror_msg_and_skip("prctl(PR_SET_PDEATHSIG)");
+       printf("prctl(PR_SET_PDEATHSIG, SIGINT) = %s\n", sprintrc(rc));
+
+       if ((rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, &pdeathsig)))
+               perror_msg_and_skip("prctl(PR_GET_PDEATHSIG)");
+       printf("prctl(PR_GET_PDEATHSIG, [SIGINT]) = %s\n", sprintrc(rc));
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_prctl && PR_GET_PDEATHSIG && PR_SET_PDEATHSIG")
+
+#endif
diff --git a/tests/prctl-pdeathsig.test b/tests/prctl-pdeathsig.test
new file mode 100755 (executable)
index 0000000..2e45aae
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check prctl PR_GET_PDEATHSIG PR_SET_PDEATHSIG decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a32 -e trace=prctl
diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c
new file mode 100644 (file)
index 0000000..230e5a8
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 JingPiao Chen <chenjingpiao@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>
+#include <linux/prctl.h>
+
+#if defined __NR_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);
+       if (rc)
+               printf("prctl(PR_GET_TSC, %p) = %s\n", &tsc, sprintrc(rc));
+       else
+               printf("prctl(PR_GET_TSC, [PR_TSC_SIGSEGV]) = %s\n",
+                      sprintrc(rc));
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_prctl && PR_GET_TSC && PR_SET_TSC")
+
+#endif
diff --git a/tests/prctl-tsc.test b/tests/prctl-tsc.test
new file mode 100755 (executable)
index 0000000..04ef1b2
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check prctl PR_GET_TSC PR_SET_TSC decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a34 -e trace=prctl