Imported Upstream version 0.3.17
[platform/upstream/liboil.git] / testsuite / double_catch.c
1
2 #ifdef HAVE_CONFIG_H
3 #include "config.h"
4 #endif
5
6 #include <liboil/liboil.h>
7 #include <liboil/liboilfault.h>
8 #include <stdio.h>
9
10 #ifdef HAVE_I386
11 void unknown_insn(void *far)
12 {
13   asm ("ud2");
14 }
15 #define HAVE_ILLEGAL_INSN
16 #endif
17
18 #ifdef HAVE_POWERPC
19 void unknown_insn(void *far)
20 {
21   asm (".long 0");
22 }
23 #define HAVE_ILLEGAL_INSN
24 #endif
25
26 int main(void)
27 {
28   oil_init();
29
30 #ifdef HAVE_ILLEGAL_INSN
31   oil_fault_check_enable();
32
33   if (oil_fault_check_try(unknown_insn, NULL)) {
34     printf("didn't catch failure\n");
35     return 1;
36   }
37
38   if (oil_fault_check_try(unknown_insn, NULL)) {
39     printf("didn't catch failure\n");
40     return 1;
41   }
42
43   oil_fault_check_disable();
44
45   printf("OK\n");
46 #else
47   printf("No illegal instruction for this architecture, test inconclusive\n");
48 #endif
49
50   return 0;
51 }