os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/step_017_xx.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // This contains Flogger Unit Test Case 017.xx
    15 
    16 // EPOC includes
    17 #include <e32base.h>
    18 
    19 // Test system includes
    20 #include <comms-infras/commsdebugutility.h>
    21 #include "TestMessage.h"
    22 #include <f32file.h>
    23 
    24 
    25 //User includes
    26 #include "teststepcomsdbg.h"
    27 #include "step_017_xx.h"
    28 
    29 
    30 /**
    31 * Function  Name	: CFloggerTest017_01
    32 * Input parameters	: None
    33 * Output parameters : None
    34 * Description		: This is the constructor
    35 */ 
    36 
    37 
    38 CFloggerTest017_01::CFloggerTest017_01()
    39 	{
    40 	// store the name of this test case
    41 	SetTestStepName(_L("step_017_01"));
    42 	}
    43 
    44 
    45 /**
    46 * Function  Name	:~ CFloggerTest017_01
    47 * Input parameters	: None
    48 * Output parameters : None
    49 * Description		: This is the Destructor
    50 */ 
    51 
    52 
    53 CFloggerTest017_01::~CFloggerTest017_01()
    54 	{
    55 	}	
    56 
    57 
    58 /**
    59 * Function  Name	: doTestStepL
    60 * Input parameters	: None
    61 * Output parameters : TVerdict 
    62 * Description		: This function returns weather the test case 017_01 has 
    63 * 					  passed or failed
    64 
    65 */
    66 
    67 
    68 TVerdict CFloggerTest017_01::doTestStepL( )
    69 	{
    70 	INFO_PRINTF1(_L("Step 017.01 called "));
    71 	
    72 	if ( executeStepL(EFalse) == KErrNone )
    73 		SetTestStepResult(EPass);
    74 
    75 	else
    76 		SetTestStepResult(EFail);
    77 
    78 	
    79 	User::After(KTimeForDisplay1);
    80 	return TestStepResult();
    81 	}
    82 /**
    83 * Function  Name		: executeStepL
    84 * Input parameters		: None
    85 * Output parameters		: TInt 
    86 * Description 			: This function writes the test data in to the log file 
    87 * 						  This function check the test message is present in the 
    88 * 						  log file 
    89 
    90 */
    91 
    92 
    93 TInt CFloggerTest017_01::executeStepL()
    94 	{
    95 	return KErrGeneral;
    96 	}
    97 
    98 /**
    99 * Function  Name		: executeStepL
   100 * Input parameters		: None
   101 * Output parameters		: TInt 
   102 * Description 			: This function writes the test data in to the log file 
   103 * 						  This function check the test message is present in the 
   104 * 						  log file 
   105 
   106 */
   107 
   108 
   109 TInt CFloggerTest017_01::executeStepL(TBool heapTest)
   110 	{
   111 	TInt ret = KErrGeneral;
   112 	
   113 	ret = DoTestWrite();
   114 	if (ret == KErrNone)
   115 		{
   116 		User::After(KTimeToLog);
   117 		TRAPD(r, ret = DoTestCheckWriteL() );
   118 		if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
   119 			{
   120 			ret = KErrNoMemory;
   121 			}
   122 		else if (r != KErrNone)
   123 			{
   124 			ret = r;
   125 			}
   126 		}		
   127 	return ret;
   128 	}
   129 
   130 
   131 /**
   132 * Function  Name		: DoTestWrite
   133 * Input parameters		: None
   134 * Output parameters		: TInt 
   135 * Description 			: This function writes the data to the file logger in hexa format
   136  
   137 */
   138 
   139 
   140 TInt CFloggerTest017_01::DoTestWrite()
   141 	{
   142 	_LIT8(KDescText, "TC 17_1:Test Msg----"); //Test body descriptor
   143 		
   144 	//Write the test datas in the hexa format
   145 	RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KHexTestHeader);
   146 
   147 	// connect so we can flush file buffer for heap check since timer is killed in heap checks
   148 	RFileLogger theFlogger;
   149 	theFlogger.Connect();
   150 	theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
   151 	ForceLogFlush(theFlogger);
   152 	theFlogger.Close();
   153 	return KErrNone; 
   154 	}
   155 
   156 
   157 /**
   158 * Function  Name		: DoTestCheckWriteL
   159 * Input parameters		: None
   160 * Output parameters		: TInt 
   161 * Description 			: This function checks the weather test data was written
   162 * 						  in to the log file by DoTestWrite() or not.
   163 					  
   164 */
   165 
   166 
   167 TInt CFloggerTest017_01::DoTestCheckWriteL()
   168 	{
   169 	User::After(KTimeToLog);
   170 
   171 	RFile theFile;
   172 	HBufC8 * hBuffer;
   173 	TInt listfilesize;
   174 	TInt returnCode;
   175 	RFs fileSystem; //For file operation create a file system	
   176 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   177 
   178 	_LIT8(KBodyTxt,"TC 17_1:Test Msg");//  First 16 chars of Test body descriptor 
   179 
   180 	User::LeaveIfError(fileSystem.Connect());
   181 
   182 	//Open the file in the read mode
   183 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)) ;
   184 
   185 	
   186 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   187 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   188 	CleanupStack::PushL(hBuffer);
   189 
   190 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   191 
   192 	// Read from position 0, i.e starting of file
   193 	returnCode = theFile.Read(ptrString);
   194 
   195 	returnCode = ptrString.Find(KHexTestHeader); //find the test  header descriptor in
   196 										 //the buffer read from the file
   197 
   198 	if (returnCode > 0) //The header is present
   199 		{
   200 		returnCode = ptrString.Find(KHexTestMargin); //find the test margin descriptor in
   201 										 //the buffer read from the file
   202 		}
   203 
   204 	if (returnCode > 0) //The margin is present
   205 		{
   206 		returnCode = ptrString.Find(KBodyTxt); //find the test descriptor in the 
   207 										 //buffer read from the file
   208 		}
   209 
   210 	theFile.Close();
   211 	fileSystem.Close(); //Close the file server
   212 	CleanupStack::PopAndDestroy(hBuffer);
   213 
   214 	if (returnCode > 0) //The test body descriptor is present
   215 		return KErrNone;
   216 	else 
   217 		return KErrNotFound;
   218 	}
   219 
   220 
   221 
   222 
   223 
   224 /**
   225 * Function  Name	: CFloggerTest017_02
   226 * Input parameters	: None
   227 * Output parameters : None
   228 * Description		: This is the constructor
   229 */ 
   230 
   231 
   232 CFloggerTest017_02::CFloggerTest017_02()
   233 	{
   234 	// store the name of this test case
   235 	SetTestStepName(_L("step_017_02"));
   236 	}
   237 
   238 
   239 /**
   240 * Function  Name	:~ CFloggerTest017_02
   241 * Input parameters	: None
   242 * Output parameters : None
   243 * Description		: This is the Destructor
   244 */
   245 
   246 
   247 CFloggerTest017_02::~CFloggerTest017_02()
   248 	{		
   249 	}
   250 
   251 
   252 /**
   253 * Function  Name	: doTestStepL
   254 * Input parameters	: None
   255 * Output parameters : TVerdict 
   256 * Description		: This function returns weather the test case 017_02 has 
   257 * 					  passed or failed
   258 
   259 */
   260 
   261 
   262 TVerdict CFloggerTest017_02::doTestStepL( )
   263 	{
   264 	INFO_PRINTF1(_L("Step 017.02 called "));
   265 	
   266 	if ( executeStepL() == KErrNone )
   267 		SetTestStepResult(EPass);
   268 
   269 	else
   270 		SetTestStepResult(EFail);
   271 
   272 	
   273 	User::After(KTimeForDisplay1);
   274 	return TestStepResult();
   275 	}
   276 
   277 /**
   278 * Function  Name		: executeStepL
   279 * Input parameters		: None
   280 * Output parameters		: TInt 
   281 * Description 			: This function writes the test data in to the log file 
   282 * 						  This function check the test message is present in the 
   283 * 						  log file 
   284 
   285 */
   286 
   287 
   288 
   289 TInt CFloggerTest017_02::executeStepL(TBool)
   290 	{
   291 	return KErrGeneral;
   292 	}
   293 /**
   294 * Function  Name		: executeStepL
   295 * Input parameters		: None
   296 * Output parameters		: TInt 
   297 * Description 			: This function writes the test data in to the log file 
   298 * 						  This function check the test message is present in the 
   299 * 						  log file 
   300 
   301 */
   302 
   303 
   304 
   305 TInt CFloggerTest017_02::executeStepL( )
   306 	{
   307 	User::After(1000*1000);	//Need this or connect will return KErrServerTerminated
   308 	TInt ret = KErrGeneral;
   309 	
   310 	ret = DoTestWrite();
   311 	if (ret == KErrNone )
   312 		{
   313 		TRAPD(r, ret = DoTestCheckWriteL());
   314 		if (r != KErrNone)
   315 			ret = r;
   316 		}
   317 		
   318 	return ret;
   319 	}
   320 
   321 
   322 /**
   323 * Function  Name		: DoTestWrite
   324 * Input parameters		: None
   325 * Output parameters		: TInt 
   326 * Description 			: This function writes the data to the file logger
   327  
   328 */
   329 
   330 
   331 TInt CFloggerTest017_02::DoTestWrite()
   332 	{
   333 
   334 	RFileLogger theFlogger;
   335 	TInt ret = KErrNone;
   336 
   337 	ret = theFlogger.Connect(); //Just to clear the old log message
   338 	if (ret == KErrNone)
   339 		ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
   340 		if (ret == KErrNone)
   341 			ret = theFlogger.ClearLog();
   342 			if (ret == KErrNone)
   343 				theFlogger.Close();
   344 
   345 	if (ret == KErrNone)
   346 		{
   347 		_LIT8(KDescText,"TC 17_2:Test Msg");
   348 
   349 		//Write the test datas in the hexa format
   350 		RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KEightSpaces8);
   351 			
   352 		return KErrNone;
   353 		}
   354 		return ret;
   355 	}
   356 
   357 
   358 /**
   359 * Function  Name		: DoTestCheckWriteL
   360 * Input parameters		: None
   361 * Output parameters		: TInt 
   362 * Description 			: This function checks the weather test data was written
   363 * 						  in to the log file by DoTestWrite() or not.
   364 					  
   365 */
   366 
   367 
   368 TInt CFloggerTest017_02::DoTestCheckWriteL()
   369 	{
   370 	User::After(KTimeToLog);
   371 	RFile theFile;
   372 	HBufC8 * hBuffer;
   373 	TInt listfilesize;
   374 	TInt returnCode;
   375 	RFs fileSystem; //For file operation create a file system	
   376 	TBuf8<256> testData; //To hold the test descriptor
   377 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   378 
   379 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message 
   380 
   381 	User::LeaveIfError(fileSystem.Connect());
   382 	
   383 	//Open the file in the read mode
   384 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   385 
   386 	CleanupClosePushL(theFile);
   387 	
   388 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   389 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   390 	CleanupStack::PushL(hBuffer);
   391 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   392 
   393 	// Read from position 0: start of file
   394 	returnCode = theFile.Read(ptrString);
   395 	
   396 	testData.FillZ();
   397 	testData.Copy(KEightSpaces8); //Copy the test descriptor 
   398 	returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
   399 										 //from the file
   400 
   401 	if (returnCode == KErrNotFound) // Check for the error message in the log
   402 		{
   403 		returnCode = ptrString.Find(KOOMError);
   404 		if (returnCode > 0)
   405 			User::Leave(KErrNoMemory);
   406 		}
   407 	
   408 	CleanupStack::PopAndDestroy(hBuffer);
   409 	CleanupStack::PopAndDestroy();	//theFile
   410 	if (returnCode > 0)
   411 		return KErrNone;
   412 	else 
   413 		return KErrGeneral;
   414 	}
   415 
   416 
   417 
   418 /**
   419 * Function  Name	: CFloggerTest017_03
   420 * Input parameters	: None
   421 * Output parameters : None
   422 * Description		: This is the constructor
   423 * Description		: This is the constructor
   424 */
   425 
   426 
   427 CFloggerTest017_03::CFloggerTest017_03()
   428 	{
   429 	// store the name of this test case
   430 	SetTestStepName(_L("step_017_03"));
   431 	}
   432 
   433 
   434 /**
   435 * Function  Name	:~ CFloggerTest017_03
   436 * Input parameters	: None
   437 * Output parameters : None
   438 * Description		: This is the Destructor
   439 */
   440 
   441 
   442 CFloggerTest017_03::~CFloggerTest017_03()
   443 	{
   444 	}
   445 
   446 
   447 /**
   448 * Function  Name	: doTestStepL
   449 * Input parameters	: None
   450 * Output parameters : TVerdict 
   451 * Description		: This function returns weather the test case 017_03 has 
   452 * 					  passed or failed
   453 
   454 */
   455 
   456 
   457 TVerdict CFloggerTest017_03::doTestStepL( )
   458 	{
   459 	INFO_PRINTF1(_L("Step 017.03 called "));
   460 	
   461 	if ( executeStepL() == KErrNone )
   462 		SetTestStepResult(EPass);
   463 
   464 	else
   465 		SetTestStepResult(EFail);
   466 
   467 	
   468 	User::After(KTimeForDisplay1);
   469 	return TestStepResult();
   470 	}
   471 
   472 
   473 /**
   474 * Function  Name		: executeStepL
   475 * Input parameters		: None
   476 * Output parameters		: TInt 
   477 * Description 			: This function writes the test data in to the log file 
   478 * 						  This function check the test message is present in the 
   479 * 						  log file 
   480 
   481 */
   482 
   483 
   484 TInt CFloggerTest017_03::executeStepL( )
   485 	{
   486 	User::After(1000*1000);	//Need this or connect will return KErrServerTerminated
   487 	TInt ret = KErrGeneral;
   488 	
   489 	ret = DoTestWrite();
   490 	if (ret == KErrNone )
   491 		{
   492 		TRAPD(r, ret = DoTestCheckWriteL());
   493 		if (ret != KErrNone)
   494 			ret = r;
   495 		}
   496 		
   497 	return ret;
   498 	}
   499 
   500 /**
   501 * Function  Name		: executeStepL
   502 * Input parameters		: None
   503 * Output parameters		: TInt 
   504 * Description 			: This function writes the test data in to the log file 
   505 * 						  This function check the test message is present in the 
   506 * 						  log file 
   507 
   508 */
   509 
   510 
   511 TInt CFloggerTest017_03::executeStepL(TBool)
   512 	{
   513 	return KErrGeneral;
   514 	}
   515 
   516 //**
   517 /* Function  Name		: DoTestWrite
   518 * Input parameters		: None
   519 * Output parameters		: TInt 
   520 * Description 			: This function writes the data to the file logger
   521  
   522 */
   523 
   524 
   525 TInt CFloggerTest017_03::DoTestWrite()
   526 	{
   527 	
   528 	RFileLogger theFlogger;
   529 	TInt ret = KErrNone;
   530 	
   531 	ret = theFlogger.Connect(); //Just to clear the old log message
   532 	if (ret == KErrNone)
   533 		ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
   534 		if (ret == KErrNone)
   535 			ret = theFlogger.ClearLog();
   536 			if (ret == KErrNone)
   537 				theFlogger.Close();
   538 
   539 	if (ret == KErrNone)
   540 		{
   541 		_LIT8(KDescText,"TC 17_3:Test Msg"); //8 bit test descriptor
   542 		
   543 		//Write the test datas in the hexa format
   544 		RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText);
   545 		
   546 		
   547 		return KErrNone;
   548 		}
   549 	return ret;
   550 	}
   551 
   552 
   553 /**
   554 * Function  Name		: DoTestCheckWriteL
   555 * Input parameters		: None
   556 * Output parameters		: TInt 
   557 * Description 			: This function checks the weather test data was written
   558 * 						  in to the log file by DoTestWrite() or not.
   559 					  
   560 */
   561 
   562 
   563 TInt CFloggerTest017_03::DoTestCheckWriteL()
   564 	{
   565 
   566 	User::After(KTimeToLog);
   567 	RFile theFile;
   568 	HBufC8 * hBuffer;
   569 	TInt listfilesize;
   570 	TInt returnCode;
   571 	RFs fileSystem; //For file operation create a file system	
   572 	TBuf8<256> testData; //To hold the test descriptor
   573 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   574 
   575 	_LIT8(KBodyTxt,"TC 17_3:Test Msg");//  Test body descriptor 
   576 
   577 	User::LeaveIfError(fileSystem.Connect());
   578 	
   579 	//Open the file in the read mode
   580 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   581 	CleanupClosePushL(theFile);
   582 	
   583 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   584 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   585 	CleanupStack::PushL(hBuffer);
   586 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   587 
   588 	// Read from position 0: start of file
   589 	returnCode=theFile.Read(ptrString);
   590 		
   591 	testData.Copy(KBodyTxt); //Copy the test descriptor 
   592 	returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
   593 										 //from the file
   594 										 
   595 	if (returnCode == KErrNotFound)  //Find the error message
   596 		{
   597 		returnCode = ptrString.Find(KErrOOM);
   598 		if (returnCode > 0)
   599 			User::Leave(KErrNoMemory);
   600 		}
   601 	
   602 	CleanupStack::PopAndDestroy(hBuffer);
   603 	CleanupStack::PopAndDestroy();	//theFile object
   604 	if (returnCode > 0)
   605 		return KErrNone;
   606 	else 
   607 		return KErrGeneral;
   608 	}
   609 
   610 
   611 
   612 /**
   613 * Function  Name	: CFloggerTest017_04
   614 * Input parameters	: None
   615 * Output parameters : None
   616 * Description		: This is the constructor
   617 */
   618 
   619 
   620 CFloggerTest017_04::CFloggerTest017_04()
   621 	{
   622 	// store the name of this test case
   623 	SetTestStepName(_L("step_017_04"));
   624 	}
   625 
   626 
   627 /**
   628 * Function  Name	:~ CFloggerTest017_04
   629 * Input parameters	: None
   630 * Output parameters : None
   631 * Description		: This is the Destructor
   632 */
   633 
   634 
   635 CFloggerTest017_04::~CFloggerTest017_04()
   636 	{
   637 	}
   638 
   639 /**
   640 * Function  Name	: doTestStepL
   641 * Input parameters	: None
   642 * Output parameters : TVerdict 
   643 * Description		: This function returns weather the test case 017_04 has 
   644 * 					  passed or failed
   645 
   646 */
   647 
   648 
   649 TVerdict CFloggerTest017_04::doTestStepL( )
   650 	{
   651 	INFO_PRINTF1(_L("Step 017.04 called "));
   652 	
   653 	if ( executeStepL() == KErrNone )
   654 		SetTestStepResult(EPass);
   655 
   656 	else
   657 		SetTestStepResult(EFail);
   658 
   659 	
   660 	User::After(KTimeForDisplay1);
   661 	return TestStepResult();
   662 	}
   663 
   664 
   665 /**
   666 * Function  Name		: executeStepL
   667 * Input parameters		: None
   668 * Output parameters		: TInt 
   669 * Description 			: This function writes the test data in to the log file 
   670 * 						  This function check the test message is present in the 
   671 * 						  log file 
   672 
   673 */
   674 
   675 
   676 TInt CFloggerTest017_04::executeStepL( )
   677 	{
   678 	User::After(1000*1000);	//Need this or connect will return KErrServerTerminated
   679 	TInt ret = KErrGeneral;
   680 	
   681 	ret = DoTestWrite();
   682 	if (ret == KErrNone )
   683 		{
   684 		TRAPD(r, ret = DoTestCheckWriteL());
   685 		if (ret != KErrNone)
   686 			ret = r;
   687 		}
   688 		
   689 	return ret;
   690 	}
   691 /**
   692 * Function  Name		: executeStepL
   693 * Input parameters		: None
   694 * Output parameters		: TInt 
   695 * Description 			: This function writes the test data in to the log file 
   696 * 						  This function check the test message is present in the 
   697 * 						  log file 
   698 
   699 */
   700 
   701 
   702 TInt CFloggerTest017_04::executeStepL(TBool)
   703 	{
   704 	return KErrGeneral;
   705 	}
   706 
   707 /**
   708 * Function  Name		: DoTestWrite
   709 * Input parameters		: None
   710 * Output parameters		: TInt 
   711 * Description 			: This function writes the data to the file logger
   712  
   713 */
   714 
   715 
   716 TInt CFloggerTest017_04::DoTestWrite()
   717 	{
   718 	_LIT8(KDescText,"TC 17_4:Test Msg");
   719 	
   720 	RFileLogger theFlogger;
   721 	TInt ret = KErrNone;
   722 	ret = theFlogger.Connect(); //Just to clear the old log message
   723 	if (ret == KErrNone)
   724 		ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
   725 		if (ret == KErrNone)
   726 			ret = theFlogger.ClearLog();
   727 			if (ret == KErrNone)
   728 				theFlogger.Close();
   729 	if (ret == KErrNone)
   730 		{
   731 		//Write the test datas in the hexa format
   732 		RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KNullDesC8);
   733 
   734 		return KErrNone;
   735 		}
   736 	return ret;
   737 	}
   738 
   739 
   740 /**
   741 * Function  Name		: DoTestCheckWriteL
   742 * Input parameters		: None
   743 * Output parameters		: TInt 
   744 * Description 			: This function checks the weather test data was written
   745 * 						  in to the log file by DoTestWrite() or not.
   746 					  
   747 */
   748 
   749 
   750 TInt CFloggerTest017_04::DoTestCheckWriteL()
   751 	{
   752 	User::After(KTimeToLog);
   753 	RFile theFile;
   754 	HBufC8 * hBuffer;
   755 	TInt listfilesize;
   756 	TInt returnCode;
   757 	RFs fileSystem; //For file operation create a file system	
   758 	TBuf8<256> testData; //To hold the test descriptor
   759 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   760 
   761 	_LIT(KBodyTxt,"TC 17_4:Test Msg");//  Test body descriptor 
   762 	TUint numSuccessful = 0;
   763 
   764 	User::LeaveIfError(fileSystem.Connect());
   765 	
   766 	//Open the file in the read mode
   767 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   768 	CleanupClosePushL(theFile);
   769 
   770 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   771 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   772 	CleanupStack::PushL(hBuffer);
   773 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   774 
   775 	// Read from position 0: start of file
   776 	returnCode = theFile.Read(ptrString);
   777 	
   778 
   779 	testData.Copy(KBodyTxt); //Copy the test descriptor 
   780 	returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
   781 									 //from the file
   782 									 
   783 	if (returnCode > 0)
   784 		numSuccessful++;
   785 		
   786 	returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
   787 		
   788 	if (returnCode == KErrNotFound)
   789 		numSuccessful++;
   790 
   791 
   792 	if (returnCode == KErrNotFound)  //Find the error message
   793 		{
   794 		returnCode = ptrString.Find(KErrOOM);
   795 		if (returnCode > 0)
   796 			User::Leave(KErrNoMemory);
   797 		}
   798 
   799 	CleanupStack::PopAndDestroy(hBuffer);
   800 	CleanupStack::PopAndDestroy();	//theFile object
   801 
   802 	if (numSuccessful == 2)
   803 		return KErrNone;
   804 	else 
   805 		return KErrGeneral;
   806 	}
   807 
   808 
   809 
   810 
   811 /**
   812 * Function  Name	: CFloggerTest017_05
   813 * Input parameters	: None
   814 * Output parameters : None
   815 * Description		: This is the constructor
   816 */ 
   817 
   818 
   819 CFloggerTest017_05::CFloggerTest017_05()
   820 	{
   821 	// store the name of this test case
   822 	SetTestStepName(_L("step_017_05"));
   823 	}
   824 
   825 
   826 /**
   827 * Function  Name	:~ CFloggerTest017_05
   828 * Input parameters	: None
   829 * Output parameters : None
   830 * Description		: This is the Destructor
   831 */ 
   832 
   833 
   834 CFloggerTest017_05::~CFloggerTest017_05()
   835 	{
   836 	}
   837 
   838 /**
   839 * Function  Name	: doTestStepL
   840 * Input parameters	: None
   841 * Output parameters : TVerdict 
   842 * Description		: This function returns weather the test case 017_05 has 
   843 * 					  passed or failed
   844 
   845 */
   846 
   847 
   848 TVerdict CFloggerTest017_05::doTestStepL( )
   849 	{
   850 	INFO_PRINTF1(_L("Step 017.05 called "));
   851 	
   852 	if ( executeStepL() == KErrNone )
   853 		SetTestStepResult(EPass);
   854 
   855 	else
   856 		SetTestStepResult(EFail);
   857 
   858 	
   859 	User::After(KTimeForDisplay1);
   860 	return TestStepResult();
   861 	}
   862 
   863 /**
   864 * Function  Name		: executeStepL
   865 * Input parameters		: None
   866 * Output parameters		: TInt 
   867 * Description 			: This function writes the test data in to the log file 
   868 * 						  This function check the test message is present in the 
   869 * 						  log file 
   870 
   871 */
   872 
   873 
   874 TInt CFloggerTest017_05::executeStepL(TBool)
   875 	{
   876 	return KErrGeneral;
   877 	}
   878 /**
   879 * Function  Name		: executeStepL
   880 * Input parameters		: None
   881 * Output parameters		: TInt 
   882 * Description 			: This function writes the test data in to the log file 
   883 * 						  This function check the test message is present in the 
   884 * 						  log file 
   885 
   886 */
   887 
   888 
   889 TInt CFloggerTest017_05::executeStepL( )
   890 	{
   891 	User::After(KTimeToLog);	//Need this or connect will return KErrServerTerminated
   892 	TInt ret = KErrGeneral;
   893 	
   894 	ret = DoTestWrite();
   895 	if (ret == KErrNone )
   896 		{
   897 		TRAPD(r, ret = DoTestCheckWriteL());
   898 		if (ret != KErrNone)
   899 			ret = r;
   900 		}
   901 	return ret;
   902 	}
   903 
   904 
   905 /**
   906 * Function  Name		: DoTestWrite
   907 * Input parameters		: None
   908 * Output parameters		: TInt 
   909 * Description 			: This function writes the data to the file logger
   910  
   911 */
   912 
   913 
   914 TInt CFloggerTest017_05::DoTestWrite()
   915 	{	
   916 	RFileLogger theFlogger;
   917 	TInt ret = KErrNone;
   918 	
   919 	ret = theFlogger.Connect(); //Just to clear the old log message
   920 	if (ret == KErrNone)
   921 		ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
   922 		if (ret == KErrNone)
   923 			ret = theFlogger.ClearLog();
   924 			if (ret == KErrNone)
   925 				theFlogger.Close();
   926 
   927 	if (ret == KErrNone)
   928 		{
   929 		//Write the test datas in the hexa format
   930 		RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KNullDesC8);
   931 		return KErrNone;
   932 		}
   933 	return ret;
   934 	}
   935 
   936 
   937 /**
   938 * Function  Name		: DoTestCheckWriteL
   939 * Input parameters		: None
   940 * Output parameters		: TInt 
   941 * Description 			: This function checks the weather test data was written
   942 * 						  in to the log file by DoTestWrite() or not.
   943 					  
   944 */
   945 
   946 
   947 TInt CFloggerTest017_05::DoTestCheckWriteL()
   948 	{
   949 	User::After(KTimeToLog);
   950 	RFile theFile;
   951 	HBufC8 * hBuffer;
   952 	TInt listfilesize;
   953 	TInt returnCode;
   954 	RFs fileSystem; //For file operation create a file system	
   955 	_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
   956 	_LIT8(KExpectedString,"0000 :");
   957 
   958 	_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
   959 
   960 	User::LeaveIfError(fileSystem.Connect());
   961 	
   962 	//Open the file in the read mode
   963 	User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); 
   964 	CleanupClosePushL(theFile);
   965 
   966 	
   967 	User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
   968 	hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
   969 	CleanupStack::PushL(hBuffer);
   970 	TPtr8 ptrString = hBuffer->Des();  ; //To hold the buffer
   971 
   972 	// Read from position 0: start of file
   973 	returnCode = theFile.Read(ptrString);
   974 	
   975 	//check for no OOM msg
   976 	returnCode = ptrString.Find(KOOMError);
   977 	if (returnCode > 0)
   978 		{
   979 		User::Leave(KErrNoMemory);
   980 		}
   981 	
   982 	
   983 	// we expect the output to be pretty blank, so not much to search for
   984 	// except make sure the standard "0000: " ins't even there
   985 	returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
   986 										 //from the file
   987 	
   988 	CleanupStack::PopAndDestroy(hBuffer);
   989 	CleanupStack::PopAndDestroy();	//theFile object
   990 	if (returnCode == KErrNotFound)
   991 		return KErrNone;
   992 	else 
   993 		return KErrGeneral;
   994 	}
   995 
   996 
   997 
   998 /*
   999 * Function  Name	: CFloggerTest017_06
  1000 * Input parameters	: None
  1001 * Output parameters : None
  1002 * Description		: This is the constructor
  1003 */
  1004 
  1005 
  1006 CFloggerTest017_06::CFloggerTest017_06()
  1007 	{
  1008 	// store the name of this test case
  1009 	SetTestStepName(_L("step_017_06"));
  1010 	}
  1011 
  1012 
  1013 /**
  1014 * Function  Name	:~ CFloggerTest017_06
  1015 * Input parameters	: None
  1016 * Output parameters : None
  1017 * Description		: This is the Destructor
  1018 */
  1019 
  1020 
  1021 CFloggerTest017_06::~CFloggerTest017_06()
  1022 	{
  1023 	}	
  1024 
  1025 
  1026 /**
  1027 * Function  Name : doTestStepL
  1028 * Input parameters : None
  1029 * Output parameters : TVerdict 
  1030 * Description : This function is responsible for doing the heap test analysis 
  1031 
  1032 */
  1033 
  1034 
  1035 
  1036 TVerdict CFloggerTest017_06::doTestStepL( )
  1037 	{
  1038 	INFO_PRINTF1(_L("Step 017.06 called "));
  1039 
  1040 	CFloggerTest017_01* step017_01 = new CFloggerTest017_01;
  1041 	CleanupStack::PushL(step017_01);
  1042 	doTestStepWithHeapFailureL( *step017_01, 1, 20, KErrNone, ETrue);
  1043 
  1044 	CleanupStack::PopAndDestroy(step017_01);
  1045 	User::After(KTimeForDisplay);
  1046 	return TestStepResult();
  1047 	}
  1048