tcuTestPackage.hpp revision 4e3ea87b79b12195e79d28ef6ab2be0a847b5d9a
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUTESTPACKAGE_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUTESTPACKAGE_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Base class for a test case. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestCase.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 334e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * \brief Test case execution interface. 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 354e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * TestCaseExecutor provides package-specific resources & initialization 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * for test cases. 374e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * 384e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * \todo [2015-03-18 pyry] Replace with following API: 394e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * 404e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * class TestInstance 414e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * { 424e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * public: 434e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * TestInstance (TestContext& testCtx); 444e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * tcu::TestResult iterate (void); 454e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * }; 464e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * 474e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * class TestInstanceFactory (???) 484e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * { 494e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * public: 504e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * TestInstance* createInstance (const TestCase* testCase, const std::string& path); 514e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * }; 524e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos *//*--------------------------------------------------------------------*/ 534e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulosclass TestCaseExecutor 544e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos{ 554e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulospublic: 564e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual ~TestCaseExecutor (void) {} 574e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos 584e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual void init (TestCase* testCase, const std::string& path) = 0; 594e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual void deinit (TestCase* testCase) = 0; 604e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual TestNode::IterateResult iterate (TestCase* testCase) = 0; 614e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos}; 624e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos 634e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos/*--------------------------------------------------------------------*//*! 644e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * \brief Base class for test packages. 654e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * 664e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * Test packages are root-level test groups. They also provide package- 674e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos * specific test case executor, see TestCaseExecutor. 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestPackage : public TestNode 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 724e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos TestPackage (TestContext& testCtx, const char* name, const char* description); 734e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual ~TestPackage (void); 744e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos 754e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual TestCaseExecutor* createExecutor (void) const = 0; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 774e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos // Deprecated 784e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual Archive* getArchive (void) { return DE_NULL; } 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 804e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos virtual IterateResult iterate (void); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestPackageRegistry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef TestPackage* (*TestPackageCreateFunc) (TestContext& testCtx); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestPackageRegistry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct PackageInfo 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PackageInfo (std::string name_, TestPackageCreateFunc createFunc_) : name(name_), createFunc(createFunc_) {} 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackageCreateFunc createFunc; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static TestPackageRegistry* getSingleton (void); 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static void destroy (void); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void registerPackage (const char* name, TestPackageCreateFunc createFunc); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<PackageInfo*>& getPackageInfos (void) const; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PackageInfo* getPackageInfoByName (const char* name) const; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackage* createPackage (const char* name, TestContext& testCtx) const; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackageRegistry (void); 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TestPackageRegistry (void); 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static TestPackageRegistry* getOrDestroy (bool isCreate); 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Member variables. 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<PackageInfo*> m_packageInfos; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestPackageDescriptor 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestPackageDescriptor 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackageDescriptor (const char* name, TestPackageCreateFunc createFunc); 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TestPackageDescriptor (void); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestPackageRoot 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TestPackageRoot : public TestNode 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackageRoot (TestContext& testCtx); 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestPackageRoot (TestContext& testCtx, const std::vector<TestNode*>& children); 1324e3ea87b79b12195e79d28ef6ab2be0a847b5d9aPyry Haulos TestPackageRoot (TestContext& testCtx, const TestPackageRegistry* packageRegistry); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~TestPackageRoot (void); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual IterateResult iterate (void); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUTESTPACKAGE_HPP 141