[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-harness.h
1 #ifndef TEST_HARNESS_H
2 #define TEST_HARNESS_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include <stdio.h>
21 #include <testcase.h>
22
23 #include <chrono>
24 #include <cstdint>
25
26 namespace TestHarness
27 {
28 enum ExitStatus
29 {
30   EXIT_STATUS_TESTCASE_SUCCEEDED, // 0
31   EXIT_STATUS_TESTCASE_FAILED,    // 1
32   EXIT_STATUS_TESTCASE_ABORTED,   // 2
33   EXIT_STATUS_FORK_FAILED,        // 3
34   EXIT_STATUS_WAITPID_FAILED,     // 4
35   EXIT_STATUS_BAD_ARGUMENT,       // 5
36   EXIT_STATUS_TESTCASE_NOT_FOUND  // 6
37 };
38
39 const int32_t MAX_NUM_CHILDREN(16);
40
41 struct TestCase
42 {
43   int32_t                               testCase;
44   const char*                           testCaseName;
45   std::chrono::steady_clock::time_point startTime;
46
47   TestCase()
48   : testCase(0),
49     testCaseName(NULL),
50     startTime()
51   {
52   }
53
54   TestCase(int32_t tc, const char* name)
55   : testCase(tc),
56     testCaseName(name),
57     startTime()
58   {
59   }
60   TestCase(const TestCase& rhs)
61   : testCase(rhs.testCase),
62     testCaseName(rhs.testCaseName),
63     startTime(rhs.startTime)
64   {
65   }
66   TestCase& operator=(const TestCase& rhs)
67   {
68     testCase     = rhs.testCase;
69     testCaseName = rhs.testCaseName;
70     startTime    = rhs.startTime;
71     return *this;
72   }
73 };
74
75 /**
76  * Run a test case
77  * @param[in] testCase The Testkit-lite test case to run
78  */
79 int32_t RunTestCase(struct testcase_s& testCase);
80
81 /**
82  * Run all test cases in parallel
83  * @param[in] processName The name of this process
84  * @param[in] tc_array The array of auto-generated testkit-lite test cases
85  * @param[in] reRunFailed True if failed test cases should be re-run
86  * @return 0 on success
87  */
88 int32_t RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFailed);
89
90 /**
91  * Run all test cases in serial
92  * @param[in] processName The name of this process
93  * @param[in] tc_array The array of auto-generated testkit-lite test cases
94  * @return 0 on success
95  */
96 int32_t RunAll(const char* processName, testcase tc_array[]);
97
98 /**
99  * Find the named test case in the given array, and run it
100  * @param[in] tc_array The array of auto-generated testkit-lite test cases
101  * @param[in] testCaseName the name of the test case to run
102  * @return 0 on success
103  */
104 int32_t FindAndRunTestCase(::testcase tc_array[], const char* testCaseName);
105
106 /**
107  * Display usage instructions for this program
108  * @param[in] program The name of this program
109  */
110 void Usage(const char* program);
111
112 } // namespace TestHarness
113
114 #endif