xref: /aosp_15_r20/external/deqp/framework/common/tcuApp.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program Tester Core
3*35238bceSAndroid Build Coastguard Worker  * ----------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Render target info.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "tcuApp.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tcuPlatform.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "tcuTestContext.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestSessionExecutor.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "tcuTestHierarchyUtil.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker #include "qpInfo.h"
33*35238bceSAndroid Build Coastguard Worker #include "qpDebugOut.h"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker #include "deMath.h"
36*35238bceSAndroid Build Coastguard Worker 
37*35238bceSAndroid Build Coastguard Worker #include <iostream>
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker namespace tcu
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker 
42*35238bceSAndroid Build Coastguard Worker using std::string;
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
45*35238bceSAndroid Build Coastguard Worker  *  Writes all packages found stdout without any
46*35238bceSAndroid Build Coastguard Worker  *  separations. Recommended to be used with a single package
47*35238bceSAndroid Build Coastguard Worker  *  only. It's possible to use test selectors for limiting the export
48*35238bceSAndroid Build Coastguard Worker  *  to one package in a multipackage binary.
49*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
writeCaselistsToStdout(TestPackageRoot & root,TestContext & testCtx)50*35238bceSAndroid Build Coastguard Worker static void writeCaselistsToStdout(TestPackageRoot &root, TestContext &testCtx)
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker     DefaultHierarchyInflater inflater(testCtx);
53*35238bceSAndroid Build Coastguard Worker     de::MovePtr<const CaseListFilter> caseListFilter(
54*35238bceSAndroid Build Coastguard Worker         testCtx.getCommandLine().createCaseListFilter(testCtx.getArchive()));
55*35238bceSAndroid Build Coastguard Worker     TestHierarchyIterator iter(root, inflater, *caseListFilter);
56*35238bceSAndroid Build Coastguard Worker 
57*35238bceSAndroid Build Coastguard Worker     while (iter.getState() != TestHierarchyIterator::STATE_FINISHED)
58*35238bceSAndroid Build Coastguard Worker     {
59*35238bceSAndroid Build Coastguard Worker         iter.next();
60*35238bceSAndroid Build Coastguard Worker 
61*35238bceSAndroid Build Coastguard Worker         while (iter.getNode()->getNodeType() != NODETYPE_PACKAGE)
62*35238bceSAndroid Build Coastguard Worker         {
63*35238bceSAndroid Build Coastguard Worker             if (iter.getState() == TestHierarchyIterator::STATE_ENTER_NODE)
64*35238bceSAndroid Build Coastguard Worker                 std::cout << (isTestNodeTypeExecutable(iter.getNode()->getNodeType()) ? "TEST" : "GROUP") << ": "
65*35238bceSAndroid Build Coastguard Worker                           << iter.getNodePath() << "\n";
66*35238bceSAndroid Build Coastguard Worker             iter.next();
67*35238bceSAndroid Build Coastguard Worker         }
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(iter.getState() == TestHierarchyIterator::STATE_LEAVE_NODE &&
70*35238bceSAndroid Build Coastguard Worker                   iter.getNode()->getNodeType() == NODETYPE_PACKAGE);
71*35238bceSAndroid Build Coastguard Worker         iter.next();
72*35238bceSAndroid Build Coastguard Worker     }
73*35238bceSAndroid Build Coastguard Worker }
74*35238bceSAndroid Build Coastguard Worker 
75*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
76*35238bceSAndroid Build Coastguard Worker  * Verifies that amber capability requirements in the .amber files
77*35238bceSAndroid Build Coastguard Worker  * match with capabilities defined on the CTS C code.
78*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
verifyAmberCapabilityCoherency(TestPackageRoot & root,TestContext & testCtx)79*35238bceSAndroid Build Coastguard Worker static void verifyAmberCapabilityCoherency(TestPackageRoot &root, TestContext &testCtx)
80*35238bceSAndroid Build Coastguard Worker {
81*35238bceSAndroid Build Coastguard Worker     DefaultHierarchyInflater inflater(testCtx);
82*35238bceSAndroid Build Coastguard Worker     de::MovePtr<const CaseListFilter> caseListFilter(
83*35238bceSAndroid Build Coastguard Worker         testCtx.getCommandLine().createCaseListFilter(testCtx.getArchive()));
84*35238bceSAndroid Build Coastguard Worker     TestHierarchyIterator iter(root, inflater, *caseListFilter);
85*35238bceSAndroid Build Coastguard Worker     int count      = 0;
86*35238bceSAndroid Build Coastguard Worker     int errorCount = 0;
87*35238bceSAndroid Build Coastguard Worker 
88*35238bceSAndroid Build Coastguard Worker     bool ok = true;
89*35238bceSAndroid Build Coastguard Worker 
90*35238bceSAndroid Build Coastguard Worker     while (iter.getState() != TestHierarchyIterator::STATE_FINISHED)
91*35238bceSAndroid Build Coastguard Worker     {
92*35238bceSAndroid Build Coastguard Worker         iter.next();
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker         while (iter.getNode()->getNodeType() != NODETYPE_PACKAGE)
95*35238bceSAndroid Build Coastguard Worker         {
96*35238bceSAndroid Build Coastguard Worker             if (iter.getState() == TestHierarchyIterator::STATE_ENTER_NODE &&
97*35238bceSAndroid Build Coastguard Worker                 isTestNodeTypeExecutable(iter.getNode()->getNodeType()))
98*35238bceSAndroid Build Coastguard Worker             {
99*35238bceSAndroid Build Coastguard Worker                 std::cout << iter.getNodePath() << "\n";
100*35238bceSAndroid Build Coastguard Worker                 testCtx.getLog() << tcu::TestLog::Message << iter.getNodePath() << tcu::TestLog::EndMessage;
101*35238bceSAndroid Build Coastguard Worker                 if (!iter.getNode()->validateRequirements())
102*35238bceSAndroid Build Coastguard Worker                 {
103*35238bceSAndroid Build Coastguard Worker                     ok = false;
104*35238bceSAndroid Build Coastguard Worker                     errorCount++;
105*35238bceSAndroid Build Coastguard Worker                 }
106*35238bceSAndroid Build Coastguard Worker                 count++;
107*35238bceSAndroid Build Coastguard Worker             }
108*35238bceSAndroid Build Coastguard Worker             iter.next();
109*35238bceSAndroid Build Coastguard Worker         }
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(iter.getState() == TestHierarchyIterator::STATE_LEAVE_NODE &&
112*35238bceSAndroid Build Coastguard Worker                   iter.getNode()->getNodeType() == NODETYPE_PACKAGE);
113*35238bceSAndroid Build Coastguard Worker         iter.next();
114*35238bceSAndroid Build Coastguard Worker     }
115*35238bceSAndroid Build Coastguard Worker     std::cout << count << " amber tests, " << errorCount << " errors.\n";
116*35238bceSAndroid Build Coastguard Worker     if (!ok)
117*35238bceSAndroid Build Coastguard Worker         TCU_THROW(InternalError, "One or more CTS and Amber test requirements do not match; check log for details");
118*35238bceSAndroid Build Coastguard Worker }
119*35238bceSAndroid Build Coastguard Worker 
120*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
121*35238bceSAndroid Build Coastguard Worker  * \brief Construct test application
122*35238bceSAndroid Build Coastguard Worker  *
123*35238bceSAndroid Build Coastguard Worker  * If a fatal error occurs during initialization constructor will call
124*35238bceSAndroid Build Coastguard Worker  * die() with debug information.
125*35238bceSAndroid Build Coastguard Worker  *
126*35238bceSAndroid Build Coastguard Worker  * \param platform Reference to platform implementation.
127*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
App(Platform & platform,Archive & archive,TestLog & log,const CommandLine & cmdLine)128*35238bceSAndroid Build Coastguard Worker App::App(Platform &platform, Archive &archive, TestLog &log, const CommandLine &cmdLine)
129*35238bceSAndroid Build Coastguard Worker     : m_platform(platform)
130*35238bceSAndroid Build Coastguard Worker     , m_watchDog(DE_NULL)
131*35238bceSAndroid Build Coastguard Worker     , m_crashHandler(DE_NULL)
132*35238bceSAndroid Build Coastguard Worker     , m_crashed(false)
133*35238bceSAndroid Build Coastguard Worker     , m_testCtx(DE_NULL)
134*35238bceSAndroid Build Coastguard Worker     , m_testRoot(DE_NULL)
135*35238bceSAndroid Build Coastguard Worker     , m_testExecutor(DE_NULL)
136*35238bceSAndroid Build Coastguard Worker {
137*35238bceSAndroid Build Coastguard Worker     if (!cmdLine.isSubProcess())
138*35238bceSAndroid Build Coastguard Worker     {
139*35238bceSAndroid Build Coastguard Worker         print("dEQP Core %s (0x%08x) starting..\n", qpGetReleaseName(), qpGetReleaseId());
140*35238bceSAndroid Build Coastguard Worker         print("  target implementation = '%s'\n", qpGetTargetName());
141*35238bceSAndroid Build Coastguard Worker     }
142*35238bceSAndroid Build Coastguard Worker 
143*35238bceSAndroid Build Coastguard Worker     if (!deSetRoundingMode(DE_ROUNDINGMODE_TO_NEAREST_EVEN))
144*35238bceSAndroid Build Coastguard Worker         qpPrintf("WARNING: Failed to set floating-point rounding mode!\n");
145*35238bceSAndroid Build Coastguard Worker 
146*35238bceSAndroid Build Coastguard Worker     try
147*35238bceSAndroid Build Coastguard Worker     {
148*35238bceSAndroid Build Coastguard Worker         const RunMode runMode = cmdLine.getRunMode();
149*35238bceSAndroid Build Coastguard Worker 
150*35238bceSAndroid Build Coastguard Worker         // Initialize watchdog
151*35238bceSAndroid Build Coastguard Worker         if (cmdLine.isWatchDogEnabled())
152*35238bceSAndroid Build Coastguard Worker             TCU_CHECK_INTERNAL(m_watchDog = qpWatchDog_create(onWatchdogTimeout, this, WATCHDOG_TOTAL_TIME_LIMIT_SECS,
153*35238bceSAndroid Build Coastguard Worker                                                               WATCHDOG_INTERVAL_TIME_LIMIT_SECS));
154*35238bceSAndroid Build Coastguard Worker 
155*35238bceSAndroid Build Coastguard Worker         // Initialize crash handler.
156*35238bceSAndroid Build Coastguard Worker         if (cmdLine.isCrashHandlingEnabled())
157*35238bceSAndroid Build Coastguard Worker             TCU_CHECK_INTERNAL(m_crashHandler = qpCrashHandler_create(onCrash, this));
158*35238bceSAndroid Build Coastguard Worker 
159*35238bceSAndroid Build Coastguard Worker         // Create test context
160*35238bceSAndroid Build Coastguard Worker         m_testCtx = new TestContext(m_platform, archive, log, cmdLine, m_watchDog);
161*35238bceSAndroid Build Coastguard Worker 
162*35238bceSAndroid Build Coastguard Worker         // Create root from registry
163*35238bceSAndroid Build Coastguard Worker         m_testRoot = new TestPackageRoot(*m_testCtx, TestPackageRegistry::getSingleton());
164*35238bceSAndroid Build Coastguard Worker 
165*35238bceSAndroid Build Coastguard Worker         // \note No executor is created if runmode is not EXECUTE
166*35238bceSAndroid Build Coastguard Worker         if (runMode == RUNMODE_EXECUTE)
167*35238bceSAndroid Build Coastguard Worker             m_testExecutor = new TestSessionExecutor(*m_testRoot, *m_testCtx);
168*35238bceSAndroid Build Coastguard Worker         else if (runMode == RUNMODE_DUMP_STDOUT_CASELIST)
169*35238bceSAndroid Build Coastguard Worker             writeCaselistsToStdout(*m_testRoot, *m_testCtx);
170*35238bceSAndroid Build Coastguard Worker         else if (runMode == RUNMODE_DUMP_XML_CASELIST)
171*35238bceSAndroid Build Coastguard Worker             writeXmlCaselistsToFiles(*m_testRoot, *m_testCtx, cmdLine);
172*35238bceSAndroid Build Coastguard Worker         else if (runMode == RUNMODE_DUMP_TEXT_CASELIST)
173*35238bceSAndroid Build Coastguard Worker             writeTxtCaselistsToFiles(*m_testRoot, *m_testCtx, cmdLine);
174*35238bceSAndroid Build Coastguard Worker         else if (runMode == RUNMODE_VERIFY_AMBER_COHERENCY)
175*35238bceSAndroid Build Coastguard Worker             verifyAmberCapabilityCoherency(*m_testRoot, *m_testCtx);
176*35238bceSAndroid Build Coastguard Worker         else
177*35238bceSAndroid Build Coastguard Worker             DE_ASSERT(false);
178*35238bceSAndroid Build Coastguard Worker     }
179*35238bceSAndroid Build Coastguard Worker     catch (const std::exception &e)
180*35238bceSAndroid Build Coastguard Worker     {
181*35238bceSAndroid Build Coastguard Worker         cleanup();
182*35238bceSAndroid Build Coastguard Worker         die("Failed to initialize dEQP: %s", e.what());
183*35238bceSAndroid Build Coastguard Worker     }
184*35238bceSAndroid Build Coastguard Worker }
185*35238bceSAndroid Build Coastguard Worker 
~App(void)186*35238bceSAndroid Build Coastguard Worker App::~App(void)
187*35238bceSAndroid Build Coastguard Worker {
188*35238bceSAndroid Build Coastguard Worker     cleanup();
189*35238bceSAndroid Build Coastguard Worker }
190*35238bceSAndroid Build Coastguard Worker 
cleanup(void)191*35238bceSAndroid Build Coastguard Worker void App::cleanup(void)
192*35238bceSAndroid Build Coastguard Worker {
193*35238bceSAndroid Build Coastguard Worker     delete m_testExecutor;
194*35238bceSAndroid Build Coastguard Worker     delete m_testRoot;
195*35238bceSAndroid Build Coastguard Worker     delete m_testCtx;
196*35238bceSAndroid Build Coastguard Worker 
197*35238bceSAndroid Build Coastguard Worker     if (m_crashHandler)
198*35238bceSAndroid Build Coastguard Worker         qpCrashHandler_destroy(m_crashHandler);
199*35238bceSAndroid Build Coastguard Worker 
200*35238bceSAndroid Build Coastguard Worker     if (m_watchDog)
201*35238bceSAndroid Build Coastguard Worker         qpWatchDog_destroy(m_watchDog);
202*35238bceSAndroid Build Coastguard Worker }
203*35238bceSAndroid Build Coastguard Worker 
204*35238bceSAndroid Build Coastguard Worker /*--------------------------------------------------------------------*//*!
205*35238bceSAndroid Build Coastguard Worker  * \brief Step forward test execution
206*35238bceSAndroid Build Coastguard Worker  * \return true if application should call iterate() again and false
207*35238bceSAndroid Build Coastguard Worker  *         if test execution session is complete.
208*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
iterate(void)209*35238bceSAndroid Build Coastguard Worker bool App::iterate(void)
210*35238bceSAndroid Build Coastguard Worker {
211*35238bceSAndroid Build Coastguard Worker     if (!m_testExecutor)
212*35238bceSAndroid Build Coastguard Worker     {
213*35238bceSAndroid Build Coastguard Worker         DE_ASSERT(m_testCtx->getCommandLine().getRunMode() != RUNMODE_EXECUTE);
214*35238bceSAndroid Build Coastguard Worker         return false;
215*35238bceSAndroid Build Coastguard Worker     }
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker     // Poll platform events
218*35238bceSAndroid Build Coastguard Worker     const bool platformOk = m_platform.processEvents();
219*35238bceSAndroid Build Coastguard Worker 
220*35238bceSAndroid Build Coastguard Worker     // Iterate a step.
221*35238bceSAndroid Build Coastguard Worker     bool testExecOk = false;
222*35238bceSAndroid Build Coastguard Worker     if (platformOk)
223*35238bceSAndroid Build Coastguard Worker     {
224*35238bceSAndroid Build Coastguard Worker         try
225*35238bceSAndroid Build Coastguard Worker         {
226*35238bceSAndroid Build Coastguard Worker             testExecOk = m_testExecutor->iterate();
227*35238bceSAndroid Build Coastguard Worker         }
228*35238bceSAndroid Build Coastguard Worker         catch (const std::exception &e)
229*35238bceSAndroid Build Coastguard Worker         {
230*35238bceSAndroid Build Coastguard Worker             die("%s", e.what());
231*35238bceSAndroid Build Coastguard Worker         }
232*35238bceSAndroid Build Coastguard Worker     }
233*35238bceSAndroid Build Coastguard Worker 
234*35238bceSAndroid Build Coastguard Worker     if ((!platformOk || !testExecOk))
235*35238bceSAndroid Build Coastguard Worker     {
236*35238bceSAndroid Build Coastguard Worker         if (!m_testCtx->getCommandLine().isSubProcess())
237*35238bceSAndroid Build Coastguard Worker         {
238*35238bceSAndroid Build Coastguard Worker             if (!platformOk)
239*35238bceSAndroid Build Coastguard Worker                 print("\nABORTED!\n");
240*35238bceSAndroid Build Coastguard Worker             else
241*35238bceSAndroid Build Coastguard Worker                 print("\nDONE!\n");
242*35238bceSAndroid Build Coastguard Worker         }
243*35238bceSAndroid Build Coastguard Worker 
244*35238bceSAndroid Build Coastguard Worker         const RunMode runMode = m_testCtx->getCommandLine().getRunMode();
245*35238bceSAndroid Build Coastguard Worker         if (runMode == RUNMODE_EXECUTE)
246*35238bceSAndroid Build Coastguard Worker         {
247*35238bceSAndroid Build Coastguard Worker             const TestRunStatus &result = m_testExecutor->getStatus();
248*35238bceSAndroid Build Coastguard Worker             if (!m_testCtx->getCommandLine().isSubProcess())
249*35238bceSAndroid Build Coastguard Worker             {
250*35238bceSAndroid Build Coastguard Worker                 // Report statistics.
251*35238bceSAndroid Build Coastguard Worker                 print("\nTest run totals:\n");
252*35238bceSAndroid Build Coastguard Worker                 print("  Passed:        %d/%d (%.1f%%)\n", result.numPassed, result.numExecuted,
253*35238bceSAndroid Build Coastguard Worker                       (result.numExecuted > 0 ? (100.0f * (float)result.numPassed / (float)result.numExecuted) : 0.0f));
254*35238bceSAndroid Build Coastguard Worker                 print("  Failed:        %d/%d (%.1f%%)\n", result.numFailed, result.numExecuted,
255*35238bceSAndroid Build Coastguard Worker                       (result.numExecuted > 0 ? (100.0f * (float)result.numFailed / (float)result.numExecuted) : 0.0f));
256*35238bceSAndroid Build Coastguard Worker                 print("  Not supported: %d/%d (%.1f%%)\n", result.numNotSupported, result.numExecuted,
257*35238bceSAndroid Build Coastguard Worker                       (result.numExecuted > 0 ? (100.0f * (float)result.numNotSupported / (float)result.numExecuted) :
258*35238bceSAndroid Build Coastguard Worker                                                 0.0f));
259*35238bceSAndroid Build Coastguard Worker                 print(
260*35238bceSAndroid Build Coastguard Worker                     "  Warnings:      %d/%d (%.1f%%)\n", result.numWarnings, result.numExecuted,
261*35238bceSAndroid Build Coastguard Worker                     (result.numExecuted > 0 ? (100.0f * (float)result.numWarnings / (float)result.numExecuted) : 0.0f));
262*35238bceSAndroid Build Coastguard Worker                 print("  Waived:        %d/%d (%.1f%%)\n", result.numWaived, result.numExecuted,
263*35238bceSAndroid Build Coastguard Worker                       (result.numExecuted > 0 ? (100.0f * (float)result.numWaived / (float)result.numExecuted) : 0.0f));
264*35238bceSAndroid Build Coastguard Worker                 if (!result.isComplete)
265*35238bceSAndroid Build Coastguard Worker                     print("Test run was ABORTED!\n");
266*35238bceSAndroid Build Coastguard Worker             }
267*35238bceSAndroid Build Coastguard Worker             else
268*35238bceSAndroid Build Coastguard Worker             {
269*35238bceSAndroid Build Coastguard Worker                 // subprocess sends test statisticts through qpa file, so that main process may read it
270*35238bceSAndroid Build Coastguard Worker                 // and add to global statistics ( search for #SubProcessStatus to see how it's done )
271*35238bceSAndroid Build Coastguard Worker                 std::ostringstream str;
272*35238bceSAndroid Build Coastguard Worker                 str << "\n#SubProcessStatus " << result.numExecuted << " " << result.numPassed << " "
273*35238bceSAndroid Build Coastguard Worker                     << result.numFailed << " " << result.numNotSupported << " " << result.numWarnings << " "
274*35238bceSAndroid Build Coastguard Worker                     << result.numWaived << "\n";
275*35238bceSAndroid Build Coastguard Worker                 m_testCtx->getLog().writeRaw(str.str().c_str());
276*35238bceSAndroid Build Coastguard Worker             }
277*35238bceSAndroid Build Coastguard Worker         }
278*35238bceSAndroid Build Coastguard Worker     }
279*35238bceSAndroid Build Coastguard Worker 
280*35238bceSAndroid Build Coastguard Worker     return platformOk && testExecOk;
281*35238bceSAndroid Build Coastguard Worker }
282*35238bceSAndroid Build Coastguard Worker 
getResult(void) const283*35238bceSAndroid Build Coastguard Worker const TestRunStatus &App::getResult(void) const
284*35238bceSAndroid Build Coastguard Worker {
285*35238bceSAndroid Build Coastguard Worker     return m_testExecutor->getStatus();
286*35238bceSAndroid Build Coastguard Worker }
287*35238bceSAndroid Build Coastguard Worker 
onWatchdogTimeout(qpWatchDog * watchDog,void * userPtr,qpTimeoutReason reason)288*35238bceSAndroid Build Coastguard Worker void App::onWatchdogTimeout(qpWatchDog *watchDog, void *userPtr, qpTimeoutReason reason)
289*35238bceSAndroid Build Coastguard Worker {
290*35238bceSAndroid Build Coastguard Worker     DE_UNREF(watchDog);
291*35238bceSAndroid Build Coastguard Worker     static_cast<App *>(userPtr)->onWatchdogTimeout(reason);
292*35238bceSAndroid Build Coastguard Worker }
293*35238bceSAndroid Build Coastguard Worker 
onCrash(qpCrashHandler * crashHandler,void * userPtr)294*35238bceSAndroid Build Coastguard Worker void App::onCrash(qpCrashHandler *crashHandler, void *userPtr)
295*35238bceSAndroid Build Coastguard Worker {
296*35238bceSAndroid Build Coastguard Worker     DE_UNREF(crashHandler);
297*35238bceSAndroid Build Coastguard Worker     static_cast<App *>(userPtr)->onCrash();
298*35238bceSAndroid Build Coastguard Worker }
299*35238bceSAndroid Build Coastguard Worker 
onWatchdogTimeout(qpTimeoutReason reason)300*35238bceSAndroid Build Coastguard Worker void App::onWatchdogTimeout(qpTimeoutReason reason)
301*35238bceSAndroid Build Coastguard Worker {
302*35238bceSAndroid Build Coastguard Worker     if (!m_crashLock.tryLock() || m_crashed)
303*35238bceSAndroid Build Coastguard Worker         return; // In crash handler already.
304*35238bceSAndroid Build Coastguard Worker 
305*35238bceSAndroid Build Coastguard Worker     m_crashed = true;
306*35238bceSAndroid Build Coastguard Worker 
307*35238bceSAndroid Build Coastguard Worker     m_testCtx->getLog().terminateCase(QP_TEST_RESULT_TIMEOUT);
308*35238bceSAndroid Build Coastguard Worker     die("Watchdog timer timeout for %s",
309*35238bceSAndroid Build Coastguard Worker         (reason == QP_TIMEOUT_REASON_INTERVAL_LIMIT ? "touch interval" : "total time"));
310*35238bceSAndroid Build Coastguard Worker }
311*35238bceSAndroid Build Coastguard Worker 
writeCrashToLog(void * userPtr,const char * infoString)312*35238bceSAndroid Build Coastguard Worker static void writeCrashToLog(void *userPtr, const char *infoString)
313*35238bceSAndroid Build Coastguard Worker {
314*35238bceSAndroid Build Coastguard Worker     // \note THIS IS CALLED BY SIGNAL HANDLER! CALLING MALLOC/FREE IS NOT ALLOWED!
315*35238bceSAndroid Build Coastguard Worker     TestLog *log = static_cast<TestLog *>(userPtr);
316*35238bceSAndroid Build Coastguard Worker     log->writeMessage(infoString);
317*35238bceSAndroid Build Coastguard Worker }
318*35238bceSAndroid Build Coastguard Worker 
writeCrashToConsole(void * userPtr,const char * infoString)319*35238bceSAndroid Build Coastguard Worker static void writeCrashToConsole(void *userPtr, const char *infoString)
320*35238bceSAndroid Build Coastguard Worker {
321*35238bceSAndroid Build Coastguard Worker     // \note THIS IS CALLED BY SIGNAL HANDLER! CALLING MALLOC/FREE IS NOT ALLOWED!
322*35238bceSAndroid Build Coastguard Worker     DE_UNREF(userPtr);
323*35238bceSAndroid Build Coastguard Worker     qpPrint(infoString);
324*35238bceSAndroid Build Coastguard Worker }
325*35238bceSAndroid Build Coastguard Worker 
onCrash(void)326*35238bceSAndroid Build Coastguard Worker void App::onCrash(void)
327*35238bceSAndroid Build Coastguard Worker {
328*35238bceSAndroid Build Coastguard Worker     // \note THIS IS CALLED BY SIGNAL HANDLER! CALLING MALLOC/FREE IS NOT ALLOWED!
329*35238bceSAndroid Build Coastguard Worker 
330*35238bceSAndroid Build Coastguard Worker     if (!m_crashLock.tryLock() || m_crashed)
331*35238bceSAndroid Build Coastguard Worker         return; // In crash handler already.
332*35238bceSAndroid Build Coastguard Worker 
333*35238bceSAndroid Build Coastguard Worker     m_crashed = true;
334*35238bceSAndroid Build Coastguard Worker 
335*35238bceSAndroid Build Coastguard Worker     bool isInCase = m_testExecutor ? m_testExecutor->isInTestCase() : false;
336*35238bceSAndroid Build Coastguard Worker 
337*35238bceSAndroid Build Coastguard Worker     if (isInCase)
338*35238bceSAndroid Build Coastguard Worker     {
339*35238bceSAndroid Build Coastguard Worker         qpCrashHandler_writeCrashInfo(m_crashHandler, writeCrashToLog, &m_testCtx->getLog());
340*35238bceSAndroid Build Coastguard Worker         m_testCtx->getLog().terminateCase(QP_TEST_RESULT_CRASH);
341*35238bceSAndroid Build Coastguard Worker     }
342*35238bceSAndroid Build Coastguard Worker     else
343*35238bceSAndroid Build Coastguard Worker         qpCrashHandler_writeCrashInfo(m_crashHandler, writeCrashToConsole, DE_NULL);
344*35238bceSAndroid Build Coastguard Worker 
345*35238bceSAndroid Build Coastguard Worker     die("Test program crashed");
346*35238bceSAndroid Build Coastguard Worker }
347*35238bceSAndroid Build Coastguard Worker 
348*35238bceSAndroid Build Coastguard Worker } // namespace tcu
349