diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 11:08:21 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:53 +0200 |
commit | 313a23e64c357260c660166f67d32d64601f164a (patch) | |
tree | afca4f585fc92f70f7bc5efca287348005c5e60e /tests/test_core.py | |
parent | dca1ceb65a07c6d1a0bdbae1705ac5c90bacd929 (diff) |
Use do_run_from_file() for test_longjmp
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index befd66ba..9646f09b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1086,41 +1086,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(self): - src = r''' - #include <stdio.h> - #include <setjmp.h> - - static jmp_buf buf; - - void second(void) { - printf("second\n"); - longjmp(buf,-1); - } - - void first(void) { - printf("first\n"); // prints - longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1 - } - - int main() { - volatile int x = 0; - int jmpval = setjmp(buf); - if (!jmpval) { - x++; // should be properly restored once longjmp jumps back - first(); // when executed, setjmp returns 1 - printf("skipped\n"); // does not print - } else if (jmpval == 1) { // when first() jumps back, setjmp returns 1 - printf("result: %d %d\n", x, jmpval); // prints - x++; - second(); // when executed, setjmp returns -1 - } else if (jmpval == -1) { // when second() jumps back, setjmp returns -1 - printf("result: %d %d\n", x, jmpval); // prints - } + test_path = path_from_root('tests', 'core', 'test_longjmp') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - self.do_run(src, 'first\nresult: 1 1\nsecond\nresult: 2 -1') + self.do_run_from_file(src, output) def test_longjmp2(self): src = r''' |