X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-platform-abstraction%2Ftct-dali-platform-abstraction-core.cpp;h=e1d620b5d525266927cf0176bb4f65a8cda47a1f;hb=97568a209c309d5f99bf288afa951a77f7fdcddd;hp=663658410dbbb4615e84e350e94eabd96d2d492e;hpb=14a7304694a538082ef6b272a774c6551075ea72;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/automated-tests/src/dali-platform-abstraction/tct-dali-platform-abstraction-core.cpp b/automated-tests/src/dali-platform-abstraction/tct-dali-platform-abstraction-core.cpp index 6636584..e1d620b 100644 --- a/automated-tests/src/dali-platform-abstraction/tct-dali-platform-abstraction-core.cpp +++ b/automated-tests/src/dali-platform-abstraction/tct-dali-platform-abstraction-core.cpp @@ -1,179 +1,52 @@ -#include -#include -#include "tct-dali-platform-abstraction-core.h" -#include #include -#include -#include -#include -#include -#include - -int RunTestCase( struct testcase_s& testCase ) -{ - int result = 1; - if( testCase.startup ) - { - testCase.startup(); - } - result = testCase.function(); - if( testCase.cleanup ) - { - testCase.cleanup(); - } - return result; -} - -#define MAX_NUM_CHILDREN 16 - -struct TestCase -{ - int testCase; - const char* testCaseName; - - TestCase() - : testCase(0), - testCaseName(NULL) - { - } - - TestCase(int tc, const char* name) - : testCase(tc), - testCaseName(name) - { - } - TestCase(const TestCase& rhs) - : testCase(rhs.testCase), - testCaseName(rhs.testCaseName) - { - } - TestCase& operator=(const TestCase& rhs) - { - testCase = rhs.testCase; - testCaseName = rhs.testCaseName; - return *this; - - } -}; - - -typedef std::map RunningTestCases; - -int RunAll(const char* processName, bool reRunFailed) -{ - int numFailures = 0; - int numPasses = 0; - unsigned int numTestCases = sizeof(tc_array)/sizeof(struct testcase_s) - 1; - - // Run test cases in child process( to kill output ), but run serially. - for( unsigned int i=0; i 0 ) - { - int testResult = WEXITSTATUS(status); - if( testResult ) - { - printf("Test case %s failed: %d\n", tc_array[i].name, testResult); - numFailures++; - } - else - { - numPasses++; - } - } - } - else if(WIFSIGNALED(status) ) - { - if( childPid > 0 ) - { - printf("Test case %s exited with signal %d\n", tc_array[i].name, WTERMSIG(status)); - numFailures++; - } - } - } - } - - - printf("\rNumber of test passes: %d\n", numPasses); - printf("Number of test failures: %d\n", numFailures); - - return numFailures; -} - -int FindAndRunTestCase(const char* testCaseName) -{ - int result = 2; - - for( int i = 0; tc_array[i].name; i++ ) - { - if( !strcmp(testCaseName, tc_array[i].name) ) - { - return RunTestCase( tc_array[i] ); - } - } +#include +#include +#include - printf("Unknown testcase name: \"%s\"\n", testCaseName); - return result; -} +#include "tct-dali-platform-abstraction-core.h" -int main(int argc, char * const argv[]) +int main(int argc, char* const argv[]) { - int result = -1; + int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT; - const char* optString = "pr"; - bool optParallel(false); - bool optRerunFailed(false); + const char* optString = "sf"; + bool optRerunFailed(true); + bool optRunSerially(false); int nextOpt = 0; do { - nextOpt = getopt( argc, argv, optString ); + nextOpt = getopt(argc, argv, optString); switch(nextOpt) { - case 'p': - optParallel = true; + case 'f': + optRerunFailed = false; + break; + case 's': + optRunSerially = true; break; - case 'r': - optRerunFailed = true; + case '?': + TestHarness::Usage(argv[0]); + exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT); break; } - } while( nextOpt != -1 ); + } while(nextOpt != -1); - if( optParallel ) + if(optind == argc) // no testcase name in argument list { - // For this test harness, run tests only in serial ( but without output ) - result = RunAll(argv[0], optRerunFailed); + if(optRunSerially) + { + result = TestHarness::RunAll(argv[0], tc_array); + } + else + { + result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed); + } } else { - if (argc != 2) { - printf("Usage: %s \n", argv[0]); - return 2; - } - result = FindAndRunTestCase(argv[1]); + // optind is index of next argument - interpret as testcase name + result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]); } return result; }