0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Example CTestStep derived implementation
|
|
15 |
//
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file ParametersStep.cpp
|
|
21 |
@internalTechnology
|
|
22 |
*/
|
|
23 |
#include "parameterstep.h"
|
|
24 |
#include "tcoredumpserversuitedefs.h"
|
|
25 |
#include <e32property.h>
|
|
26 |
#include <crashdatasave.h>
|
|
27 |
#include <e32std.h>
|
|
28 |
#include <coredumpserverapi.h>
|
|
29 |
|
|
30 |
CParametersStep::~CParametersStep()
|
|
31 |
/**
|
|
32 |
* Destructor
|
|
33 |
*/
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
CParametersStep::CParametersStep()
|
|
38 |
/**
|
|
39 |
* Constructor
|
|
40 |
*/
|
|
41 |
{
|
|
42 |
// **MUST** call SetTestStepName in the constructor as the controlling
|
|
43 |
// framework uses the test step name immediately following construction to set
|
|
44 |
// up the step's unique logging ID.
|
|
45 |
SetTestStepName(KParametersStep);
|
|
46 |
}
|
|
47 |
|
|
48 |
TVerdict CParametersStep::doTestStepPreambleL()
|
|
49 |
/**
|
|
50 |
* @return - TVerdict code
|
|
51 |
* Override of base class virtual
|
|
52 |
*/
|
|
53 |
{
|
|
54 |
TInt ret = KErrNone;
|
|
55 |
ret = iSess.Connect();
|
|
56 |
if(ret != KErrNone)
|
|
57 |
{
|
|
58 |
SetTestStepResult( EFail );
|
|
59 |
ERR_PRINTF2(_L("Error %d from iSess->Connect()"), ret);
|
|
60 |
}
|
|
61 |
else
|
|
62 |
{
|
|
63 |
SetTestStepResult(EPass);
|
|
64 |
}
|
|
65 |
|
|
66 |
INFO_PRINTF1(_L("Successfully connected session to the Core Dump Server"));
|
|
67 |
|
|
68 |
ret = iSecSess.Connect(securityServerVersion);
|
|
69 |
if(ret != KErrNone)
|
|
70 |
{
|
|
71 |
SetTestStepResult( EFail );
|
|
72 |
ERR_PRINTF2(_L("Error %d from iSecSess->Connect()"), ret);
|
|
73 |
}
|
|
74 |
else
|
|
75 |
{
|
|
76 |
SetTestStepResult(EPass);
|
|
77 |
}
|
|
78 |
|
|
79 |
INFO_PRINTF1(_L("Successfully connected session to the debug security server"));
|
|
80 |
|
|
81 |
ret = iFs.Connect();
|
|
82 |
if(ret != KErrNone)
|
|
83 |
{
|
|
84 |
SetTestStepResult( EFail );
|
|
85 |
ERR_PRINTF2(_L("Error %d from iFs->Connect()"), ret);
|
|
86 |
}
|
|
87 |
else
|
|
88 |
{
|
|
89 |
SetTestStepResult(EPass);
|
|
90 |
}
|
|
91 |
|
|
92 |
INFO_PRINTF1(_L("Successfully connected session to the file server"));
|
|
93 |
|
|
94 |
return TestStepResult();
|
|
95 |
}
|
|
96 |
|
|
97 |
TVerdict CParametersStep::doTestStepL()
|
|
98 |
/**
|
|
99 |
* @return - TVerdict code
|
|
100 |
* Override of base class pure virtual
|
|
101 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
102 |
* not leave. That being the case, the current test result value will be EPass.
|
|
103 |
*/
|
|
104 |
{
|
|
105 |
if (TestStepResult()==EPass)
|
|
106 |
{
|
|
107 |
TInt ret = KErrNone;
|
|
108 |
|
|
109 |
__UHEAP_MARK;
|
|
110 |
|
|
111 |
TRAP(ret, ClientAppL());
|
|
112 |
if(KErrNone != ret)
|
|
113 |
{
|
|
114 |
SetTestStepResult(EFail);
|
|
115 |
INFO_PRINTF2(_L("Error %d from CParametersStep->ClientAppL()"), ret);
|
|
116 |
}
|
|
117 |
|
|
118 |
//Make sure its dead
|
|
119 |
_LIT(KCrashApp, "crash");
|
|
120 |
KillCrashAppL(KCrashApp);
|
|
121 |
|
|
122 |
__UHEAP_MARKEND;
|
|
123 |
|
|
124 |
}
|
|
125 |
return TestStepResult();
|
|
126 |
}
|
|
127 |
|
|
128 |
void CParametersStep::ClientAppL()
|
|
129 |
/**
|
|
130 |
* @return void
|
|
131 |
* This calls each stage of the test
|
|
132 |
*/
|
|
133 |
{
|
|
134 |
INFO_PRINTF1(_L("Starting CDS Parameters Test Suite") );
|
|
135 |
INFO_PRINTF1(_L("This tests two scenarios: When the main thread crashes and when a child thread crashes"));
|
|
136 |
INFO_PRINTF1(_L("In each case we test all possible CDS config values to make sure that the correct things are happening \n\n"));
|
|
137 |
|
|
138 |
//Here we are testing the post processing conditions when a main thread crashes and when a child thread crashes
|
|
139 |
CrashChildThreadAndTestPostProcL();
|
|
140 |
CrashMainThreadAndTestPostProcL();
|
|
141 |
|
|
142 |
//Now we test the preprocessing values
|
|
143 |
CrashChildThreadAndTestPreProcL();
|
|
144 |
}
|
|
145 |
void CParametersStep::CrashChildThreadAndTestPreProcL()
|
|
146 |
/**
|
|
147 |
* @return void
|
|
148 |
* Tests the pre processing values do the right thing when we crash a child thread
|
|
149 |
*/
|
|
150 |
{
|
|
151 |
if (TestStepResult()==EPass)
|
|
152 |
{
|
|
153 |
INFO_PRINTF1(_L("Testing all pre proccessing options for when child thread crashes"));
|
|
154 |
|
|
155 |
_LIT(KCrashAppParams, "-m1 -d2 -c2"); //Will have one child thread that crashes after 2 sec
|
|
156 |
|
|
157 |
//1 = suspend thread, 2 = suspend process
|
|
158 |
for(TInt preVal = 1; preVal <3; preVal++ )
|
|
159 |
{
|
|
160 |
INFO_PRINTF3(_L("************* New Crash (Main thread) CDS PreProc val = %d Post Proc val = %d ************* "), preVal, 0);
|
|
161 |
//Call crash app
|
|
162 |
GenerateAndHandleCrashL(KCrashAppParams, 0, preVal);
|
|
163 |
TProcessId pid = IsCrashAppAliveL();
|
|
164 |
|
|
165 |
if(preVal == 1)
|
|
166 |
{
|
|
167 |
//Here the child should be frozen and main thread still running
|
|
168 |
if(IsCrashAppMainThreadRunningL())
|
|
169 |
{
|
|
170 |
INFO_PRINTF1(_L("Main thread running as expected"));
|
|
171 |
}
|
|
172 |
else
|
|
173 |
{
|
|
174 |
SetTestStepError(EFail);
|
|
175 |
ERR_PRINTF1(_L("Main thread is expected to be running and it is not"));
|
|
176 |
User::Leave(KErrGeneral);
|
|
177 |
}
|
|
178 |
}
|
|
179 |
else if(preVal == 2)
|
|
180 |
{
|
|
181 |
if(!IsCrashAppMainThreadRunningL())
|
|
182 |
{
|
|
183 |
INFO_PRINTF1(_L("Main thread frozen as expected"));
|
|
184 |
}
|
|
185 |
else
|
|
186 |
{
|
|
187 |
SetTestStepError(EFail);
|
|
188 |
ERR_PRINTF1(_L("Main thread is expected to be frozen and is not")) ;
|
|
189 |
User::Leave(KErrGeneral);
|
|
190 |
}
|
|
191 |
}
|
|
192 |
|
|
193 |
|
|
194 |
//Disconnect the CDS' handle on this exe
|
|
195 |
if(pid)
|
|
196 |
{
|
|
197 |
iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
|
|
198 |
INFO_PRINTF1(_L("Attaching DSS to executable"));
|
|
199 |
User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
|
|
200 |
ResumeProcessL(pid);
|
|
201 |
User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));
|
|
202 |
|
|
203 |
_LIT(KCrashApp, "crash");
|
|
204 |
KillCrashAppL(KCrashApp);
|
|
205 |
User::After(2000000);
|
|
206 |
|
|
207 |
if(IsCrashAppAliveL())
|
|
208 |
{
|
|
209 |
SetTestStepResult( EFail );
|
|
210 |
ERR_PRINTF1(_L("Failed to kill app"));
|
|
211 |
User::Leave(KErrGeneral);
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
|
|
216 |
}
|
|
217 |
}
|
|
218 |
|
|
219 |
}
|
|
220 |
|
|
221 |
void CParametersStep::CrashMainThreadAndTestPostProcL()
|
|
222 |
/**
|
|
223 |
* @return void
|
|
224 |
* Tests the CDS post processing when the main thread of the crash app dies.
|
|
225 |
* In all cases the app should be dead except when we do not resume the process (option 0)
|
|
226 |
*/
|
|
227 |
{
|
|
228 |
if (TestStepResult()==EPass)
|
|
229 |
{
|
|
230 |
TInt cdsPreConfigVal = 2; //Suspend process (this is irrelevant really, we will check this seperately)
|
|
231 |
|
|
232 |
INFO_PRINTF1(_L("Testing all post proccessing options for when main thread crashes (in all cases crash app should be gone)"));
|
|
233 |
INFO_PRINTF1(KPostCrashEventActionPrompt);
|
|
234 |
|
|
235 |
_LIT(KCrashAppParams, "-s -d1 -c2"); //Will have a second thread to main, and main will crash after 1 second
|
|
236 |
|
|
237 |
TInt cdsPostConfigVal = 8;
|
|
238 |
do
|
|
239 |
{
|
|
240 |
//Right shift 1 to cycle 4,2,1,0
|
|
241 |
cdsPostConfigVal>>=1;
|
|
242 |
|
|
243 |
INFO_PRINTF3(_L("************* New Crash (Main thread) CDS PreProc val = %d Post Proc val = %d ************* "), cdsPreConfigVal, cdsPostConfigVal);
|
|
244 |
|
|
245 |
//Call crash app and handling with range of post processing values (0,1,2,4 inc)
|
|
246 |
GenerateAndHandleCrashL(KCrashAppParams, cdsPostConfigVal, cdsPreConfigVal);
|
|
247 |
//Let the process be resumed or killed or whatever
|
|
248 |
User::After( 4500000 );
|
|
249 |
|
|
250 |
//Now we validate the post processing values
|
|
251 |
TProcessId pid = IsCrashAppAliveL();
|
|
252 |
if(pid)
|
|
253 |
{
|
|
254 |
//If post proc = 0 (suspend) it should still be alive. we need to resume it all so we can kill it
|
|
255 |
if(cdsPostConfigVal == 0)
|
|
256 |
{
|
|
257 |
INFO_PRINTF1(_L("CDS configured not to resume process and it is still alive as expected"));
|
|
258 |
|
|
259 |
//Disconnect the CDS' handle on this exe
|
|
260 |
iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
|
|
261 |
INFO_PRINTF1(_L("Attaching DSS to executable"));
|
|
262 |
User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
|
|
263 |
ResumeProcessL(pid);
|
|
264 |
User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));
|
|
265 |
}
|
|
266 |
else
|
|
267 |
{
|
|
268 |
RDebug::Printf("Error is here ****************");
|
|
269 |
SetTestStepError(EFail);
|
|
270 |
ERR_PRINTF2(_L("Expected crash app to be dead and it wasn't. Crash was in main thread and CDS post processing was configured at %d"), cdsPostConfigVal);
|
|
271 |
User::Leave(KErrGeneral);
|
|
272 |
}
|
|
273 |
}
|
|
274 |
else if(cdsPostConfigVal ==0)
|
|
275 |
{
|
|
276 |
SetTestStepError(EFail);
|
|
277 |
ERR_PRINTF2(_L("Expected crash app to be alive and it wasn't. Crash was in main thread and CDS post processing was configured at %d"), cdsPostConfigVal);
|
|
278 |
User::Leave(KErrGeneral);
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
INFO_PRINTF2(_L("Crash app died as expected with post proc param %d"), cdsPostConfigVal);
|
|
283 |
}
|
|
284 |
|
|
285 |
_LIT(KCrashApp, "crash");
|
|
286 |
KillCrashAppL(KCrashApp);
|
|
287 |
User::After(3000000 );
|
|
288 |
|
|
289 |
if(IsCrashAppAliveL())
|
|
290 |
{
|
|
291 |
SetTestStepResult( EFail );
|
|
292 |
ERR_PRINTF1(_L("Failed to kill app"));
|
|
293 |
User::Leave(KErrGeneral);
|
|
294 |
}
|
|
295 |
}
|
|
296 |
while(cdsPostConfigVal > 0);
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
void CParametersStep::CrashChildThreadAndTestPostProcL()
|
|
301 |
/**
|
|
302 |
* @return void
|
|
303 |
* Tests the CDS post processing when the child thread of the crash app dies. The pre processing
|
|
304 |
* step is suspend process
|
|
305 |
*/
|
|
306 |
{
|
|
307 |
if (TestStepResult()==EPass)
|
|
308 |
{
|
|
309 |
TInt cdsPreConfigVal = 2; //Suspend process (this is irrelevant really, we will check this seperately)
|
|
310 |
|
|
311 |
INFO_PRINTF1(_L("Testing all post proccessing options for when main thread crashes (in all cases crash app should be gone)"));
|
|
312 |
INFO_PRINTF1(KPostCrashEventActionPrompt);
|
|
313 |
|
|
314 |
_LIT(KCrashAppParams, "-m1 -d1 -c2"); //Will have one child thread that crashes after 1 sec
|
|
315 |
|
|
316 |
TInt cdsPostConfigVal = 8;
|
|
317 |
do
|
|
318 |
{
|
|
319 |
//Right shift 1 to cycle 4,2,1,0
|
|
320 |
cdsPostConfigVal>>=1;
|
|
321 |
|
|
322 |
INFO_PRINTF3(_L("************* New Crash (Child thread) CDS PreProc val = %d Post Proc val = %d ************* "),cdsPreConfigVal, cdsPostConfigVal);
|
|
323 |
|
|
324 |
//Call crash app and handling with range of post processing values (0,1,2,4 inc)
|
|
325 |
GenerateAndHandleCrashL(KCrashAppParams, cdsPostConfigVal, cdsPreConfigVal);
|
|
326 |
//Wait for crashapp to be resumed or killed or whatever
|
|
327 |
User::After( 1000000 );
|
|
328 |
|
|
329 |
TProcessId pid = IsCrashAppAliveL();
|
|
330 |
|
|
331 |
if(cdsPostConfigVal == 0)//do nothing
|
|
332 |
{
|
|
333 |
//In this case the whole process is suspended
|
|
334 |
if(pid && !IsCrashAppMainThreadRunningL())
|
|
335 |
{
|
|
336 |
INFO_PRINTF1(_L("Crash app alive and main thread suspended as expected"));
|
|
337 |
}
|
|
338 |
else
|
|
339 |
{
|
|
340 |
SetTestStepResult( EFail );
|
|
341 |
ERR_PRINTF1(_L("Crash app was dead - not expected"));
|
|
342 |
User::Leave(KErrGeneral);
|
|
343 |
}
|
|
344 |
}
|
|
345 |
else if(cdsPostConfigVal == 1)//resume thread
|
|
346 |
{
|
|
347 |
//Only thread is resumed, not whole process
|
|
348 |
if(pid && !IsCrashAppMainThreadRunningL())
|
|
349 |
{
|
|
350 |
INFO_PRINTF1(_L("Crash app alive and main thread suspended as expected"));
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
SetTestStepResult( EFail );
|
|
355 |
ERR_PRINTF1(_L("Crash app was dead - not expected"));
|
|
356 |
User::Leave(KErrGeneral);
|
|
357 |
}
|
|
358 |
}
|
|
359 |
else if(cdsPostConfigVal == 2)//resume proc
|
|
360 |
{
|
|
361 |
//Only thread is resumed, not whole process
|
|
362 |
if(pid && IsCrashAppMainThreadRunningL())
|
|
363 |
{
|
|
364 |
INFO_PRINTF1(_L("Crash app alive and main thread running as expected"));
|
|
365 |
}
|
|
366 |
else
|
|
367 |
{
|
|
368 |
SetTestStepResult( EFail );
|
|
369 |
ERR_PRINTF1(_L("Crash app main thread not running - not expected"));
|
|
370 |
User::Leave(KErrGeneral);
|
|
371 |
}
|
|
372 |
}
|
|
373 |
else if(cdsPostConfigVal == 4)//kill proc
|
|
374 |
{
|
|
375 |
if(pid)
|
|
376 |
{
|
|
377 |
SetTestStepResult( EFail );
|
|
378 |
ERR_PRINTF1(_L("Process is still alive but should be dead"));
|
|
379 |
User::Leave(KErrGeneral);
|
|
380 |
}
|
|
381 |
else
|
|
382 |
{
|
|
383 |
INFO_PRINTF1(_L("Process dead as expected"));
|
|
384 |
}
|
|
385 |
}
|
|
386 |
|
|
387 |
//Kill the process if its still running
|
|
388 |
if(pid)
|
|
389 |
{
|
|
390 |
|
|
391 |
//Disconnect the CDS' handle on this exe
|
|
392 |
iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, EFalse);
|
|
393 |
INFO_PRINTF1(_L("Attaching DSS to executable"));
|
|
394 |
User::LeaveIfError(iSecSess.AttachExecutable(KCrashAppFileName, EFalse));
|
|
395 |
ResumeProcessL(pid);
|
|
396 |
User::LeaveIfError(iSecSess.DetachExecutable(KCrashAppFileName));
|
|
397 |
|
|
398 |
_LIT(KCrashApp, "crash");
|
|
399 |
KillCrashAppL(KCrashApp);
|
|
400 |
User::After(2000000);
|
|
401 |
|
|
402 |
if(IsCrashAppAliveL())
|
|
403 |
{
|
|
404 |
SetTestStepResult( EFail );
|
|
405 |
ERR_PRINTF1(_L("Failed to kill app"));
|
|
406 |
User::Leave(KErrGeneral);
|
|
407 |
}
|
|
408 |
}
|
|
409 |
}
|
|
410 |
while(cdsPostConfigVal > 0);
|
|
411 |
}
|
|
412 |
|
|
413 |
}
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
void CParametersStep::ResumeProcessL(TUint64 aPid)
|
|
418 |
/**
|
|
419 |
Called to resume all the threads of the specified process. CCoreCrashHandler executes it as a post-processing action.
|
|
420 |
@param aPid ID of process to be resumed
|
|
421 |
@leave err one of the system wide error codes
|
|
422 |
iSecSess must be attached to the executable in question
|
|
423 |
*/
|
|
424 |
{
|
|
425 |
INFO_PRINTF1(_L("Resuming process"));
|
|
426 |
|
|
427 |
//Get the threads we wish to resume
|
|
428 |
RThreadPointerList threadList;
|
|
429 |
TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupThreadList, (TAny*)&threadList);
|
|
430 |
CleanupStack::PushL(cleanupProcesses);
|
|
431 |
|
|
432 |
iSess.GetThreadsL(threadList, aPid);
|
|
433 |
|
|
434 |
TInt err = KErrNone;
|
|
435 |
//first resume child threads
|
|
436 |
TInt looperr = KErrNone;
|
|
437 |
for(TInt j = 1; j < threadList.Count(); j++)
|
|
438 |
{
|
|
439 |
looperr = iSecSess.ResumeThread( threadList[j]->Id() );
|
|
440 |
if( (looperr != KErrNone) && (looperr != KErrNotFound) )
|
|
441 |
{
|
|
442 |
err = looperr;
|
|
443 |
ERR_PRINTF2(_L("CParametersStep::ResumeProcessL - unable to resume thread! err:%d"), err);
|
|
444 |
}
|
|
445 |
}
|
|
446 |
|
|
447 |
looperr = KErrNone;
|
|
448 |
//then resume the main thread
|
|
449 |
if(threadList.Count())
|
|
450 |
{
|
|
451 |
INFO_PRINTF2(_L("resuming main thread:%Ld\n"), threadList[0]->Id());
|
|
452 |
looperr = iSecSess.ResumeThread(threadList[0]->Id());
|
|
453 |
}
|
|
454 |
|
|
455 |
if( (looperr != KErrNone) && (looperr != KErrNotFound) )
|
|
456 |
{
|
|
457 |
err = looperr;
|
|
458 |
ERR_PRINTF2(_L("CCoreDumpSession::ResumeProcessL - unable to resume main thread! err:%d"), err);
|
|
459 |
}
|
|
460 |
CleanupStack::PopAndDestroy(&threadList);
|
|
461 |
User::LeaveIfError(err);
|
|
462 |
}
|
|
463 |
|
|
464 |
TProcessId CParametersStep::IsCrashAppAliveL()
|
|
465 |
/**
|
|
466 |
* @return TInt PID of process if alive, null if not
|
|
467 |
* Scans the process list looking for crash app. Returns true if its found
|
|
468 |
*/
|
|
469 |
{
|
|
470 |
TProcessId pid = NULL;
|
|
471 |
|
|
472 |
RProcessPointerList procList;
|
|
473 |
TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
|
|
474 |
CleanupStack::PushL(cleanupProcesses);
|
|
475 |
|
|
476 |
iSess.GetProcessesL( procList );
|
|
477 |
|
|
478 |
for(TInt i=0; i < procList.Count(); i++ )
|
|
479 |
{
|
|
480 |
if(procList[i]->Name() == KCrashAppFileName)
|
|
481 |
{
|
|
482 |
INFO_PRINTF1(_L("Found the crash app"));
|
|
483 |
pid = procList[i]->Id();
|
|
484 |
}
|
|
485 |
}
|
|
486 |
CleanupStack::PopAndDestroy(&procList);
|
|
487 |
|
|
488 |
return pid;
|
|
489 |
|
|
490 |
}
|
|
491 |
|
|
492 |
void CParametersStep::KillCrashAppL(const TDesC& aProcessName)
|
|
493 |
/**
|
|
494 |
* @return void
|
|
495 |
* Kills specified process
|
|
496 |
*/
|
|
497 |
{
|
|
498 |
_LIT(KAsterisk, "*");
|
|
499 |
HBufC* buf = HBufC::NewLC(1+aProcessName.Length());
|
|
500 |
TPtr bufPtr = buf->Des();
|
|
501 |
bufPtr.Append(aProcessName);
|
|
502 |
bufPtr.Append(KAsterisk);
|
|
503 |
|
|
504 |
TFindProcess finder(bufPtr);
|
|
505 |
TFullName fullname;
|
|
506 |
RProcess process;
|
|
507 |
while(finder.Next(fullname) == KErrNone)
|
|
508 |
{
|
|
509 |
TInt err = process.Open(finder);
|
|
510 |
if(err == KErrNone)
|
|
511 |
{
|
|
512 |
INFO_PRINTF1(_L("Killing process"));
|
|
513 |
INFO_PRINTF1(process.Name());
|
|
514 |
process.Kill(KErrNone);
|
|
515 |
process.Close();
|
|
516 |
}
|
|
517 |
else
|
|
518 |
{
|
|
519 |
ERR_PRINTF2(_L("Failed to kill process. Error = %d "), err);
|
|
520 |
}
|
|
521 |
}
|
|
522 |
CleanupStack::PopAndDestroy(buf);
|
|
523 |
}
|
|
524 |
|
|
525 |
void CParametersStep::GenerateAndHandleCrashL(const TDesC& aCrashAppParameters,
|
|
526 |
const TUint& aCDSPostProcParam,
|
|
527 |
const TUint& aCDSPreProcParam)
|
|
528 |
/**
|
|
529 |
* @return void
|
|
530 |
* This will:
|
|
531 |
* 1. Load Formatter
|
|
532 |
* 2. Load writer
|
|
533 |
* 3. Configure CDS to post process after crash
|
|
534 |
* 4. Observe the crash process
|
|
535 |
* 5. Start the crash process
|
|
536 |
* 6. Monitor the crash progress until its dead
|
|
537 |
*/
|
|
538 |
{
|
|
539 |
//Start the process that we intend to crash....
|
|
540 |
RProcess crashProcess;
|
|
541 |
CleanupClosePushL(crashProcess);
|
|
542 |
|
|
543 |
TInt ret = crashProcess.Create( KCrashAppFileName, aCrashAppParameters);
|
|
544 |
if(ret != KErrNone)
|
|
545 |
{
|
|
546 |
ERR_PRINTF2(_L("Error %d from RProcess .Create(z:\\sys\\bin\\crashapp.exe)/n"), ret);
|
|
547 |
SetTestStepResult(EFail);
|
|
548 |
User::Leave(ret);
|
|
549 |
}
|
|
550 |
|
|
551 |
//Now we configure CDS and writer
|
|
552 |
INFO_PRINTF2(_L("Configuring pre processing of CDS with %d"), aCDSPreProcParam);
|
|
553 |
DoConfigureL(EPreCrashEventAction, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KNullDesC,
|
|
554 |
1, KNullDesC, aCDSPreProcParam, KNullDesC);
|
|
555 |
|
|
556 |
INFO_PRINTF2(_L("Configuring post processing of CDS with %d"), aCDSPostProcParam);
|
|
557 |
DoConfigureL(EPostCrashEventAction, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KNullDesC,
|
|
558 |
1, KNullDesC, aCDSPostProcParam, KNullDesC );
|
|
559 |
|
|
560 |
INFO_PRINTF1(_L("Observing process"));
|
|
561 |
iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue);
|
|
562 |
|
|
563 |
crashProcess.Resume();
|
|
564 |
CleanupStack::PopAndDestroy(&crashProcess);
|
|
565 |
|
|
566 |
//This waits for the formatting to complete
|
|
567 |
MonitorProgressL();
|
|
568 |
}
|
|
569 |
|
|
570 |
void CParametersStep::MonitorProgressL()
|
|
571 |
/**
|
|
572 |
* @return void
|
|
573 |
* This method monitors the RProperty for the crash progress. There are several states of this but we are
|
|
574 |
* only interested in the start and finish of these properties
|
|
575 |
*/
|
|
576 |
{
|
|
577 |
RProperty crashProgress;
|
|
578 |
User::LeaveIfError(crashProgress.Attach(KCoreDumpServUid, ECrashProgress));
|
|
579 |
|
|
580 |
TBuf<50> crashProg;
|
|
581 |
|
|
582 |
TRequestStatus status;
|
|
583 |
crashProgress.Subscribe(status);
|
|
584 |
|
|
585 |
INFO_PRINTF1(_L("CDS has started processing"));
|
|
586 |
//Now we wait until its finished
|
|
587 |
do
|
|
588 |
{
|
|
589 |
User::WaitForRequest(status);
|
|
590 |
crashProgress.Subscribe(status);
|
|
591 |
|
|
592 |
User::LeaveIfError(crashProgress.Get(crashProg ));
|
|
593 |
LOG_MSG("Found property and it was:");
|
|
594 |
}
|
|
595 |
while(crashProg != KEndOfProcessing);
|
|
596 |
|
|
597 |
INFO_PRINTF1(_L("CDS has finished processing"));
|
|
598 |
|
|
599 |
}
|
|
600 |
|
|
601 |
TInt CParametersStep::GetNumberOfProccessesL()
|
|
602 |
/**
|
|
603 |
* @return TInt
|
|
604 |
* Utility function to get the number of proccesses running
|
|
605 |
*/
|
|
606 |
{
|
|
607 |
|
|
608 |
RProcessPointerList procList;
|
|
609 |
TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupProcessList, (TAny*)&procList);
|
|
610 |
CleanupStack::PushL(cleanupProcesses);
|
|
611 |
|
|
612 |
iSess.GetProcessesL(procList);
|
|
613 |
TInt numProcs = procList.Count();
|
|
614 |
|
|
615 |
CleanupStack::PopAndDestroy();
|
|
616 |
|
|
617 |
return numProcs;
|
|
618 |
|
|
619 |
}
|
|
620 |
|
|
621 |
TInt CParametersStep::GetNumberThreadsL()
|
|
622 |
/**
|
|
623 |
* @return TInt
|
|
624 |
* Utility function to get the number of proccesses running
|
|
625 |
*/
|
|
626 |
{
|
|
627 |
RThreadPointerList threadList;
|
|
628 |
TCleanupItem cleanupProcesses(CTe_coredumpserverSuite::CleanupThreadList, (TAny*)&threadList);
|
|
629 |
CleanupStack::PushL(cleanupProcesses);
|
|
630 |
|
|
631 |
iSess.GetThreadsL(threadList);
|
|
632 |
TInt numThreads = threadList.Count();
|
|
633 |
|
|
634 |
CleanupStack::PopAndDestroy();
|
|
635 |
|
|
636 |
return numThreads;
|
|
637 |
}
|
|
638 |
|
|
639 |
void CParametersStep::DoConfigureL(const TUint32& aIndex,
|
|
640 |
const TUint32& aUID,
|
|
641 |
const COptionConfig::TParameterSource& aSource,
|
|
642 |
const COptionConfig::TOptionType& aType,
|
|
643 |
const TDesC& aPrompt,
|
|
644 |
const TUint32& aNumOptions,
|
|
645 |
const TDesC& aOptions,
|
|
646 |
const TInt32& aVal,
|
|
647 |
const TDesC& aStrValue )
|
|
648 |
/**
|
|
649 |
* @return void
|
|
650 |
* @param aIndex Internal index to the component that owns the object
|
|
651 |
* @param aUID UID of the component that owns the object
|
|
652 |
* @param aSource Type of component that owns the object
|
|
653 |
* @param aType Type of parameter
|
|
654 |
* @param aPrompt Prompt to present to user
|
|
655 |
* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
|
|
656 |
* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
|
|
657 |
* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
|
|
658 |
* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
|
|
659 |
*/
|
|
660 |
{
|
|
661 |
COptionConfig * config;
|
|
662 |
|
|
663 |
config = COptionConfig::NewL( aIndex,
|
|
664 |
aUID,
|
|
665 |
aSource,
|
|
666 |
aType,
|
|
667 |
aPrompt,
|
|
668 |
aNumOptions,
|
|
669 |
aOptions,
|
|
670 |
aVal,
|
|
671 |
aStrValue);
|
|
672 |
|
|
673 |
CleanupStack::PushL(config);
|
|
674 |
|
|
675 |
//Configure now...
|
|
676 |
TRAPD(ret, iSess.SetConfigParameterL(*config) );
|
|
677 |
if(ret != KErrNone)
|
|
678 |
{
|
|
679 |
ERR_PRINTF2(_L("Error %d changing param"), ret );
|
|
680 |
SetTestStepResult(EFail);
|
|
681 |
User::Leave(ret);
|
|
682 |
}
|
|
683 |
|
|
684 |
CleanupStack::PopAndDestroy(config);
|
|
685 |
}
|
|
686 |
|
|
687 |
TBool CParametersStep::IsCrashAppMainThreadRunningL()
|
|
688 |
/**
|
|
689 |
* Reads the main threads property to make sure its being updated
|
|
690 |
*/
|
|
691 |
{
|
|
692 |
TInt mainThreadCounter1 = 0;
|
|
693 |
TInt mainThreadCounter2 = 0;
|
|
694 |
User::LeaveIfError(RProperty::Get(KCrashAppUid, 0, mainThreadCounter1));
|
|
695 |
User::After(1500000);
|
|
696 |
User::LeaveIfError(RProperty::Get(KCrashAppUid, 0, mainThreadCounter2));
|
|
697 |
return (mainThreadCounter2 > mainThreadCounter1);
|
|
698 |
}
|
|
699 |
|
|
700 |
TVerdict CParametersStep::doTestStepPostambleL()
|
|
701 |
/**
|
|
702 |
* @return - TVerdict code
|
|
703 |
* Override of base class virtual
|
|
704 |
*/
|
|
705 |
{
|
|
706 |
iSess.Disconnect();
|
|
707 |
iSecSess.Close();
|
|
708 |
iFs.Close();
|
|
709 |
User::After(5000000); //ensure we give enough time for session to close
|
|
710 |
return TestStepResult();
|
|
711 |
}
|