4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 #include <sys/queue.h>
44 #ifdef RTE_LIBRTE_CMDLINE
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_socket.h>
49 extern cmdline_parse_ctx_t main_ctx[];
52 #include <rte_memory.h>
53 #include <rte_memzone.h>
55 #include <rte_cycles.h>
57 #include <rte_string_fns.h>
58 #ifdef RTE_LIBRTE_TIMER
59 #include <rte_timer.h>
64 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
66 const char *prgname; /* to be set to argv[0] */
68 static const char *recursive_call; /* used in linuxapp for MP and other tests */
71 no_action(void){ return 0; }
74 do_recursive_call(void)
79 int (*action_fn)(void);
81 { "run_secondary_instances", test_mp_secondary },
82 { "test_missing_c_flag", no_action },
83 { "test_master_lcore_flag", no_action },
84 { "test_invalid_n_flag", no_action },
85 { "test_no_hpet_flag", no_action },
86 { "test_whitelist_flag", no_action },
87 { "test_invalid_b_flag", no_action },
88 { "test_invalid_vdev_flag", no_action },
89 { "test_invalid_r_flag", no_action },
90 { "test_misc_flags", no_action },
91 { "test_memory_flags", no_action },
92 { "test_file_prefix", no_action },
93 { "test_no_huge_flag", no_action },
96 if (recursive_call == NULL)
98 for (i = 0; i < sizeof(actions)/sizeof(actions[0]); i++) {
99 if (strcmp(actions[i].env_var, recursive_call) == 0)
100 return (actions[i].action_fn)();
102 printf("ERROR - missing action to take for %s\n", recursive_call);
107 main(int argc, char **argv)
109 #ifdef RTE_LIBRTE_CMDLINE
114 ret = rte_eal_init(argc, argv);
118 #ifdef RTE_LIBRTE_TIMER
119 rte_timer_subsystem_init();
122 if (commands_init() < 0)
129 if ((recursive_call = getenv(RECURSIVE_ENV_VAR)) != NULL)
130 return do_recursive_call();
132 #ifdef RTE_LIBEAL_USE_HPET
133 if (rte_eal_hpet_init(1) < 0)
136 "HPET is not enabled, using TSC as default timer\n");
139 #ifdef RTE_LIBRTE_CMDLINE
140 cl = cmdline_stdin_new(main_ctx, "RTE>>");
144 cmdline_interact(cl);
145 cmdline_stdin_exit(cl);
153 unit_test_suite_runner(struct unit_test_suite *suite)
156 unsigned int total = 0, executed = 0, skipped = 0;
157 unsigned int succeeded = 0, failed = 0, unsupported = 0;
160 if (suite->suite_name) {
161 printf(" + ------------------------------------------------------- +\n");
162 printf(" + Test Suite : %s\n", suite->suite_name);
166 if (suite->setup() != 0)
169 printf(" + ------------------------------------------------------- +\n");
171 while (suite->unit_test_cases[total].testcase) {
172 if (!suite->unit_test_cases[total].enabled) {
180 /* run test case setup */
181 if (suite->unit_test_cases[total].setup)
182 test_success = suite->unit_test_cases[total].setup();
184 test_success = TEST_SUCCESS;
186 if (test_success == TEST_SUCCESS) {
187 /* run the test case */
188 test_success = suite->unit_test_cases[total].testcase();
189 if (test_success == TEST_SUCCESS)
191 else if (test_success == -ENOTSUP)
195 } else if (test_success == -ENOTSUP) {
201 /* run the test case teardown */
202 if (suite->unit_test_cases[total].teardown)
203 suite->unit_test_cases[total].teardown();
205 if (test_success == TEST_SUCCESS)
206 status = "succeeded";
207 else if (test_success == -ENOTSUP)
208 status = "unsupported";
212 printf(" + TestCase [%2d] : %s %s\n", total,
213 suite->unit_test_cases[total].name, status);
218 /* Run test suite teardown */
225 printf(" + ------------------------------------------------------- +\n");
226 printf(" + Test Suite Summary \n");
227 printf(" + Tests Total : %2d\n", total);
228 printf(" + Tests Skipped : %2d\n", skipped);
229 printf(" + Tests Executed : %2d\n", executed);
230 printf(" + Tests Unsupported: %2d\n", unsupported);
231 printf(" + Tests Passed : %2d\n", succeeded);
232 printf(" + Tests Failed : %2d\n", failed);
233 printf(" + ------------------------------------------------------- +\n");