diff options
author | Yi Sun <yi.sun@intel.com> | 2013-09-04 10:48:48 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-09-04 14:30:41 +0800 |
commit | c72251dfb74db37fa058d1979b198fee8658428e (patch) | |
tree | f48b8cb4f872eb1f8a4c7c832d5f36907dad45f3 /utests/utest_run.cpp | |
parent | 98df3ca0d785a5d08699b4fd9d3644d56271dcbd (diff) | |
download | beignet-c72251dfb74db37fa058d1979b198fee8658428e.tar.gz |
Utests_run: Add known issue cases support.
Add some arguments:
-c <casename>: run sub-case named 'casename'
-l : list all the available case name
-a : run all test cases
-n : run all test cases without known issue
-h : display this usage
Add a alternate macro named MAKE_UTEST_FROM_FUNCTION_WITH_ISSUE to register a new test case, which has some known issue to be fixed till now.
While utest_run running, only cases which registered by MAKE_UTEST_FROM_FUNCTION will be involved by defalut.
If you want to run all the test cases including those with known issue, you should use argument '-a'.
Besides, you can use option '-c' to run any test case.
Signed-off-by: Yi Sun <yi.sun@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests/utest_run.cpp')
-rw-r--r-- | utests/utest_run.cpp | 98 |
1 files changed, 83 insertions, 15 deletions
diff --git a/utests/utest_run.cpp b/utests/utest_run.cpp index 86536d74..94fbbee0 100644 --- a/utests/utest_run.cpp +++ b/utests/utest_run.cpp @@ -25,26 +25,94 @@ */ #include "utest_helper.hpp" #include "utest_exception.hpp" -#include <string.h> #include <iostream> +#include <getopt.h> + +static const char *shortopts = "c:lanh"; +struct option longopts[] = { +{"casename", required_argument, NULL, 'c'}, +{"list", no_argument, NULL, 'l'}, +{"all", no_argument, NULL, 'a'}, +{"allnoissue", no_argument, NULL, 'n'}, +{"help", no_argument, NULL, 'h'}, +{0, 0, 0, 0}, +}; + +void usage() +{ + std::cout << "\ +Usage:\n\ + ./utest_run <option>\n\ +\n\ + option:\n\ + -c <casename>: run sub-case named 'casename'\n\ + -l : list all the available case name\n\ + -a : run all test cases\n\ + -n : run all test cases without known issue (default option)\n\ + -h : display this usage\n\ +\ + "<< std::endl; +} int main(int argc, char *argv[]) { - try { - if (argc == 2 && !strcmp(argv[1], "--list")) { - UTest::listAll(); - return 0; - } - cl_ocl_init(); - if (argc >= 2) - for (int i = 1; i < argc; ++i) - UTest::run(argv[i]); - else - UTest::runAll(); - cl_ocl_destroy(); - } catch (Exception e) { - std::cout << " " << e.what() << " [SUCCESS]" << std::endl; + int c = 0; + cl_ocl_init(); + + c = getopt_long (argc, argv, shortopts, longopts, NULL); + + if (argc == 1) + c = 'n'; + if (argc == 2 && c < 1 ){ + c = 'c'; + optarg = argv[1]; } + + { + switch (c) + { + case 'c': + try { + UTest::run(optarg); + } + catch (Exception e){ + std::cout << " " << e.what() << " [SUCCESS]" << std::endl; + } + + break; + + case 'l': + UTest::listAllCases(); + break; + + case 'a': + try { + UTest::runAll(); + } + catch (Exception e){ + std::cout << " " << e.what() << " [SUCCESS]" << std::endl; + } + + break; + + case 'n': + try { + UTest::runAllNoIssue(); + } + catch (Exception e){ + std::cout << " " << e.what() << " [SUCCESS]" << std::endl; + } + + break; + + case 'h': + default: + usage(); + exit(1); + } + } while ((c = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) + + cl_ocl_destroy(); } |