kerneltest/f32test/server/t_main.cpp
branchRCL_3
changeset 19 4a8fed1c0ef6
parent 0 a41df078684a
child 21 e7d2d738d3c2
equal deleted inserted replaced
15:2d65c2f76d7b 19:4a8fed1c0ef6
   660 	test_KErrNone(r);
   660 	test_KErrNone(r);
   661 	gDriveCacheFlags = gVolInfo.iFileCacheFlags;
   661 	gDriveCacheFlags = gVolInfo.iFileCacheFlags;
   662 	test.Printf(_L("DriveCacheFlags = %08X\n"), gDriveCacheFlags);
   662 	test.Printf(_L("DriveCacheFlags = %08X\n"), gDriveCacheFlags);
   663 
   663 
   664 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   664 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   665 	test.Printf(_L("\n"));
       
   666 
       
   667 	TInt orgSessionCount;
       
   668 	r = controlIo(TheFs,theDrive, KControlIoSessionCount, orgSessionCount);
       
   669 	test(r==KErrNone);
       
   670 	test.Printf(_L("Session count start=%d\n"),orgSessionCount);
       
   671 
       
   672 	TInt orgObjectCount;
       
   673 	r = controlIo(TheFs,theDrive, KControlIoObjectCount, orgObjectCount);
       
   674 	test(r==KErrNone);
       
   675 	test.Printf(_L("Object count start=%d\n"),orgObjectCount);
       
   676 
       
   677 
   665 	TPckgBuf<TIOCacheValues> pkgOrgValues;
   678 	TPckgBuf<TIOCacheValues> pkgOrgValues;
   666 	TIOCacheValues& orgValues=pkgOrgValues();
   679 	TIOCacheValues& orgValues=pkgOrgValues();
   667 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues);
   680 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues);
   668 	test_KErrNone(r);
   681 	test_KErrNone(r);
   669 
   682 
   670 	test.Printf(_L("\n"));
       
   671 	test.Printf(_L("Requests on close queue at start=%d\n"),orgValues.iCloseCount);
   683 	test.Printf(_L("Requests on close queue at start=%d\n"),orgValues.iCloseCount);
   672 	test.Printf(_L("Requests on free queue at start=%d\n"),orgValues.iFreeCount);
   684 	test.Printf(_L("Requests on free queue at start=%d\n"),orgValues.iFreeCount);
   673 	test.Printf(_L("Requests dynamically allocated at start=%d\n"),orgValues.iAllocated);
   685 	test.Printf(_L("Requests dynamically allocated at start=%d\n"),orgValues.iAllocated);
   674 	test.Printf(_L("Requests in total at start=%d\n"),orgValues.iTotalCount);
   686 	test.Printf(_L("Requests in total at start=%d\n"),orgValues.iTotalCount);
   675 
   687 
   700 	test_KErrNone(r);
   712 	test_KErrNone(r);
   701 	test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
   713 	test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
   702 	TheFs.SetAllocFailure(gAllocFailOff);
   714 	TheFs.SetAllocFailure(gAllocFailOff);
   703 	
   715 	
   704 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   716 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   717 	// Close and then re-open the main file server session to force the closure of
       
   718 	// any sub-sessions which may have been left open....
       
   719 	// NB: This won't help if the test has opened another session & left sub-sessions open.
       
   720 	TheFs.Close();
       
   721 	r=TheFs.Connect();
       
   722 	test(r==KErrNone);
       
   723 
       
   724 	// Display the file cache stats before closing the file queue
       
   725 	TFileCacheStats endFileCacheStats;
       
   726 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
       
   727 	test_Value(r, r == KErrNone || r == KErrNotSupported);
       
   728 	test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"),
       
   729 		endFileCacheStats.iFreeCount, 
       
   730 		endFileCacheStats.iUsedCount, 
       
   731 		endFileCacheStats.iAllocatedSegmentCount,
       
   732 		endFileCacheStats.iLockedSegmentCount,
       
   733 		endFileCacheStats.iFilesOnClosedQueue);
       
   734 
       
   735 
       
   736 	// Wait up to 3 seconds for all file server sessions & objects to close
       
   737 	// and then test session & object counts haven't changed
       
   738 	TInt endSessionCount = 0;
       
   739 	TInt endObjectCount = 0;
       
   740 	for (TInt n=0; n<3; n++)
       
   741 		{
       
   742 		// Flush the closed files queue as a file-cache object on the closed queue is counted as an open object
       
   743 		test.Printf(_L("Flushing close queue...\n"));
       
   744 		r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles);
       
   745 		test_KErrNone(r);
       
   746 
       
   747 		r = controlIo(TheFs,theDrive, KControlIoSessionCount, endSessionCount);
       
   748 		test(r==KErrNone);
       
   749 		test.Printf(_L("Session count end=%d\n"),endSessionCount);
       
   750 
       
   751 		r = controlIo(TheFs,theDrive, KControlIoObjectCount, endObjectCount);
       
   752 		test(r==KErrNone);
       
   753 		test.Printf(_L("Object count end=%d\n"),endObjectCount);
       
   754 
       
   755 		if (endSessionCount == orgSessionCount && endObjectCount == orgObjectCount)
       
   756 			break;
       
   757 		
       
   758 		test.Printf(_L("Warning: Session/object count leak\n"));
       
   759 		User::After(1000000);
       
   760 		}
       
   761 
       
   762 	// some tests don't close their sessions, so this test won't work until 
       
   763 	// all the tests are fixed :
       
   764 //	test(endSessionCount == orgSessionCount);
       
   765 //	test(endObjectCount == orgObjectCount);
       
   766 
       
   767 
       
   768 	// Test that the File cache hasn't leaked ....
       
   769 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
       
   770 	test_Value(r, r == KErrNone || r == KErrNotSupported);
       
   771 	test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"),
       
   772 		endFileCacheStats.iFreeCount, 
       
   773 		endFileCacheStats.iUsedCount, 
       
   774 		endFileCacheStats.iAllocatedSegmentCount,
       
   775 		endFileCacheStats.iLockedSegmentCount,
       
   776 		endFileCacheStats.iFilesOnClosedQueue);
       
   777 	if (r == KErrNone)
       
   778 		{
       
   779 		test(startFileCacheStats.iFreeCount == endFileCacheStats.iFreeCount);
       
   780 		test(startFileCacheStats.iUsedCount == endFileCacheStats.iUsedCount);
       
   781 		test(startFileCacheStats.iAllocatedSegmentCount == endFileCacheStats.iAllocatedSegmentCount);
       
   782 		test(startFileCacheStats.iLockedSegmentCount == endFileCacheStats.iLockedSegmentCount);
       
   783 		test(startFileCacheStats.iFileCount == endFileCacheStats.iFileCount);
       
   784 		}
       
   785 #endif
       
   786 
       
   787 
       
   788 	
       
   789 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
   790 	// Test that the request allocator hasn't leaked...
   705 	TPckgBuf<TIOCacheValues> pkgValues;
   791 	TPckgBuf<TIOCacheValues> pkgValues;
   706 	TIOCacheValues& values=pkgValues();
   792 	TIOCacheValues& values=pkgValues();
   707 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, values);
   793 	r = controlIo(TheFs,theDrive, KControlIoCacheCount, values);
   708 	test_KErrNone(r);
   794 	test_KErrNone(r);
   709 	
   795 	
   721 	// The total number of allocated requests should be equal to :
   807 	// The total number of allocated requests should be equal to :
   722 	// requests on the close queue + requests on free queue 
   808 	// requests on the close queue + requests on free queue 
   723 	// + 1 (because we used one request to issue KControlIoCacheCount)
   809 	// + 1 (because we used one request to issue KControlIoCacheCount)
   724 	// If this doesn't equate then this implies a request leak
   810 	// If this doesn't equate then this implies a request leak
   725 	test(values.iTotalCount == values.iCloseCount + values.iFreeCount + 1);
   811 	test(values.iTotalCount == values.iCloseCount + values.iFreeCount + 1);
   726 
       
   727 	// File cache
       
   728 	TFileCacheStats endFileCacheStats;
       
   729 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
       
   730 	test_Value(r, r == KErrNone || r == KErrNotSupported);
       
   731 
       
   732 	test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"),
       
   733 		endFileCacheStats.iFreeCount, 
       
   734 		endFileCacheStats.iUsedCount, 
       
   735 		endFileCacheStats.iAllocatedSegmentCount,
       
   736 		endFileCacheStats.iLockedSegmentCount,
       
   737 		endFileCacheStats.iFilesOnClosedQueue);
       
   738 
       
   739 	// flush closed files queue
       
   740 	test.Printf(_L("Flushing close queue..."));
       
   741 	r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles);
       
   742 	test_KErrNone(r);
       
   743 
       
   744 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
       
   745 	test_Value(r, r == KErrNone || r == KErrNotSupported);
       
   746 	test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"),
       
   747 		endFileCacheStats.iFreeCount, 
       
   748 		endFileCacheStats.iUsedCount, 
       
   749 		endFileCacheStats.iAllocatedSegmentCount,
       
   750 		endFileCacheStats.iLockedSegmentCount,
       
   751 		endFileCacheStats.iFilesOnClosedQueue);
       
   752 
       
   753 
       
   754 	if (r == KErrNone)
       
   755 		{
       
   756 		test(startFileCacheStats.iFreeCount == endFileCacheStats.iFreeCount);
       
   757 		test(startFileCacheStats.iUsedCount == endFileCacheStats.iUsedCount);
       
   758 		test(startFileCacheStats.iAllocatedSegmentCount == endFileCacheStats.iAllocatedSegmentCount);
       
   759 		test(startFileCacheStats.iLockedSegmentCount == endFileCacheStats.iLockedSegmentCount);
       
   760 		test(startFileCacheStats.iFileCount == endFileCacheStats.iFileCount);
       
   761 		}
       
   762 #endif
   812 #endif
   763 
   813 
   764 	TheFs.Close();
   814 	TheFs.Close();
   765 	test.End();
   815 	test.End();
   766 	test.Close();
   816 	test.Close();