use fork() to test rte_panic() */
| 34 | |
| 35 | /* use fork() to test rte_panic() */ |
| 36 | static int |
| 37 | test_panic(void) |
| 38 | { |
| 39 | int pid; |
| 40 | int status; |
| 41 | |
| 42 | pid = fork(); |
| 43 | |
| 44 | if (pid == 0) { |
| 45 | struct rlimit rl; |
| 46 | |
| 47 | /* No need to generate a coredump when panicking. */ |
| 48 | rl.rlim_cur = rl.rlim_max = 0; |
| 49 | setrlimit(RLIMIT_CORE, &rl); |
| 50 | rte_panic("Test Debug\n"); |
| 51 | } else if (pid < 0) { |
| 52 | printf("Fork Failed\n"); |
| 53 | return -1; |
| 54 | } |
| 55 | wait(&status); |
| 56 | if(status == 0){ |
| 57 | printf("Child process terminated normally!\n"); |
| 58 | return -1; |
| 59 | } else |
| 60 | printf("Child process terminated as expected - Test passed!\n"); |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | /* use fork() to test rte_exit() */ |
| 66 | static int |