1 #ifndef _TCUTESTPACKAGE_HPP 2 #define _TCUTESTPACKAGE_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 5 * ---------------------------------------- 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Base class for a test case. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuDefs.hpp" 27 #include "tcuTestCase.hpp" 28 #include <map> 29 30 namespace tcu 31 { 32 33 //! Test run summary. 34 class TestRunStatus 35 { 36 public: TestRunStatus(void)37 TestRunStatus (void) { clear(); } 38 clear(void)39 void clear (void) 40 { 41 numExecuted = 0; 42 numPassed = 0; 43 numFailed = 0; 44 numNotSupported = 0; 45 numWarnings = 0; 46 numWaived = 0; 47 isComplete = false; 48 } 49 50 int numExecuted; //!< Total number of cases executed. 51 int numPassed; //!< Number of cases passed. 52 int numFailed; //!< Number of cases failed. 53 int numNotSupported; //!< Number of cases not supported. 54 int numWarnings; //!< Number of QualityWarning / CompatibilityWarning results. 55 int numWaived; //!< Number of waived tests. 56 bool isComplete; //!< Is run complete. 57 }; 58 59 60 /*--------------------------------------------------------------------*//*! 61 * \brief Test case execution interface. 62 * 63 * TestCaseExecutor provides package-specific resources & initialization 64 * for test cases. 65 * 66 * \todo [2015-03-18 pyry] Replace with following API: 67 * 68 * class TestInstance 69 * { 70 * public: 71 * TestInstance (TestContext& testCtx); 72 * tcu::TestResult iterate (void); 73 * }; 74 * 75 * class TestInstanceFactory (???) 76 * { 77 * public: 78 * TestInstance* createInstance (const TestCase* testCase, const std::string& path); 79 * }; 80 *//*--------------------------------------------------------------------*/ 81 class TestCaseExecutor 82 { 83 public: ~TestCaseExecutor(void)84 virtual ~TestCaseExecutor (void) {} 85 86 virtual void init (TestCase* testCase, const std::string& path) = 0; 87 virtual void deinit (TestCase* testCase) = 0; 88 virtual TestNode::IterateResult iterate (TestCase* testCase) = 0; deinitTestPackage(TestContext & testCtx)89 virtual void deinitTestPackage (TestContext& testCtx) { DE_UNREF(testCtx); }; usesLocalStatus()90 virtual bool usesLocalStatus () { return false; } updateGlobalStatus(tcu::TestRunStatus & status)91 virtual void updateGlobalStatus (tcu::TestRunStatus& status) { DE_UNREF(status); } reportDurations(tcu::TestContext & testCtx,const std::string & packageName,const deInt64 & duration,const std::map<std::string,deUint64> & groupsDurationTime)92 virtual void reportDurations (tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime) { DE_UNREF(testCtx); DE_UNREF(packageName); DE_UNREF(duration); DE_UNREF(groupsDurationTime); } 93 }; 94 95 /*--------------------------------------------------------------------*//*! 96 * \brief Base class for test packages. 97 * 98 * Test packages are root-level test groups. They also provide package- 99 * specific test case executor, see TestCaseExecutor. 100 *//*--------------------------------------------------------------------*/ 101 class TestPackage : public TestNode 102 { 103 public: 104 TestPackage (TestContext& testCtx, const char* name, const char* description); 105 virtual ~TestPackage (void); 106 107 virtual TestCaseExecutor* createExecutor (void) const = 0; 108 109 // Deprecated getArchive(void)110 virtual Archive* getArchive (void) { return DE_NULL; } 111 112 virtual IterateResult iterate (void); 113 }; 114 115 // TestPackageRegistry 116 117 typedef TestPackage* (*TestPackageCreateFunc) (TestContext& testCtx); 118 119 class TestPackageRegistry 120 { 121 public: 122 struct PackageInfo 123 { PackageInfotcu::TestPackageRegistry::PackageInfo124 PackageInfo (std::string name_, TestPackageCreateFunc createFunc_) : name(name_), createFunc(createFunc_) {} 125 126 std::string name; 127 TestPackageCreateFunc createFunc; 128 }; 129 130 static TestPackageRegistry* getSingleton (void); 131 static void destroy (void); 132 133 void registerPackage (const char* name, TestPackageCreateFunc createFunc); 134 const std::vector<PackageInfo*>& getPackageInfos (void) const; 135 PackageInfo* getPackageInfoByName (const char* name) const; 136 TestPackage* createPackage (const char* name, TestContext& testCtx) const; 137 138 private: 139 TestPackageRegistry (void); 140 ~TestPackageRegistry (void); 141 142 static TestPackageRegistry* getOrDestroy (bool isCreate); 143 144 // Member variables. 145 std::vector<PackageInfo*> m_packageInfos; 146 }; 147 148 // TestPackageDescriptor 149 150 class TestPackageDescriptor 151 { 152 public: 153 TestPackageDescriptor (const char* name, TestPackageCreateFunc createFunc); 154 ~TestPackageDescriptor (void); 155 }; 156 157 // TestPackageRoot 158 159 class TestPackageRoot : public TestNode 160 { 161 public: 162 TestPackageRoot (TestContext& testCtx); 163 TestPackageRoot (TestContext& testCtx, const std::vector<TestNode*>& children); 164 TestPackageRoot (TestContext& testCtx, const TestPackageRegistry* packageRegistry); 165 virtual ~TestPackageRoot (void); 166 167 virtual IterateResult iterate (void); 168 }; 169 170 } // tcu 171 172 #endif // _TCUTESTPACKAGE_HPP 173