diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2014-06-16 21:45:52 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2014-06-18 15:18:47 +0000 |
commit | b0764206921fcbbe3adb66606ed98962df414c1a (patch) | |
tree | f49c260040473d7e50aeb4c1db72141179a80a9b | |
parent | c588b205be19f84f757dec6f2e6ed2a157750f97 (diff) | |
download | android_external_strace-b0764206921fcbbe3adb66606ed98962df414c1a.tar.gz android_external_strace-b0764206921fcbbe3adb66606ed98962df414c1a.tar.bz2 android_external_strace-b0764206921fcbbe3adb66606ed98962df414c1a.zip |
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.
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/stack-fcall-0.c | 6 | ||||
-rw-r--r-- | tests/stack-fcall-1.c | 6 | ||||
-rw-r--r-- | tests/stack-fcall-2.c | 6 | ||||
-rw-r--r-- | tests/stack-fcall-3.c | 6 | ||||
-rw-r--r-- | tests/stack-fcall.c | 32 |
6 files changed, 28 insertions, 30 deletions
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 <unistd.h> + +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 <unistd.h> -#include <sys/types.h> - -/* 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; } |