]> git.droids-corp.org - dpdk.git/commitdiff
test: use env variable to run tests
authorHarry van Haaren <harry.van.haaren@intel.com>
Thu, 11 Jan 2018 17:50:33 +0000 (17:50 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Jan 2018 23:04:37 +0000 (00:04 +0100)
With this patch the test binary checks the DPDK_TEST
environment variable and if set, the contents of the var
are inserted on the test app command line, and run.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
test/test/commands.c
test/test/test.c
test/test/test.h

index 4097a3310a6aca5be5d9cc6adb913cadb8b8d5de..6649cfc3218128723ca27a26a9776f14ea13c682 100644 (file)
@@ -103,6 +103,7 @@ static void cmd_autotest_parsed(void *parsed_result,
                        ret = t->callback();
        }
 
+       last_test_result = ret;
        if (ret == 0)
                printf("Test OK\n");
        else
index ffe3b9260e71f4ce23024e822336f8c4c1d43535..af1b1bf9d9def11d69fe51dde1830f7d8b9fe4ea 100644 (file)
@@ -73,6 +73,8 @@ do_recursive_call(void)
        return -1;
 }
 
+int last_test_result;
+
 int
 main(int argc, char **argv)
 {
@@ -111,6 +113,20 @@ main(int argc, char **argv)
        if (cl == NULL) {
                return -1;
        }
+
+       char *dpdk_test = getenv("DPDK_TEST");
+       if (dpdk_test && strlen(dpdk_test)) {
+               char buf[1024];
+               snprintf(buf, sizeof(buf), "%s\n", dpdk_test);
+               if (cmdline_in(cl, buf, strlen(buf)) < 0) {
+                       printf("error on cmdline input\n");
+                       return -1;
+               }
+
+               cmdline_stdin_exit(cl);
+               return last_test_result;
+       }
+       /* if no DPDK_TEST env variable, go interactive */
        cmdline_interact(cl);
        cmdline_stdin_exit(cl);
 #endif
@@ -202,6 +218,8 @@ suite_summary:
        printf(" + Tests Failed :      %2d\n", failed);
        printf(" + ------------------------------------------------------- +\n");
 
+       last_test_result = failed;
+
        if (failed)
                return -1;
 
index 4b1c6e79eaba8922a10ef4e5f42d1a616590f243..5198330ccccf4a752c3e987a66a4b68cf9cb5809 100644 (file)
@@ -191,6 +191,7 @@ struct unit_test_suite {
 };
 
 int unit_test_suite_runner(struct unit_test_suite *suite);
+extern int last_test_result;
 
 #define RECURSIVE_ENV_VAR "RTE_TEST_RECURSIVE"