kerneltest/f32test/server/t_notifydismount.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    13 // Description:
    13 // Description:
    14 // f32test\manager\t_notifydismount.cpp
    14 // f32test\manager\t_notifydismount.cpp
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 #define __E32TEST_EXTENSION__
       
    19 #include <f32file.h>
    18 #include <f32file.h>
    20 #include <e32test.h>
    19 #include <e32test.h>
    21 #include <e32hal.h>
    20 #include <e32hal.h>
    22 #include <e32math.h>
    21 #include <e32math.h>
    23 #include <f32dbg.h>
    22 #include <f32dbg.h>
    45 //	
    44 //	
    46 {
    45 {
    47 	test.Next( _L("Test File Handle Closure"));
    46 	test.Next( _L("Test File Handle Closure"));
    48 
    47 
    49 	TInt r = file.Replace(TheFs, fn, EFileWrite); 
    48 	TInt r = file.Replace(TheFs, fn, EFileWrite); 
    50 	test_KErrNone(r); 
    49 	test(r == KErrNone); 
    51 	r = TheFs.FileSystemName(fsname,aDrvNum);
    50 	r = TheFs.FileSystemName(fsname,aDrvNum);
    52 	test_KErrNone(r); 
    51 	test(r == KErrNone); 
    53 	buf = _L8("handle test23456");
    52 	buf = _L8("handle test23456");
    54 	r = file.Write(buf); 
    53 	r = file.Write(buf); 
    55 	test_KErrNone(r); 
    54 	test(r == KErrNone); 
    56 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
    55 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
    57 	User::WaitForRequest(stat);         
    56 	User::WaitForRequest(stat);         
    58 	test(stat.Int() == KErrNone);
    57 	test(stat.Int() == KErrNone);
    59 
    58 
    60 	// PDEF137626 Connectivity: Phone reboots automatically when connecting to PC via USB after pl 
    59 	// PDEF137626 Connectivity: Phone reboots automatically when connecting to PC via USB after pl 
    61 	// Check that writing data to a file when the drive is dismounted doesn't upset the file server
    60 	// Check that writing data to a file when the drive is dismounted doesn't upset the file server
    62 	r = file.Write(buf); 
    61 	r = file.Write(buf); 
    63 	test_Value(r, r == KErrNotReady || r == KErrDisMounted); 
    62 	test(r == KErrNotReady || r == KErrDisMounted); 
    64 
    63 
    65 	// PDEF091956 was a file server fault EFsDriveThreadError when the file 
    64 	// PDEF091956 was a file server fault EFsDriveThreadError when the file 
    66 	// handle was closed
    65 	// handle was closed
    67 	file.Close(); 
    66 	file.Close(); 
    68 	r = TheFs.MountFileSystem(fsname,aDrvNum);
    67 	r = TheFs.MountFileSystem(fsname,aDrvNum);
    69 	test_KErrNone(r); 
    68 	test(r == KErrNone); 
    70 }
    69 }
    71 
    70 
    72 
    71 
    73 LOCAL_C void TestRequestCancelling(TInt aDrvNum)
    72 LOCAL_C void TestRequestCancelling(TInt aDrvNum)
    74 //
    73 //
    77 //
    76 //
    78 	{
    77 	{
    79 	test.Next( _L("Test Request Cancelling") );
    78 	test.Next( _L("Test Request Cancelling") );
    80 
    79 
    81 	TInt r = TheFs.FileSystemName(fsname,aDrvNum);
    80 	TInt r = TheFs.FileSystemName(fsname,aDrvNum);
    82 	test_KErrNone(r); 
    81 	test(r == KErrNone); 
    83 	
    82 	
    84 	//***************************************
    83 	//***************************************
    85 	// first test with an open file handle
    84 	// first test with an open file handle
    86 	//***************************************
    85 	//***************************************
    87 	r = file.Replace(TheFs, fn, EFileWrite); 
    86 	r = file.Replace(TheFs, fn, EFileWrite); 
    88 	test_KErrNone(r); 
    87 	test(r == KErrNone); 
    89 
    88 
    90 	// up the priority of this thread so that we can queue 2 requests onto the drive thread - 
    89 	// up the priority of this thread so that we can queue 2 requests onto the drive thread - 
    91 	// i.e. a TFsNotifyDismount and a TFsCloseObject
    90 	// i.e. a TFsNotifyDismount and a TFsCloseObject
    92 	RThread				thisThread;
    91 	RThread				thisThread;
    93 	thisThread.SetPriority(EPriorityRealTime);
    92 	thisThread.SetPriority(EPriorityRealTime);
   105 	test(stat.Int() == KErrNone);
   104 	test(stat.Int() == KErrNone);
   106 	
   105 	
   107 	thisThread.SetPriority(EPriorityNormal);
   106 	thisThread.SetPriority(EPriorityNormal);
   108 
   107 
   109 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   108 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   110 	test_KErrNone(r); 
   109 	test(r == KErrNone); 
   111 
   110 
   112 
   111 
   113 	//***************************************
   112 	//***************************************
   114 	// now test with an open directory handle
   113 	// now test with an open directory handle
   115 	//***************************************
   114 	//***************************************
   116 
   115 
   117 	RDir dir;
   116 	RDir dir;
   118 	TFileName sessionPath;
   117 	TFileName sessionPath;
   119 	r=TheFs.SessionPath(sessionPath);
   118 	r=TheFs.SessionPath(sessionPath);
   120 	test_KErrNone(r);
   119 	test(r==KErrNone);
   121 	TFileName path=_L("?:\\*");
   120 	TFileName path=_L("?:\\*");
   122 	path[0]=sessionPath[0];
   121 	path[0]=sessionPath[0];
   123 	r=dir.Open(TheFs,path,KEntryAttMaskSupported);
   122 	r=dir.Open(TheFs,path,KEntryAttMaskSupported);
   124 	test_KErrNone(r);
   123 	test(r==KErrNone);
   125 
   124 
   126 	thisThread.SetPriority(EPriorityRealTime);
   125 	thisThread.SetPriority(EPriorityRealTime);
   127 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
   126 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
   128 	dir.Close();
   127 	dir.Close();
   129 
   128 
   131 	test(stat.Int() == KErrNone);
   130 	test(stat.Int() == KErrNone);
   132 	
   131 	
   133 	thisThread.SetPriority(EPriorityNormal);
   132 	thisThread.SetPriority(EPriorityNormal);
   134 
   133 
   135 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   134 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   136 	test_KErrNone(r); 
   135 	test(r == KErrNone); 
   137 	}
   136 	}
   138 
   137 
   139 
   138 
   140 LOCAL_C void TestFileSizeFlushing(TInt aDrvNum)
   139 LOCAL_C void TestFileSizeFlushing(TInt aDrvNum)
   141 //
   140 //
   145 	{	
   144 	{	
   146 	test.Next( _L("Test File Size Flushing with EFsDismountForceDismount") );
   145 	test.Next( _L("Test File Size Flushing with EFsDismountForceDismount") );
   147 
   146 
   148 	TInt size = 0;
   147 	TInt size = 0;
   149 	TInt r = file.Replace(TheFs, fn, EFileWrite); 
   148 	TInt r = file.Replace(TheFs, fn, EFileWrite); 
   150 	test_KErrNone(r); 
   149 	test(r == KErrNone); 
   151 	r = TheFs.FileSystemName(fsname,aDrvNum);
   150 	r = TheFs.FileSystemName(fsname,aDrvNum);
   152 	test_KErrNone(r); 
   151 	test(r == KErrNone); 
   153 	buf = _L8("size test9123456"); 
   152 	buf = _L8("size test9123456"); 
   154 	r = file.Write(buf); 
   153 	r = file.Write(buf); 
   155 	test_KErrNone(r); 
   154 	test(r == KErrNone); 
   156 	r = file.Flush(); 
   155 	r = file.Flush(); 
   157 	test_KErrNone(r); 
   156 	test(r == KErrNone); 
   158 	r = file.Write(buf); 
   157 	r = file.Write(buf); 
   159 	test_KErrNone(r); 
   158 	test(r == KErrNone); 
   160 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
   159 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountForceDismount); 
   161 	User::WaitForRequest(stat);         
   160 	User::WaitForRequest(stat);         
   162 	test(stat.Int() == KErrNone);
   161 	test(stat.Int() == KErrNone);
   163 	file.Close();
   162 	file.Close();
   164 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   163 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   165 	test_KErrNone(r); 
   164 	test(r == KErrNone); 
   166 	file.Open(TheFs, fn, EFileWrite);
   165 	file.Open(TheFs, fn, EFileWrite);
   167 	r = file.Size(size); 
   166 	r = file.Size(size); 
   168 	test_KErrNone(r); 
   167 	test(r == KErrNone); 
   169 	// PDEF091956 was, for example, a file size of 16 rather than 32. new file sizes were
   168 	// PDEF091956 was, for example, a file size of 16 rather than 32. new file sizes were
   170 	// not flushed for the forced dismount. this was only a problem with rugged fat off.
   169 	// not flushed for the forced dismount. this was only a problem with rugged fat off.
   171 	test(size == 32);
   170 	test(size == 32);
   172 	file.Close();
   171 	file.Close();
   173 
   172 
   174 	test.Next( _L("Test File Size Flushing with EFsDismountNotifyClients") );
   173 	test.Next( _L("Test File Size Flushing with EFsDismountNotifyClients") );
   175 	size = 0;
   174 	size = 0;
   176 	r = file.Replace(TheFs, fn, EFileWrite); 
   175 	r = file.Replace(TheFs, fn, EFileWrite); 
   177 	test_KErrNone(r); 
   176 	test(r == KErrNone); 
   178 
   177 
   179 	r = file.Write(buf); 
   178 	r = file.Write(buf); 
   180 	test_KErrNone(r); 
   179 	test(r == KErrNone); 
   181 
   180 
   182 	r = file.Write(buf); 
   181 	r = file.Write(buf); 
   183 	test_KErrNone(r); 
   182 	test(r == KErrNone); 
   184 
   183 
   185 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountNotifyClients); 
   184 	TheFs.NotifyDismount(aDrvNum, stat, EFsDismountNotifyClients); 
   186 	User::WaitForRequest(stat);
   185 	User::WaitForRequest(stat);
   187 
   186 
   188 	test(stat.Int() == KErrNone);
   187 	test(stat.Int() == KErrNone);
   189 	file.Close();
   188 	file.Close();
   190 
   189 
   191 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   190 	r = TheFs.MountFileSystem(fsname,aDrvNum);
   192 	test_KErrNone(r); 
   191 	test(r == KErrNone); 
   193 	file.Open(TheFs, fn, EFileWrite);
   192 	file.Open(TheFs, fn, EFileWrite);
   194 	r = file.Size(size); 
   193 	r = file.Size(size); 
   195 	test_KErrNone(r); 
   194 	test(r == KErrNone); 
   196 	test(size == 32);
   195 	test(size == 32);
   197 	file.Close();
   196 	file.Close();
   198 	}
   197 	}
   199 #endif
   198 #endif
   200 
   199 
   227 	{
   226 	{
   228 	test.Title();
   227 	test.Title();
   229 	TInt drvNum, r;
   228 	TInt drvNum, r;
   230 
   229 
   231 	r=TheFs.CharToDrive(gDriveToTest,drvNum);
   230 	r=TheFs.CharToDrive(gDriveToTest,drvNum);
   232 	test_KErrNone(r);
   231 	test(r==KErrNone);
   233 
   232 
   234 
   233 
   235 	// dismounting with file system extension present doesn't seem to work
   234 	// dismounting with file system extension present doesn't seem to work
   236 	// so skip the test for now.
   235 	// so skip the test for now.
   237 	TFullName extName;
   236 	TFullName extName;
   267 		{
   266 		{
   268 		// next test requires rugged fat off
   267 		// next test requires rugged fat off
   269 		TUint8 isRugged;
   268 		TUint8 isRugged;
   270 		TPtr8 pRugged(&isRugged,1,1);
   269 		TPtr8 pRugged(&isRugged,1,1);
   271 		r=TheFs.ControlIo(drvNum,KControlIoIsRugged,pRugged);
   270 		r=TheFs.ControlIo(drvNum,KControlIoIsRugged,pRugged);
   272 		test_KErrNone(r);
   271 		test(r==KErrNone);
   273 		if(isRugged)
   272 		if(isRugged)
   274 			{
   273 			{
   275 			r=TheFs.ControlIo(drvNum,KControlIoRuggedOff);
   274 			r=TheFs.ControlIo(drvNum,KControlIoRuggedOff);
   276 			test_KErrNone(r);
   275 			test(r==KErrNone);
   277 			}
   276 			}
   278 
   277 
   279 		TestFileSizeFlushing(drvNum);
   278 		TestFileSizeFlushing(drvNum);
   280 	
   279 	
   281 		// if originally rugged set system back to rugged
   280 		// if originally rugged set system back to rugged
   282 		if(isRugged)
   281 		if(isRugged)
   283 			{
   282 			{
   284 			r=TheFs.ControlIo(drvNum,KControlIoRuggedOn);
   283 			r=TheFs.ControlIo(drvNum,KControlIoRuggedOn);
   285 			test_KErrNone(r);
   284 			test(r==KErrNone);
   286 			}	
   285 			}	
   287 		}
   286 		}
   288 	else
   287 	else
   289 		{
   288 		{
   290 		test.Printf(_L("CallTestsL: Skip TestFileSizeFlushing - not a FAT filesystem.\n"));
   289 		test.Printf(_L("CallTestsL: Skip TestFileSizeFlushing - not a FAT filesystem.\n"));