From 162b5c1c0a1d12b47250e422b036882eefc99732 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 16 Mar 2001 03:20:36 +0000 Subject: Add in a setjmp test from David Schleef --- test/setjmp/setjmp_test.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/setjmp/setjmp_test.c (limited to 'test/setjmp/setjmp_test.c') diff --git a/test/setjmp/setjmp_test.c b/test/setjmp/setjmp_test.c new file mode 100644 index 000000000..f371048a5 --- /dev/null +++ b/test/setjmp/setjmp_test.c @@ -0,0 +1,35 @@ + +#include +#include +#include + + +jmp_buf jb; +int tries=0; + +int main(int argc,char *argv[]) +{ + int ret; + + printf("calling setjmp, should return with 0\n"); + + ret = setjmp(jb); + + printf("setjmp returned %d\n",ret); + + if(!ret){ + if(tries++>4){ + printf("Hmmm... in loop, must be broken.\n"); + return 0; + } + printf("now calling longjmp, setjmp should return with 1\n"); + + longjmp(jb,1); + + printf("returned from longjmp, must be broken\n"); + return 0; + } + + return 0; +} + -- cgit v1.2.3