aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-07 20:39:09 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 20:39:09 -0800
commit51480ab006fe32fae1d717d70aea1147190845e5 (patch)
tree4d7e341e9b7ebc0308fd525bdc6e0a122e08dcdb /tests
parentd2f19271a1aaa96a938a3cef6d65f15e934555a0 (diff)
rewrite setjmp code to identify, uniquely, each setjmp and match it to a longjmp. add testcase for #747, works in unoptimized builds
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 5cdc9497..6832d41e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2130,6 +2130,57 @@ setjmp exception execution path, level: 0
Exiting setjmp function, level: 0
''')
+ def test_longjmp4(self):
+ src = r'''
+ #include <setjmp.h>
+ #include <stdio.h>
+
+ typedef struct {
+ jmp_buf* jmp;
+ } jmp_state;
+
+ void second_func(jmp_state* s);
+
+ void first_func(jmp_state* s) {
+ jmp_buf* prev_jmp = s->jmp;
+ jmp_buf c_jmp;
+ int once = 0;
+
+ if (setjmp(c_jmp) == 0) {
+ printf("Normal execution path of first function!\n");
+
+ s->jmp = &c_jmp;
+ second_func(s);
+ } else {
+ printf("Exception execution path of first function! %d\n", once);
+
+ if (!once) {
+ printf("Calling longjmp the second time!\n");
+ once = 1;
+ longjmp(*(s->jmp), 1);
+ }
+ }
+ }
+
+ void second_func(jmp_state* s) {
+ longjmp(*(s->jmp), 1);
+ }
+
+ int main(int argc, char *argv[]) {
+ jmp_state s;
+ s.jmp = NULL;
+
+ first_func(&s);
+
+ return 0;
+ }
+ '''
+ self.do_run(src, '''Normal execution path of first function!
+Exception execution path of first function! 0
+Calling longjmp the second time!
+Exception execution path of first function! 1
+''')
+
def test_exceptions(self):
if Settings.QUANTUM_SIZE == 1: return self.skip("we don't support libcxx in q1")