1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #ifdef RTE_EXEC_ENV_WINDOWS
14 printf("debug not supported on Windows, skipping test\n");
20 #include <sys/resource.h>
25 #include <rte_debug.h>
26 #include <rte_common.h>
28 #include <rte_service_component.h>
35 /* use fork() to test rte_panic() */
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");
52 printf("Fork Failed\n");
57 printf("Child process terminated normally!\n");
60 printf("Child process terminated as expected - Test passed!\n");
65 /* use fork() to test rte_exit() */
67 test_exit_val(int exit_val)
72 /* manually cleanup EAL memory, as the fork() below would otherwise
73 * cause the same hugepages to be free()-ed multiple times.
75 rte_service_finalize();
80 rte_exit(exit_val, __func__);
82 printf("Fork Failed\n");
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",
98 int test_vals[] = { 0, 1, 2, 255, -1 };
100 for (i = 0; i < RTE_DIM(test_vals); i++) {
101 if (test_exit_val(test_vals[i]) < 0)
104 printf("%s Passed\n", __func__);
109 dummy_app_usage(const char *progname)
111 RTE_SET_USED(progname);
117 if (rte_set_application_usage_hook(dummy_app_usage) != NULL) {
118 printf("Non-NULL value returned for initial usage hook\n");
121 if (rte_set_application_usage_hook(NULL) != dummy_app_usage) {
122 printf("Incorrect value returned for application usage hook\n");
132 if (test_panic() < 0)
136 if (test_usage() < 0)
141 #endif /* !RTE_EXEC_ENV_WINDOWS */
143 REGISTER_TEST_COMMAND(debug_autotest, test_debug);