1 #ifndef _XEBATCHEXECUTOR_HPP 2 #define _XEBATCHEXECUTOR_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Test Executor 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 Test batch executor. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "xeDefs.hpp" 27 #include "xeBatchResult.hpp" 28 #include "xeCommLink.hpp" 29 #include "xeTestLogParser.hpp" 30 #include "xeCallQueue.hpp" 31 32 #include <string> 33 #include <vector> 34 35 namespace xe 36 { 37 38 struct TargetConfiguration 39 { TargetConfigurationxe::TargetConfiguration40 TargetConfiguration(void) : maxCasesPerSession(1000) 41 { 42 } 43 44 std::string binaryName; 45 std::string workingDir; 46 std::string cmdLineArgs; 47 int maxCasesPerSession; 48 }; 49 50 class BatchExecutorLogHandler : public TestLogHandler 51 { 52 public: 53 BatchExecutorLogHandler(BatchResult *batchResult); 54 ~BatchExecutorLogHandler(void); 55 56 void setSessionInfo(const SessionInfo &sessionInfo); 57 58 TestCaseResultPtr startTestCaseResult(const char *casePath); 59 void testCaseResultUpdated(const TestCaseResultPtr &resultData); 60 void testCaseResultComplete(const TestCaseResultPtr &resultData); 61 62 private: 63 BatchResult *m_batchResult; 64 }; 65 66 class BatchExecutor 67 { 68 public: 69 BatchExecutor(const TargetConfiguration &config, CommLink *commLink, const TestNode *root, const TestSet &testSet, 70 BatchResult *batchResult, InfoLog *infoLog); 71 ~BatchExecutor(void); 72 73 void run(void); 74 void cancel(void); //!< Cancel current run(), can be called from any thread. 75 76 private: 77 BatchExecutor(const BatchExecutor &other); 78 BatchExecutor &operator=(const BatchExecutor &other); 79 80 bool iterate(void); 81 82 void onStateChanged(CommLinkState state, const char *message); 83 void onTestLogData(const uint8_t *bytes, size_t numBytes); 84 void onInfoLogData(const uint8_t *bytes, size_t numBytes); 85 86 void launchTestSet(const TestSet &testSet); 87 88 // Callbacks for CommLink. 89 static void enqueueStateChanged(void *userPtr, CommLinkState state, const char *message); 90 static void enqueueTestLogData(void *userPtr, const uint8_t *bytes, size_t numBytes); 91 static void enqueueInfoLogData(void *userPtr, const uint8_t *bytes, size_t numBytes); 92 93 // Called in CallQueue dispatch. 94 static void dispatchStateChanged(CallReader &data); 95 static void dispatchTestLogData(CallReader &data); 96 static void dispatchInfoLogData(CallReader &data); 97 98 enum State 99 { 100 STATE_NOT_STARTED, 101 STATE_STARTED, 102 STATE_FINISHED, 103 104 STATE_LAST 105 }; 106 107 TargetConfiguration m_config; 108 CommLink *m_commLink; 109 110 const TestNode *m_root; 111 const TestSet &m_testSet; 112 113 BatchExecutorLogHandler m_logHandler; 114 BatchResult *m_batchResult; 115 InfoLog *m_infoLog; 116 117 State m_state; 118 TestSet m_casesToExecute; 119 120 TestLogParser m_testLogParser; 121 122 CallQueue m_dispatcher; 123 }; 124 125 } // namespace xe 126 127 #endif // _XEBATCHEXECUTOR_HPP 128