0
|
1 |
// Copyright (c) 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 |
@file testsignaling.cpp
|
|
19 |
@internalTechnology
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include <crashdatasave.h>
|
|
23 |
#include <s32file.h>
|
|
24 |
#include <bautils.h>
|
|
25 |
|
|
26 |
#include "testsignaling.h"
|
|
27 |
#include "tcoredumpserversuitedefs.h"
|
|
28 |
#include "tcoredumpserverSuiteServer.h"
|
|
29 |
|
|
30 |
/* Null UID set for ECrashProgress which does not have UID */
|
|
31 |
const TUint KNULLUID = 999;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Constructor
|
|
35 |
*/
|
|
36 |
CTestSignaling::CTestSignaling()
|
|
37 |
|
|
38 |
{
|
|
39 |
// **MUST** call SetTestStepName in the constructor as the controlling
|
|
40 |
// framework uses the test step name immediately following construction to set
|
|
41 |
// up the step's unique logging ID.
|
|
42 |
SetTestStepName (KTestSignaling);
|
|
43 |
}
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Destructor
|
|
47 |
*/
|
|
48 |
CTestSignaling::~CTestSignaling()
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
/**
|
|
53 |
* @return - TVerdict code
|
|
54 |
* Override of base class virtual
|
|
55 |
* establishing connection to core dump server and file server
|
|
56 |
* Property handles created and also the corresponding buffers
|
|
57 |
*/
|
|
58 |
TVerdict CTestSignaling::doTestStepPreambleL()
|
|
59 |
{
|
|
60 |
TInt ret = KErrNone;
|
|
61 |
SetTestStepResult (EPass);
|
|
62 |
|
|
63 |
ret = iSess.Connect ();
|
|
64 |
if ( ret != KErrNone)
|
|
65 |
{
|
|
66 |
SetTestStepResult ( EFail);
|
|
67 |
ERR_PRINTF2 (_L ("Error %d from iSess->Connect()/n"), ret);
|
|
68 |
User::Leave(ret);
|
|
69 |
}
|
|
70 |
|
|
71 |
ret = iFs.Connect ();
|
|
72 |
if ( ret != KErrNone)
|
|
73 |
{
|
|
74 |
SetTestStepResult ( EFail);
|
|
75 |
ERR_PRINTF2 (_L ("Error %d from iFs->Connect()/n"), ret);
|
|
76 |
User::Leave(ret);
|
|
77 |
}
|
|
78 |
|
|
79 |
ret = iCrashProgress.Attach(KCoreDumpServUid, ECrashProgress);
|
|
80 |
if ( ret != KErrNone)
|
|
81 |
{
|
|
82 |
SetTestStepResult ( EFail);
|
|
83 |
ERR_PRINTF2 (_L ("Error %d from iCrashProgress.Attach()/n"), ret);
|
|
84 |
User::Leave(ret);
|
|
85 |
}
|
|
86 |
|
|
87 |
ret = iCrashMediaName.Attach(KCoreDumpServUid, ECrashMediaName);
|
|
88 |
if ( ret != KErrNone)
|
|
89 |
{
|
|
90 |
SetTestStepResult ( EFail);
|
|
91 |
ERR_PRINTF2 (_L ("Error %d from iCrashMediaName.Attach()/n"), ret);
|
|
92 |
User::Leave(ret);
|
|
93 |
}
|
|
94 |
|
|
95 |
ret = iCrashCancel.Attach(KCoreDumpServUid, ECancelCrash);
|
|
96 |
if ( ret != KErrNone)
|
|
97 |
{
|
|
98 |
SetTestStepResult ( EFail);
|
|
99 |
ERR_PRINTF2 (_L ("Error %d from iCrashCancel.Attach()/n"), ret);
|
|
100 |
User::Leave(ret);
|
|
101 |
}
|
|
102 |
|
|
103 |
ret = iCrashProgressBuffer.Create(KMaxCrashProgressBuffer);
|
|
104 |
if ( ret != KErrNone)
|
|
105 |
{
|
|
106 |
SetTestStepResult ( EFail);
|
|
107 |
ERR_PRINTF2 (_L ("Error %d from iCrashProgressBuffer.Create()/n"), ret);
|
|
108 |
User::Leave(ret);
|
|
109 |
}
|
|
110 |
|
|
111 |
ret = iCrashMediaNameBuffer.Create(KNumofEntries * KMaxEntryLength);
|
|
112 |
if ( ret != KErrNone)
|
|
113 |
{
|
|
114 |
SetTestStepResult ( EFail);
|
|
115 |
ERR_PRINTF2 (_L ("Error %d from iCrashMediaNameBuffer.Create()/n"), ret);
|
|
116 |
User::Leave(ret);
|
|
117 |
}
|
|
118 |
|
|
119 |
return TestStepResult();
|
|
120 |
}
|
|
121 |
|
|
122 |
/**
|
|
123 |
* @return - TVerdict code
|
|
124 |
* Override of base class virtual
|
|
125 |
* releasing the sessions to the servers
|
|
126 |
* closing the RProperty handles and buffers
|
|
127 |
*/
|
|
128 |
TVerdict CTestSignaling::doTestStepPostambleL()
|
|
129 |
{
|
|
130 |
iSess.Disconnect();
|
|
131 |
User::After(10000000); //ensure we give enough time for session to close
|
|
132 |
iFs.Close();
|
|
133 |
|
|
134 |
iCrashProgress.Close();
|
|
135 |
iCrashMediaName.Close();
|
|
136 |
iCrashCancel.Close();
|
|
137 |
|
|
138 |
iCrashProgressBuffer.Close();
|
|
139 |
iCrashMediaNameBuffer.Close();
|
|
140 |
|
|
141 |
return EPass;
|
|
142 |
}
|
|
143 |
|
|
144 |
/**
|
|
145 |
* @return - TVerdict code
|
|
146 |
* Override of base class pure virtual
|
|
147 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
148 |
* not leave. That being the case, the current test result value will be EPass.
|
|
149 |
*/
|
|
150 |
TVerdict CTestSignaling::doTestStepL()
|
|
151 |
{
|
|
152 |
if(TestStepResult() == EPass)
|
|
153 |
{
|
|
154 |
TInt ret = KErrNone;
|
|
155 |
|
|
156 |
__UHEAP_MARK;
|
|
157 |
|
|
158 |
TRAP (ret, ClientAppL ());
|
|
159 |
if (KErrNone != ret)
|
|
160 |
{
|
|
161 |
SetTestStepResult (EFail);
|
|
162 |
ERR_PRINTF2 (
|
|
163 |
_L ("Error %d from CTestFormatterUserSideStep->ClientAppL()"),
|
|
164 |
ret);
|
|
165 |
User::Leave(ret);
|
|
166 |
}
|
|
167 |
|
|
168 |
__UHEAP_MARKEND;
|
|
169 |
|
|
170 |
}
|
|
171 |
return TestStepResult ();
|
|
172 |
}
|
|
173 |
|
|
174 |
/**
|
|
175 |
* @return void
|
|
176 |
* This calls each stage of the test
|
|
177 |
*/
|
|
178 |
void CTestSignaling::ClientAppL()
|
|
179 |
{
|
|
180 |
|
|
181 |
INFO_PRINTF1 (_L ("Starting Test Signaling Mechanism Test Suite"));
|
|
182 |
TestSignalingMechanismL();
|
|
183 |
|
|
184 |
}
|
|
185 |
|
|
186 |
/**
|
|
187 |
* @return void
|
|
188 |
* Tests the signaling mechanism through RProperty updates
|
|
189 |
* checks for the crash progress and crash media name property updates
|
|
190 |
*/
|
|
191 |
void CTestSignaling::TestSignalingMechanismL()
|
|
192 |
{
|
|
193 |
if (TestStepResult() == EPass)
|
|
194 |
{
|
|
195 |
//reading configuration from the ini file
|
|
196 |
TPtrC crashAppParam;
|
|
197 |
TPtrC crashFileName;
|
|
198 |
TPtrC testNumberofCrashes;
|
|
199 |
|
|
200 |
if(!GetStringFromConfig(ConfigSection(), KTe_CrashAppParam, crashAppParam) ||
|
|
201 |
!GetStringFromConfig(ConfigSection(), KTe_CrashFileName, crashFileName) ||
|
|
202 |
!GetStringFromConfig(ConfigSection(), KNumberofCrashes, testNumberofCrashes))
|
|
203 |
{
|
|
204 |
ERR_PRINTF1(_L("Failed to get data from the ini file"));
|
|
205 |
SetTestStepResult(EFail);
|
|
206 |
User::Leave(KErrGeneral);
|
|
207 |
}
|
|
208 |
|
|
209 |
//Convert number of crashes
|
|
210 |
TLex luther(testNumberofCrashes);
|
|
211 |
User::LeaveIfError(luther.Val(iTimestoCrash));
|
|
212 |
|
|
213 |
if(iTimestoCrash < KNumofEntries)
|
|
214 |
{
|
|
215 |
ERR_PRINTF3(_L ("Expecting the number of crashes %d to be more than %d"), iTimestoCrash, KNumofEntries);
|
|
216 |
SetTestStepResult(EFail);
|
|
217 |
User::Leave(KErrGeneral);
|
|
218 |
}
|
|
219 |
|
|
220 |
INFO_PRINTF2(_L("Number of crashes to happen %d"), iTimestoCrash);
|
|
221 |
|
|
222 |
iCrashFileName.Copy(crashFileName);
|
|
223 |
|
|
224 |
// setting the crash media name to zero
|
|
225 |
// ** caution this is just done for testing **
|
|
226 |
ZeroCrashMediaNameL();
|
|
227 |
|
|
228 |
// Load the SELF Formatter and File Writer
|
|
229 |
LoadandConfigurePluginsL(crashFileName);
|
|
230 |
|
|
231 |
//lets do the first crash
|
|
232 |
//start the application that would crash and observe it
|
|
233 |
StartCrashAppL(crashAppParam);
|
|
234 |
|
|
235 |
// check for the presence of UID in the crash progress messages
|
|
236 |
CheckUIDCrashProgressL();
|
|
237 |
iNumberofCrashes++;
|
|
238 |
|
|
239 |
// breather -- TODO: Why is this here? Document or remove
|
|
240 |
User::After(1000000);
|
|
241 |
|
|
242 |
// create more crashes to create iTimestoCrash - 1 crashes
|
|
243 |
// and check the ECrashMediaName buffer content
|
|
244 |
for (TInt i = 0; i < (iTimestoCrash - 1); i++ )
|
|
245 |
{
|
|
246 |
|
|
247 |
StartCrashAppL(crashAppParam);
|
|
248 |
|
|
249 |
//CheckUIDCrashProgressL();
|
|
250 |
CheckCrashMediaNameL();
|
|
251 |
|
|
252 |
// TODO: Why is this here? Document or remove
|
|
253 |
User::After(1000000);
|
|
254 |
}
|
|
255 |
|
|
256 |
// now we have done multiple crashes
|
|
257 |
// and we would like to investigate the crash media name buffer
|
|
258 |
TestCrashMessageBufferL();
|
|
259 |
|
|
260 |
//now going to test the cancel crash scenario
|
|
261 |
StartCrashAppL(crashAppParam);
|
|
262 |
|
|
263 |
CheckCancelCrashL();
|
|
264 |
|
|
265 |
TidyFilesL(crashFileName);
|
|
266 |
|
|
267 |
INFO_PRINTF1 (_L ("\nSuccessfully tested the signaling mechanism! Adios!\n"));
|
|
268 |
|
|
269 |
}
|
|
270 |
|
|
271 |
}
|
|
272 |
|
|
273 |
/**
|
|
274 |
* Deletes the crash files generated by this test to prevent corruption
|
|
275 |
* of future test
|
|
276 |
* @param aFilenameRoot root of filename to remove (we will remove aFilenameRoot*)
|
|
277 |
* @leave One of the system wide error codes
|
|
278 |
*/
|
|
279 |
void CTestSignaling::TidyFilesL(const TDesC& aFilenameRoot)
|
|
280 |
{
|
|
281 |
_LIT(KWildCardMatch, "*");
|
|
282 |
|
|
283 |
TBuf<KMaxFileName> file;
|
|
284 |
file.Append(aFilenameRoot);
|
|
285 |
file.Append(KWildCardMatch);
|
|
286 |
|
|
287 |
BaflUtils::DeleteFile(iFs, file);
|
|
288 |
}
|
|
289 |
|
|
290 |
/**
|
|
291 |
* @return void
|
|
292 |
* @param parameters for crashapp/exe
|
|
293 |
* Starts the crashapp.exe and observe for the crash via CDS
|
|
294 |
*/
|
|
295 |
void CTestSignaling::StartCrashAppL(const TDesC& aCrashAppParam)
|
|
296 |
{
|
|
297 |
|
|
298 |
INFO_PRINTF2(_L ("Executing crashapp.exe %S \n"), &aCrashAppParam);
|
|
299 |
|
|
300 |
//Start the process that we intend to crash....
|
|
301 |
RProcess crashProcess;
|
|
302 |
CleanupClosePushL (crashProcess);
|
|
303 |
|
|
304 |
TInt ret = crashProcess.Create(KCrashAppFileName, aCrashAppParam);
|
|
305 |
if ( ret != KErrNone)
|
|
306 |
{
|
|
307 |
ERR_PRINTF2 (
|
|
308 |
_L ("Error %d from RProcess.Create(z:\\sys\\bin\\crashapp.exe)/n"),
|
|
309 |
ret);
|
|
310 |
SetTestStepResult (EFail);
|
|
311 |
User::Leave(ret);
|
|
312 |
}
|
|
313 |
|
|
314 |
// Observe the process and wait for a crash
|
|
315 |
TRAP (ret, iSess.ObservationRequestL( KCrashAppFileName, KCrashAppFileName, ETrue));
|
|
316 |
if ( ret != KErrNone)
|
|
317 |
{
|
|
318 |
ERR_PRINTF2 (
|
|
319 |
_L ("Error %d iSess.ObservationRequestL(z:\\sys\\bin\\crashapp.exe)\n"),
|
|
320 |
ret);
|
|
321 |
SetTestStepResult(EFail);
|
|
322 |
User::Leave(ret);
|
|
323 |
}
|
|
324 |
|
|
325 |
//start the crash process
|
|
326 |
crashProcess.Resume ();
|
|
327 |
CleanupStack::PopAndDestroy (&crashProcess);
|
|
328 |
}
|
|
329 |
|
|
330 |
/**
|
|
331 |
* @return void
|
|
332 |
* Check for the presence of UID in the crash progress messages
|
|
333 |
* also check for messages if they have the same crash UID
|
|
334 |
*/
|
|
335 |
void CTestSignaling::CheckUIDCrashProgressL()
|
|
336 |
{
|
|
337 |
INFO_PRINTF1(_L ("Subscribing and Reading ECrashProgress Messages"));
|
|
338 |
|
|
339 |
TUint uid = 0;
|
|
340 |
TUint saveduid = KNULLUID;
|
|
341 |
TRequestStatus status;
|
|
342 |
TInt i = 0;
|
|
343 |
|
|
344 |
iCrashProgressBuffer.Zero();
|
|
345 |
User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
|
|
346 |
|
|
347 |
// read the crash UID and the crash progress message present
|
|
348 |
ReadCrashProgressPacketL(uid, iCrashProgressBuffer);
|
|
349 |
|
|
350 |
if(uid != KNULLUID)
|
|
351 |
{
|
|
352 |
ERR_PRINTF1(_L("First crashprogress message should no crash uid in it"));
|
|
353 |
SetTestStepResult(EFail);
|
|
354 |
User::Leave(KErrGeneral);
|
|
355 |
}
|
|
356 |
|
|
357 |
INFO_PRINTF2(_L ("CrashProgress Messages %S"), &iCrashProgressBuffer);
|
|
358 |
|
|
359 |
//Now we read the crash progress messages until the processing is finished
|
|
360 |
do
|
|
361 |
{
|
|
362 |
i++;
|
|
363 |
|
|
364 |
//start the subscription to see change in the property ECrashProgress
|
|
365 |
iCrashProgress.Subscribe(status);
|
|
366 |
User::WaitForRequest (status);
|
|
367 |
User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
|
|
368 |
|
|
369 |
INFO_PRINTF2(_L ("CrashProgress Messages %S"), &iCrashProgressBuffer);
|
|
370 |
|
|
371 |
// read the crash UID and the crash progress message present
|
|
372 |
ReadCrashProgressPacketL(uid, iCrashProgressBuffer);
|
|
373 |
|
|
374 |
// check for first message to be "Start"
|
|
375 |
if ( (1 == i) && (iCrashProgressBuffer.CompareF(_L("Start")) != 0) )
|
|
376 |
{
|
|
377 |
// the first message has to be Start
|
|
378 |
ERR_PRINTF2(_L("First crashprogress message %S should have Start in it"), &iCrashProgressBuffer);
|
|
379 |
SetTestStepResult(EFail);
|
|
380 |
User::Leave(KErrGeneral);
|
|
381 |
}
|
|
382 |
else if ( (1 == i) && (iCrashProgressBuffer.CompareF(_L("Start")) == 0) )
|
|
383 |
{
|
|
384 |
// save the crash UID for future checks
|
|
385 |
if (uid != KNULLUID)
|
|
386 |
SaveCrashUIDL(uid);
|
|
387 |
}
|
|
388 |
else if( (saveduid != KNULLUID) && (uid != KNULLUID) )
|
|
389 |
{
|
|
390 |
// chec if all the messages do have the same crash UID
|
|
391 |
if(saveduid != uid)
|
|
392 |
{
|
|
393 |
ERR_PRINTF3(_L("Mismatch in the UID values saveduid %S does not match with uid %S"), saveduid, uid);
|
|
394 |
SetTestStepResult(EFail);
|
|
395 |
User::Leave(KErrGeneral);
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
saveduid = uid;
|
|
400 |
}
|
|
401 |
while(iCrashProgressBuffer != KEndOfProcessing);
|
|
402 |
|
|
403 |
iCrashProgressBuffer.Zero();
|
|
404 |
|
|
405 |
INFO_PRINTF1(_L ("Succesful Read all the ECrashProgress Messages"));
|
|
406 |
}
|
|
407 |
|
|
408 |
/**
|
|
409 |
* @return void
|
|
410 |
* Check for the the crash media name messages
|
|
411 |
* parses the values and validates the crash media name and the status bit
|
|
412 |
*/
|
|
413 |
void CTestSignaling::CheckCrashMediaNameL()
|
|
414 |
{
|
|
415 |
INFO_PRINTF1(_L ("Validate the Crash Media Name Messages"));
|
|
416 |
|
|
417 |
TUint crashUID = 0;
|
|
418 |
TBuf<KMaxStatusLength> statusbit;
|
|
419 |
TRequestStatus status;
|
|
420 |
|
|
421 |
do
|
|
422 |
{
|
|
423 |
// subscribe to the Crash Progress Property
|
|
424 |
// intention is to be notified of the crash processing start
|
|
425 |
iCrashProgress.Subscribe(status);
|
|
426 |
User::WaitForRequest(status);
|
|
427 |
|
|
428 |
User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
|
|
429 |
// extract the crash UID and the crash progress message
|
|
430 |
ReadCrashProgressPacketL(crashUID, iCrashProgressBuffer);
|
|
431 |
|
|
432 |
if(iCrashProgressBuffer.CompareF(_L("Start")) == 0)
|
|
433 |
{
|
|
434 |
// now read the crash media name which should be updated
|
|
435 |
// no need to subscribe for ECrashMediaName as it has already been updated
|
|
436 |
User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
|
|
437 |
INFO_PRINTF2(_L ("Crash Media Name Messages %S"), &iCrashMediaNameBuffer);
|
|
438 |
|
|
439 |
// read the crash media name entry for the particular crash uid
|
|
440 |
ParseMediaNameBufferL(crashUID, iCrashMediaNameBuffer, statusbit);
|
|
441 |
|
|
442 |
//check if the crash status bit "I" i.e it is still In Progress
|
|
443 |
if(statusbit.CompareF(_L("I")) != 0)
|
|
444 |
{
|
|
445 |
ERR_PRINTF2(_L("Incorrect status bit %S expecting it to be I"), &statusbit);
|
|
446 |
SetTestStepResult(EFail);
|
|
447 |
User::Leave(KErrGeneral);
|
|
448 |
}
|
|
449 |
|
|
450 |
// check if the CrashFile name is valid name
|
|
451 |
iCrashFileName.Append(_L("*"));
|
|
452 |
if (iCrashMediaNameBuffer.MatchF(iCrashFileName) == KErrNotFound)
|
|
453 |
{
|
|
454 |
ERR_PRINTF3(_L("Crash Media Name %S does not match with %S"), &iCrashFileName, &iCrashMediaNameBuffer);
|
|
455 |
SetTestStepResult(EFail);
|
|
456 |
User::Leave(KErrGeneral);
|
|
457 |
}
|
|
458 |
|
|
459 |
// happy to save the crash UID for future checks
|
|
460 |
SaveCrashUIDL(crashUID);
|
|
461 |
|
|
462 |
}
|
|
463 |
|
|
464 |
}
|
|
465 |
while(iCrashProgressBuffer != KEndOfProcessing);
|
|
466 |
|
|
467 |
//now check the status bit message
|
|
468 |
User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
|
|
469 |
INFO_PRINTF2(_L ("Crash Media Name Messages %S"), &iCrashMediaNameBuffer);
|
|
470 |
// parse the crash media name message
|
|
471 |
ParseMediaNameBufferL(iCrashUID[iNumberofCrashes - 1], iCrashMediaNameBuffer, statusbit);
|
|
472 |
|
|
473 |
//check if the crash status bit "D" i.e the crash processing is now done
|
|
474 |
if(statusbit.CompareF(_L("D")) != 0)
|
|
475 |
{
|
|
476 |
ERR_PRINTF2(_L("Incorrect status bit %S supposed to be D"), &statusbit);
|
|
477 |
SetTestStepResult(EFail);
|
|
478 |
User::Leave(KErrGeneral);
|
|
479 |
}
|
|
480 |
|
|
481 |
INFO_PRINTF1(_L ("Successful checked the Crash Media Name Messages"));
|
|
482 |
}
|
|
483 |
|
|
484 |
/**
|
|
485 |
* @return void
|
|
486 |
* Check for the the crash media name messages after multiple crashes has happened
|
|
487 |
* expects that the number of crashes is more than the KNumofEntries
|
|
488 |
* parses the crash media name buffer and validates the status bit
|
|
489 |
* also checks if we have all the latest crashes in the crash media buffer
|
|
490 |
*/
|
|
491 |
void CTestSignaling::TestCrashMessageBufferL()
|
|
492 |
{
|
|
493 |
INFO_PRINTF1(_L ("Test the final Crash Media Name Message Buffer"));
|
|
494 |
|
|
495 |
// read the crash media name buffer
|
|
496 |
iCrashMediaNameBuffer.Zero();
|
|
497 |
User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
|
|
498 |
INFO_PRINTF2(_L("Final Crash Media name Buffer %S"), &iCrashMediaNameBuffer);
|
|
499 |
|
|
500 |
TInt numofEntries = iCrashMediaNameBuffer.Length() / KMaxEntryLength;
|
|
501 |
// expects that the number of crashes is greater than KNumofEntries
|
|
502 |
if (numofEntries != KNumofEntries)
|
|
503 |
{
|
|
504 |
ERR_PRINTF2(_L("%d Entries is not equal to the max length"), numofEntries);
|
|
505 |
SetTestStepResult(EFail);
|
|
506 |
User::Leave(KErrGeneral);
|
|
507 |
}
|
|
508 |
|
|
509 |
// check for the buffer consistency
|
|
510 |
if( (iCrashMediaNameBuffer.Length() % KMaxEntryLength) != 0 )
|
|
511 |
{
|
|
512 |
ERR_PRINTF2(_L("Buffer corrupt iCrashMediaNameBuffer.Length() %d"), iCrashMediaNameBuffer.Length());
|
|
513 |
SetTestStepResult(EFail);
|
|
514 |
User::Leave(KErrGeneral);
|
|
515 |
}
|
|
516 |
|
|
517 |
// run through the buffer
|
|
518 |
for(TInt i = 0; i < numofEntries; i++ )
|
|
519 |
{
|
|
520 |
// check for the status bit
|
|
521 |
// used as a bit to check on the validity of the entry
|
|
522 |
TPtrC statusptr = iCrashMediaNameBuffer.Mid((i * KMaxEntryLength), KMaxStatusLength);
|
|
523 |
|
|
524 |
if ((statusptr.CompareF(_L("D")) != 0) )
|
|
525 |
{
|
|
526 |
ERR_PRINTF2(_L("Entry Number %d does not seem to have complete status"), i);
|
|
527 |
SetTestStepResult(EFail);
|
|
528 |
User::Leave(KErrGeneral);
|
|
529 |
}
|
|
530 |
|
|
531 |
// now check if we have all the latest crashes by checking on the crash UID
|
|
532 |
// check for UID and match with the saved UID values
|
|
533 |
// we have been saving the crash UID in the right fashion always keeping the latest crashes
|
|
534 |
TPtrC uidptr = iCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength), KMaxUIDLength);
|
|
535 |
|
|
536 |
TUint uid = 0;
|
|
537 |
TLex lexuid(uidptr);
|
|
538 |
User::LeaveIfError(lexuid.Val(uid));
|
|
539 |
|
|
540 |
if ( uid != iCrashUID[i])
|
|
541 |
{
|
|
542 |
ERR_PRINTF3(_L("Entry Number %d does not match with iCrashUID %d"), uid, iCrashUID[i]);
|
|
543 |
SetTestStepResult(EFail);
|
|
544 |
User::Leave(KErrGeneral);
|
|
545 |
}
|
|
546 |
|
|
547 |
//check for the terminating character '/'
|
|
548 |
TPtrC endptr = iCrashMediaNameBuffer.Mid((((i + 1) * KMaxEntryLength) - KMaxEndLength), KMaxEndLength);
|
|
549 |
|
|
550 |
if(endptr.CompareF(_L("\\")) != 0 )
|
|
551 |
{
|
|
552 |
ERR_PRINTF3(_L("Entry Number %d does not have the right termination character instead has %S"), i, &endptr);
|
|
553 |
SetTestStepResult(EFail);
|
|
554 |
User::Leave(KErrGeneral);
|
|
555 |
}
|
|
556 |
|
|
557 |
}
|
|
558 |
|
|
559 |
INFO_PRINTF1(_L ("Successfully tested the final Crash Media Name Message Buffer"));
|
|
560 |
}
|
|
561 |
|
|
562 |
void CTestSignaling::CheckCancelCrashL()
|
|
563 |
{
|
|
564 |
INFO_PRINTF1(_L ("Test the Cancel status message update in the Crash Media Buffer"));
|
|
565 |
|
|
566 |
TUint crashUID = 0;
|
|
567 |
TBuf<KMaxStatusLength> statusbit;
|
|
568 |
TRequestStatus status;
|
|
569 |
|
|
570 |
do
|
|
571 |
{
|
|
572 |
// subscribe to the Crash Progress Property
|
|
573 |
// intention is to be notified of the crash processing start
|
|
574 |
iCrashProgress.Subscribe(status);
|
|
575 |
User::WaitForRequest(status);
|
|
576 |
|
|
577 |
User::LeaveIfError(iCrashProgress.Get(iCrashProgressBuffer));
|
|
578 |
// extract the crash UID and the crash progress message
|
|
579 |
ReadCrashProgressPacketL(crashUID, iCrashProgressBuffer);
|
|
580 |
|
|
581 |
if(iCrashProgressBuffer.CompareF(_L("Start")) == 0)
|
|
582 |
{
|
|
583 |
// now that the crash processing has started
|
|
584 |
// issue a cancel crash command
|
|
585 |
iCrashCancel.Set(ETrue);
|
|
586 |
|
|
587 |
}
|
|
588 |
|
|
589 |
}
|
|
590 |
while(iCrashProgressBuffer != KEndOfProcessing);
|
|
591 |
|
|
592 |
// once the processing is done
|
|
593 |
// read the crash media buffer to see
|
|
594 |
// if we have the latest crash has the cancelled status bit
|
|
595 |
User::LeaveIfError(iCrashMediaName.Get(iCrashMediaNameBuffer));
|
|
596 |
|
|
597 |
// read the last crash entry as it has the latest crash
|
|
598 |
// check for the status bit to have "C" signifying the processing was cancelled
|
|
599 |
TPtrC statusptr = iCrashMediaNameBuffer.Mid(((KNumofEntries - 1) * KMaxEntryLength), KMaxStatusLength);
|
|
600 |
|
|
601 |
if( statusptr.CompareF(_L("C")) != 0)
|
|
602 |
{
|
|
603 |
ERR_PRINTF2(_L("The entry does not seem to be valid status bit %S"), &statusptr);
|
|
604 |
SetTestStepResult(EFail);
|
|
605 |
User::Leave(KErrGeneral);
|
|
606 |
}
|
|
607 |
|
|
608 |
INFO_PRINTF1(_L ("Completed Successfully Cancel status message update in the Crash Media Buffer"));
|
|
609 |
}
|
|
610 |
/**
|
|
611 |
* @return void
|
|
612 |
* @param aCrashUID crash UID used to find the matching crash in the entries
|
|
613 |
* @param aCrashMediaNameBuffer RProperty message buffer
|
|
614 |
* @param aStatusBit status bit of the crash media name entry
|
|
615 |
* Reads the CrashMediaName property value extracts the crash UID
|
|
616 |
* and the crash media name and the status bit
|
|
617 |
* The function runs through all the buffer entries
|
|
618 |
* but this is not needed as it is guranteed that the last entry has the latest crash information
|
|
619 |
* Here is how the buffer entries looks like
|
|
620 |
* there are KNumofEntries number of entries each of KMaxEntryLength
|
|
621 |
* |Status| MediaName |UID |END|
|
|
622 |
* 1 128 + 20 10 1 number of characters = KMaxEntryLength = 160
|
|
623 |
|
|
624 |
* Status: D stands for Done
|
|
625 |
* I stands for In progress
|
|
626 |
* C stands for Cancel
|
|
627 |
* UID: lower 32 bit of crash time
|
|
628 |
* MediaName: medianame + 64 bit time appended to it
|
|
629 |
* END: end character \
|
|
630 |
*/
|
|
631 |
void CTestSignaling::ParseMediaNameBufferL(TUint aCrashUID, TDes& aCrashMediaNameBuffer, TDes& aStatusBit)
|
|
632 |
{
|
|
633 |
|
|
634 |
TBool matchfound = EFalse;
|
|
635 |
TInt numofEntries = aCrashMediaNameBuffer.Length() / KMaxEntryLength;
|
|
636 |
// check the number of entries are not more than KNumofEntries
|
|
637 |
if (numofEntries > KNumofEntries)
|
|
638 |
{
|
|
639 |
ERR_PRINTF2(_L("entries %d more than the max length"), numofEntries);
|
|
640 |
SetTestStepResult(EFail);
|
|
641 |
User::Leave(KErrGeneral);
|
|
642 |
}
|
|
643 |
|
|
644 |
// check for the buffer consistency the each should be of length KMaxEntryLength
|
|
645 |
if( (iCrashMediaNameBuffer.Length() % KMaxEntryLength) != 0 )
|
|
646 |
{
|
|
647 |
ERR_PRINTF2(_L("Buffer corrupt iCrashMediaNameBuffer.Length() %d"), iCrashMediaNameBuffer.Length());
|
|
648 |
SetTestStepResult(EFail);
|
|
649 |
User::Leave(KErrGeneral);
|
|
650 |
}
|
|
651 |
|
|
652 |
// now read through all the entries and check for consistency
|
|
653 |
for(TInt i = 0; i < numofEntries; i++ )
|
|
654 |
{
|
|
655 |
// read the status bit and check for validity
|
|
656 |
TPtrC statusptr = aCrashMediaNameBuffer.Mid((i * KMaxEntryLength), KMaxStatusLength);
|
|
657 |
|
|
658 |
if ((statusptr.CompareF(_L("D")) == 0) || (statusptr.CompareF(_L("I")) == 0) || (statusptr.CompareF(_L("C")) == 0) )
|
|
659 |
{
|
|
660 |
// read the crash UID and see if we can find a match
|
|
661 |
TPtrC uidptr = aCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength), KMaxUIDLength);
|
|
662 |
|
|
663 |
TUint uid = 0;
|
|
664 |
TLex lexuid(uidptr);
|
|
665 |
User::LeaveIfError(lexuid.Val(uid));
|
|
666 |
|
|
667 |
//check if the last the crash entry is the latest one
|
|
668 |
if (uid == aCrashUID)
|
|
669 |
{
|
|
670 |
if( (i+1) != numofEntries)
|
|
671 |
{
|
|
672 |
ERR_PRINTF2(_L("The last entry does not have the last crash information %d"), i);
|
|
673 |
SetTestStepResult(EFail);
|
|
674 |
User::Leave(KErrGeneral);
|
|
675 |
}
|
|
676 |
|
|
677 |
TPtrC crashmediaptr = aCrashMediaNameBuffer.Mid(((i * KMaxEntryLength) + KMaxStatusLength + KMaxUIDLength), KMaxMediaLength);
|
|
678 |
|
|
679 |
//update the crash media name
|
|
680 |
aCrashMediaNameBuffer.Copy(crashmediaptr);
|
|
681 |
//update the status
|
|
682 |
aStatusBit.Copy(statusptr);
|
|
683 |
|
|
684 |
// we have found a macthing UID
|
|
685 |
matchfound = ETrue;
|
|
686 |
}
|
|
687 |
|
|
688 |
}
|
|
689 |
else
|
|
690 |
{
|
|
691 |
ERR_PRINTF2(_L("The entry does not seem to be valid status bit %S"), &statusptr);
|
|
692 |
SetTestStepResult(EFail);
|
|
693 |
User::Leave(KErrGeneral);
|
|
694 |
}
|
|
695 |
|
|
696 |
}
|
|
697 |
|
|
698 |
// if we dont find it match flag it as error
|
|
699 |
if(!matchfound)
|
|
700 |
{
|
|
701 |
ERR_PRINTF2(_L("The entry not found with the right UID %d"), aCrashUID);
|
|
702 |
SetTestStepResult(EFail);
|
|
703 |
User::Leave(KErrGeneral);
|
|
704 |
}
|
|
705 |
|
|
706 |
}
|
|
707 |
|
|
708 |
/**
|
|
709 |
* @return void
|
|
710 |
* @param aUID carsh UID
|
|
711 |
* @param aMessageBuffer RProperty message for crashprogress
|
|
712 |
* Reads the CrashProgress property value extracts the crash UID
|
|
713 |
* and the crash progress message
|
|
714 |
*/
|
|
715 |
void CTestSignaling::ReadCrashProgressPacketL(TUint& aUID, TDes& aMessageBuffer)
|
|
716 |
{
|
|
717 |
if ( (aMessageBuffer.CompareF(_L("")) == 0) || (aMessageBuffer.CompareF(_L("clear")) == 0) || (aMessageBuffer.CompareF(_L("idle")) == 0) || (aMessageBuffer.CompareF(_L("Cancel")) == 0))
|
|
718 |
{
|
|
719 |
//signifying that these messages does not have a UID
|
|
720 |
aUID = KNULLUID;
|
|
721 |
}
|
|
722 |
else
|
|
723 |
{
|
|
724 |
//INFO_PRINTF2(_L("aMessageBuffer %S"), &aMessageBuffer);
|
|
725 |
//process the UID
|
|
726 |
RBuf uidbuf;
|
|
727 |
TInt ret = KErrNone;
|
|
728 |
ret = uidbuf.Create(aMessageBuffer, KMaxUIDLength);
|
|
729 |
if (ret != KErrNone)
|
|
730 |
{
|
|
731 |
ERR_PRINTF2(_L("Error %d rbuf create for UID /n"), ret);
|
|
732 |
SetTestStepResult (EFail);
|
|
733 |
User::Leave(ret);
|
|
734 |
}
|
|
735 |
|
|
736 |
TLex lexuid(uidbuf);
|
|
737 |
ret = lexuid.Val(aUID);
|
|
738 |
if (ret != KErrNone)
|
|
739 |
{
|
|
740 |
ERR_PRINTF2(_L("Error %d lex uid /n"), ret);
|
|
741 |
SetTestStepResult (EFail);
|
|
742 |
User::Leave(ret);
|
|
743 |
}
|
|
744 |
uidbuf.Close();
|
|
745 |
|
|
746 |
// stripping the UID and the crash progress message
|
|
747 |
TPtr message = aMessageBuffer.MidTPtr(KMaxUIDLength);
|
|
748 |
aMessageBuffer.Copy(message);
|
|
749 |
}
|
|
750 |
}
|
|
751 |
|
|
752 |
/**
|
|
753 |
* @return void
|
|
754 |
* Utility function to save the crash UID present in the crash progress messages
|
|
755 |
*/
|
|
756 |
void CTestSignaling::SaveCrashUIDL(TUint aSaveCrashUID)
|
|
757 |
{
|
|
758 |
if (iNumberofCrashes < KNumofEntries)
|
|
759 |
{
|
|
760 |
iCrashUID[iNumberofCrashes] = aSaveCrashUID;
|
|
761 |
iNumberofCrashes++;
|
|
762 |
}
|
|
763 |
else
|
|
764 |
{
|
|
765 |
for (TInt i = 0; i < (KNumofEntries - 1); i++)
|
|
766 |
{
|
|
767 |
iCrashUID[i] = iCrashUID[i+1];
|
|
768 |
}
|
|
769 |
|
|
770 |
iCrashUID[iNumberofCrashes-1] = aSaveCrashUID;
|
|
771 |
}
|
|
772 |
|
|
773 |
if(iNumberofCrashes > iNumberofCrashes)
|
|
774 |
{
|
|
775 |
ERR_PRINTF2(_L("Mismatch in crash uid storing %d"), iNumberofCrashes);
|
|
776 |
SetTestStepResult(EFail);
|
|
777 |
User::Leave(KErrGeneral);
|
|
778 |
}
|
|
779 |
}
|
|
780 |
/**
|
|
781 |
* @return void
|
|
782 |
* sets the CrashMediaName property to zero
|
|
783 |
* this is done solely for testing purposes
|
|
784 |
* clients of CDS are not expected to modify the property
|
|
785 |
*/
|
|
786 |
void CTestSignaling::ZeroCrashMediaNameL()
|
|
787 |
{
|
|
788 |
|
|
789 |
iCrashMediaNameBuffer.Zero();
|
|
790 |
User::LeaveIfError(iCrashMediaName.Set(iCrashMediaNameBuffer));
|
|
791 |
// setting this resets the crash UID array to zero
|
|
792 |
iNumberofCrashes = 0;
|
|
793 |
|
|
794 |
}
|
|
795 |
|
|
796 |
/**
|
|
797 |
* @return void
|
|
798 |
* @param aIndex Internal index to the component that owns the object
|
|
799 |
* @param aUID UID of the component that owns the object
|
|
800 |
* @param aSource Type of component that owns the object
|
|
801 |
* @param aType Type of parameter
|
|
802 |
* @param aPrompt Prompt to present to user
|
|
803 |
* @param aNumOptions Number of options that the parameter can be set to. Only applies if type is ETMultiEntryEnum.
|
|
804 |
* @param aOptions Comma separated list of options. Applies to ETMultiEntryEnum and ETBool
|
|
805 |
* @param aVal Integer value. Applies to ETInt, ETUInt, ETBool
|
|
806 |
* @param aStrValue String value. Applies to ETString, ETFileName, ETMultiEntry, ETBool
|
|
807 |
*/
|
|
808 |
void CTestSignaling::DoConfigureL(const TUint32& aIndex, const TUint32& aUID,
|
|
809 |
const COptionConfig::TParameterSource& aSource,
|
|
810 |
const COptionConfig::TOptionType& aType, const TDesC& aPrompt,
|
|
811 |
const TUint32& aNumOptions, const TDesC& aOptions, const TInt32& aVal,
|
|
812 |
const TDesC& aStrValue, const TUint aInstance)
|
|
813 |
|
|
814 |
{
|
|
815 |
COptionConfig * config;
|
|
816 |
|
|
817 |
config = COptionConfig::NewL ( aIndex, aUID, aSource, aType, aPrompt,
|
|
818 |
aNumOptions, aOptions, aVal, aStrValue);
|
|
819 |
|
|
820 |
CleanupStack::PushL (config);
|
|
821 |
|
|
822 |
config->Instance (aInstance);
|
|
823 |
|
|
824 |
//Configure now...
|
|
825 |
TRAPD (ret, iSess.SetConfigParameterL (*config));
|
|
826 |
if ( ret != KErrNone)
|
|
827 |
{
|
|
828 |
ERR_PRINTF2(_L("Error %d changing parameter/n"), ret);
|
|
829 |
SetTestStepResult (EFail);
|
|
830 |
User::Leave(ret);
|
|
831 |
}
|
|
832 |
|
|
833 |
CleanupStack::PopAndDestroy (config);
|
|
834 |
}
|
|
835 |
|
|
836 |
/**
|
|
837 |
* @return void
|
|
838 |
* Utility function to load the SELF Formatter and File Writer
|
|
839 |
* Configures the file writer and the CDS
|
|
840 |
*/
|
|
841 |
void CTestSignaling::LoadandConfigurePluginsL(const TDesC& aCrashFileName)
|
|
842 |
{
|
|
843 |
INFO_PRINTF1 (_L ("Attempting to load SELF Formatter V2 and File Writer"));
|
|
844 |
|
|
845 |
// SELF Formatter V2
|
|
846 |
TPluginRequest SELFreq;
|
|
847 |
SELFreq.iPluginType = TPluginRequest::EFormatter;
|
|
848 |
SELFreq.iLoad = ETrue;
|
|
849 |
SELFreq.iUid = KUidSELFFormatterV2;
|
|
850 |
|
|
851 |
TRAPD(ret, iSess.PluginRequestL(SELFreq));
|
|
852 |
if ( ret != KErrNone)
|
|
853 |
{
|
|
854 |
ERR_PRINTF2 (_L ("Failed to load SELF Formatter V2 plugin, error = %d"), ret);
|
|
855 |
SetTestStepResult (EFail);
|
|
856 |
User::Leave(ret);
|
|
857 |
}
|
|
858 |
|
|
859 |
// File Writer
|
|
860 |
TPluginRequest writerreq;
|
|
861 |
writerreq.iUid = WRITER_UID;
|
|
862 |
writerreq.iPluginType = TPluginRequest::EWriter;
|
|
863 |
writerreq.iLoad = ETrue;
|
|
864 |
|
|
865 |
TRAP(ret, iSess.PluginRequestL(writerreq ));
|
|
866 |
if(ret != KErrNone)
|
|
867 |
{
|
|
868 |
ERR_PRINTF2(_L("Failed to load writer plugin, error = %d"), ret);
|
|
869 |
SetTestStepResult(EFail);
|
|
870 |
User::Leave(ret);
|
|
871 |
}
|
|
872 |
|
|
873 |
INFO_PRINTF1(_L("Successfully loaded SELF Formatter V2 and File Writer"));
|
|
874 |
|
|
875 |
//Now we configure CDS and writer
|
|
876 |
_LIT( KFilePathPrompt, "not_important" );
|
|
877 |
|
|
878 |
DoConfigureL(2, CDS_UID.iUid, COptionConfig::ECoreDumpServer, COptionConfig::ETUInt, KPostCrashEventActionPrompt,
|
|
879 |
1, KNullDesC, 4, KNullDesC, 0);
|
|
880 |
|
|
881 |
DoConfigureL((TInt)(CCrashDataSave::ECoreFilePath), WRITER_UID.iUid, COptionConfig::EWriterPlugin, COptionConfig::ETFileName,
|
|
882 |
KFilePathPrompt, 1, KNullDesC, 0, aCrashFileName, 0);
|
|
883 |
|
|
884 |
INFO_PRINTF1(_L("Successfully configured File Writer and CDS"));
|
|
885 |
|
|
886 |
}
|