about summary refs log tree commit diff homepage
path: root/test/Runtime
diff options
context:
space:
mode:
authorTomas Jasek <tomsik68@posteo.net>2020-10-26 18:27:54 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-10-30 14:53:29 +0000
commitbd317816647a870e64fecde5096cc3a0c2b50370 (patch)
treef2f5132fb1fe83098f146f23c6b69014ec84f470 /test/Runtime
parent535e37da22016855cfbe51189e81000eaf6c584d (diff)
downloadklee-bd317816647a870e64fecde5096cc3a0c2b50370.tar.gz
Add test for atexit order
Diffstat (limited to 'test/Runtime')
-rw-r--r--test/Runtime/klee-libc/atexit_order.c27
1 files changed, 27 insertions, 0 deletions
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 <assert.h>
+
+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;
+}