From: Yi Sun Date: Wed, 4 Sep 2013 02:48:48 +0000 (+0800) Subject: Utests_run: Add known issue cases support. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c72251dfb74db37fa058d1979b198fee8658428e;p=contrib%2Fbeignet.git Utests_run: Add known issue cases support. Add some arguments: -c : 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 Reviewed-by: Zhigang Gong --- diff --git a/utests/utest.cpp b/utests/utest.cpp index 24045c7..0bd7b1b 100644 --- a/utests/utest.cpp +++ b/utests/utest.cpp @@ -32,7 +32,7 @@ using namespace std; vector *UTest::utestList = NULL; void releaseUTestList(void) { delete UTest::utestList; } -UTest::UTest(Function fn, const char *name) : fn(fn), name(name) { +UTest::UTest(Function fn, const char *name, bool haveIssue) : fn(fn), name(name), haveIssue(haveIssue) { if (utestList == NULL) { utestList = new vector; atexit(releaseUTestList); @@ -40,7 +40,7 @@ UTest::UTest(Function fn, const char *name) : fn(fn), name(name) { utestList->push_back(*this); } -UTest::UTest(void) : fn(NULL), name(NULL) {} +UTest::UTest(void) : fn(NULL), name(NULL), haveIssue(false) {} static bool strequal(const char *s1, const char *s2) { if (strcmp(s1, s2) == 0) return true; @@ -52,7 +52,7 @@ void UTest::run(const char *name) { if (utestList == NULL) return; for (size_t i = 0; i < utestList->size(); ++i) { const UTest &utest = (*utestList)[i]; - if (utest.name == NULL || utest.fn == NULL) continue; + if (utest.name == NULL || utest.fn == NULL || utest.haveIssue) continue; if (strequal(utest.name, name)) { std::cout << utest.name << ":" << std::endl; (utest.fn)(); @@ -76,11 +76,25 @@ void UTest::runAll(void) { } } -void UTest::listAll(void) { +void UTest::runAllNoIssue(void) { if (utestList == NULL) return; for (size_t i = 0; i < utestList->size(); ++i) { const UTest &utest = (*utestList)[i]; - if (utest.fn == NULL) continue; - std::cout << utest.name << std::endl; + if (utest.fn == NULL || utest.haveIssue) continue; + std::cout << utest.name << ":" << std::endl; + (utest.fn)(); + std::cout << std::endl; + cl_kernel_destroy(); + cl_buffer_destroy(); } } + +void UTest::listAllCases() +{ + if (utestList == NULL) return; + for (size_t i = 0; i < utestList->size(); ++i) { + const UTest &utest = (*utestList)[i]; + if (utest.fn == NULL) continue; + std::cout << utest.name << std::endl; + } +} diff --git a/utests/utest.hpp b/utests/utest.hpp index 93b3d87..d3a6a6f 100644 --- a/utests/utest.hpp +++ b/utests/utest.hpp @@ -39,19 +39,23 @@ struct UTest /*! Empty test */ UTest(void); /*! Build a new unit test and append it to the unit test list */ - UTest(Function fn, const char *name); + UTest(Function fn, const char *name, bool haveIssue = false); /*! Function to execute */ Function fn; /*! Name of the test */ const char *name; + /*! Indicate whether current test cases has issue to be fixes */ + bool haveIssue; /*! The tests that are registered */ static std::vector *utestList; /*! Run the test with the given name */ static void run(const char *name); + /*! Run all the tests without known issue*/ + static void runAllNoIssue(void); /*! Run all the tests */ static void runAll(void); - /*! List all the tests */ - static void listAll(void); + /*! List all test cases */ + static void listAllCases(void); }; /*! Register a new unit test */ @@ -62,6 +66,12 @@ struct UTest static void __ANON__##FN##__(void) { UTEST_EXPECT_SUCCESS(FN()); } \ static const UTest __##FN##__(__ANON__##FN##__, #FN); +/*! Register a test case which has issue to be fixed */ +#define MAKE_UTEST_FROM_FUNCTION_WITH_ISSUE(FN) \ + static void __ANON__##FN##__(void) { UTEST_EXPECT_SUCCESS(FN()); } \ + static const UTest __##FN##__(__ANON__##FN##__, #FN, true); + + /*! No assert is expected */ #define UTEST_EXPECT_SUCCESS(EXPR) \ do { \ diff --git a/utests/utest_run.cpp b/utests/utest_run.cpp index 86536d7..94fbbee 100644 --- a/utests/utest_run.cpp +++ b/utests/utest_run.cpp @@ -25,26 +25,94 @@ */ #include "utest_helper.hpp" #include "utest_exception.hpp" -#include #include +#include + +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