From: Dmitry V. Levin Date: Mon, 16 Jun 2014 21:45:52 +0000 (+0000) Subject: tests: robustify -k test X-Git-Tag: v4.9~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0764206921fcbbe3adb66606ed98962df414c1a;p=strace tests: robustify -k test Split stack-fcall.c into several compilation units so that intermediate function calls would not be optimized out by compiler. * tests/stack-fcall.c: Move intermediate functions to ... * tests/stack-fcall-*.c: ... new files. * tests/Makefile.am (stack_fcall_SOURCES): Add stack-fcall-*.c. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index efe646db..922452ab 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,8 @@ check_PROGRAMS = \ uio uio_CFLAGS = $(AM_CFLAGS) -D_FILE_OFFSET_BITS=64 +stack_fcall_SOURCES = stack-fcall.c \ + stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c TESTS = \ ptrace_setoptions.test \ diff --git a/tests/stack-fcall-0.c b/tests/stack-fcall-0.c new file mode 100644 index 00000000..12a260de --- /dev/null +++ b/tests/stack-fcall-0.c @@ -0,0 +1,6 @@ +int f1(int i); + +int f0(int i) +{ + return f1(i) - i; +} diff --git a/tests/stack-fcall-1.c b/tests/stack-fcall-1.c new file mode 100644 index 00000000..8716702d --- /dev/null +++ b/tests/stack-fcall-1.c @@ -0,0 +1,6 @@ +int f2(int i); + +int f1(int i) +{ + return f2(i) + i; +} diff --git a/tests/stack-fcall-2.c b/tests/stack-fcall-2.c new file mode 100644 index 00000000..19f8cf83 --- /dev/null +++ b/tests/stack-fcall-2.c @@ -0,0 +1,6 @@ +int f3(int i); + +int f2(int i) +{ + return f3(i) - i; +} diff --git a/tests/stack-fcall-3.c b/tests/stack-fcall-3.c new file mode 100644 index 00000000..3af1667f --- /dev/null +++ b/tests/stack-fcall-3.c @@ -0,0 +1,6 @@ +#include + +int f3(int i) +{ + return getpid() + i; +} diff --git a/tests/stack-fcall.c b/tests/stack-fcall.c index 7329bdc6..134d54f6 100644 --- a/tests/stack-fcall.c +++ b/tests/stack-fcall.c @@ -1,35 +1,7 @@ -#include -#include - -/* Use "volatile" to avoid compiler optimization. */ - -int f3(int i) -{ - static pid_t (* volatile g)(void) = getpid; - return g() + i; -} - -int f2(volatile int i) -{ - static int (* volatile g)(int) = f3; - return g(i) - i; -} - -int f1(volatile int i) -{ - static int (* volatile g)(int) = f2; - return g(i) + i; -} - -int f0(volatile int i) -{ - static int (* volatile g)(int) = f1; - return g(i) - i; -} +int f0(int i); int main(int argc, char** argv) { - static int (* volatile g)(int) = f0; - g(argc); + f0(argc); return 0; }