3 #include "tct-dali-platform-abstraction-core.h"
12 int RunTestCase( struct testcase_s& testCase )
15 if( testCase.startup )
19 result = testCase.function();
20 if( testCase.cleanup )
27 #define MAX_NUM_CHILDREN 16
32 const char* testCaseName;
40 TestCase(int tc, const char* name)
45 TestCase(const TestCase& rhs)
46 : testCase(rhs.testCase),
47 testCaseName(rhs.testCaseName)
50 TestCase& operator=(const TestCase& rhs)
52 testCase = rhs.testCase;
53 testCaseName = rhs.testCaseName;
60 typedef std::map<int, TestCase> RunningTestCases;
62 int RunAll(const char* processName, bool reRunFailed)
66 unsigned int numTestCases = sizeof(tc_array)/sizeof(struct testcase_s) - 1;
68 // Run test cases in child process( to kill output ), but run serially.
69 for( unsigned int i=0; i<numTestCases; i++)
72 if( pid == 0 ) // Child process
76 exit( RunTestCase( tc_array[i] ) );
83 else // Parent process
86 int childPid = waitpid(-1, &status, 0);
92 if( WIFEXITED(status) )
96 int testResult = WEXITSTATUS(status);
99 printf("Test case %s failed: %d\n", tc_array[i].name, testResult);
108 else if(WIFSIGNALED(status) )
112 printf("Test case %s exited with signal %d\n", tc_array[i].name, WTERMSIG(status));
120 printf("\rNumber of test passes: %d\n", numPasses);
121 printf("Number of test failures: %d\n", numFailures);
126 int FindAndRunTestCase(const char* testCaseName)
130 for( int i = 0; tc_array[i].name; i++ )
132 if( !strcmp(testCaseName, tc_array[i].name) )
134 return RunTestCase( tc_array[i] );
138 printf("Unknown testcase name: \"%s\"\n", testCaseName);
142 int main(int argc, char * const argv[])
146 const char* optString = "pr";
147 bool optParallel(false);
148 bool optRerunFailed(false);
153 nextOpt = getopt( argc, argv, optString );
160 optRerunFailed = true;
163 } while( nextOpt != -1 );
167 // For this test harness, run tests only in serial ( but without output )
168 result = RunAll(argv[0], optRerunFailed);
173 printf("Usage: %s <testcase name>\n", argv[0]);
176 result = FindAndRunTestCase(argv[1]);