1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
7 #include <sys/resource.h>
12 #include <rte_debug.h>
13 #include <rte_common.h>
15 #include <rte_service_component.h>
24 /* use fork() to test rte_panic() */
36 /* No need to generate a coredump when panicking. */
37 rl.rlim_cur = rl.rlim_max = 0;
38 setrlimit(RLIMIT_CORE, &rl);
39 rte_panic("Test Debug\n");
41 printf("Fork Failed\n");
46 printf("Child process terminated normally!\n");
49 printf("Child process terminated as expected - Test passed!\n");
54 /* use fork() to test rte_exit() */
56 test_exit_val(int exit_val)
61 /* manually cleanup EAL memory, as the fork() below would otherwise
62 * cause the same hugepages to be free()-ed multiple times.
64 rte_service_finalize();
69 rte_exit(exit_val, __func__);
71 printf("Fork Failed\n");
75 printf("Child process status: %d\n", status);
76 if(!WIFEXITED(status) || WEXITSTATUS(status) != (uint8_t)exit_val){
77 printf("Child process terminated with incorrect status (expected = %d)!\n",
87 int test_vals[] = { 0, 1, 2, 255, -1 };
89 for (i = 0; i < RTE_DIM(test_vals); i++) {
90 if (test_exit_val(test_vals[i]) < 0)
93 printf("%s Passed\n", __func__);
98 dummy_app_usage(const char *progname)
100 RTE_SET_USED(progname);
106 if (rte_set_application_usage_hook(dummy_app_usage) != NULL) {
107 printf("Non-NULL value returned for initial usage hook\n");
110 if (rte_set_application_usage_hook(NULL) != dummy_app_usage) {
111 printf("Incorrect value returned for application usage hook\n");
121 if (test_panic() < 0)
125 if (test_usage() < 0)
130 REGISTER_TEST_COMMAND(debug_autotest, test_debug);