|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: daemonmt class member functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <Stiftestinterface.h> |
|
22 #include "daemonmt.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // Cdaemonmt::Cdaemonmt |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 Cdaemonmt::Cdaemonmt() |
|
34 { |
|
35 |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // Cdaemonmt::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // |
|
42 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created |
|
43 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger |
|
44 // allocates memory from heap and therefore causes error situations with OOM |
|
45 // testing. For more information about STIF Logger construction, see STIF Users |
|
46 // Guide. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void Cdaemonmt::ConstructL() |
|
50 { |
|
51 iLog = CStifLogger::NewL( KdaemonmtLogPath, |
|
52 KdaemonmtLogFile); |
|
53 |
|
54 // Sample how to use logging |
|
55 _LIT( KLogStart, "daemonmt logging starts!" ); |
|
56 iLog->Log( KLogStart ); |
|
57 |
|
58 iScheduler = new (ELeave) CActiveScheduler; |
|
59 CActiveScheduler::Install( iScheduler ); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // Cdaemonmt::NewL |
|
64 // Two-phased constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 Cdaemonmt* Cdaemonmt::NewL() |
|
68 { |
|
69 Cdaemonmt* self = new (ELeave) Cdaemonmt; |
|
70 |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop(); |
|
74 |
|
75 return self; |
|
76 |
|
77 } |
|
78 |
|
79 // Destructor |
|
80 Cdaemonmt::~Cdaemonmt() |
|
81 { |
|
82 iProperty.Close(); |
|
83 delete iLog; |
|
84 if( iBtSettings ) |
|
85 { |
|
86 delete iBtSettings; |
|
87 } |
|
88 delete iScheduler; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // Cdaemonmt::InitL |
|
93 // InitL is used to initialize the Test Module. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TInt Cdaemonmt::InitL( |
|
97 TFileName& /*aIniFile*/, |
|
98 TBool /*aFirstTime*/ ) |
|
99 { |
|
100 return KErrNone; |
|
101 // start LocalConnectivityDaemon.exe |
|
102 //return StartDaemon(); |
|
103 |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // Cdaemonmt::GetTestCasesL |
|
108 // GetTestCases is used to inquire test cases from the Test Module. Test |
|
109 // cases are stored to array of test cases. The Test Framework will be |
|
110 // the owner of the data in the RPointerArray after GetTestCases return |
|
111 // and it does the memory deallocation. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TInt Cdaemonmt::GetTestCasesL( |
|
115 const TFileName& /*aConfig*/, |
|
116 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
117 { |
|
118 |
|
119 // Loop through all test cases and create new |
|
120 // TTestCaseInfo items and append items to aTestCase array |
|
121 for( TInt i = 0; Case(i).iMethod != NULL; i++ ) |
|
122 { |
|
123 |
|
124 // Allocate new TTestCaseInfo from heap for a testcase definition. |
|
125 TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); |
|
126 |
|
127 // PushL TTestCaseInfo to CleanupStack. |
|
128 CleanupStack::PushL( newCase ); |
|
129 |
|
130 // Set number for the testcase. |
|
131 // When the testcase is run, this comes as a parameter to RunTestCaseL. |
|
132 newCase->iCaseNumber = i; |
|
133 |
|
134 // Set title for the test case. This is shown in UI to user. |
|
135 newCase->iTitle.Copy( Case(i).iCaseName ); |
|
136 |
|
137 // Append TTestCaseInfo to the testcase array. After appended |
|
138 // successfully the TTestCaseInfo object is owned (and freed) |
|
139 // by the TestServer. |
|
140 User::LeaveIfError(aTestCases.Append ( newCase ) ); |
|
141 |
|
142 // Pop TTestCaseInfo from the CleanupStack. |
|
143 CleanupStack::Pop( newCase ); |
|
144 |
|
145 } |
|
146 |
|
147 return KErrNone; |
|
148 |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // Cdaemonmt::RunTestCaseL |
|
153 // RunTestCaseL is used to run an individual test case specified |
|
154 // by aTestCase. Test cases that can be run may be requested from |
|
155 // Test Module by GetTestCases method before calling RunTestCase. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TInt Cdaemonmt::RunTestCaseL( |
|
159 const TInt aCaseNumber, |
|
160 const TFileName& /*aConfig*/, |
|
161 TTestResult& aResult ) |
|
162 { |
|
163 |
|
164 // Return value |
|
165 TInt execStatus = KErrNone; |
|
166 |
|
167 // Get the pointer to test case function |
|
168 TCaseInfo tmp = Case ( aCaseNumber ); |
|
169 |
|
170 _LIT( KLogStartTC, "Starting testcase [%S]" ); |
|
171 iLog->Log( KLogStartTC, &tmp.iCaseName); |
|
172 |
|
173 // Check that case number was valid |
|
174 if ( tmp.iMethod != NULL ) |
|
175 { |
|
176 // Valid case was found, call it via function pointer |
|
177 iMethod = tmp.iMethod; |
|
178 execStatus = ( this->*iMethod )( aResult ); |
|
179 } |
|
180 else |
|
181 { |
|
182 // Valid case was not found, return error. |
|
183 execStatus = KErrNotFound; |
|
184 } |
|
185 |
|
186 // Return case execution status (not the result of the case execution) |
|
187 return execStatus; |
|
188 |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // Cdaemonmt::OOMTestQueryL |
|
193 // Used to check if a particular test case should be run in OOM conditions and |
|
194 // which memory allocations should fail. |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TBool Cdaemonmt::OOMTestQueryL( |
|
198 const TFileName& /* aTestCaseFile */, |
|
199 const TInt aCaseNumber, |
|
200 TOOMFailureType& /* aFailureType */, |
|
201 TInt& aFirstMemFailure, |
|
202 TInt& aLastMemFailure ) |
|
203 { |
|
204 _LIT( KLogOOMTestQueryL, "Cdaemonmt::OOMTestQueryL" ); |
|
205 iLog->Log( KLogOOMTestQueryL ); |
|
206 |
|
207 aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation; |
|
208 aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; |
|
209 |
|
210 return Case( aCaseNumber ).iIsOOMTest; |
|
211 |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // Cdaemonmt::OOMTestInitializeL |
|
216 // Used to perform the test environment setup for a particular OOM test case. |
|
217 // Test Modules may use the initialization file to read parameters for Test |
|
218 // Module initialization but they can also have their own configure file or |
|
219 // some other routine to initialize themselves. |
|
220 // |
|
221 // NOTE: User may add implementation for OOM test environment initialization. |
|
222 // Usually no implementation is required. |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void Cdaemonmt::OOMTestInitializeL( |
|
226 const TFileName& /* aTestCaseFile */, |
|
227 const TInt /* aCaseNumber */ ) |
|
228 { |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // Cdaemonmt::OOMHandleWarningL |
|
233 // In some cases the heap memory allocation should be skipped, either due to |
|
234 // problems in the OS code or components used by the code being tested, or even |
|
235 // inside the tested components which are implemented this way on purpose (by |
|
236 // design), so it is important to give the tester a way to bypass allocation |
|
237 // failures. |
|
238 // |
|
239 // NOTE: User may add implementation for OOM test warning handling. Usually no |
|
240 // implementation is required. |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void Cdaemonmt::OOMHandleWarningL( |
|
244 const TFileName& /* aTestCaseFile */, |
|
245 const TInt /* aCaseNumber */, |
|
246 TInt& /* aFailNextValue */ ) |
|
247 { |
|
248 } |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // Cdaemonmt::OOMTestFinalizeL |
|
252 // Used to perform the test environment cleanup for a particular OOM test case. |
|
253 // |
|
254 // NOTE: User may add implementation for OOM test environment finalization. |
|
255 // Usually no implementation is required. |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void Cdaemonmt::OOMTestFinalizeL( |
|
259 const TFileName& /* aTestCaseFile */, |
|
260 const TInt /* aCaseNumber */ ) |
|
261 { |
|
262 } |
|
263 |
|
264 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // LibEntryL is a polymorphic Dll entry point |
|
268 // Returns: CTestModuleBase*: Pointer to Test Module object |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 EXPORT_C CTestModuleBase* LibEntryL() |
|
272 { |
|
273 return Cdaemonmt::NewL(); |
|
274 |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // SetRequirements handles test module parameters(implements evolution |
|
279 // version 1 for test module's heap and stack sizes configuring). |
|
280 // Returns: TInt: Symbian error code. |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, |
|
284 TUint32& /*aParameterValid*/ ) |
|
285 { |
|
286 |
|
287 /* --------------------------------- NOTE --------------------------------- |
|
288 USER PANICS occurs in test thread creation when: |
|
289 1) "The panic occurs when the value of the stack size is negative." |
|
290 2) "The panic occurs if the minimum heap size specified is less |
|
291 than KMinHeapSize". |
|
292 KMinHeapSize: "Functions that require a new heap to be allocated will |
|
293 either panic, or will reset the required heap size to this value if |
|
294 a smaller heap size is specified". |
|
295 3) "The panic occurs if the minimum heap size specified is greater than |
|
296 the maximum size to which the heap can grow". |
|
297 Other: |
|
298 1) Make sure that your hardware or Symbian OS is supporting given sizes. |
|
299 e.g. Hardware might support only sizes that are divisible by four. |
|
300 ------------------------------- NOTE end ------------------------------- */ |
|
301 |
|
302 // Normally STIF uses default heap and stack sizes for test thread, see: |
|
303 // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. |
|
304 // If needed heap and stack sizes can be configured here by user. Remove |
|
305 // comments and define sizes. |
|
306 |
|
307 /* |
|
308 aParameterValid = KStifTestModuleParameterChanged; |
|
309 |
|
310 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
311 // Stack size |
|
312 param->iTestThreadStackSize= 16384; // 16K stack |
|
313 // Heap sizes |
|
314 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
315 param->iTestThreadMaxHeap = 1048576;// 1M heap max |
|
316 |
|
317 aTestModuleParam = param; |
|
318 */ |
|
319 return KErrNone; |
|
320 |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // E32Dll is a DLL entry point function |
|
325 // Returns: KErrNone: No error |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 #ifndef EKA2 // Hide Dll entry point to EKA2 |
|
329 GLDEF_C TInt E32Dll( |
|
330 TDllReason /*aReason*/) // Reason |
|
331 { |
|
332 return(KErrNone); |
|
333 |
|
334 } |
|
335 #endif // EKA2 |
|
336 |
|
337 // End of File |