From: JingPiao Chen Date: Thu, 17 Nov 2016 13:15:51 +0000 (+0800) Subject: tests: add prctl-pdeathsig.test and prctl-tsc.test X-Git-Tag: v4.15~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d945e74377fe069de0fe1aa2823442cf8dbdbb52;p=strace tests: add prctl-pdeathsig.test and prctl-tsc.test * 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. --- diff --git a/tests/.gitignore b/tests/.gitignore index ce714a47..0d7ec864 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index ab43e2a6..0cc94e92 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..20526772 --- /dev/null +++ b/tests/prctl-pdeathsig.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016 JingPiao Chen + * 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 +#include + +#if defined __NR_prctl && defined PR_GET_PDEATHSIG && defined PR_SET_PDEATHSIG + +# include +# include +# include + +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 index 00000000..2e45aae6 --- /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 -a32 -e trace=prctl diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c new file mode 100644 index 00000000..230e5a80 --- /dev/null +++ b/tests/prctl-tsc.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 JingPiao Chen + * 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 +#include + +#if defined __NR_prctl && defined PR_GET_TSC && defined PR_SET_TSC + +# include +# include + +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 index 00000000..04ef1b23 --- /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 -a34 -e trace=prctl