diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 11:09:29 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:53 +0200 |
commit | bbd1757a00344ca8a309d88ea550502078236cc3 (patch) | |
tree | 98e4d27c2518581b05c129a5c18f7213c1269aeb /tests/core/test_longjmp2.in | |
parent | 313a23e64c357260c660166f67d32d64601f164a (diff) |
Use do_run_from_file() for test_longjmp2
Diffstat (limited to 'tests/core/test_longjmp2.in')
-rw-r--r-- | tests/core/test_longjmp2.in | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/core/test_longjmp2.in b/tests/core/test_longjmp2.in new file mode 100644 index 00000000..ef73c8ba --- /dev/null +++ b/tests/core/test_longjmp2.in @@ -0,0 +1,37 @@ + + #include <setjmp.h> + #include <stdio.h> + + typedef struct { + jmp_buf* jmp; + } jmp_state; + + void stack_manipulate_func(jmp_state* s, int level) { + jmp_buf buf; + + printf("Entering stack_manipulate_func, level: %d\n", level); + + if (level == 0) { + s->jmp = &buf; + if (setjmp(*(s->jmp)) == 0) { + printf("Setjmp normal execution path, level: %d\n", level); + stack_manipulate_func(s, level + 1); + } else { + printf("Setjmp error execution path, level: %d\n", level); + } + } else { + printf("Perform longjmp at level %d\n", level); + longjmp(*(s->jmp), 1); + } + + printf("Exiting stack_manipulate_func, level: %d\n", level); + } + + int main(int argc, char *argv[]) { + jmp_state s; + s.jmp = NULL; + stack_manipulate_func(&s, 0); + + return 0; + } +
\ No newline at end of file |