[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-harness.h
index e6dc517..e884c64 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_HARNESS_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <stdio.h>
 #include <testcase.h>
 
+#include <chrono>
+#include <cstdint>
+
 namespace TestHarness
 {
-
 enum ExitStatus
 {
-  EXIT_STATUS_TESTCASE_SUCCEEDED,   // 0
-  EXIT_STATUS_TESTCASE_FAILED,      // 1
-  EXIT_STATUS_TESTCASE_ABORTED,     // 2
-  EXIT_STATUS_FORK_FAILED,          // 3
-  EXIT_STATUS_WAITPID_FAILED,       // 4
-  EXIT_STATUS_BAD_ARGUMENT,         // 5
-  EXIT_STATUS_TESTCASE_NOT_FOUND    // 6
+  EXIT_STATUS_TESTCASE_SUCCEEDED, // 0
+  EXIT_STATUS_TESTCASE_FAILED,    // 1
+  EXIT_STATUS_TESTCASE_ABORTED,   // 2
+  EXIT_STATUS_FORK_FAILED,        // 3
+  EXIT_STATUS_WAITPID_FAILED,     // 4
+  EXIT_STATUS_BAD_ARGUMENT,       // 5
+  EXIT_STATUS_TESTCASE_NOT_FOUND  // 6
 };
 
-const int MAX_NUM_CHILDREN(16);
+const int32_t MAX_NUM_CHILDREN(16);
 
 struct TestCase
 {
-  int testCase;
-  const char* testCaseName;
-
+  int32_t                               testCase;
+  const char*                           name;
+  std::chrono::steady_clock::time_point startTime;
+  std::chrono::system_clock::time_point startSystemTime;
+  int32_t                               result{0};
+  pid_t                                 childPid{0};
+  testcase*                             tctPtr;
+  bool                                  finished{false};
+
+  TestCase(int32_t index, testcase* testCase)
+  : testCase(index),
+    name(testCase->name),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(testCase)
+  {
+  }
   TestCase()
   : testCase(0),
-    testCaseName(NULL)
+    name(NULL),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(nullptr)
   {
   }
 
-  TestCase(int tc, const char* name)
+  TestCase(int32_t tc, const char* name)
   : testCase(tc),
-    testCaseName(name)
+    name(name),
+    startTime(),
+    startSystemTime(),
+    result(0),
+    childPid(0),
+    tctPtr(nullptr)
   {
   }
   TestCase(const TestCase& rhs)
   : testCase(rhs.testCase),
-    testCaseName(rhs.testCaseName)
+    name(rhs.name),
+    startTime(rhs.startTime),
+    startSystemTime(rhs.startSystemTime),
+    result(rhs.result),
+    childPid(rhs.childPid),
+    tctPtr(rhs.tctPtr)
   {
   }
   TestCase& operator=(const TestCase& rhs)
   {
-    testCase = rhs.testCase;
-    testCaseName = rhs.testCaseName;
+    testCase        = rhs.testCase;
+    name            = rhs.name;
+    startTime       = rhs.startTime;
+    startSystemTime = rhs.startSystemTime;
+    result          = rhs.result;
+    childPid        = rhs.childPid;
+    tctPtr          = rhs.tctPtr;
     return *this;
-
   }
 };
 
@@ -70,7 +107,7 @@ struct TestCase
  * Run a test case
  * @param[in] testCase The Testkit-lite test case to run
  */
-int RunTestCase( struct testcase_s& testCase );
+int32_t RunTestCase(struct testcase_s& testCase);
 
 /**
  * Run all test cases in parallel
@@ -79,16 +116,15 @@ int RunTestCase( struct testcase_s& testCase );
  * @param[in] reRunFailed True if failed test cases should be re-run
  * @return 0 on success
  */
-int RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFailed);
+int32_t RunAllInParallel(const char* processName, testcase tc_array[], bool reRunFailed);
 
 /**
  * Run all test cases in serial
  * @param[in] processName The name of this process
  * @param[in] tc_array The array of auto-generated testkit-lite test cases
- * @param[in] reRunFailed True if failed test cases should be re-run
  * @return 0 on success
  */
-int RunAll(const char* processName, testcase tc_array[], bool reRunFailed);
+int32_t RunAll(const char* processName, testcase tc_array[]);
 
 /**
  * Find the named test case in the given array, and run it
@@ -96,7 +132,7 @@ int RunAll(const char* processName, testcase tc_array[], bool reRunFailed);
  * @param[in] testCaseName the name of the test case to run
  * @return 0 on success
  */
-int FindAndRunTestCase(::testcase tc_array[], const char* testCaseName);
+int32_t FindAndRunTestCase(::testcase tc_array[], const char* testCaseName);
 
 /**
  * Display usage instructions for this program
@@ -104,6 +140,14 @@ int FindAndRunTestCase(::testcase tc_array[], const char* testCaseName);
  */
 void Usage(const char* program);
 
+/**
+ * Main function.
+ * @param[in] argc Argument count
+ * @param[in] argv Argument vector
+ * @param[in] tc_array Array of test cases
+ */
+int RunTests(int argc, char* const argv[], ::testcase tc_array[]);
+
 } // namespace TestHarness
 
 #endif