X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit-internal%2Ftct-dali-toolkit-internal-core.cpp;h=0a37d059844025258a5203132fe48701f073994e;hp=c80af33de348a3ffae55ef2c493c1aba098ebc5d;hb=10d2080e1d25b75347daa2f8c2dcee494fbcb175;hpb=55d1df73f96208cdb37517e5115f8b632c250040 diff --git a/automated-tests/src/dali-toolkit-internal/tct-dali-toolkit-internal-core.cpp b/automated-tests/src/dali-toolkit-internal/tct-dali-toolkit-internal-core.cpp index c80af33..0a37d05 100644 --- a/automated-tests/src/dali-toolkit-internal/tct-dali-toolkit-internal-core.cpp +++ b/automated-tests/src/dali-toolkit-internal/tct-dali-toolkit-internal-core.cpp @@ -1,192 +1,14 @@ -#include #include -#include "tct-dali-toolkit-internal-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; - -// Constantly runs up to MAX_NUM_CHILDREN processes -int RunAllInParallel(const char* processName, bool reRunFailed) -{ - int numFailures = 0; - int numPasses = 0; - int numTestCases = sizeof(tc_array)/sizeof(struct testcase_s) - 1; - - RunningTestCases children; - std::vector failedTestCases; - - // Fork up to MAX_NUM_CHILDREN processes, then - // wait. As soon as a proc completes, fork the next. - - int nextTestCase = 0; - int numRunningChildren = 0; - while( nextTestCase < numTestCases || numRunningChildren > 0) - { - if( nextTestCase < numTestCases ) - { - while( numRunningChildren < MAX_NUM_CHILDREN ) - { - int pid = fork(); - if( pid == 0 ) // Child process - { - close(STDOUT_FILENO); - close(STDERR_FILENO); - exit( RunTestCase( tc_array[nextTestCase] ) ); - } - else if(pid == -1) - { - perror("fork"); - exit(2); - } - else // Parent process - { - TestCase tc(nextTestCase, tc_array[nextTestCase].name); - children[pid] = tc; - nextTestCase++; - numRunningChildren++; - } - } - } - - int status=0; - int childPid = waitpid(-1, &status, 0); - if( childPid == -1 ) - { - perror("waitpid"); - exit(2); - } - - if( WIFEXITED(status) ) - { - if( childPid > 0 ) - { - int testResult = WEXITSTATUS(status); - if( testResult ) - { - printf("Test case %s failed: %d\n", children[childPid].testCaseName, testResult); - failedTestCases.push_back(children[childPid].testCase); - numFailures++; - } - else - { - numPasses++; - } - numRunningChildren--; - } - } - - else if( WIFSIGNALED(status) ) - { - if( childPid > 0 ) - { - RunningTestCases::iterator iter = children.find(childPid); - if( iter != children.end() ) - { - printf("Test case %s exited with signal %d\n", iter->second.testCaseName, WTERMSIG(status)); - failedTestCases.push_back(iter->second.testCase); - } - else - { - printf("Unknown child process: %d signaled %d\n", childPid, WTERMSIG(status)); - } - - numFailures++; - numRunningChildren--; - } - } - } - - printf("\rNumber of test passes: %d \n", numPasses); - printf("Number of test failures: %d\n", numFailures); - - if( reRunFailed ) - { - for( unsigned int i=0; i +#include +#include "tct-dali-toolkit-internal-core.h" int main(int argc, char * const argv[]) { - int result = -1; + int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT; - const char* optString = "pr"; - bool optParallel(false); + const char* optString = "r"; bool optRerunFailed(false); int nextOpt = 0; @@ -195,26 +17,24 @@ int main(int argc, char * const argv[]) nextOpt = getopt( argc, argv, optString ); switch(nextOpt) { - case 'p': - optParallel = true; - break; case 'r': optRerunFailed = true; break; + case '?': + TestHarness::Usage(argv[0]); + exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT); + break; } } while( nextOpt != -1 ); - if( optParallel ) + if( optind == argc ) // no testcase name in argument list { - result = RunAllInParallel(argv[0], optRerunFailed); + 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; }