kerneltest/f32test/server/t_rcount.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
    13 // Description:
    13 // Description:
    14 // f32test\server\t_rcount.cpp
    14 // f32test\server\t_rcount.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 
    20 
    22 #include "../server/t_server.h"
    21 #include "../server/t_server.h"
    23 
    22 
    39 	test(count==0);
    38 	test(count==0);
    40 	TFileName name=_L("Z:\\Test\\T_FILE.CPP");
    39 	TFileName name=_L("Z:\\Test\\T_FILE.CPP");
    41 	name[0] = gExeFileName[0];
    40 	name[0] = gExeFileName[0];
    42 	test.Printf(_L("%S\n"),&name);
    41 	test.Printf(_L("%S\n"),&name);
    43 	TInt r=file.Open(TheFs,name,EFileRead);
    42 	TInt r=file.Open(TheFs,name,EFileRead);
    44 	test_KErrNone(r);
    43 	test(r==KErrNone);
    45 	count=TheFs.ResourceCount();
    44 	count=TheFs.ResourceCount();
    46 	test(count==1);
    45 	test(count==1);
    47 	file.Close();
    46 	file.Close();
    48 	count=TheFs.ResourceCount();
    47 	count=TheFs.ResourceCount();
    49 	test(count==0);
    48 	test(count==0);
    58 	{
    57 	{
    59 
    58 
    60 	User::SetJustInTime(EFalse);
    59 	User::SetJustInTime(EFalse);
    61 	RFs fs;
    60 	RFs fs;
    62 	TInt r=fs.Connect();
    61 	TInt r=fs.Connect();
    63 	test_KErrNone(r);
    62 	test(r==KErrNone);
    64 	RFile file;
    63 	RFile file;
    65 	fs.ResourceCountMarkStart();
    64 	fs.ResourceCountMarkStart();
    66 	TFileName name=_L("Z:\\Test\\T_FILE.CPP");
    65 	TFileName name=_L("Z:\\Test\\T_FILE.CPP");
    67 	name[0] = gExeFileName[0];
    66 	name[0] = gExeFileName[0];
    68 
    67 
    69 	r=file.Open(fs,name,EFileRead);
    68 	r=file.Open(fs,name,EFileRead);
    70 	test_KErrNone(r);
    69 	test(r==KErrNone);
    71 	TInt count=fs.ResourceCount();
    70 	TInt count=fs.ResourceCount();
    72 	test(count==1);
    71 	test(count==1);
    73 	fs.ResourceCountMarkEnd(); // MarkEnd without close
    72 	fs.ResourceCountMarkEnd(); // MarkEnd without close
    74 	fs.Close();
    73 	fs.Close();
    75 	return KErrNone;
    74 	return KErrNone;
    83 
    82 
    84 	test.Next(_L("Test resource count failure"));
    83 	test.Next(_L("Test resource count failure"));
    85 	TRequestStatus stat;	
    84 	TRequestStatus stat;	
    86 	RThread t;
    85 	RThread t;
    87 	TInt r=t.Create(_L("TestPanicThread"),TestPanic,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
    86 	TInt r=t.Create(_L("TestPanicThread"),TestPanic,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
    88 	test_KErrNone(r);
    87 	test(r==KErrNone);
    89 	t.Logon(stat);
    88 	t.Logon(stat);
    90 	t.Resume();
    89 	t.Resume();
    91 	User::WaitForRequest(stat);	
    90 	User::WaitForRequest(stat);	
    92 	test(t.ExitReason()==CSession2::ESesFoundResCountHeaven);
    91 	test(t.ExitReason()==CSession2::ESesFoundResCountHeaven);
    93 	test(t.ExitType()==EExitPanic);
    92 	test(t.ExitType()==EExitPanic);
   153 // the thread should get paniced by the file server
   152 // the thread should get paniced by the file server
   154 //
   153 //
   155 	{
   154 	{
   156 	RFs f;
   155 	RFs f;
   157 	TInt r = f.Connect();
   156 	TInt r = f.Connect();
   158 	test_KErrNone(r);
   157 	test(r==KErrNone);
   159 
   158 
   160 	RFile a;
   159 	RFile a;
   161 	r=a.Replace(f,KFileName1,EFileWrite);
   160 	r=a.Replace(f,KFileName1,EFileWrite);
   162 	test_KErrNone(r);
   161 	test(r==KErrNone);
   163 	RFile b(a);
   162 	RFile b(a);
   164 	a.Close();
   163 	a.Close();
   165 	
   164 	
   166 	r=b.Write(_L8("testing testing"));
   165 	r=b.Write(_L8("testing testing"));
   167 	
   166 	
   180 // the thread should get panniced by the server
   179 // the thread should get panniced by the server
   181 //
   180 //
   182 	{
   181 	{
   183 	RFs f;
   182 	RFs f;
   184 	TInt r = f.Connect();
   183 	TInt r = f.Connect();
   185 	test_KErrNone(r);
   184 	test(r==KErrNone);
   186 
   185 
   187 	RDir a;
   186 	RDir a;
   188 	r=a.Open(f,KDirName1,KEntryAttNormal);
   187 	r=a.Open(f,KDirName1,KEntryAttNormal);
   189 	test_KErrNone(r);
   188 	test(r==KErrNone);
   190 	RDir b(a);
   189 	RDir b(a);
   191 	a.Close();
   190 	a.Close();
   192 	
   191 	
   193 	TEntryArray dummyarray;
   192 	TEntryArray dummyarray;
   194 	r=b.Read(dummyarray);
   193 	r=b.Read(dummyarray);
   214 	_LIT(KDrive1, "X:\\");
   213 	_LIT(KDrive1, "X:\\");
   215 #endif
   214 #endif
   216 
   215 
   217 	RFs f;
   216 	RFs f;
   218 	TInt r = f.Connect();
   217 	TInt r = f.Connect();
   219 	test_KErrNone(r);
   218 	test(r==KErrNone);
   220 
   219 
   221 	RFormat a;
   220 	RFormat a;
   222 	TInt count;
   221 	TInt count;
   223 	r=a.Open(f,KDrive1,EQuickFormat,count);
   222 	r=a.Open(f,KDrive1,EQuickFormat,count);
   224 	test_KErrNone(r);
   223 	test(r==KErrNone);
   225 	RFormat b(a);
   224 	RFormat b(a);
   226 	a.Close();
   225 	a.Close();
   227 	
   226 	
   228 	r=b.Next(count);
   227 	r=b.Next(count);
   229 	
   228 	
   249 	const TInt KDrive1 = EDriveX;
   248 	const TInt KDrive1 = EDriveX;
   250 #endif
   249 #endif
   251 	
   250 	
   252 	RFs f;
   251 	RFs f;
   253 	TInt r = f.Connect();
   252 	TInt r = f.Connect();
   254 	test_KErrNone(r);
   253 	test(r==KErrNone);
   255 
   254 
   256 	RRawDisk a;
   255 	RRawDisk a;
   257     r=a.Open(f,KDrive1);
   256     r=a.Open(f,KDrive1);
   258 
   257 
   259 	test_KErrNone(r);
   258 	test(r==KErrNone);
   260 	RRawDisk b(a);
   259 	RRawDisk b(a);
   261 	a.Close();
   260 	a.Close();
   262 	TBuf8<19> buffer;
   261 	TBuf8<19> buffer;
   263 	r=b.Read(0,buffer);
   262 	r=b.Read(0,buffer);
   264 	
   263