aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-23 11:16:11 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-23 11:16:11 -0700
commit27601a8a9f19446c84f1904e460375a29564b192 (patch)
tree65f3ed0bd8ef4f6a1f38e22f9d18db375b1bc66d
parent23ed21d54e73db3597b64b6b06ab09194717c1c4 (diff)
add test for repeated longjmp to a single setjmp
-rwxr-xr-xtests/runner.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index bd6fd838..76dde558 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2524,6 +2524,34 @@ Exception execution path of first function! 1
'''
self.do_run(src, 'second\nmain: 1\n')
+ def test_longjmp_repeat(self):
+ Settings.MAX_SETJMPS = 1
+
+ src = r'''
+ #include <stdio.h>
+ #include <setjmp.h>
+
+ static jmp_buf buf;
+
+ int main() {
+ volatile int x = 0;
+ printf("setjmp:%d\n", setjmp(buf));
+ x++;
+ printf("x:%d\n", x);
+ if (x < 4) longjmp(buf, x*2);
+ return 0;
+ }
+ '''
+ self.do_run(src, '''setjmp:0
+x:1
+setjmp:2
+x:2
+setjmp:4
+x:3
+setjmp:6
+x:4
+''')
+
def test_setjmp_many(self):
src = r'''
#include <stdio.h>