net/mlx5: use global default miss for E-Switch sampling
[dpdk.git] / app / test / test.c
index ea1e98f..624dd48 100644 (file)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include <sys/queue.h>
 
-#ifdef RTE_LIBRTE_CMDLINE
+#ifdef RTE_LIB_CMDLINE
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
 #include <cmdline_socket.h>
@@ -25,12 +25,12 @@ extern cmdline_parse_ctx_t main_ctx[];
 #include <rte_cycles.h>
 #include <rte_log.h>
 #include <rte_string_fns.h>
-#ifdef RTE_LIBRTE_TIMER
+#ifdef RTE_LIB_TIMER
 #include <rte_timer.h>
 #endif
 
 #include "test.h"
-#ifdef RTE_LIBRTE_PDUMP
+#ifdef RTE_LIB_PDUMP
 #include "test_pdump.h"
 #endif
 
@@ -52,14 +52,16 @@ do_recursive_call(void)
                int (*action_fn)(void);
        } actions[] =  {
                        { "run_secondary_instances", test_mp_secondary },
-#ifdef RTE_LIBRTE_PDUMP
+#ifdef RTE_LIB_PDUMP
+#ifdef RTE_NET_RING
                        { "run_pdump_server_tests", test_pdump },
+#endif
 #endif
                        { "test_missing_c_flag", no_action },
-                       { "test_master_lcore_flag", no_action },
+                       { "test_main_lcore_flag", no_action },
                        { "test_invalid_n_flag", no_action },
                        { "test_no_hpet_flag", no_action },
-                       { "test_whitelist_flag", no_action },
+                       { "test_allow_flag", no_action },
                        { "test_invalid_b_flag", no_action },
                        { "test_invalid_vdev_flag", no_action },
                        { "test_invalid_r_flag", no_action },
@@ -67,12 +69,14 @@ do_recursive_call(void)
                        { "test_memory_flags", no_action },
                        { "test_file_prefix", no_action },
                        { "test_no_huge_flag", no_action },
+#ifdef RTE_LIB_TIMER
                        { "timer_secondary_spawn_wait", test_timer_secondary },
+#endif
        };
 
        if (recursive_call == NULL)
                return -1;
-       for (i = 0; i < sizeof(actions)/sizeof(actions[0]); i++) {
+       for (i = 0; i < RTE_DIM(actions); i++) {
                if (strcmp(actions[i].env_var, recursive_call) == 0)
                        return (actions[i].action_fn)();
        }
@@ -87,7 +91,7 @@ int last_test_result;
 int
 main(int argc, char **argv)
 {
-#ifdef RTE_LIBRTE_CMDLINE
+#ifdef RTE_LIB_CMDLINE
        struct cmdline *cl;
 #endif
        char *extra_args;
@@ -130,7 +134,7 @@ main(int argc, char **argv)
                goto out;
        }
 
-#ifdef RTE_LIBRTE_TIMER
+#ifdef RTE_LIB_TIMER
        if (rte_timer_subsystem_init() < 0) {
                ret = -1;
                goto out;
@@ -159,35 +163,44 @@ main(int argc, char **argv)
                                "HPET is not enabled, using TSC as default timer\n");
 
 
-#ifdef RTE_LIBRTE_CMDLINE
-       cl = cmdline_stdin_new(main_ctx, "RTE>>");
-       if (cl == NULL) {
-               ret = -1;
-               goto out;
-       }
-
+#ifdef RTE_LIB_CMDLINE
        char *dpdk_test = getenv("DPDK_TEST");
        if (dpdk_test && strlen(dpdk_test)) {
                char buf[1024];
+
+               cl = cmdline_new(main_ctx, "RTE>>", 0, 1);
+               if (cl == NULL) {
+                       ret = -1;
+                       goto out;
+               }
+
                snprintf(buf, sizeof(buf), "%s\n", dpdk_test);
                if (cmdline_in(cl, buf, strlen(buf)) < 0) {
                        printf("error on cmdline input\n");
+
+                       ret = -1;
+               } else {
+                       ret = last_test_result;
+               }
+               cmdline_free(cl);
+               goto out;
+       } else {
+               /* if no DPDK_TEST env variable, go interactive */
+               cl = cmdline_stdin_new(main_ctx, "RTE>>");
+               if (cl == NULL) {
                        ret = -1;
                        goto out;
                }
 
+               cmdline_interact(cl);
                cmdline_stdin_exit(cl);
-               ret = last_test_result;
-               goto out;
+               cmdline_free(cl);
        }
-       /* if no DPDK_TEST env variable, go interactive */
-       cmdline_interact(cl);
-       cmdline_stdin_exit(cl);
 #endif
        ret = 0;
 
 out:
-#ifdef RTE_LIBRTE_TIMER
+#ifdef RTE_LIB_TIMER
        rte_timer_subsystem_finalize();
 #endif
        rte_eal_cleanup();
@@ -208,14 +221,16 @@ unit_test_suite_runner(struct unit_test_suite *suite)
                printf(" + Test Suite : %s\n", suite->suite_name);
        }
 
-       if (suite->setup)
-               if (suite->setup() != 0) {
+       if (suite->setup) {
+               test_success = suite->setup();
+               if (test_success != 0) {
                        /*
-                        * setup failed, so count all enabled tests and mark
-                        * them as failed
+                        * setup did not pass, so count all enabled tests and
+                        * mark them as failed/skipped
                         */
                        while (suite->unit_test_cases[total].testcase) {
-                               if (!suite->unit_test_cases[total].enabled)
+                               if (!suite->unit_test_cases[total].enabled ||
+                                   test_success == TEST_SKIPPED)
                                        skipped++;
                                else
                                        failed++;
@@ -223,6 +238,7 @@ unit_test_suite_runner(struct unit_test_suite *suite)
                        }
                        goto suite_summary;
                }
+       }
 
        printf(" + ------------------------------------------------------- +\n");
 
@@ -246,6 +262,8 @@ unit_test_suite_runner(struct unit_test_suite *suite)
                        test_success = suite->unit_test_cases[total].testcase();
                        if (test_success == TEST_SUCCESS)
                                succeeded++;
+                       else if (test_success == TEST_SKIPPED)
+                               skipped++;
                        else if (test_success == -ENOTSUP)
                                unsupported++;
                        else
@@ -262,6 +280,8 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 
                if (test_success == TEST_SUCCESS)
                        status = "succeeded";
+               else if (test_success == TEST_SKIPPED)
+                       status = "skipped";
                else if (test_success == -ENOTSUP)
                        status = "unsupported";
                else
@@ -293,7 +313,8 @@ suite_summary:
        last_test_result = failed;
 
        if (failed)
-               return -1;
-
-       return 0;
+               return TEST_FAILED;
+       if (total == skipped)
+               return TEST_SKIPPED;
+       return TEST_SUCCESS;
 }