summaryrefslogtreecommitdiff
path: root/test/setjmp/setjmp_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/setjmp/setjmp_test.c')
-rw-r--r--test/setjmp/setjmp_test.c35
1 files changed, 35 insertions, 0 deletions
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 <stdio.h>
+#include <setjmp.h>
+#include <unistd.h>
+
+
+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;
+}
+