summaryrefslogtreecommitdiff
path: root/tests/test_core.py
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 11:16:18 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:53 +0200
commit9635141fdd8aaa73657f7a6644d9dc200ea05332 (patch)
tree5b37bb40c86b8891f718d14aff1aaca53ed64854 /tests/test_core.py
parent205422ce0a76f4e7f6b1bed08b5abc20bf13430e (diff)
Use do_run_from_file() for test_longjmp_funcptr
Diffstat (limited to 'tests/test_core.py')
-rw-r--r--tests/test_core.py35
1 files changed, 3 insertions, 32 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index 7e48e3a6..d16e02d3 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1110,39 +1110,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_longjmp_funcptr(self):
- src = r'''
- #include <stdio.h>
- #include <setjmp.h>
-
- static jmp_buf buf;
-
- void (*fp)() = NULL;
-
- void second(void) {
- printf("second\n"); // prints
- longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1
- }
-
- void first(void) {
- fp();
- printf("first\n"); // does not print
- }
-
- int main(int argc, char **argv) {
- fp = argc == 200 ? NULL : second;
-
- volatile int x = 0;
- if ( ! setjmp(buf) ) {
- x++;
- first(); // when executed, setjmp returns 0
- } else { // when longjmp jumps back, setjmp returns 1
- printf("main: %d\n", x); // prints
- }
+ test_path = path_from_root('tests', 'core', 'test_longjmp_funcptr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, 'second\nmain: 1\n')
+ self.do_run_from_file(src, output)
def test_longjmp_repeat(self):
Settings.MAX_SETJMPS = 1