From bd317816647a870e64fecde5096cc3a0c2b50370 Mon Sep 17 00:00:00 2001 From: Tomas Jasek Date: Mon, 26 Oct 2020 18:27:54 +0100 Subject: Add test for atexit order --- test/Runtime/klee-libc/atexit_order.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Runtime/klee-libc/atexit_order.c (limited to 'test/Runtime') diff --git a/test/Runtime/klee-libc/atexit_order.c b/test/Runtime/klee-libc/atexit_order.c new file mode 100644 index 00000000..f8ebb160 --- /dev/null +++ b/test/Runtime/klee-libc/atexit_order.c @@ -0,0 +1,27 @@ +// RUN: %clang %s -emit-llvm %O0opt -c -o %t1.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --exit-on-error --libc=klee %t1.bc + +// make sure the functions passed to atexit are called in reverse order + +#include + +extern void atexit(void (*)()); + +static int counter = 0; + +void first() { + assert(counter == 0); + ++counter; +} + +void second() { + assert(counter == 1); + ++counter; +} + +int main() { + atexit(second); + atexit(first); + return 0; +} -- cgit 1.4.1