summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/test_longjmp2.in37
-rw-r--r--tests/core/test_longjmp2.out6
-rw-r--r--tests/test_core.py46
3 files changed, 46 insertions, 43 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
diff --git a/tests/core/test_longjmp2.out b/tests/core/test_longjmp2.out
new file mode 100644
index 00000000..82956215
--- /dev/null
+++ b/tests/core/test_longjmp2.out
@@ -0,0 +1,6 @@
+Entering stack_manipulate_func, level: 0
+Setjmp normal execution path, level: 0
+Entering stack_manipulate_func, level: 1
+Perform longjmp at level 1
+Setjmp error execution path, level: 0
+Exiting stack_manipulate_func, level: 0
diff --git a/tests/test_core.py b/tests/test_core.py
index 9646f09b..0d5e3c36 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1092,50 +1092,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_longjmp2(self):
- src = r'''
- #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);
+ test_path = path_from_root('tests', 'core', 'test_longjmp2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''Entering stack_manipulate_func, level: 0
-Setjmp normal execution path, level: 0
-Entering stack_manipulate_func, level: 1
-Perform longjmp at level 1
-Setjmp error execution path, level: 0
-Exiting stack_manipulate_func, level: 0
-''')
+ self.do_run_from_file(src, output)
def test_longjmp3(self):
src = r'''