xref: /aosp_15_r20/external/deqp/framework/common/tcuApp.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _TCUAPP_HPP
2 #define _TCUAPP_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
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 Tester application.
24  *
25  * Platform port (see tcuPlatform.hpp) must create App and issue calls to
26  * App::iterate() until it signals that test execution is completed.
27  *//*--------------------------------------------------------------------*/
28 
29 #include "tcuDefs.hpp"
30 #include "qpWatchDog.h"
31 #include "qpCrashHandler.h"
32 #include "deMutex.hpp"
33 
34 namespace tcu
35 {
36 
37 class Archive;
38 class Platform;
39 class TestContext;
40 class TestSessionExecutor;
41 class CommandLine;
42 class TestLog;
43 class TestPackageRoot;
44 class TestRunStatus;
45 
46 enum
47 {
48     WATCHDOG_TOTAL_TIME_LIMIT_SECS    = 400,
49     WATCHDOG_INTERVAL_TIME_LIMIT_SECS = 30
50 };
51 
52 /*--------------------------------------------------------------------*//*!
53  * \brief Test application
54  *
55  * Test application encapsulates full test execution logic. Platform port
56  * must create App object and repeately call iterate() until it returns
57  * false.
58  *
59  * On systems where main loop is not in control of application (such as
60  * Android or iOS) iterate() should be called in application update/draw
61  * callback.
62  *
63  * App is responsible of setting up crash handler (qpCrashHandler) and
64  * watchdog (qpWatchDog).
65  *
66  * See tcuMain.cpp for an example on how to implement application stub.
67  *//*--------------------------------------------------------------------*/
68 class App
69 {
70 public:
71     App(Platform &platform, Archive &archive, TestLog &log, const CommandLine &cmdLine);
72     virtual ~App(void);
73 
74     bool iterate(void);
75     const TestRunStatus &getResult(void) const;
76 
77 protected:
78     void cleanup(void);
79 
80     void onWatchdogTimeout(qpTimeoutReason reason);
81     void onCrash(void);
82 
83     static void onWatchdogTimeout(qpWatchDog *watchDog, void *userPtr, qpTimeoutReason reason);
84     static void onCrash(qpCrashHandler *crashHandler, void *userPtr);
85 
86     Platform &m_platform;
87     qpWatchDog *m_watchDog;
88     qpCrashHandler *m_crashHandler;
89     de::Mutex m_crashLock;
90     bool m_crashed;
91 
92     TestContext *m_testCtx;
93     TestPackageRoot *m_testRoot;
94     TestSessionExecutor *m_testExecutor;
95 };
96 
97 } // namespace tcu
98 
99 #endif // _TCUAPP_HPP
100