kerneltest/f32test/server/t_main.cpp
changeset 175 5af6c74cd793
parent 90 947f0dc9f7a8
child 297 b2826f67641f
equal deleted inserted replaced
148:31ea0f8e3c99 175:5af6c74cd793
    22 #include <e32hal.h>
    22 #include <e32hal.h>
    23 #include <e32math.h>
    23 #include <e32math.h>
    24 #include <f32dbg.h>
    24 #include <f32dbg.h>
    25 #include "t_server.h"
    25 #include "t_server.h"
    26 #include "t_chlffs.h"
    26 #include "t_chlffs.h"
       
    27 #include "f32_test_utils.h"
    27 
    28 
    28 GLDEF_D	RFs TheFs;
    29 GLDEF_D	RFs TheFs;
    29 GLDEF_D TFileName gSessionPath;
    30 GLDEF_D TFileName gSessionPath;
    30 GLDEF_D TFileName gExeFileName(RProcess().FileName());
    31 GLDEF_D TFileName gExeFileName(RProcess().FileName());
    31 GLDEF_D TInt gAllocFailOff=KAllocFailureOff;
    32 GLDEF_D TInt gAllocFailOff=KAllocFailureOff;
   155 		TChar letter=0;
   156 		TChar letter=0;
   156 		TBool illegalChar=ETrue;
   157 		TBool illegalChar=ETrue;
   157 
   158 
   158 		while(illegalChar)
   159 		while(illegalChar)
   159 			{
   160 			{
   160 #if defined(__WINS__)
   161 			if (F32_Test_Utils::Is_SimulatedSystemDrive(TheFs, CurrentDrive()))
   161 			if (gSessionPath[0]=='C')
       
   162 				letter=(TChar)('A'+Math::Rand(aSeed)%26);
   162 				letter=(TChar)('A'+Math::Rand(aSeed)%26);
   163 			else
   163 			else
   164 				letter=(TChar)Math::Rand(aSeed)%256;
   164 				letter=(TChar)Math::Rand(aSeed)%256;
   165 #else
   165 
   166 			letter=(TChar)Math::Rand(aSeed)%256;
       
   167 #endif
       
   168 			TBool space=letter.IsSpace();
   166 			TBool space=letter.IsSpace();
   169 			if (space && spaceChar==-1)
   167 			if (space && spaceChar==-1)
   170 				spaceChar=i;
   168 				spaceChar=i;
   171 			else if (!space && spaceChar!=-1)
   169 			else if (!space && spaceChar!=-1)
   172 				spaceChar=-1;
   170 				spaceChar=-1;
   664 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   662 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   665 	test.Printf(_L("\n"));
   663 	test.Printf(_L("\n"));
   666 
   664 
   667 	TInt orgSessionCount;
   665 	TInt orgSessionCount;
   668 	r = controlIo(TheFs,theDrive, KControlIoSessionCount, orgSessionCount);
   666 	r = controlIo(TheFs,theDrive, KControlIoSessionCount, orgSessionCount);
   669 	test(r==KErrNone);
   667 	test_KErrNone(r);
   670 	test.Printf(_L("Session count start=%d\n"),orgSessionCount);
   668 	test.Printf(_L("Session count start=%d\n"),orgSessionCount);
   671 
   669 
   672 	TInt orgObjectCount;
   670 	TInt orgObjectCount;
   673 	r = controlIo(TheFs,theDrive, KControlIoObjectCount, orgObjectCount);
   671 	r = controlIo(TheFs,theDrive, KControlIoObjectCount, orgObjectCount);
   674 	test(r==KErrNone);
   672 	test_KErrNone(r);
   675 	test.Printf(_L("Object count start=%d\n"),orgObjectCount);
   673 	test.Printf(_L("Object count start=%d\n"),orgObjectCount);
   676 
   674 
   677 
   675 
   678 	TPckgBuf<TIOCacheValues> pkgOrgValues;
   676 	TPckgBuf<TIOCacheValues> pkgOrgValues;
   679 	TIOCacheValues& orgValues=pkgOrgValues();
   677 	TIOCacheValues& orgValues=pkgOrgValues();
   715 	// Close and then re-open the main file server session to force the closure of
   713 	// Close and then re-open the main file server session to force the closure of
   716 	// any sub-sessions which may have been left open....
   714 	// any sub-sessions which may have been left open....
   717 	// NB: This won't help if the test has opened another session & left sub-sessions open.
   715 	// NB: This won't help if the test has opened another session & left sub-sessions open.
   718 	TheFs.Close();
   716 	TheFs.Close();
   719 	r=TheFs.Connect();
   717 	r=TheFs.Connect();
   720 	test(r==KErrNone);
   718 	test_KErrNone(r);
   721 
   719 
   722 	// Display the file cache stats before closing the file queue
   720 	// Display the file cache stats before closing the file queue
   723 	TFileCacheStats endFileCacheStats;
   721 	TFileCacheStats endFileCacheStats;
   724 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
   722 	r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats);
   725 	test_Value(r, r == KErrNone || r == KErrNotSupported);
   723 	test_Value(r, r == KErrNone || r == KErrNotSupported);
   741 		test.Printf(_L("Flushing close queue...\n"));
   739 		test.Printf(_L("Flushing close queue...\n"));
   742 		r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles);
   740 		r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles);
   743 		test_KErrNone(r);
   741 		test_KErrNone(r);
   744 
   742 
   745 		r = controlIo(TheFs,theDrive, KControlIoSessionCount, endSessionCount);
   743 		r = controlIo(TheFs,theDrive, KControlIoSessionCount, endSessionCount);
   746 		test(r==KErrNone);
   744 		test_KErrNone(r);
   747 		test.Printf(_L("Session count end=%d\n"),endSessionCount);
   745 		test.Printf(_L("Session count end=%d\n"),endSessionCount);
   748 
   746 
   749 		r = controlIo(TheFs,theDrive, KControlIoObjectCount, endObjectCount);
   747 		r = controlIo(TheFs,theDrive, KControlIoObjectCount, endObjectCount);
   750 		test(r==KErrNone);
   748 		test_KErrNone(r);
   751 		test.Printf(_L("Object count end=%d\n"),endObjectCount);
   749 		test.Printf(_L("Object count end=%d\n"),endObjectCount);
   752 
   750 
   753 		if (endSessionCount == orgSessionCount && endObjectCount == orgObjectCount)
   751 		if (endSessionCount == orgSessionCount && endObjectCount == orgObjectCount)
   754 			break;
   752 			break;
   755 		
   753