• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <iostream>
16 #include "tcuPlatform.hpp"
17 #include "tcuTestContext.hpp"
18 #include "tcuTestSessionExecutor.hpp"
19 #include "tcuTestHierarchyUtil.hpp"
20 #include "tcuCommandLine.hpp"
21 #include "tcuTestLog.hpp"
22 #include "qpInfo.h"
23 #include "qpDebugOut.h"
24 #include "deMath.h"
25 #include "ActsApp.h"
26 namespace tcu {
27 using std::string;
28 
29 /*
30  * \brief Construct test application
31  *
32  * If a fatal error occurs during initialization constructor will call
33  * die() with debug information.
34  *
35  * \param platform Reference to platform implementation.
36  */
ActsApp(Platform & platform,Archive & archive,TestLog & log,const CommandLine & cmdLine)37 ActsApp::ActsApp (Platform& platform, Archive& archive, TestLog& log, const CommandLine& cmdLine)
38     : m_platform(platform),
39     m_watchDog(DE_NULL),
40     m_crashHandler(DE_NULL),
41     m_crashed(false),
42     m_testCtx(DE_NULL),
43     m_testRoot(DE_NULL),
44     m_sessionExecutor(DE_NULL)
45 {
46     print("dEQP Core %s (0x%08x) starting..\n", qpGetReleaseName(), qpGetReleaseId());
47     print("  target implementation = '%s'\n", qpGetTargetName());
48 
49     if (!deSetRoundingMode(DE_ROUNDINGMODE_TO_NEAREST_EVEN)) {
50         qpPrintf("WARNING: Failed to set floating-point rounding mode!\n");
51     }
52     try {
53         const RunMode    runMode    = cmdLine.getRunMode();
54 
55         // Create test context
56         m_testCtx = new TestContext(m_platform, archive, log, cmdLine, m_watchDog);
57 
58         // Create root from registry
59         m_testRoot = new TestPackageRoot(*m_testCtx, TestPackageRegistry::getSingleton());
60 
61         // \note No executor is created if runmode is not EXECUTE
62         if (runMode == RUNMODE_EXECUTE) {
63             m_sessionExecutor = new TestSessionExecutor(*m_testRoot, *m_testCtx);
64         } else {
65             DE_ASSERT(false);
66         }
67     } catch (const std::exception& e) {
68         cleanup();
69         die("Failed to initialize dEQP: %s", e.what());
70     }
71 }
72 
~ActsApp(void)73 ActsApp::~ActsApp (void)
74 {
75     cleanup();
76 }
77 
cleanup(void)78 void ActsApp::cleanup (void)
79 {
80     delete m_sessionExecutor;
81     delete m_testRoot;
82     delete m_testCtx;
83 
84     m_sessionExecutor = DE_NULL;
85     m_testRoot = DE_NULL;
86     m_testCtx = DE_NULL;
87 
88     if (m_crashHandler) {
89         qpCrashHandler_destroy(m_crashHandler);
90     }
91 
92     if (m_watchDog) {
93         qpWatchDog_destroy(m_watchDog);
94     }
95 }
96 
97 /*
98  * \brief Step forward test execution
99  * \return true if application should call iterate() again and false
100  *         if test execution session is complete.
101  */
iterate(void)102 bool ActsApp::iterate (void)
103 {
104     if (!m_sessionExecutor) {
105         DE_ASSERT(m_testCtx->getCommandLine().getRunMode() != RUNMODE_EXECUTE);
106         return false;
107     }
108 
109     // Poll platform events
110     const bool platformOk = m_platform.processEvents();
111 
112     // Iterate a step.
113     bool testExecOk = false;
114     if (platformOk) {
115         try {
116             testExecOk = m_sessionExecutor->iterate();
117         } catch (const std::exception& e) {
118             die("%s", e.what());
119         }
120     }
121 
122     return platformOk && testExecOk;
123 }
124 
getResult(void) const125 const TestRunStatus& ActsApp::getResult (void) const
126 {
127     return m_sessionExecutor->getStatus();
128 }
129 } // tcu
130