X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=test%2Ftest%2Ftest.c;h=44dfe20efe29958e12eb2a38d3fa5c6a5c75b099;hb=85c73894b9277d85456e6601366366f152c9a7e4;hp=a86dc86e841268116f2d667312557b5436256ecc;hpb=151f4d0341f1e4b63471e42ac6c1949882472c78;p=dpdk.git diff --git a/test/test/test.c b/test/test/test.c index a86dc86e84..44dfe20efe 100644 --- a/test/test/test.c +++ b/test/test/test.c @@ -1,34 +1,5 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation */ #include @@ -50,7 +21,6 @@ extern cmdline_parse_ctx_t main_ctx[]; #endif #include -#include #include #include #include @@ -87,11 +57,7 @@ do_recursive_call(void) { "test_invalid_b_flag", no_action }, { "test_invalid_vdev_flag", no_action }, { "test_invalid_r_flag", no_action }, -#ifdef RTE_LIBRTE_XEN_DOM0 - { "test_dom0_misc_flags", no_action }, -#else { "test_misc_flags", no_action }, -#endif { "test_memory_flags", no_action }, { "test_file_prefix", no_action }, { "test_no_huge_flag", no_action }, @@ -107,6 +73,8 @@ do_recursive_call(void) return -1; } +int last_test_result; + int main(int argc, char **argv) { @@ -145,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 @@ -157,7 +139,8 @@ int unit_test_suite_runner(struct unit_test_suite *suite) { int test_success; - unsigned total = 0, executed = 0, skipped = 0, succeeded = 0, failed = 0; + unsigned int total = 0, executed = 0, skipped = 0; + unsigned int succeeded = 0, failed = 0, unsupported = 0; const char *status; if (suite->suite_name) { @@ -166,8 +149,20 @@ unit_test_suite_runner(struct unit_test_suite *suite) } if (suite->setup) - if (suite->setup() != 0) + if (suite->setup() != 0) { + /* + * setup failed, so count all enabled tests and mark + * them as failed + */ + while (suite->unit_test_cases[total].testcase) { + if (!suite->unit_test_cases[total].enabled) + skipped++; + else + failed++; + total++; + } goto suite_summary; + } printf(" + ------------------------------------------------------- +\n"); @@ -191,8 +186,12 @@ 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 == -ENOTSUP) + unsupported++; else failed++; + } else if (test_success == -ENOTSUP) { + unsupported++; } else { failed++; } @@ -203,6 +202,8 @@ unit_test_suite_runner(struct unit_test_suite *suite) if (test_success == TEST_SUCCESS) status = "succeeded"; + else if (test_success == -ENOTSUP) + status = "unsupported"; else status = "failed"; @@ -224,10 +225,13 @@ suite_summary: printf(" + Tests Total : %2d\n", total); printf(" + Tests Skipped : %2d\n", skipped); printf(" + Tests Executed : %2d\n", executed); + printf(" + Tests Unsupported: %2d\n", unsupported); printf(" + Tests Passed : %2d\n", succeeded); printf(" + Tests Failed : %2d\n", failed); printf(" + ------------------------------------------------------- +\n"); + last_test_result = failed; + if (failed) return -1;