use fork() to test rte_exit() */
| 64 | |
| 65 | /* use fork() to test rte_exit() */ |
| 66 | static int |
| 67 | test_exit_val(int exit_val) |
| 68 | { |
| 69 | int pid; |
| 70 | int status; |
| 71 | |
| 72 | /* manually cleanup EAL memory, as the fork() below would otherwise |
| 73 | * cause the same hugepages to be free()-ed multiple times. |
| 74 | */ |
| 75 | rte_service_finalize(); |
| 76 | |
| 77 | pid = fork(); |
| 78 | |
| 79 | if (pid == 0) |
| 80 | rte_exit(exit_val, __func__); |
| 81 | else if (pid < 0){ |
| 82 | printf("Fork Failed\n"); |
| 83 | return -1; |
| 84 | } |
| 85 | wait(&status); |
| 86 | printf("Child process status: %d\n", status); |
| 87 | if(!WIFEXITED(status) || WEXITSTATUS(status) != (uint8_t)exit_val){ |
| 88 | printf("Child process terminated with incorrect status (expected = %d)!\n", |
| 89 | exit_val); |
| 90 | return -1; |
| 91 | } |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | static int |
| 96 | test_exit(void) |
no test coverage detected