]> granicus.if.org Git - strace/commitdiff
tests: additional checks for prctl-* tests
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 18 Nov 2016 17:51:44 +0000 (20:51 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 30 Nov 2016 23:46:20 +0000 (23:46 +0000)
* tests/prctl-pdeathsig.c (main): Additional checks.
* tests/prctl-tsc.c (main): Likewise.
* tests/prctl-pdeathsig.test: Update value of -a argument.
* tests/prctl-tsc.test: Likewise.

tests/prctl-pdeathsig.c
tests/prctl-pdeathsig.test
tests/prctl-tsc.c
tests/prctl-tsc.test

index 20526772f59a7bff063ab9bb6e07bd83c7cd93b0..eb6c59e4dfb652e200f4801a7d96cd0bcf2a66dd 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2016 JingPiao Chen <chenjingpiao@foxmail.com>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 # include <unistd.h>
 # include <sys/signal.h>
 
+# include "kernel_types.h"
+
 int
 main(void)
 {
-       int pdeathsig;
+       static const kernel_ulong_t bogus_signal =
+               (kernel_ulong_t) 0xbadc0deddeadfeedULL;
+
+       int *pdeathsig = tail_alloc(sizeof(*pdeathsig));
        long rc;
 
-       if ((rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, SIGINT)))
-               perror_msg_and_skip("prctl(PR_SET_PDEATHSIG)");
+       rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, bogus_signal);
+       printf("prctl(PR_SET_PDEATHSIG, %llu) = %s\n",
+              (unsigned long long) bogus_signal, sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, SIGINT);
        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));
+       rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, NULL);
+       printf("prctl(PR_GET_PDEATHSIG, NULL) = %s\n", sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, pdeathsig + 1);
+       printf("prctl(PR_GET_PDEATHSIG, %p) = %s\n",
+              pdeathsig + 1, sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_GET_PDEATHSIG, pdeathsig);
+       if (rc) {
+               printf("prctl(PR_GET_PDEATHSIG, %p) = %s\n",
+                      pdeathsig, sprintrc(rc));
+       } else {
+               printf("prctl(PR_GET_PDEATHSIG, [SIGINT]) = %s\n",
+                      sprintrc(rc));
+       }
 
        puts("+++ exited with 0 +++");
        return 0;
index 2e45aae61a4d86532ed5c9b1e1aa420d1d26857c..d8c793a45303a5e27d754b638b353b65a5d483f4 100755 (executable)
@@ -3,4 +3,4 @@
 # Check prctl PR_GET_PDEATHSIG PR_SET_PDEATHSIG decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a32 -e trace=prctl
+run_strace_match_diff -a30 -e trace=prctl
index 230e5a80905c196cbc351a2cfb32d0bed5e4c659..47771199b09af47fb27cce9078b349e7708de90d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2016 JingPiao Chen <chenjingpiao@foxmail.com>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 # include <stdio.h>
 # include <unistd.h>
 
+# include "kernel_types.h"
+
 int
 main(void)
 {
-       int tsc;
+       static const kernel_ulong_t bogus_tsc =
+               (kernel_ulong_t) 0xdeadc0defacebeefULL;
+
+       int *tsc = tail_alloc(sizeof(*tsc));
        long rc;
 
+       rc = syscall(__NR_prctl, PR_SET_TSC, 0);
+       printf("prctl(PR_SET_TSC, 0 /* PR_TSC_??? */) = %s\n", sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_SET_TSC, bogus_tsc);
+       printf("prctl(PR_SET_TSC, %#x /* PR_TSC_??? */) = %s\n",
+              (unsigned int) bogus_tsc, sprintrc(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);
+       rc = syscall(__NR_prctl, PR_GET_TSC, NULL);
+       printf("prctl(PR_GET_TSC, NULL) = %s\n", sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_GET_TSC, tsc + 1);
+       printf("prctl(PR_GET_TSC, %p) = %s\n", tsc + 1, sprintrc(rc));
+
+       rc = syscall(__NR_prctl, PR_GET_TSC, tsc);
        if (rc)
-               printf("prctl(PR_GET_TSC, %p) = %s\n", &tsc, sprintrc(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));
index 04ef1b23caf78d74e3d940e3952e6641a4b17c40..ea1a477848aa033aadb6934420d79ca1b3bd68b0 100755 (executable)
@@ -3,4 +3,4 @@
 # Check prctl PR_GET_TSC PR_SET_TSC decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a34 -e trace=prctl
+run_strace_match_diff -a24 -e trace=prctl