diff options
author | Anthony Pesch <anthony@usamp.com> | 2013-05-19 21:54:25 -0700 |
---|---|---|
committer | Anthony Pesch <anthony@usamp.com> | 2013-05-19 21:54:25 -0700 |
commit | 3ba500f7721d562d7acce1935b2195aca850fc6f (patch) | |
tree | 3c800a62b56224168d4a470b0abc4353e50cd695 | |
parent | 0a1cb8b8d74458d4de2e2d3830680c4f48da0278 (diff) |
Updated test_longjmp to test against negative values
-rwxr-xr-x | tests/runner.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/runner.py b/tests/runner.py index 0d8878c3..b44632bc 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2403,28 +2403,34 @@ returned |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie', static jmp_buf buf; void second(void) { - printf("second\n"); // prints - longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1 + printf("second\n"); + longjmp(buf,-1); } void first(void) { - second(); - printf("first\n"); // does not print + 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; - if ( ! setjmp(buf) ) { + 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++; - first(); // when executed, setjmp returns 0 - } else { // when longjmp jumps back, setjmp returns 1 - printf("main: %d\n", x); // prints + 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 } return 0; } ''' - self.do_run(src, 'second\nmain: 1\n') + self.do_run(src, 'first\nresult: 1 1\nsecond\nresult: 2 -1') def test_longjmp2(self): src = r''' |