os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_030_xx.cpp
Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // See the test specification for details of what these test cases do.
15 #include "teststepcomsdbg.h"
16 #include "TestMessage.h"
17 #include "step_030_xx.h"
20 #include <comms-infras/commsdebugutility.h>
25 * This is the Constructor
29 CFloggerTest030_Tag_Setup::CFloggerTest030_Tag_Setup()
31 // Store the name of this test case
32 SetTestStepName(_L("step_030_Tag_Setup"));
37 * This is the Destructor
41 CFloggerTest030_Tag_Setup::~CFloggerTest030_Tag_Setup()
47 * This function returns whether the test case has
52 TVerdict CFloggerTest030_Tag_Setup::doTestStepL( )
54 if ( executeStepL() == KErrNone )
55 SetTestStepResult(EPass);
58 SetTestStepResult(EFail);
60 //INFO_PRINTF1(_L("leaving Step 030_Tag_Setup "));
61 User::After(KTimeForDisplay);
64 return TestStepResult();
68 TInt CFloggerTest030_Tag_Setup::executeStepL(TBool)
73 TInt CFloggerTest030_Tag_Setup::executeStepL()
75 return constructFloggerIniL(KTagTestsIniFileSettings);
83 * 030_TagSetLogTag01: Test that flogger handles empty tags
86 CFloggerTest030_TagSetLogTag01::CFloggerTest030_TagSetLogTag01()
88 // Store the name of this test case
89 SetTestStepName(_L("step_030_TagSetLogTag01"));
95 CFloggerTest030_TagSetLogTag01::~CFloggerTest030_TagSetLogTag01()
102 TVerdict CFloggerTest030_TagSetLogTag01::doTestStepL( )
104 if ( executeStepL() == KErrNone )
105 SetTestStepResult(EPass);
108 SetTestStepResult(EFail);
110 User::After(KTimeForDisplay);
113 return TestStepResult();
116 TInt CFloggerTest030_TagSetLogTag01::executeStepL(TBool)
122 TInt CFloggerTest030_TagSetLogTag01::executeStepL()
126 RFileLogger theFlogger;
127 ret = theFlogger.Connect();
129 if ( ret == KErrNone)
131 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
132 theFlogger.ClearLog();
133 theFlogger.SetLogTags(KNullDesC8, KNullDesC8);
134 theFlogger.Write(KTestMessage);
136 User::After(KTimeToLog);
137 TRAPD(r, ret = DoTestCheckWriteL());
149 TInt CFloggerTest030_TagSetLogTag01::DoTestCheckWriteL()
153 TInt listfilesize,returnCode;
154 RFs fileSystem; //For file operation create a file system
155 TUint numSuccessful = 0;
158 User::LeaveIfError(fileSystem.Connect());
159 CleanupClosePushL(fileSystem);
161 //Open the file in the read mode
162 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
164 CleanupClosePushL(theFile);
166 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
168 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
169 CleanupStack::PushL(hBuffer);
171 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
173 // Read from position 0: start of file
174 User::LeaveIfError(returnCode = theFile.Read(ptrString));
176 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
179 if (returnCode == KErrNotFound)
182 returnCode = ptrString.Find(KErrOOM);
184 User::Leave(KErrNoMemory);
188 CleanupStack::PopAndDestroy(hBuffer);
189 CleanupStack::PopAndDestroy(); //theFile
190 CleanupStack::PopAndDestroy(); //fileSystem
192 if (numSuccessful == 1)
202 * 030_TagSetLogTag02: Test that flogger handles empty subsys tag
205 CFloggerTest030_TagSetLogTag02::CFloggerTest030_TagSetLogTag02()
207 // Store the name of this test case
208 SetTestStepName(_L("step_030_TagSetLogTag02"));
214 CFloggerTest030_TagSetLogTag02::~CFloggerTest030_TagSetLogTag02()
221 TVerdict CFloggerTest030_TagSetLogTag02::doTestStepL( )
223 if ( executeStepL() == KErrNone )
224 SetTestStepResult(EPass);
227 SetTestStepResult(EFail);
229 User::After(KTimeForDisplay);
232 return TestStepResult();
236 TInt CFloggerTest030_TagSetLogTag02::executeStepL(TBool)
241 TInt CFloggerTest030_TagSetLogTag02::executeStepL()
245 RFileLogger theFlogger;
246 ret = theFlogger.Connect();
248 if ( ret == KErrNone)
250 //Create Log by passing the subsystem and component name as parameters
251 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
252 theFlogger.ClearLog();
253 theFlogger.SetLogTags(KNullDesC8, KStdCompTag8);
254 theFlogger.Write(KTestMessage);
256 User::After(KTimeToLog);
257 TRAPD(r, ret = DoTestCheckWriteL());
269 TInt CFloggerTest030_TagSetLogTag02::DoTestCheckWriteL()
273 TInt listfilesize,returnCode;
274 RFs fileSystem; //For file operation create a file system
275 TUint numSuccessful = 0;
278 User::LeaveIfError(fileSystem.Connect());
279 CleanupClosePushL(fileSystem);
281 //Open the file in the read mode
282 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
284 CleanupClosePushL(theFile);
286 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
288 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
289 CleanupStack::PushL(hBuffer);
291 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
293 // Read from position 0: start of file
294 User::LeaveIfError(returnCode = theFile.Read(ptrString));
296 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
299 if (returnCode == KErrNotFound)
302 returnCode = ptrString.Find(KErrOOM);
304 User::Leave(KErrNoMemory);
308 CleanupStack::PopAndDestroy(hBuffer);
309 CleanupStack::PopAndDestroy(); //theFile
310 CleanupStack::PopAndDestroy(); //fileSystem
312 if (numSuccessful == 1)
321 * 030_TagSetLogTag03: Test that flogger handles empty component tag
324 CFloggerTest030_TagSetLogTag03::CFloggerTest030_TagSetLogTag03()
326 // Store the name of this test case
327 SetTestStepName(_L("step_030_TagSetLogTag03"));
333 CFloggerTest030_TagSetLogTag03::~CFloggerTest030_TagSetLogTag03()
340 TVerdict CFloggerTest030_TagSetLogTag03::doTestStepL( )
342 if ( executeStepL() == KErrNone )
343 SetTestStepResult(EPass);
346 SetTestStepResult(EFail);
348 User::After(KTimeForDisplay);
351 return TestStepResult();
354 TInt CFloggerTest030_TagSetLogTag03::executeStepL(TBool)
360 TInt CFloggerTest030_TagSetLogTag03::executeStepL()
364 RFileLogger theFlogger;
365 ret = theFlogger.Connect();
367 if ( ret == KErrNone)
369 //Create Log by passing the subsystem and component name as parameters
370 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
371 theFlogger.ClearLog();
372 theFlogger.SetLogTags(KStdSubsysTag8, KNullDesC8);
373 theFlogger.Write(KTestMessage);
375 User::After(KTimeToLog);
376 TRAPD(r, ret = DoTestCheckWriteL());
388 TInt CFloggerTest030_TagSetLogTag03::DoTestCheckWriteL()
392 TInt listfilesize,returnCode;
393 RFs fileSystem; //For file operation create a file system
394 TUint numSuccessful = 0;
397 User::LeaveIfError(fileSystem.Connect());
398 CleanupClosePushL(fileSystem);
400 //Open the file in the read mode
401 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
403 CleanupClosePushL(theFile);
405 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
407 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
408 CleanupStack::PushL(hBuffer);
410 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
412 // Read from position 0: start of file
413 User::LeaveIfError(returnCode = theFile.Read(ptrString));
415 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
418 if (returnCode == KErrNotFound)
421 returnCode = ptrString.Find(KErrOOM);
423 User::Leave(KErrNoMemory);
427 CleanupStack::PopAndDestroy(hBuffer);
428 CleanupStack::PopAndDestroy(); //theFile
429 CleanupStack::PopAndDestroy(); //fileSystem
431 if (numSuccessful == 1)
441 * 030_TagSetLogTag04: Test that flogger handles spaces in tags
444 CFloggerTest030_TagSetLogTag04::CFloggerTest030_TagSetLogTag04()
446 // Store the name of this test case
447 SetTestStepName(_L("step_030_TagSetLogTag04"));
453 CFloggerTest030_TagSetLogTag04::~CFloggerTest030_TagSetLogTag04()
460 TVerdict CFloggerTest030_TagSetLogTag04::doTestStepL( )
462 if ( executeStepL() == KErrNone )
463 SetTestStepResult(EPass);
466 SetTestStepResult(EFail);
468 User::After(KTimeForDisplay);
471 return TestStepResult();
475 TInt CFloggerTest030_TagSetLogTag04::executeStepL(TBool)
480 TInt CFloggerTest030_TagSetLogTag04::executeStepL()
484 RFileLogger theFlogger;
485 ret = theFlogger.Connect();
487 if ( ret == KErrNone)
489 //Create Log by passing the subsystem and component name as parameters
490 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
491 theFlogger.ClearLog();
492 theFlogger.SetLogTags(KStdSubsysTag8, KCompTagWithSpaceChars8);
493 theFlogger.Write(KTestMessage);
495 User::After(KTimeToLog);
496 TRAPD(r, ret = DoTestCheckWriteL());
508 TInt CFloggerTest030_TagSetLogTag04::DoTestCheckWriteL()
512 TInt listfilesize,returnCode;
513 RFs fileSystem; //For file operation create a file system
514 TUint numSuccessful = 0;
517 User::LeaveIfError(fileSystem.Connect());
518 CleanupClosePushL(fileSystem);
520 //Open the file in the read mode
521 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
523 CleanupClosePushL(theFile);
525 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
527 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
528 CleanupStack::PushL(hBuffer);
530 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
532 // Read from position 0: start of file
533 User::LeaveIfError(returnCode = theFile.Read(ptrString));
535 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
538 if (returnCode == KErrNotFound)
541 returnCode = ptrString.Find(KErrOOM);
543 User::Leave(KErrNoMemory);
547 CleanupStack::PopAndDestroy(hBuffer);
548 CleanupStack::PopAndDestroy(); //theFile
549 CleanupStack::PopAndDestroy(); //fileSystem
551 if (numSuccessful == 1)
562 * 030_TagSetLogTag05: Test that flogger handles punctuation in tags
565 CFloggerTest030_TagSetLogTag05::CFloggerTest030_TagSetLogTag05()
567 // Store the name of this test case
568 SetTestStepName(_L("step_030_TagSetLogTag05"));
574 CFloggerTest030_TagSetLogTag05::~CFloggerTest030_TagSetLogTag05()
581 TVerdict CFloggerTest030_TagSetLogTag05::doTestStepL( )
583 if ( executeStepL() == KErrNone )
584 SetTestStepResult(EPass);
587 SetTestStepResult(EFail);
589 User::After(KTimeForDisplay);
592 return TestStepResult();
596 TInt CFloggerTest030_TagSetLogTag05::executeStepL(TBool)
601 TInt CFloggerTest030_TagSetLogTag05::executeStepL()
605 RFileLogger theFlogger;
606 ret = theFlogger.Connect();
608 if ( ret == KErrNone)
610 //Create Log by passing the subsystem and component name as parameters
611 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
612 theFlogger.ClearLog();
613 theFlogger.SetLogTags(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8);
614 theFlogger.Write(KTestMessage);
616 User::After(KTimeToLog);
617 TRAPD(r, ret = DoTestCheckWriteL());
629 TInt CFloggerTest030_TagSetLogTag05::DoTestCheckWriteL()
633 TInt listfilesize,returnCode;
634 RFs fileSystem; //For file operation create a file system
635 TUint numSuccessful = 0;
638 User::LeaveIfError(fileSystem.Connect());
639 CleanupClosePushL(fileSystem);
641 //Open the file in the read mode
642 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
644 CleanupClosePushL(theFile);
646 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
648 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
649 CleanupStack::PushL(hBuffer);
651 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
653 // Read from position 0: start of file
654 User::LeaveIfError(returnCode = theFile.Read(ptrString));
656 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
659 if (returnCode == KErrNotFound)
662 returnCode = ptrString.Find(KErrOOM);
664 User::Leave(KErrNoMemory);
668 CleanupStack::PopAndDestroy(hBuffer);
669 CleanupStack::PopAndDestroy(); //theFile
670 CleanupStack::PopAndDestroy(); //fileSystem
672 if (numSuccessful == 1)
680 * 030_TagSetLogTag06: Test that flogger handles long tags
683 CFloggerTest030_TagSetLogTag06::CFloggerTest030_TagSetLogTag06()
685 // Store the name of this test case
686 SetTestStepName(_L("step_030_TagSetLogTag06"));
692 CFloggerTest030_TagSetLogTag06::~CFloggerTest030_TagSetLogTag06()
699 TVerdict CFloggerTest030_TagSetLogTag06::doTestStepL( )
701 if ( executeStepL() == KErrNone )
702 SetTestStepResult(EPass);
705 SetTestStepResult(EFail);
707 User::After(KTimeForDisplay);
710 return TestStepResult();
714 TInt CFloggerTest030_TagSetLogTag06::executeStepL(TBool)
719 TInt CFloggerTest030_TagSetLogTag06::executeStepL()
723 RFileLogger theFlogger;
724 ret = theFlogger.Connect();
726 if ( ret == KErrNone)
728 //Create Log by passing the subsystem and component name as parameters
729 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
730 theFlogger.ClearLog();
731 theFlogger.SetLogTags(KSubsysTag16char8, KCompTag16char8);
732 theFlogger.Write(KTestMessage8);
734 User::After(KTimeToLog);
735 TRAPD(r, ret = DoTestCheckWriteL());
747 TInt CFloggerTest030_TagSetLogTag06::DoTestCheckWriteL()
751 TInt listfilesize,returnCode;
752 RFs fileSystem; //For file operation create a file system
753 TUint numSuccessful = 0;
756 User::LeaveIfError(fileSystem.Connect());
757 CleanupClosePushL(fileSystem);
759 //Open the file in the read mode
760 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
762 CleanupClosePushL(theFile);
764 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
766 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
767 CleanupStack::PushL(hBuffer);
769 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
771 // Read from position 0: start of file
772 User::LeaveIfError(returnCode = theFile.Read(ptrString));
774 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
781 else if (returnCode == KErrNotFound)
783 returnCode = ptrString.Find(KErrOOM);
785 User::Leave(KErrNoMemory);
789 CleanupStack::PopAndDestroy(hBuffer);
790 CleanupStack::PopAndDestroy(); //theFile
791 CleanupStack::PopAndDestroy(); //fileSystem
793 if (numSuccessful == 1)
803 * 030_TagSetLogTag07: Test that flogger handles long tags
806 CFloggerTest030_TagSetLogTag07::CFloggerTest030_TagSetLogTag07()
808 // Store the name of this test case
809 SetTestStepName(_L("step_030_TagSetLogTag07"));
815 CFloggerTest030_TagSetLogTag07::~CFloggerTest030_TagSetLogTag07()
822 TVerdict CFloggerTest030_TagSetLogTag07::doTestStepL( )
824 if ( executeStepL() == KErrNone )
825 SetTestStepResult(EPass);
828 SetTestStepResult(EFail);
830 User::After(KTimeForDisplay);
833 return TestStepResult();
837 TInt CFloggerTest030_TagSetLogTag07::executeStepL(TBool)
842 TInt CFloggerTest030_TagSetLogTag07::executeStepL()
846 RFileLogger theFlogger;
847 ret = theFlogger.Connect();
849 if ( ret == KErrNone)
851 //Create Log by passing the subsystem and component name as parameters
852 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
853 theFlogger.ClearLog();
854 theFlogger.SetLogTags(KSubsysTag17char8, KCompTag17char8);
855 theFlogger.Write(KTestMessage8);
857 User::After(KTimeToLog);
858 TRAPD(r, ret = DoTestCheckWriteL());
870 TInt CFloggerTest030_TagSetLogTag07::DoTestCheckWriteL()
874 TInt listfilesize,returnCode;
875 RFs fileSystem; //For file operation create a file system
876 TUint numSuccessful = 0;
879 User::LeaveIfError(fileSystem.Connect());
880 CleanupClosePushL(fileSystem);
882 //Open the file in the read mode
883 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
885 CleanupClosePushL(theFile);
887 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
889 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
890 CleanupStack::PushL(hBuffer);
892 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
894 // Read from position 0: start of file
895 User::LeaveIfError(returnCode = theFile.Read(ptrString));
897 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
904 else if (returnCode == KErrNotFound)
906 returnCode = ptrString.Find(KErrOOM);
908 User::Leave(KErrNoMemory);
911 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
912 returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
919 returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read
921 if (returnCode == KErrNotFound)
926 CleanupStack::PopAndDestroy(hBuffer);
927 CleanupStack::PopAndDestroy(); //theFile
928 CleanupStack::PopAndDestroy(); //fileSystem
930 if (numSuccessful == 3)
940 * 030_TagSetLogTag08: Test that flogger handles very long tags
943 CFloggerTest030_TagSetLogTag08::CFloggerTest030_TagSetLogTag08()
945 // Store the name of this test case
946 SetTestStepName(_L("step_030_TagSetLogTag08"));
952 CFloggerTest030_TagSetLogTag08::~CFloggerTest030_TagSetLogTag08()
959 TVerdict CFloggerTest030_TagSetLogTag08::doTestStepL( )
961 if ( executeStepL() == KErrNone )
962 SetTestStepResult(EPass);
965 SetTestStepResult(EFail);
967 User::After(KTimeForDisplay);
970 return TestStepResult();
974 TInt CFloggerTest030_TagSetLogTag08::executeStepL(TBool)
979 TInt CFloggerTest030_TagSetLogTag08::executeStepL()
983 RFileLogger theFlogger;
984 ret = theFlogger.Connect();
986 if ( ret == KErrNone)
988 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
989 theFlogger.ClearLog();
990 theFlogger.SetLogTags(KSubsysTag66char8, KCompTag66char8);
991 theFlogger.Write(KTestMessage);
993 User::After(KTimeToLog);
994 TRAPD(r, ret = DoTestCheckWriteL());
1006 TInt CFloggerTest030_TagSetLogTag08::DoTestCheckWriteL()
1010 TInt listfilesize,returnCode;
1011 RFs fileSystem; //For file operation create a file system
1012 TUint numSuccessful = 0;
1015 User::LeaveIfError(fileSystem.Connect());
1016 CleanupClosePushL(fileSystem);
1018 //Open the file in the read mode
1019 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1021 CleanupClosePushL(theFile);
1023 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1025 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1026 CleanupStack::PushL(hBuffer);
1028 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1030 // Read from position 0: start of file
1031 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1033 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1040 else if (returnCode == KErrNotFound)
1042 returnCode = ptrString.Find(KErrOOM);
1044 User::Leave(KErrNoMemory);
1047 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
1048 returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
1055 CleanupStack::PopAndDestroy(hBuffer);
1056 CleanupStack::PopAndDestroy(); //theFile
1057 CleanupStack::PopAndDestroy(); //fileSystem
1059 if (numSuccessful == 2)
1062 return KErrNotFound;
1068 /***************************************************************************************/
1071 * 030_TagCreateLog01: Test that flogger handles empty tags
1074 CFloggerTest030_TagCreateLog01::CFloggerTest030_TagCreateLog01()
1076 // Store the name of this test case
1077 SetTestStepName(_L("step_030_TagCreateLog01"));
1083 CFloggerTest030_TagCreateLog01::~CFloggerTest030_TagCreateLog01()
1090 TVerdict CFloggerTest030_TagCreateLog01::doTestStepL( )
1092 if ( executeStepL() == KErrNone )
1093 SetTestStepResult(EPass);
1096 SetTestStepResult(EFail);
1098 User::After(KTimeForDisplay);
1101 return TestStepResult();
1105 TInt CFloggerTest030_TagCreateLog01::executeStepL(TBool)
1110 TInt CFloggerTest030_TagCreateLog01::executeStepL()
1114 RFileLogger theFlogger;
1115 ret = theFlogger.Connect();
1117 if ( ret == KErrNone)
1119 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1120 theFlogger.ClearLog();
1121 theFlogger.CreateLog(KNullDesC16, KNullDesC16, EFileLoggingModeOverwrite);
1122 theFlogger.Write(KTestMessage);
1124 User::After(KTimeToLog);
1125 TRAPD(r, ret = DoTestCheckWriteL());
1137 TInt CFloggerTest030_TagCreateLog01::DoTestCheckWriteL()
1141 TInt listfilesize,returnCode;
1142 RFs fileSystem; //For file operation create a file system
1143 TUint numSuccessful = 0;
1146 User::LeaveIfError(fileSystem.Connect());
1147 CleanupClosePushL(fileSystem);
1149 //Open the file in the read mode
1150 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1152 CleanupClosePushL(theFile);
1154 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1156 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1157 CleanupStack::PushL(hBuffer);
1159 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1161 // Read from position 0: start of file
1162 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1164 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1167 if (returnCode == KErrNotFound)
1170 returnCode = ptrString.Find(KErrOOM);
1172 User::Leave(KErrNoMemory);
1176 CleanupStack::PopAndDestroy(hBuffer);
1177 CleanupStack::PopAndDestroy(); //theFile
1178 CleanupStack::PopAndDestroy(); //fileSystem
1180 if (numSuccessful == 1)
1183 return KErrNotFound;
1190 * 030_TagCreateLog02: Test that flogger handles empty subsys tag
1193 CFloggerTest030_TagCreateLog02::CFloggerTest030_TagCreateLog02()
1195 // Store the name of this test case
1196 SetTestStepName(_L("step_030_TagCreateLog02"));
1202 CFloggerTest030_TagCreateLog02::~CFloggerTest030_TagCreateLog02()
1209 TVerdict CFloggerTest030_TagCreateLog02::doTestStepL( )
1211 if ( executeStepL() == KErrNone )
1212 SetTestStepResult(EPass);
1215 SetTestStepResult(EFail);
1217 User::After(KTimeForDisplay);
1220 return TestStepResult();
1223 TInt CFloggerTest030_TagCreateLog02::executeStepL(TBool)
1229 TInt CFloggerTest030_TagCreateLog02::executeStepL()
1233 RFileLogger theFlogger;
1234 ret = theFlogger.Connect();
1236 if ( ret == KErrNone)
1238 //Create Log by passing the subsystem and component name as parameters
1239 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1240 theFlogger.ClearLog();
1241 theFlogger.CreateLog(KNullDesC16, KStdCompTag16, EFileLoggingModeOverwrite);
1242 theFlogger.Write(KTestMessage);
1244 User::After(KTimeToLog);
1245 TRAPD(r, ret = DoTestCheckWriteL());
1257 TInt CFloggerTest030_TagCreateLog02::DoTestCheckWriteL()
1261 TInt listfilesize,returnCode;
1262 RFs fileSystem; //For file operation create a file system
1263 TUint numSuccessful = 0;
1266 User::LeaveIfError(fileSystem.Connect());
1267 CleanupClosePushL(fileSystem);
1269 //Open the file in the read mode
1270 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1272 CleanupClosePushL(theFile);
1274 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1276 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1277 CleanupStack::PushL(hBuffer);
1279 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1281 // Read from position 0: start of file
1282 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1284 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1287 if (returnCode == KErrNotFound)
1290 returnCode = ptrString.Find(KErrOOM);
1292 User::Leave(KErrNoMemory);
1296 CleanupStack::PopAndDestroy(hBuffer);
1297 CleanupStack::PopAndDestroy(); //theFile
1298 CleanupStack::PopAndDestroy(); //fileSystem
1300 if (numSuccessful == 1)
1303 return KErrNotFound;
1309 * 030_TagCreateLog03: Test that flogger handles empty component tag
1312 CFloggerTest030_TagCreateLog03::CFloggerTest030_TagCreateLog03()
1314 // Store the name of this test case
1315 SetTestStepName(_L("step_030_TagCreateLog03"));
1321 CFloggerTest030_TagCreateLog03::~CFloggerTest030_TagCreateLog03()
1328 TVerdict CFloggerTest030_TagCreateLog03::doTestStepL( )
1330 if ( executeStepL() == KErrNone )
1331 SetTestStepResult(EPass);
1334 SetTestStepResult(EFail);
1336 User::After(KTimeForDisplay);
1339 return TestStepResult();
1343 TInt CFloggerTest030_TagCreateLog03::executeStepL(TBool)
1348 TInt CFloggerTest030_TagCreateLog03::executeStepL()
1352 RFileLogger theFlogger;
1353 ret = theFlogger.Connect();
1355 if ( ret == KErrNone)
1357 //Create Log by passing the subsystem and component name as parameters
1358 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1359 theFlogger.ClearLog();
1360 theFlogger.CreateLog(KStdSubsysTag16, KNullDesC16, EFileLoggingModeOverwrite);
1361 theFlogger.Write(KTestMessage);
1363 User::After(KTimeToLog);
1364 TRAPD(r, ret = DoTestCheckWriteL());
1376 TInt CFloggerTest030_TagCreateLog03::DoTestCheckWriteL()
1380 TInt listfilesize,returnCode;
1381 RFs fileSystem; //For file operation create a file system
1382 TUint numSuccessful = 0;
1385 User::LeaveIfError(fileSystem.Connect());
1386 CleanupClosePushL(fileSystem);
1388 //Open the file in the read mode
1389 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1391 CleanupClosePushL(theFile);
1393 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1395 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1396 CleanupStack::PushL(hBuffer);
1398 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1400 // Read from position 0: start of file
1401 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1403 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1406 if (returnCode == KErrNotFound)
1409 returnCode = ptrString.Find(KErrOOM);
1411 User::Leave(KErrNoMemory);
1415 CleanupStack::PopAndDestroy(hBuffer);
1416 CleanupStack::PopAndDestroy(); //theFile
1417 CleanupStack::PopAndDestroy(); //fileSystem
1419 if (numSuccessful == 1)
1422 return KErrNotFound;
1429 * 030_TagCreateLog04: Test that flogger handles spaces in tags
1432 CFloggerTest030_TagCreateLog04::CFloggerTest030_TagCreateLog04()
1434 // Store the name of this test case
1435 SetTestStepName(_L("step_030_TagCreateLog04"));
1441 CFloggerTest030_TagCreateLog04::~CFloggerTest030_TagCreateLog04()
1448 TVerdict CFloggerTest030_TagCreateLog04::doTestStepL( )
1450 if ( executeStepL() == KErrNone )
1451 SetTestStepResult(EPass);
1454 SetTestStepResult(EFail);
1456 User::After(KTimeForDisplay);
1459 return TestStepResult();
1463 TInt CFloggerTest030_TagCreateLog04::executeStepL(TBool)
1468 TInt CFloggerTest030_TagCreateLog04::executeStepL()
1472 RFileLogger theFlogger;
1473 ret = theFlogger.Connect();
1475 if ( ret == KErrNone)
1477 //Create Log by passing the subsystem and component name as parameters
1478 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1479 theFlogger.ClearLog();
1480 theFlogger.CreateLog(KStdSubsysTag16, KCompTagWithSpaceChars16, EFileLoggingModeOverwrite);
1481 theFlogger.Write(KTestMessage);
1483 User::After(KTimeToLog);
1484 TRAPD(r, ret = DoTestCheckWriteL());
1496 TInt CFloggerTest030_TagCreateLog04::DoTestCheckWriteL()
1500 TInt listfilesize,returnCode;
1501 RFs fileSystem; //For file operation create a file system
1502 TUint numSuccessful = 0;
1505 User::LeaveIfError(fileSystem.Connect());
1506 CleanupClosePushL(fileSystem);
1508 //Open the file in the read mode
1509 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1511 CleanupClosePushL(theFile);
1513 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1515 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1516 CleanupStack::PushL(hBuffer);
1518 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1520 // Read from position 0: start of file
1521 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1523 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1526 if (returnCode == KErrNotFound)
1529 returnCode = ptrString.Find(KErrOOM);
1531 User::Leave(KErrNoMemory);
1535 CleanupStack::PopAndDestroy(hBuffer);
1536 CleanupStack::PopAndDestroy(); //theFile
1537 CleanupStack::PopAndDestroy(); //fileSystem
1539 if (numSuccessful == 1)
1542 return KErrNotFound;
1550 * 030_TagCreateLog05: Test that flogger handles punctuation in tags
1553 CFloggerTest030_TagCreateLog05::CFloggerTest030_TagCreateLog05()
1555 // Store the name of this test case
1556 SetTestStepName(_L("step_030_TagCreateLog05"));
1562 CFloggerTest030_TagCreateLog05::~CFloggerTest030_TagCreateLog05()
1569 TVerdict CFloggerTest030_TagCreateLog05::doTestStepL( )
1571 if ( executeStepL() == KErrNone )
1572 SetTestStepResult(EPass);
1575 SetTestStepResult(EFail);
1577 User::After(KTimeForDisplay);
1580 return TestStepResult();
1584 TInt CFloggerTest030_TagCreateLog05::executeStepL(TBool)
1589 TInt CFloggerTest030_TagCreateLog05::executeStepL()
1593 RFileLogger theFlogger;
1594 ret = theFlogger.Connect();
1596 if ( ret == KErrNone)
1598 //Create Log by passing the subsystem and component name as parameters
1599 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1600 theFlogger.ClearLog();
1601 theFlogger.CreateLog(KSubsysTagWithPunctuationChars16, KCompTagWithPunctuationChars16, EFileLoggingModeOverwrite);
1602 theFlogger.Write(KTestMessage);
1604 User::After(KTimeToLog);
1605 TRAPD(r, ret = DoTestCheckWriteL());
1617 TInt CFloggerTest030_TagCreateLog05::DoTestCheckWriteL()
1621 TInt listfilesize,returnCode;
1622 RFs fileSystem; //For file operation create a file system
1623 TUint numSuccessful = 0;
1626 User::LeaveIfError(fileSystem.Connect());
1627 CleanupClosePushL(fileSystem);
1629 //Open the file in the read mode
1630 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1632 CleanupClosePushL(theFile);
1634 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1636 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1637 CleanupStack::PushL(hBuffer);
1639 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1641 // Read from position 0: start of file
1642 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1644 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
1647 if (returnCode == KErrNotFound)
1650 returnCode = ptrString.Find(KErrOOM);
1652 User::Leave(KErrNoMemory);
1656 CleanupStack::PopAndDestroy(hBuffer);
1657 CleanupStack::PopAndDestroy(); //theFile
1658 CleanupStack::PopAndDestroy(); //fileSystem
1660 if (numSuccessful == 1)
1663 return KErrNotFound;
1669 * 030_TagCreateLog06: Test that flogger handles length 16 tags
1672 CFloggerTest030_TagCreateLog06::CFloggerTest030_TagCreateLog06()
1674 // Store the name of this test case
1675 SetTestStepName(_L("step_030_TagCreateLog06"));
1681 CFloggerTest030_TagCreateLog06::~CFloggerTest030_TagCreateLog06()
1688 TVerdict CFloggerTest030_TagCreateLog06::doTestStepL( )
1690 if ( executeStepL() == KErrNone )
1691 SetTestStepResult(EPass);
1694 SetTestStepResult(EFail);
1696 User::After(KTimeForDisplay);
1699 return TestStepResult();
1703 TInt CFloggerTest030_TagCreateLog06::executeStepL(TBool)
1708 TInt CFloggerTest030_TagCreateLog06::executeStepL()
1712 RFileLogger theFlogger;
1713 ret = theFlogger.Connect();
1715 if ( ret == KErrNone)
1717 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1718 theFlogger.ClearLog();
1719 theFlogger.CreateLog(KSubsysTag16char16, KCompTag16char16, EFileLoggingModeOverwrite);
1720 theFlogger.Write(KTestMessage);
1722 User::After(KTimeToLog);
1723 TRAPD(r, ret = DoTestCheckWriteL());
1736 TInt CFloggerTest030_TagCreateLog06::DoTestCheckWriteL()
1740 TInt listfilesize,returnCode;
1741 RFs fileSystem; //For file operation create a file system
1742 TBuf8<256> testData; //To hold the test descriptor
1745 _LIT8(KOOMError, "#Logs may be lost out of memory!!");
1747 User::LeaveIfError(fileSystem.Connect());
1749 //Open the file in the read mode
1750 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1752 CleanupClosePushL(theFile);
1754 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1756 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1757 CleanupStack::PushL(hBuffer);
1759 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1761 // Read from position 0: start of file
1762 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1764 testData.Copy(KTestMessage); //Copy the test descriptor
1765 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1768 if (returnCode == KErrNotFound)
1770 returnCode = ptrString.Find(KOOMError);
1772 User::Leave(KErrNoMemory);
1776 CleanupStack::PopAndDestroy(hBuffer);
1777 CleanupStack::PopAndDestroy(); //theFile
1781 return KErrNotFound;
1792 * 030_TagCreateLog07: Test that flogger handles length 17 tags by truncating
1795 CFloggerTest030_TagCreateLog07::CFloggerTest030_TagCreateLog07()
1797 // Store the name of this test case
1798 SetTestStepName(_L("step_030_TagCreateLog07"));
1804 CFloggerTest030_TagCreateLog07::~CFloggerTest030_TagCreateLog07()
1811 TVerdict CFloggerTest030_TagCreateLog07::doTestStepL( )
1813 if ( executeStepL() == KErrNone )
1814 SetTestStepResult(EPass);
1817 SetTestStepResult(EFail);
1819 User::After(KTimeForDisplay);
1822 return TestStepResult();
1826 TInt CFloggerTest030_TagCreateLog07::executeStepL(TBool)
1831 TInt CFloggerTest030_TagCreateLog07::executeStepL()
1835 RFileLogger theFlogger;
1836 ret = theFlogger.Connect();
1838 if ( ret == KErrNone)
1840 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1841 theFlogger.ClearLog();
1842 theFlogger.CreateLog(KSubsysTag17char16, KCompTag17char16, EFileLoggingModeOverwrite);
1843 theFlogger.Write(KTestMessage);
1845 User::After(KTimeToLog);
1846 TRAPD(r, ret = DoTestCheckWriteL());
1858 * This function checks whether test data was written
1859 * in to the log file .
1863 TInt CFloggerTest030_TagCreateLog07::DoTestCheckWriteL()
1867 TInt listfilesize,returnCode;
1868 RFs fileSystem; //For file operation create a file system
1869 TBuf8<256> testData; //To hold the test descriptor
1870 TInt numSuccessful = 0;
1873 _LIT8(KOOMError, "#Logs may be lost out of memory!!");
1875 User::LeaveIfError(fileSystem.Connect());
1877 //Open the file in the read mode
1878 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
1880 CleanupClosePushL(theFile);
1882 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
1884 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
1885 CleanupStack::PushL(hBuffer);
1887 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
1889 // Read from position 0: start of file
1890 User::LeaveIfError(returnCode = theFile.Read(ptrString));
1892 testData.Copy(KTestMessage); //Copy the test descriptor
1893 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1900 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
1901 testData.Copy(KSubsysTag16char16); //Copy the test descriptor
1902 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1909 testData.Copy(KSubsysTag17char16); //Copy the test descriptor
1910 returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
1912 if (returnCode == KErrNotFound)
1917 if (returnCode == KErrNotFound)
1919 returnCode = ptrString.Find(KOOMError);
1921 User::Leave(KErrNoMemory);
1926 CleanupStack::PopAndDestroy(hBuffer);
1927 CleanupStack::PopAndDestroy(); //theFile
1928 if (numSuccessful == 3)
1931 return KErrNotFound;
1936 * 030_TagCreateLog08: Test that flogger handles very long tags
1939 CFloggerTest030_TagCreateLog08::CFloggerTest030_TagCreateLog08()
1941 // Store the name of this test case
1942 SetTestStepName(_L("step_030_TagCreateLog08"));
1948 CFloggerTest030_TagCreateLog08::~CFloggerTest030_TagCreateLog08()
1955 TVerdict CFloggerTest030_TagCreateLog08::doTestStepL( )
1957 if ( executeStepL() == KErrNone )
1958 SetTestStepResult(EPass);
1961 SetTestStepResult(EFail);
1963 User::After(KTimeForDisplay);
1966 return TestStepResult();
1970 TInt CFloggerTest030_TagCreateLog08::executeStepL(TBool)
1975 TInt CFloggerTest030_TagCreateLog08::executeStepL()
1979 RFileLogger theFlogger;
1980 ret = theFlogger.Connect();
1982 if ( ret == KErrNone)
1984 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
1985 theFlogger.ClearLog();
1986 theFlogger.CreateLog(KSubsysTag66char16, KCompTag66char16, EFileLoggingModeOverwrite);
1987 theFlogger.Write(KTestMessage);
1989 User::After(KTimeToLog);
1990 TRAPD(r, ret = DoTestCheckWriteL());
2002 TInt CFloggerTest030_TagCreateLog08::DoTestCheckWriteL()
2006 TInt listfilesize,returnCode;
2007 RFs fileSystem; //For file operation create a file system
2008 TUint numSuccessful = 0;
2011 User::LeaveIfError(fileSystem.Connect());
2012 CleanupClosePushL(fileSystem);
2014 //Open the file in the read mode
2015 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2017 CleanupClosePushL(theFile);
2019 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2021 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2022 CleanupStack::PushL(hBuffer);
2024 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2026 // Read from position 0: start of file
2027 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2029 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2036 else if (returnCode == KErrNotFound)
2038 returnCode = ptrString.Find(KErrOOM);
2040 User::Leave(KErrNoMemory);
2043 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
2044 returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
2051 CleanupStack::PopAndDestroy(hBuffer);
2052 CleanupStack::PopAndDestroy(); //theFile
2053 CleanupStack::PopAndDestroy(); //fileSystem
2055 if (numSuccessful == 2)
2058 return KErrNotFound;
2064 /***************************************************************************************/
2068 * 030_TagWrite01: Test that flogger handles empty tags
2071 CFloggerTest030_TagWrite01::CFloggerTest030_TagWrite01()
2073 // Store the name of this test case
2074 SetTestStepName(_L("step_030_TagWrite01"));
2080 CFloggerTest030_TagWrite01::~CFloggerTest030_TagWrite01()
2087 TVerdict CFloggerTest030_TagWrite01::doTestStepL( )
2089 if ( executeStepL() == KErrNone )
2090 SetTestStepResult(EPass);
2093 SetTestStepResult(EFail);
2095 User::After(KTimeForDisplay);
2098 return TestStepResult();
2102 TInt CFloggerTest030_TagWrite01::executeStepL(TBool)
2107 TInt CFloggerTest030_TagWrite01::executeStepL()
2111 RFileLogger theFlogger;
2112 ret = theFlogger.Connect();
2114 if ( ret == KErrNone)
2116 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2117 theFlogger.ClearLog();
2119 RFileLogger::Write(KNullDesC8, KNullDesC8,KTestMessage);
2120 User::After(KTimeToLog);
2121 TRAPD(r, ret = DoTestCheckWriteL());
2133 TInt CFloggerTest030_TagWrite01::DoTestCheckWriteL()
2137 TInt listfilesize,returnCode;
2138 RFs fileSystem; //For file operation create a file system
2139 TUint numSuccessful = 0;
2142 User::LeaveIfError(fileSystem.Connect());
2143 CleanupClosePushL(fileSystem);
2145 //Open the file in the read mode
2146 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2148 CleanupClosePushL(theFile);
2150 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2152 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2153 CleanupStack::PushL(hBuffer);
2155 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2157 // Read from position 0: start of file
2158 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2160 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2163 if (returnCode == KErrNotFound)
2166 returnCode = ptrString.Find(KErrOOM);
2168 User::Leave(KErrNoMemory);
2172 CleanupStack::PopAndDestroy(hBuffer);
2173 CleanupStack::PopAndDestroy(); //theFile
2174 CleanupStack::PopAndDestroy(); //fileSystem
2176 if (numSuccessful == 1)
2179 return KErrNotFound;
2186 * 030_TagWrite02: Test that flogger handles empty subsys tag
2189 CFloggerTest030_TagWrite02::CFloggerTest030_TagWrite02()
2191 // Store the name of this test case
2192 SetTestStepName(_L("step_030_TagWrite02"));
2198 CFloggerTest030_TagWrite02::~CFloggerTest030_TagWrite02()
2205 TVerdict CFloggerTest030_TagWrite02::doTestStepL( )
2207 if ( executeStepL() == KErrNone )
2208 SetTestStepResult(EPass);
2211 SetTestStepResult(EFail);
2213 User::After(KTimeForDisplay);
2216 return TestStepResult();
2220 TInt CFloggerTest030_TagWrite02::executeStepL(TBool)
2225 TInt CFloggerTest030_TagWrite02::executeStepL()
2229 RFileLogger theFlogger;
2230 ret = theFlogger.Connect();
2232 if ( ret == KErrNone)
2234 //Create Log by passing the subsystem and component name as parameters
2235 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2236 theFlogger.ClearLog();
2238 RFileLogger::Write(KNullDesC8, KStdCompTag8,KTestMessage);
2239 User::After(KTimeToLog);
2240 TRAPD(r, ret = DoTestCheckWriteL());
2252 TInt CFloggerTest030_TagWrite02::DoTestCheckWriteL()
2256 TInt listfilesize,returnCode;
2257 RFs fileSystem; //For file operation create a file system
2258 TUint numSuccessful = 0;
2261 User::LeaveIfError(fileSystem.Connect());
2262 CleanupClosePushL(fileSystem);
2264 //Open the file in the read mode
2265 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2267 CleanupClosePushL(theFile);
2269 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2271 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2272 CleanupStack::PushL(hBuffer);
2274 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2276 // Read from position 0: start of file
2277 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2279 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2282 if (returnCode == KErrNotFound)
2285 returnCode = ptrString.Find(KErrOOM);
2287 User::Leave(KErrNoMemory);
2291 CleanupStack::PopAndDestroy(hBuffer);
2292 CleanupStack::PopAndDestroy(); //theFile
2293 CleanupStack::PopAndDestroy(); //fileSystem
2295 if (numSuccessful == 1)
2298 return KErrNotFound;
2304 * 030_TagWrite03: Test that flogger handles empty component tag
2307 CFloggerTest030_TagWrite03::CFloggerTest030_TagWrite03()
2309 // Store the name of this test case
2310 SetTestStepName(_L("step_030_TagWrite03"));
2316 CFloggerTest030_TagWrite03::~CFloggerTest030_TagWrite03()
2323 TVerdict CFloggerTest030_TagWrite03::doTestStepL( )
2325 if ( executeStepL() == KErrNone )
2326 SetTestStepResult(EPass);
2329 SetTestStepResult(EFail);
2331 User::After(KTimeForDisplay);
2334 return TestStepResult();
2338 TInt CFloggerTest030_TagWrite03::executeStepL(TBool)
2343 TInt CFloggerTest030_TagWrite03::executeStepL()
2347 RFileLogger theFlogger;
2348 ret = theFlogger.Connect();
2350 if ( ret == KErrNone)
2352 //Create Log by passing the subsystem and component name as parameters
2353 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2354 theFlogger.ClearLog();
2356 RFileLogger::Write(KStdSubsysTag8, KNullDesC8,KTestMessage);
2357 User::After(KTimeToLog);
2358 TRAPD(r, ret = DoTestCheckWriteL());
2370 TInt CFloggerTest030_TagWrite03::DoTestCheckWriteL()
2374 TInt listfilesize,returnCode;
2375 RFs fileSystem; //For file operation create a file system
2376 TUint numSuccessful = 0;
2379 User::LeaveIfError(fileSystem.Connect());
2380 CleanupClosePushL(fileSystem);
2382 //Open the file in the read mode
2383 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2385 CleanupClosePushL(theFile);
2387 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2389 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2390 CleanupStack::PushL(hBuffer);
2392 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2394 // Read from position 0: start of file
2395 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2397 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2400 if (returnCode == KErrNotFound)
2403 returnCode = ptrString.Find(KErrOOM);
2405 User::Leave(KErrNoMemory);
2409 CleanupStack::PopAndDestroy(hBuffer);
2410 CleanupStack::PopAndDestroy(); //theFile
2411 CleanupStack::PopAndDestroy(); //fileSystem
2413 if (numSuccessful == 1)
2416 return KErrNotFound;
2423 * 030_TagWrite04: Test that flogger handles spaces in tags
2426 CFloggerTest030_TagWrite04::CFloggerTest030_TagWrite04()
2428 // Store the name of this test case
2429 SetTestStepName(_L("step_030_TagWrite04"));
2435 CFloggerTest030_TagWrite04::~CFloggerTest030_TagWrite04()
2442 TVerdict CFloggerTest030_TagWrite04::doTestStepL( )
2444 if ( executeStepL() == KErrNone )
2445 SetTestStepResult(EPass);
2448 SetTestStepResult(EFail);
2450 User::After(KTimeForDisplay);
2453 return TestStepResult();
2457 TInt CFloggerTest030_TagWrite04::executeStepL(TBool)
2462 TInt CFloggerTest030_TagWrite04::executeStepL()
2466 RFileLogger theFlogger;
2467 ret = theFlogger.Connect();
2469 if ( ret == KErrNone)
2471 //Create Log by passing the subsystem and component name as parameters
2472 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2473 theFlogger.ClearLog();
2475 RFileLogger::Write(KStdSubsysTag8, KCompTagWithSpaceChars8,KTestMessage);
2476 User::After(KTimeToLog);
2477 TRAPD(r, ret = DoTestCheckWriteL());
2489 TInt CFloggerTest030_TagWrite04::DoTestCheckWriteL()
2493 TInt listfilesize,returnCode;
2494 RFs fileSystem; //For file operation create a file system
2495 TUint numSuccessful = 0;
2498 User::LeaveIfError(fileSystem.Connect());
2499 CleanupClosePushL(fileSystem);
2501 //Open the file in the read mode
2502 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2504 CleanupClosePushL(theFile);
2506 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2508 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2509 CleanupStack::PushL(hBuffer);
2511 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2513 // Read from position 0: start of file
2514 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2516 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2519 if (returnCode == KErrNotFound)
2522 returnCode = ptrString.Find(KErrOOM);
2524 User::Leave(KErrNoMemory);
2528 CleanupStack::PopAndDestroy(hBuffer);
2529 CleanupStack::PopAndDestroy(); //theFile
2530 CleanupStack::PopAndDestroy(); //fileSystem
2532 if (numSuccessful == 1)
2535 return KErrNotFound;
2543 * 030_TagWrite05: Test that flogger handles punctuation in tags
2546 CFloggerTest030_TagWrite05::CFloggerTest030_TagWrite05()
2548 // Store the name of this test case
2549 SetTestStepName(_L("step_030_TagWrite05"));
2555 CFloggerTest030_TagWrite05::~CFloggerTest030_TagWrite05()
2562 TVerdict CFloggerTest030_TagWrite05::doTestStepL( )
2564 if ( executeStepL() == KErrNone )
2565 SetTestStepResult(EPass);
2568 SetTestStepResult(EFail);
2570 User::After(KTimeForDisplay);
2573 return TestStepResult();
2576 TInt CFloggerTest030_TagWrite05::executeStepL(TBool)
2582 TInt CFloggerTest030_TagWrite05::executeStepL()
2586 RFileLogger theFlogger;
2587 ret = theFlogger.Connect();
2589 if ( ret == KErrNone)
2591 //Create Log by passing the subsystem and component name as parameters
2592 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2593 theFlogger.ClearLog();
2595 RFileLogger::Write(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8,KTestMessage);
2596 User::After(KTimeToLog);
2597 TRAPD(r, ret = DoTestCheckWriteL());
2609 TInt CFloggerTest030_TagWrite05::DoTestCheckWriteL()
2613 TInt listfilesize,returnCode;
2614 RFs fileSystem; //For file operation create a file system
2615 TUint numSuccessful = 0;
2618 User::LeaveIfError(fileSystem.Connect());
2619 CleanupClosePushL(fileSystem);
2621 //Open the file in the read mode
2622 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2624 CleanupClosePushL(theFile);
2626 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2628 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2629 CleanupStack::PushL(hBuffer);
2631 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2633 // Read from position 0: start of file
2634 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2636 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2639 if (returnCode == KErrNotFound)
2642 returnCode = ptrString.Find(KErrOOM);
2644 User::Leave(KErrNoMemory);
2648 CleanupStack::PopAndDestroy(hBuffer);
2649 CleanupStack::PopAndDestroy(); //theFile
2650 CleanupStack::PopAndDestroy(); //fileSystem
2652 if (numSuccessful == 1)
2655 return KErrNotFound;
2660 * 030_TagWrite06: Test that flogger handles long tags
2663 CFloggerTest030_TagWrite06::CFloggerTest030_TagWrite06()
2665 // Store the name of this test case
2666 SetTestStepName(_L("step_030_TagWrite06"));
2672 CFloggerTest030_TagWrite06::~CFloggerTest030_TagWrite06()
2679 TVerdict CFloggerTest030_TagWrite06::doTestStepL( )
2681 if ( executeStepL() == KErrNone )
2682 SetTestStepResult(EPass);
2685 SetTestStepResult(EFail);
2687 User::After(KTimeForDisplay);
2690 return TestStepResult();
2694 TInt CFloggerTest030_TagWrite06::executeStepL(TBool)
2699 TInt CFloggerTest030_TagWrite06::executeStepL()
2703 RFileLogger theFlogger;
2704 ret = theFlogger.Connect();
2706 if ( ret == KErrNone)
2708 //Create Log by passing the subsystem and component name as parameters
2709 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2710 theFlogger.ClearLog();
2712 RFileLogger::Write(KSubsysTag16char8, KCompTag16char8,KTestMessage8);
2713 User::After(KTimeToLog);
2714 TRAPD(r, ret = DoTestCheckWriteL());
2726 TInt CFloggerTest030_TagWrite06::DoTestCheckWriteL()
2730 TInt listfilesize,returnCode;
2731 RFs fileSystem; //For file operation create a file system
2732 TUint numSuccessful = 0;
2735 User::LeaveIfError(fileSystem.Connect());
2736 CleanupClosePushL(fileSystem);
2738 //Open the file in the read mode
2739 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2741 CleanupClosePushL(theFile);
2743 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2745 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2746 CleanupStack::PushL(hBuffer);
2748 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2750 // Read from position 0: start of file
2751 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2753 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2760 else if (returnCode == KErrNotFound)
2762 returnCode = ptrString.Find(KErrOOM);
2764 User::Leave(KErrNoMemory);
2768 CleanupStack::PopAndDestroy(hBuffer);
2769 CleanupStack::PopAndDestroy(); //theFile
2770 CleanupStack::PopAndDestroy(); //fileSystem
2772 if (numSuccessful == 1)
2775 return KErrNotFound;
2782 * 030_TagWrite07: Test that flogger handles long tags
2785 CFloggerTest030_TagWrite07::CFloggerTest030_TagWrite07()
2787 // Store the name of this test case
2788 SetTestStepName(_L("step_030_TagWrite07"));
2794 CFloggerTest030_TagWrite07::~CFloggerTest030_TagWrite07()
2801 TVerdict CFloggerTest030_TagWrite07::doTestStepL( )
2803 if ( executeStepL() == KErrNone )
2804 SetTestStepResult(EPass);
2807 SetTestStepResult(EFail);
2809 User::After(KTimeForDisplay);
2812 return TestStepResult();
2816 TInt CFloggerTest030_TagWrite07::executeStepL(TBool)
2821 TInt CFloggerTest030_TagWrite07::executeStepL()
2825 RFileLogger theFlogger;
2826 ret = theFlogger.Connect();
2828 if ( ret == KErrNone)
2830 //Create Log by passing the subsystem and component name as parameters
2831 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2832 theFlogger.ClearLog();
2834 RFileLogger::Write(KSubsysTag17char8, KCompTag17char8,KTestMessage8);
2835 User::After(KTimeToLog);
2836 TRAPD(r, ret = DoTestCheckWriteL());
2848 TInt CFloggerTest030_TagWrite07::DoTestCheckWriteL()
2852 TInt listfilesize,returnCode;
2853 RFs fileSystem; //For file operation create a file system
2854 TUint numSuccessful = 0;
2857 User::LeaveIfError(fileSystem.Connect());
2858 CleanupClosePushL(fileSystem);
2860 //Open the file in the read mode
2861 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2863 CleanupClosePushL(theFile);
2865 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
2867 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
2868 CleanupStack::PushL(hBuffer);
2870 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
2872 // Read from position 0: start of file
2873 User::LeaveIfError(returnCode = theFile.Read(ptrString));
2875 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
2882 else if (returnCode == KErrNotFound)
2884 returnCode = ptrString.Find(KErrOOM);
2886 User::Leave(KErrNoMemory);
2889 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
2890 returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
2897 returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read
2899 if (returnCode == KErrNotFound)
2904 CleanupStack::PopAndDestroy(hBuffer);
2905 CleanupStack::PopAndDestroy(); //theFile
2906 CleanupStack::PopAndDestroy(); //fileSystem
2908 if (numSuccessful == 3)
2911 return KErrNotFound;
2918 * 030_TagWrite08: Test that flogger handles very long tags
2921 CFloggerTest030_TagWrite08::CFloggerTest030_TagWrite08()
2923 // Store the name of this test case
2924 SetTestStepName(_L("step_030_TagWrite08"));
2930 CFloggerTest030_TagWrite08::~CFloggerTest030_TagWrite08()
2937 TVerdict CFloggerTest030_TagWrite08::doTestStepL( )
2939 if ( executeStepL() == KErrNone )
2940 SetTestStepResult(EPass);
2943 SetTestStepResult(EFail);
2945 User::After(KTimeForDisplay);
2948 return TestStepResult();
2952 TInt CFloggerTest030_TagWrite08::executeStepL(TBool)
2957 TInt CFloggerTest030_TagWrite08::executeStepL()
2961 RFileLogger theFlogger;
2962 ret = theFlogger.Connect();
2964 if ( ret == KErrNone)
2966 theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
2967 theFlogger.ClearLog();
2969 RFileLogger::Write(KSubsysTag66char8, KCompTag66char8,KTestMessage);
2970 User::After(KTimeToLog);
2971 TRAPD(r, ret = DoTestCheckWriteL());
2983 TInt CFloggerTest030_TagWrite08::DoTestCheckWriteL()
2987 TInt listfilesize,returnCode;
2988 RFs fileSystem; //For file operation create a file system
2989 TUint numSuccessful = 0;
2992 User::LeaveIfError(fileSystem.Connect());
2993 CleanupClosePushL(fileSystem);
2995 //Open the file in the read mode
2996 User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
2998 CleanupClosePushL(theFile);
3000 User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
3002 hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
3003 CleanupStack::PushL(hBuffer);
3005 TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
3007 // Read from position 0: start of file
3008 User::LeaveIfError(returnCode = theFile.Read(ptrString));
3010 returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
3017 else if (returnCode == KErrNotFound)
3019 returnCode = ptrString.Find(KErrOOM);
3021 User::Leave(KErrNoMemory);
3024 // We expect to see the string "subsystem0123456" but not "subsystem01234567"
3025 returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
3032 CleanupStack::PopAndDestroy(hBuffer);
3033 CleanupStack::PopAndDestroy(); //theFile
3034 CleanupStack::PopAndDestroy(); //fileSystem
3036 if (numSuccessful == 2)
3039 return KErrNotFound;