[Liboil-commit] testsuite/double_catch.c
David Schleef
ds at kemper.freedesktop.org
Thu Mar 13 15:41:04 PDT 2008
testsuite/double_catch.c | 85 +++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 43 deletions(-)
New commits:
commit 3a7f182e9eeee911dc8a6256d69a4d8fdd0431f5
Author: David Schleef <ds at ginger.bigkitten.com>
Date: Thu Mar 13 15:43:00 2008 -0700
Make double_catch work on all architectures
diff --git a/testsuite/double_catch.c b/testsuite/double_catch.c
index 0e4fd8b..f83e198 100644
--- a/testsuite/double_catch.c
+++ b/testsuite/double_catch.c
@@ -1,52 +1,51 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <liboil/liboil.h>
#include <liboil/liboilfault.h>
-#include <signal.h>
#include <stdio.h>
-#include <setjmp.h>
-void blip(void *far) {
- write(2,"hip\n",4);
- asm("ud2");
- write(2,"hop\n",4);
+
+#ifdef HAVE_I386
+void unknown_insn(void *far)
+{
+ asm ("ud2");
}
+#define HAVE_ILLEGAL_INSN
+#endif
-jmp_buf buf;
-void handle(int num) {
- fprintf(stderr,"my catch!\n");
- longjmp(buf, 1);
+#ifdef HAVE_POWERPC
+void unknown_insn(void *far)
+{
+ asm ("illegal");
}
-int main(void) {
-#if 0
- struct sigaction act;
- int ret;
-
- memset(&act, 0, sizeof(act));
- act.sa_handler = &handle;
- act.sa_flags = SA_NOMASK;
- sigaction(SIGILL, &act, NULL);
-
- ret = setjmp(buf);
- if (!ret) {
- fprintf(stderr,"soo..\n");
- blip(NULL);
- }
- if (ret)
- fprintf(stderr,"failed\n");
-
- ret = setjmp(buf);
- if (!ret) {
- fprintf(stderr,"soo..\n");
- blip(NULL);
- }
- if (ret)
- fprintf(stderr,"failed\n");
+#define HAVE_ILLEGAL_INSN
+#endif
+int main(void)
+{
+ oil_init();
+
+#ifdef HAVE_ILLEGAL_INSN
+ oil_fault_check_enable();
+
+ if (oil_fault_check_try(unknown_insn, NULL)) {
+ printf("didn't catch failure\n");
+ return 1;
+ }
+
+ if (oil_fault_check_try(unknown_insn, NULL)) {
+ printf("didn't catch failure\n");
+ return 1;
+ }
+
+ oil_fault_check_disable();
+
+ printf("OK\n");
#else
- oil_fault_check_enable();
- fprintf(stderr,"soo..\n");
- if (!oil_fault_check_try(blip, NULL))
- fprintf(stderr,"failed\n");
- fprintf(stderr,"soo..\n");
- if (!oil_fault_check_try(blip, NULL))
- fprintf(stderr,"failed\n");
- fprintf(stderr,"done..\n");
+ printf("No illegal instruction for this architecture, test inconclusive\n");
#endif
+
+ return 0;
}
More information about the Liboil-commit
mailing list