sl@0
|
1 |
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent - Internal Symbian test code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
#ifndef __EGLTEST_ENDPOINT_ENGINE_H__
|
sl@0
|
24 |
#define __EGLTEST_ENDPOINT_ENGINE_H__
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "localtestbase.h"
|
sl@0
|
27 |
#include "remotetestbase.h"
|
sl@0
|
28 |
#include "egltest_surface.h"
|
sl@0
|
29 |
#include "egltest_endpoint_engine_types.h"
|
sl@0
|
30 |
#include "egltest_endpoint_images.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
#define ENGINE_ASSERT(x) DoEngineAssert((x) != 0, #x, __FILE__, __LINE__)
|
sl@0
|
33 |
|
sl@0
|
34 |
static inline void DoEngineAssert(TInt aX, const char *aXStr,
|
sl@0
|
35 |
const char *aFile, TInt aLine)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
if (!aX)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
RDebug::Printf("EGL_ENDPOINT_TEST_ENGINE ASSERT(%s) failed (value %d) at %s:%d\n",
|
sl@0
|
40 |
aXStr, aX, aFile, aLine);
|
sl@0
|
41 |
User::Panic(_L("ENGINE_ASSERT"), aLine);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
// This could be wrapped in #if/#else to allow us to generate non-unicode text content.
|
sl@0
|
47 |
#define TESTIDS(x) _S(x)
|
sl@0
|
48 |
#define CASETITLE(x) _S(x)
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
// SurfaceType lists.
|
sl@0
|
52 |
// We use macros so that we get an automatic comment as to what the fields are,
|
sl@0
|
53 |
// rather than just listing enums in an array.
|
sl@0
|
54 |
#define SurfaceTypes1(type1) 1, { type1 }
|
sl@0
|
55 |
#define SurfaceTypes2(type1, type2) 2, { type1, type2 }
|
sl@0
|
56 |
#define SurfaceTypes3(type1, type2, type3) 3, { type1, type2, type3 }
|
sl@0
|
57 |
#define SurfaceTypes4(type1, type2, type3, type4) 4, { type1, type2, type3, type4 }
|
sl@0
|
58 |
|
sl@0
|
59 |
// Macro used for building a TTestCases entry.
|
sl@0
|
60 |
#define TestCase(x) { x, sizeof(x) / sizeof(x[0]) }
|
sl@0
|
61 |
|
sl@0
|
62 |
// Forward declare this class.
|
sl@0
|
63 |
class CEgltest_Local_Engine_Exec;
|
sl@0
|
64 |
|
sl@0
|
65 |
// The object passed back from the exec thread to the
|
sl@0
|
66 |
// controller thread.
|
sl@0
|
67 |
class TExecResult
|
sl@0
|
68 |
{
|
sl@0
|
69 |
public:
|
sl@0
|
70 |
TExecResult();
|
sl@0
|
71 |
|
sl@0
|
72 |
//Constructor for sending result info.
|
sl@0
|
73 |
TExecResult(TVerdict aVerdict, TEngineCases aCase);
|
sl@0
|
74 |
|
sl@0
|
75 |
// Constructor for sending result of buffer count paramters.
|
sl@0
|
76 |
TExecResult(TVerdict aBufferCountVerdict, TVerdict aVerdict, TEngineCases aCase);
|
sl@0
|
77 |
|
sl@0
|
78 |
public:
|
sl@0
|
79 |
//Result message.
|
sl@0
|
80 |
TVerdict iVerdict;
|
sl@0
|
81 |
// Checking buffer count.
|
sl@0
|
82 |
TVerdict iBufferCountVerdict;
|
sl@0
|
83 |
// Get Surface parameter reply.
|
sl@0
|
84 |
TSurfaceParamsRemote iSurfaceParams;
|
sl@0
|
85 |
// To check that we are in sync - it should match the request.
|
sl@0
|
86 |
TEngineCases iCase;
|
sl@0
|
87 |
};
|
sl@0
|
88 |
|
sl@0
|
89 |
const TInt KMaxLoadThreads = 4;
|
sl@0
|
90 |
|
sl@0
|
91 |
NONSHARABLE_CLASS(CEgltest_Local_Engine): public CLocalTestStepBase
|
sl@0
|
92 |
{
|
sl@0
|
93 |
private:
|
sl@0
|
94 |
enum TExecState
|
sl@0
|
95 |
{
|
sl@0
|
96 |
EExecStateNone = 0,
|
sl@0
|
97 |
EExecStateRemote,
|
sl@0
|
98 |
EExecStateLocal
|
sl@0
|
99 |
};
|
sl@0
|
100 |
public:
|
sl@0
|
101 |
CEgltest_Local_Engine(const TTestCases *aTestCases, TInt aNumCases);
|
sl@0
|
102 |
virtual ~CEgltest_Local_Engine();
|
sl@0
|
103 |
virtual TVerdict doTestStepL();
|
sl@0
|
104 |
virtual void DoPreambleL();
|
sl@0
|
105 |
virtual void DoPostambleL();
|
sl@0
|
106 |
void SetTestCasesL(const TTestCases * const aTestCases, TInt aNumCases);
|
sl@0
|
107 |
|
sl@0
|
108 |
private:
|
sl@0
|
109 |
void RunTestCase(const TTestCases &aTestCase);
|
sl@0
|
110 |
void RunOneTestCase(const TTestCase& aTestCase, TSurfaceType aSurfType);
|
sl@0
|
111 |
void SendLocalTestCase(const TRemoteTestParams &aParams);
|
sl@0
|
112 |
void RunLocalTestCase(TEngineCases aCase);
|
sl@0
|
113 |
void DoSyncToLocal();
|
sl@0
|
114 |
void GetLocalResult(TExecResult& aResult, TEngineCases aCase);
|
sl@0
|
115 |
void DoMonitorThreadEntry();
|
sl@0
|
116 |
void ForwardPanic(RThread& aThread, RThread& aOtherThread, TRequestStatus &aStatus);
|
sl@0
|
117 |
static TInt MonitorThreadEntry(TAny *aParam);
|
sl@0
|
118 |
void RunControllerLocalAndRemoteL(const TEngineTestCase&, const TRemoteTestParams& params);
|
sl@0
|
119 |
|
sl@0
|
120 |
protected:
|
sl@0
|
121 |
void RunLocalTestCase(const TRemoteTestParams& aMessageIn, TExecResult& aResult);
|
sl@0
|
122 |
TVerdict RunRemoteTestCase(TInt aTestCase, const TRemoteTestParams& aMessageIn);
|
sl@0
|
123 |
void RunSingleCaseL(const TTestCase& aTestCase, TSurfaceType aSurfType);
|
sl@0
|
124 |
void CommonPreambleL();
|
sl@0
|
125 |
CEgltest_Local_Engine();
|
sl@0
|
126 |
// The StartThread and EndThread needs to be overridden in the
|
sl@0
|
127 |
// implementation to provide a good functionality.
|
sl@0
|
128 |
virtual void StartThreadL(TInt aThreadNumber);
|
sl@0
|
129 |
virtual void EndThread(TInt aThreadNumber);
|
sl@0
|
130 |
|
sl@0
|
131 |
protected:
|
sl@0
|
132 |
const TTestCases* iTestCases;
|
sl@0
|
133 |
TInt iNumCases;
|
sl@0
|
134 |
RThread iExecThread;
|
sl@0
|
135 |
RThread iMonitorThread;
|
sl@0
|
136 |
RThread iControllerThread; // Controller thread
|
sl@0
|
137 |
RMsgQueue<TExecResult> iExecResultOutQueue;
|
sl@0
|
138 |
RMsgQueue<TRemoteTestParamsPacket> iExecParamsInQueue;
|
sl@0
|
139 |
TExecState iExecState;
|
sl@0
|
140 |
TBool iLogging;
|
sl@0
|
141 |
};
|
sl@0
|
142 |
|
sl@0
|
143 |
|
sl@0
|
144 |
struct TRemoteTestArgs
|
sl@0
|
145 |
{
|
sl@0
|
146 |
EGLDisplay iDisplay;
|
sl@0
|
147 |
EGLEndpointNOK iEndpoint;
|
sl@0
|
148 |
EGLImageKHR iImage;
|
sl@0
|
149 |
};
|
sl@0
|
150 |
|
sl@0
|
151 |
|
sl@0
|
152 |
struct TAvailableMemory
|
sl@0
|
153 |
{
|
sl@0
|
154 |
TInt iHeapMemAvailable;
|
sl@0
|
155 |
TInt iGpuMemAvailable;
|
sl@0
|
156 |
};
|
sl@0
|
157 |
|
sl@0
|
158 |
// Base class that allows "script" style exectution of testcases.
|
sl@0
|
159 |
NONSHARABLE_CLASS(CEgltest_Remote_Engine): public CRemoteTestStepBase
|
sl@0
|
160 |
{
|
sl@0
|
161 |
public:
|
sl@0
|
162 |
CEgltest_Remote_Engine();
|
sl@0
|
163 |
virtual ~CEgltest_Remote_Engine();
|
sl@0
|
164 |
virtual TRemoteTestVerdict DoStartRemoteTestStepL(const TRemoteTestParams& aParams);
|
sl@0
|
165 |
virtual TRemoteTestVerdict DoEndRemoteTestStepL(const TRemoteTestParams& aParams);
|
sl@0
|
166 |
virtual TRemoteTestVerdict DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aParams);
|
sl@0
|
167 |
private:
|
sl@0
|
168 |
void LogDump(const TEngineTestCase& aCase);
|
sl@0
|
169 |
EGLDisplay GetDisplay(TInt aFlags);
|
sl@0
|
170 |
EGLEndpointNOK GetEndpoint(TInt aIndex, TInt aFlags);
|
sl@0
|
171 |
EGLImageKHR GetImage(TInt aIndex, TInt aFlags);
|
sl@0
|
172 |
EGLenum GetEndpointType(TInt aFlags);
|
sl@0
|
173 |
EGLenum GetSourceType(TInt aFlags);
|
sl@0
|
174 |
const TSurfaceId GetSurfaceId(TInt aFlags, const TSurfaceId& aSurfaceId);
|
sl@0
|
175 |
void CheckReturn(TInt aRetval, const TEngineTestCase& aStreamItem, TInt aFailValue,
|
sl@0
|
176 |
const TText* aFailSymbol, const TText* aFunction);
|
sl@0
|
177 |
void RunCaseL(TInt aTestCase, const TRemoteTestParams &aParams, const TRemoteTestArgs& aArgs);
|
sl@0
|
178 |
void CreateEndpointCaseL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
|
sl@0
|
179 |
void ReleaseImageCaseL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
|
sl@0
|
180 |
void ActivateVgContextL();
|
sl@0
|
181 |
void RequestNotificationL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
|
sl@0
|
182 |
void GetEndpointDirtyAreaL(const TRemoteTestParams& aParams, const TRemoteTestArgs& aArgs);
|
sl@0
|
183 |
void DoCheckRectsL(EGLint *aActualRects, EGLint aRectCount, EGLint aMaxRects,
|
sl@0
|
184 |
TInt aRectsIndex, const TRect aSurfacRect);
|
sl@0
|
185 |
void CheckForMemoryLeaks();
|
sl@0
|
186 |
void CheckForMemoryLeaksFinish();
|
sl@0
|
187 |
|
sl@0
|
188 |
TInt FillGpuMemory();
|
sl@0
|
189 |
TInt CalculateAvailableGPUMemory();
|
sl@0
|
190 |
TInt CalculateAvailableHeapMemory();
|
sl@0
|
191 |
|
sl@0
|
192 |
// Thread entry points for "load" threads.
|
sl@0
|
193 |
static TInt LoadHeapMemory(TAny *);
|
sl@0
|
194 |
void LoadHeapMemoryL();
|
sl@0
|
195 |
static TInt LoadGpuMemory(TAny *);
|
sl@0
|
196 |
void LoadGpuMemoryL();
|
sl@0
|
197 |
|
sl@0
|
198 |
void StartThreadL(TInt aThreadNumber);
|
sl@0
|
199 |
void EndThread(TInt aThreadNumber);
|
sl@0
|
200 |
TThreadFunction GetThreadFunction(TInt aThreadNumber);
|
sl@0
|
201 |
|
sl@0
|
202 |
private:
|
sl@0
|
203 |
EGLEndpointNOK iEndpoints[KMaxEndpoints];
|
sl@0
|
204 |
EGLImageKHR iEglImage[KMaxEndpoints];
|
sl@0
|
205 |
CTestVgEglImage* iVgImage[KMaxEndpoints];
|
sl@0
|
206 |
TRequestStatus iRequestStatus[KMaxEndpoints];
|
sl@0
|
207 |
TRemoteTestVerdict iTestVerdict;
|
sl@0
|
208 |
TBool iLogging;
|
sl@0
|
209 |
CEglWindowSurface *iSurface;
|
sl@0
|
210 |
// when this flag is set, errors discovered during a test-step is logged.
|
sl@0
|
211 |
// This is normally true, but for stress tests [etc], it can be turned
|
sl@0
|
212 |
// off so that when a test is set up to run 1000 times, but only succeeds
|
sl@0
|
213 |
// X times, we don't get "error, something failed", when we really didn't
|
sl@0
|
214 |
// get an error.
|
sl@0
|
215 |
TBool iLogErrors;
|
sl@0
|
216 |
|
sl@0
|
217 |
// Tracking memory available.
|
sl@0
|
218 |
RArray<TAvailableMemory> iMemoryStats;
|
sl@0
|
219 |
|
sl@0
|
220 |
// Variables to keep track of load-threads.
|
sl@0
|
221 |
RThread iLoadThread[KMaxLoadThreads];
|
sl@0
|
222 |
TBool iStopThreadFlag[KMaxLoadThreads];
|
sl@0
|
223 |
|
sl@0
|
224 |
RHeap* iMainThreadHeap;
|
sl@0
|
225 |
PFNEGLQUERYPROFILINGDATANOKPROC ipfnEglQueryProfilingDataNOK;
|
sl@0
|
226 |
};
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
#define CASE(x) case x: caseName=_S(#x); break
|
sl@0
|
230 |
|
sl@0
|
231 |
static inline const TText* EngineCaseName(TEngineCases aCase)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
const TText* caseName = _S("Unknown Engine Case");
|
sl@0
|
234 |
switch (aCase)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
CASE(ECreateEndpointCase);
|
sl@0
|
237 |
CASE(EBeginStreamingCase);
|
sl@0
|
238 |
CASE(EAcquireImageCase);
|
sl@0
|
239 |
CASE(EReleaseImageCase);
|
sl@0
|
240 |
CASE(EEndStreamingCase);
|
sl@0
|
241 |
CASE(EContentUpdateCase);
|
sl@0
|
242 |
CASE(EDestroyEndpointCase);
|
sl@0
|
243 |
CASE(EInitializeCase);
|
sl@0
|
244 |
CASE(ETerminateCase);
|
sl@0
|
245 |
CASE(EGetAttribCase);
|
sl@0
|
246 |
CASE(ESetAttribCase);
|
sl@0
|
247 |
CASE(ECreateSurfaceCase);
|
sl@0
|
248 |
CASE(EDrawContentCase);
|
sl@0
|
249 |
CASE(ECompareImageCase);
|
sl@0
|
250 |
CASE(EWaitForCase);
|
sl@0
|
251 |
CASE(ENotifyWhenCase);
|
sl@0
|
252 |
CASE(ETestVgImageValidCase);
|
sl@0
|
253 |
CASE(EDestroyVgImageCase);
|
sl@0
|
254 |
CASE(EDestroyEglImageCase);
|
sl@0
|
255 |
CASE(ETimeStampCase);
|
sl@0
|
256 |
CASE(ERequestNotificationCase);
|
sl@0
|
257 |
CASE(EWaitForNotificationCase);
|
sl@0
|
258 |
CASE(ECancelNotificationCase);
|
sl@0
|
259 |
CASE(EBreakPointCase);
|
sl@0
|
260 |
CASE(ELogEnableCase);
|
sl@0
|
261 |
CASE(EIllegalCase);
|
sl@0
|
262 |
CASE(EPanicCase);
|
sl@0
|
263 |
CASE(EGetEndpointDirtyAreaCase);
|
sl@0
|
264 |
CASE(ESyncLocalCase);
|
sl@0
|
265 |
CASE(EGetSurfaceParamsCase);
|
sl@0
|
266 |
CASE(EFinishedCase);
|
sl@0
|
267 |
CASE(ECreateVgImageCase);
|
sl@0
|
268 |
CASE(EDestroySurfaceCase);
|
sl@0
|
269 |
CASE(EStartLoadThreadCase);
|
sl@0
|
270 |
CASE(EEndLoadThreadCase);
|
sl@0
|
271 |
CASE(ECheckForMemoryLeaks);
|
sl@0
|
272 |
CASE(ECheckForMemoryLeaksFinish);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
return caseName;
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
#undef CASE
|
sl@0
|
278 |
|
sl@0
|
279 |
|
sl@0
|
280 |
inline void LogDump(CTestExecuteLogger &aLogger, const TEngineTestCase& aCase)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
const TText *caseName = EngineCaseName(aCase.iCase);
|
sl@0
|
283 |
aLogger.LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo,
|
sl@0
|
284 |
_L("Performing subcase %d (%s), with flags=%d, err=%04x endpointidx=%d, image=%d, args=(%d, %d)"),
|
sl@0
|
285 |
aCase.iCase,
|
sl@0
|
286 |
caseName,
|
sl@0
|
287 |
aCase.iFlags,
|
sl@0
|
288 |
aCase.iErrorExpected,
|
sl@0
|
289 |
aCase.iEndpointIndex,
|
sl@0
|
290 |
aCase.iImageIndex,
|
sl@0
|
291 |
aCase.iArg1, aCase.iArg2);
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
|
sl@0
|
295 |
#endif // __EGLTEST_ENDPOINT_ENGINE_H__
|