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