diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 11:11:39 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:53 +0200 |
commit | d6df214bd4359c10e44c09ded0c3a1f6004303fc (patch) | |
tree | c41bac62102072fb3ad0b4678c835584991f900c /tests | |
parent | bbd1757a00344ca8a309d88ea550502078236cc3 (diff) |
Use do_run_from_file() for test_longjmp3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_longjmp3.in | 42 | ||||
-rw-r--r-- | tests/core/test_longjmp3.out | 7 | ||||
-rw-r--r-- | tests/test_core.py | 52 |
3 files changed, 52 insertions, 49 deletions
diff --git a/tests/core/test_longjmp3.in b/tests/core/test_longjmp3.in new file mode 100644 index 00000000..95fcf36c --- /dev/null +++ b/tests/core/test_longjmp3.in @@ -0,0 +1,42 @@ + + #include <setjmp.h> + #include <stdio.h> + + typedef struct { + jmp_buf* jmp; + } jmp_state; + + void setjmp_func(jmp_state* s, int level) { + jmp_buf* prev_jmp = s->jmp; + jmp_buf c_jmp; + + if (level == 2) { + printf("level is 2, perform longjmp!\n"); + longjmp(*(s->jmp), 1); + } + + if (setjmp(c_jmp) == 0) { + printf("setjmp normal execution path, level: %d\n", level); + s->jmp = &c_jmp; + setjmp_func(s, level + 1); + } else { + printf("setjmp exception execution path, level: %d\n", level); + if (prev_jmp) { + printf("prev_jmp is not empty, continue with longjmp!\n"); + s->jmp = prev_jmp; + longjmp(*(s->jmp), 1); + } + } + + printf("Exiting setjmp function, level: %d\n", level); + } + + int main(int argc, char *argv[]) { + jmp_state s; + s.jmp = NULL; + + setjmp_func(&s, 0); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_longjmp3.out b/tests/core/test_longjmp3.out new file mode 100644 index 00000000..c0d39cfb --- /dev/null +++ b/tests/core/test_longjmp3.out @@ -0,0 +1,7 @@ +setjmp normal execution path, level: 0 +setjmp normal execution path, level: 1 +level is 2, perform longjmp! +setjmp exception execution path, level: 1 +prev_jmp is not empty, continue with longjmp! +setjmp exception execution path, level: 0 +Exiting setjmp function, level: 0 diff --git a/tests/test_core.py b/tests/test_core.py index 0d5e3c36..a31ef832 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1098,56 +1098,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) def test_longjmp3(self): - src = r''' - #include <setjmp.h> - #include <stdio.h> - - typedef struct { - jmp_buf* jmp; - } jmp_state; - - void setjmp_func(jmp_state* s, int level) { - jmp_buf* prev_jmp = s->jmp; - jmp_buf c_jmp; - - if (level == 2) { - printf("level is 2, perform longjmp!\n"); - longjmp(*(s->jmp), 1); - } - - if (setjmp(c_jmp) == 0) { - printf("setjmp normal execution path, level: %d\n", level); - s->jmp = &c_jmp; - setjmp_func(s, level + 1); - } else { - printf("setjmp exception execution path, level: %d\n", level); - if (prev_jmp) { - printf("prev_jmp is not empty, continue with longjmp!\n"); - s->jmp = prev_jmp; - longjmp(*(s->jmp), 1); - } - } - - printf("Exiting setjmp function, level: %d\n", level); - } - - int main(int argc, char *argv[]) { - jmp_state s; - s.jmp = NULL; - - setjmp_func(&s, 0); + test_path = path_from_root('tests', 'core', 'test_longjmp3') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - self.do_run(src, '''setjmp normal execution path, level: 0 -setjmp normal execution path, level: 1 -level is 2, perform longjmp! -setjmp exception execution path, level: 1 -prev_jmp is not empty, continue with longjmp! -setjmp exception execution path, level: 0 -Exiting setjmp function, level: 0 -''') + self.do_run_from_file(src, output) def test_longjmp4(self): src = r''' |