Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Try to fool $CC harder in ATF ptrace(2) t...



details:   https://anonhg.NetBSD.org/src/rev/15de53c750c0
branches:  trunk
changeset: 832763:15de53c750c0
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sun May 27 17:16:39 2018 +0000

description:
Try to fool $CC harder in ATF ptrace(2) tests in trigger_fpe()

A function that returns a value that is not used, can be optimized out by
a compiler. Try to fool the compiler with calling libc functions that shall
trigger a division by zero crash.

Sponsored by <The NetBSD Foundation>

diffstat:

 tests/lib/libc/sys/t_ptrace_wait.h |  13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diffs (31 lines):

diff -r 1bb087d3d909 -r 15de53c750c0 tests/lib/libc/sys/t_ptrace_wait.h
--- a/tests/lib/libc/sys/t_ptrace_wait.h        Sun May 27 17:14:23 2018 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.h        Sun May 27 17:16:39 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.h,v 1.8 2018/05/26 15:15:17 kamil Exp $  */
+/*     $NetBSD: t_ptrace_wait.h,v 1.9 2018/05/27 17:16:39 kamil Exp $  */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -554,17 +554,14 @@
 #endif
 }
 
-static int __used
+static void __used
 trigger_fpe(void)
 {
-       static volatile int a = 1;
-       static volatile int b = 0;
-       static volatile int c;
+       volatile int a = getpid();
+       volatile int b = atoi("0");
 
        /* Division by zero causes CPU trap, translated to SIGFPE */
-       c = a / b;
-
-       return c;
+       usleep(a / b);
 }
 
 static void __used



Home | Main Index | Thread Index | Old Index