Ejemplo n.º 1
0
LOCAL_C void ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
	{
	CDirScan* scanner = NULL;
	TRAP(r, scanner = CDirScan::NewL(TheFs));
	test_Value(r, r == KErrNone && scanner);

	TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
	test_KErrNone(r);
	
	CDir *entryList=NULL;
	for (;;)
		{
		TRAP(r, scanner->NextL(entryList));
		test_Value(r, r == aError);
		if (entryList==NULL)
			break;
		TInt count=entryList->Count();
		while (count--)
			{
			TEntry data=(*entryList)[count];
			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
			dirName = path;
			dirName.Append(data.iName);
			test.Printf(_L("    %S\n"),&dirName);
			
			}
		delete entryList;
		entryList=NULL;
		}
	delete scanner;

	}
Ejemplo n.º 2
0
/**
    Testing the case of passing a directory name longer than KMaxFileName to the file server.
    KErrBadName shall be the result
*/
LOCAL_C void DoTestLongDirName2(void)
{
    RFs         rfs;
    TBool       bDirExisted=EFalse;

    CleanupClosePushL(rfs);    
    test(rfs.Connect() == KErrNone);
    
    //-- create a dir c:\a
    _LIT(dirName, "C:\\a\\");
    TInt err = rfs.MkDir(dirName);
    test_Value(err, err == KErrNone || err == KErrAlreadyExists);
    
    if(err == KErrAlreadyExists)
        bDirExisted = ETrue;
    
    //-- dir name longer than KMaxFileName
    _LIT(longDirName, "C:\\a\\longnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongname\\");
    //TInt nLen = dirName().Length();
    
    //-- try to create a directory with a very long name, checking that it doesn't get truncated to the "c:\a"
    err = rfs.MkDir(longDirName);
    test_Value(err, err == KErrBadName);

    //-- clean up, remove created directory, otherwise some ill-designed tests can fail
    if(!bDirExisted)
        rfs.RmDir(dirName);
    
    CleanupStack::PopAndDestroy(1); // rfs
}
Ejemplo n.º 3
0
LOCAL_C void MakeDirs()
//
// Create system and private directories for scan with and without DC
//
	{
	TInt r;
	r = TheFs.MkDir(_L("\\normal\\"));
	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
	r = TheFs.MkDir(_L("\\normal\\one\\"));
	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
	r = TheFs.MkDir(_L("\\normal\\two\\"));
	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
	r = TheFs.MkDir(_L("\\sys\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\sys\\one\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\sys\\two\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\private\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\private\\one\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\private\\two\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.MkDir(_L("\\ZZZZZZ\\"));
	test_Value(r, r == KErrNone || r == KErrAlreadyExists);
	}
Ejemplo n.º 4
0
LOCAL_C void privateSIDRFiletest()
//
//
//
	{

	r=TheFs.SetSessionToPrivate(gTheDriveNum);
	test_KErrNone(r);
		
	r=file1.Temp(TheFs,theprivatepath,fromTemp,EFileWrite);
	test_KErrNone(r);
	file1.Close();
	r=file1.Create(TheFs,KFilePri,EFileWrite);
	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
	file1.Close();
	r=file1.Open(TheFs,KFilePri,EFileWrite);
	test_KErrNone(r);
	file1.Close();
	r=file1.Open(TheFs,KFilePri,EFileRead);
	test_KErrNone(r);
	file1.Close();
	r=file1.Replace(TheFs,KFilePri,EFileWrite);
	test_KErrNone(r);
	r=file1.Rename(KFilePri3);
	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
	file1.Close();

	}
Ejemplo n.º 5
0
void DeAllocateBuffers()
{
    test.Printf(_L("DeAllocate Buffers -"));

    if (gFragSharedMemory || gSharedMemory)
    {
        test.Printf(_L("Shared Memory\n"));
        test.Printf(_L("Close user chunk handle\n"));
        TheChunk.Close();

        test.Printf(_L("Close kernel chunk handle\n"));
        TInt r = Ldd.CloseChunk();
        test_Value(r, r == 1);

        test.Printf(_L("Check chunk is destroyed\n"));
        r = Ldd.IsDestroyed();
        test_Value(r, r == 1);

        test.Printf(_L("Close test driver\n"));
        Ldd.Close();
    }
    else
    {
        test.Printf(_L("Heap Memory\n"));
        test.Printf(_L("Delete Heap Buffer\n"));
        delete DataBufH;
    }
}
Ejemplo n.º 6
0
LOCAL_C void Test2()
//
// Test RFs::ReadFileSection() on UID reads
//
	{

	
	test.Next(_L("Use RFs::ReadFileSection() to read UIDs from files"));

	TBuf8<sizeof(TCheckedUid)> uidBuf(sizeof(TCheckedUid));
	TPtr uidPtr((TText*)uidBuf.Ptr(),sizeof(TCheckedUid),sizeof(TCheckedUid));
	
	TInt r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.BLG"),0,uidPtr,sizeof(TCheckedUid));
	test_KErrNone(r);
	TCheckedUid uid(uidBuf);
	TUidType uidType=uid.UidType();
	test(uidType.IsValid());
	
	test(uidType[0]==TUid::Uid('U') && uidType[1]==TUid::Uid('I') && uidType[2]==TUid::Uid('D'));

	r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.MSG"),0,uidBuf,sizeof(TCheckedUid));
	test_KErrNone(r);
	uid.Set(uidBuf);
	uidType=uid.UidType();
	test(uidType.IsValid());
	test(uidType[0]==TUid::Uid('X') && uidType[1]==TUid::Uid('Y') && uidType[2]==TUid::Uid('Z'));
	
	
	// Test for Null File length
	TBuf8<256> testDesN;
	test.Next(_L("Check for null file name"));
 	r=TheFs.ReadFileSection(_L(""),0,testDesN,26);
 	test_Value(r, r == KErrBadName);
 	
	// Check the lentgh of descriptor.	
 	TInt x = testDesN.Length();
 	test ( x == 0);
 	
 	test.Next(_L("Check for non existing file"));
	r=TheFs.ReadFileSection(_L("sdfsd.dfg"),0,testDesN,26);
 	test.Printf(_L("Return %d"),r);
 	test_Value(r, (r == KErrNotFound) || (r == KErrPathNotFound));
 	
	// Check the lentgh of descriptor.	
 	x = testDesN.Length();
	test ( x == 0);
	
	r=TheFs.ReadFileSection(_L("\\F32-TST\\UIDCHK.DAT"),0,uidBuf,sizeof(TCheckedUid));
	test_KErrNone(r);
	uid.Set(uidBuf);
	uidType=uid.UidType();
	test(uidType.IsValid());
	test(uidType[0]==TUid::Uid('D') && uidType[1]==TUid::Uid('A') && uidType[2]==TUid::Uid('T'));
	

	}
Ejemplo n.º 7
0
LOCAL_C void TestPathCheck()
//
// This test case is brought in by INC054580
// (NTT Renaming sys ¨Cfolder on C -drive on H2 allows user to access sys -files)
//
    {
    TInt r = TheFs.Rename(_L("\\sys"), _L("\\sysbad"));
    test_Value(r, r == KErrPermissionDenied);
    r = TheFs.Rename(_L("\\resource"), _L("\\resourcebad"));
    test_Value(r, r == KErrPermissionDenied);
    r = TheFs.Rename(_L("\\private"), _L("\\privatebad"));
    test_Value(r, r == KErrPermissionDenied);
    }
Ejemplo n.º 8
0
LOCAL_C void resourceRFiletest()
//
//
//
	{
	r=TheFs.SetSessionPath(restestname);
	test_KErrNone(r);

	r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Create(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);

	r=file1.ChangeMode(EFileShareExclusive);	//this is not illegal though will prevent shared access to resource which is nit my fault but may be desirable to prevent
	test_Value(r, r == KErrNone || r==KErrPathNotFound);

	//this operation is prevented as you can not open a file for write access in the resource directory
	r=file1.Rename(KFileRes3);
	test_Value(r, r == KErrPermissionDenied || r==KErrAccessDenied);

	file1.Close();

	r=file1.Replace(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	}
Ejemplo n.º 9
0
void TestCommitDecommit(RPageMove& pagemove, RChunk& aChunk)
	{
	test.Printf(_L("Attempt to move a page while it is being committed and decommited\n"));
	RThread thread;
	TRequestStatus s;
	test_KErrNone(thread.Create(_L("CommitDecommit"), &CommitDecommit, KDefaultStackSize, NULL, (TAny*)&aChunk));
	thread.Logon(s);
	thread.SetPriority(EPriorityMore);
	thread.Resume();

	TUint8* firstpage=(TUint8*)_ALIGN_DOWN((TLinAddr)aChunk.Base(), PageSize);
	for (TInt i=0; i < Repitions; i++)
		{
		TInt r = pagemove.TryMovingUserPage(firstpage, ETrue);
		// Allow all valid return codes as we are only testing that this doesn't 
		// crash the kernel and the page could be commited, paged out or decommited
		// at any one time.
		test_Value(r, r <= KErrNone);
		}

	thread.Kill(KErrNone);
	User::WaitForRequest(s);
	test_Equal(EExitKill,thread.ExitType());
	test_KErrNone(thread.ExitReason());
	thread.Close();
	}
Ejemplo n.º 10
0
LOCAL_C void RemountFileSystem(TInt aDrive, TBool aSync)
/// Unmount and remount the file system on the specified drive in the
/// selected mode.
/// @param aDrive Drive number (EDriveC etc.).
/// @param aSync  Mount synchronous if true, asynchronous if not.
	{
	TChar c;
	TInt r=TheFs.DriveToChar(aDrive,c);
	r=TheFs.FileSystemName(gFsName, aDrive);
	test_Value(r, r == KErrNone || r==KErrNotFound);

	if (gFsName.Length() > 0)
		{
		r=TheFs.DismountFileSystem(gFsName, aDrive);
		test_KErrNone(r);
		}

	TBufC<16> type = _L("asynchronous");
	if (aSync)
		type = _L("synchronous");
	test.Printf(_L("Mount filesystem %c: %-8S as %S\n"), (TUint)c, &gFsName, &type);

#ifdef __CONCURRENT_FILE_ACCESS__
	r=TheFs.MountFileSystem(gFsName, aDrive, aSync);
#else
	r=TheFs.MountFileSystem(gFsName, aDrive);
#endif

	test_KErrNone(r);
	}
Ejemplo n.º 11
0
LOCAL_C void TestCaps()
//
//	test format etc that require certain capabilities
//
	{
	driveBuf[0]=(TText)gDriveToTest;
	r=TheFs.SessionPath(temp);
	test_KErrNone(r);

	test.Printf(_L("Session path: %S"),&temp);

	r=TheFs.CreatePrivatePath(gTheDriveNum);
	test_Value(r, r == KErrNone || r== KErrAlreadyExists);

	TBuf<18> tempPri;
	r=TheFs.PrivatePath(tempPri);
	test_KErrNone(r);
	theprivatepath = _L("?:");
	theprivatepath.Append(tempPri);
	
	DiskAdminTest();

	TFileName thesessionpath;

	r=TheFs.SetSessionToPrivate(gTheDriveNum);
	test_KErrNone(r);
	r=TheFs.SessionPath(thesessionpath);
	test_KErrNone(r);

	test(thesessionpath == theprivatepath);
	}
Ejemplo n.º 12
0
void UnfragmentMemory(TBool aDiscard, TBool aTouchMemory, TBool aFragThread)
	{
	test_Value(aTouchMemory, !aTouchMemory || !aFragThread);
	if (aTouchMemory && !ManualTest)
		{
		TouchDataStop = ETrue;
		User::WaitForRequest(TouchStatus);
		test_Equal(EExitKill, TouchThread.ExitType());
		test_KErrNone(TouchThread.ExitReason());
		CLOSE_AND_WAIT(TouchThread);
		}
	if (aFragThread)
		{
		FragThreadStop = ETrue;
		User::WaitForRequest(FragStatus);
		test_Equal(EExitKill, FragThread.ExitType());
		test_KErrNone(FragThread.ExitReason());
		CLOSE_AND_WAIT(FragThread);
		}
	else
		UnfragmentMemoryFunc();
	if (CacheSizeAdjustable)
		test_KErrNone(DPTest::SetCacheSize(OrigMinCacheSize, OrigMaxCacheSize));
	CLOSE_AND_WAIT(Chunk);
	}
Ejemplo n.º 13
0
LOCAL_C void RDirtest()
//
//
//
	{
	//system
	dirNameBuf.Zero();
	dirNameBuf = KSystemPath;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;
	//Private//falseid
	dirNameBuf=KPrivateFalseID;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;
	//Private
	dirNameBuf=KPrivatePath;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrPermissionDenied);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrPermissionDenied);
	dirNameBuf.Zero();
	delete dirEntries;
	//Private/uid
	TheFs.PrivatePath(dirNameBuf);
	dirNameBuf.Insert(0,_L("?:"));
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_KErrNone(r);
	dir.Close();
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_KErrNone(r);
	dirNameBuf.Zero();
	delete dirEntries;
	//Resource
	dirNameBuf=KResourcePath;
	dirNameBuf[0]=(TText)gDriveToTest;
	r=dir.Open(TheFs,dirNameBuf,KEntryAttNormal);
	test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound);
	r=TheFs.GetDir(dirNameBuf,KEntryAttMatchMask,ESortByName,dirEntries);
	test_Value(r, r == KErrNone || r==KErrPathNotFound || r==KErrNotFound);
	dir.Close();
	delete dirEntries;
	}
Ejemplo n.º 14
0
void MakeDir(const TDesC& aDirName)
//
// Make a directory
//
	{
	TInt r=TheFs.MkDirAll(aDirName);
	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
	}
Ejemplo n.º 15
0
void FragmentMemory(TUint aSize, TUint aFrequency, TBool aDiscard, TBool aTouchMemory, TBool aFragThread)
	{
	test_Value(aTouchMemory, !aTouchMemory || !aFragThread);
	test_Value(aSize, aSize < aFrequency);
	FragData.iSize = aSize;
	FragData.iFrequency = aFrequency;
	FragData.iDiscard = aDiscard;
	FragData.iFragThread = aFragThread;

	TChunkCreateInfo chunkInfo;
	chunkInfo.SetDisconnected(0, 0, TotalRam);
	chunkInfo.SetPaging(TChunkCreateInfo::EUnpaged);
	chunkInfo.SetClearByte(0x19);
	test_KErrNone(Chunk.Create(chunkInfo));

	if (aFragThread)
		{
		TInt r = FragThread.Create(_L("FragThread"), FragmentMemoryThreadFunc, KDefaultStackSize, PageSize, PageSize, NULL);
		test_KErrNone(r);
		FragThread.Logon(FragStatus);
		FragThreadStop = EFalse;
		TRequestStatus threadInitialised;
		FragThread.Rendezvous(threadInitialised);
		FragThread.Resume();
		User::WaitForRequest(threadInitialised);
		test_KErrNone(threadInitialised.Int());
		}
	else
		{
		FragmentMemoryFunc();
		}
	if (aTouchMemory && !ManualTest)
		{
		TouchData.iSize = aSize;
		TouchData.iFrequency = aFrequency;
		TInt r = TouchThread.Create(_L("TouchThread"), TouchMemory, KDefaultStackSize, PageSize, PageSize, NULL);
		test_KErrNone(r);
		TouchThread.Logon(TouchStatus);
		TouchDataStop = EFalse;
		TRequestStatus threadInitialised;
		TouchThread.Rendezvous(threadInitialised);
		TouchThread.Resume();
		User::WaitForRequest(threadInitialised);
		test_KErrNone(threadInitialised.Int());
		}
	}
Ejemplo n.º 16
0
void RmDir(const TDesC& aDirName)
	{
	TFileName filename_dir = aDirName;
	TInt r = 0;
	r = TheFs.SetAtt(filename_dir, 0, KEntryAttReadOnly);
	test_KErrNone(r);
	r=gFileMan->RmDir(filename_dir);
	test_Value(r, r == KErrNone || r==KErrNotFound || r==KErrPathNotFound || r==KErrInUse);
	}
Ejemplo n.º 17
0
static void CreateManyLargFiles(TInt aNumber)
//
// Make a directory with aNumber entries
//
{
    RFile64 f;
    TInt maxEntry=aNumber;

    test.Printf(_L("Create a directory with %d entries\n"),aNumber);

    TFileName sessionPath;
    TInt r=TheFs.SessionPath(sessionPath);
    test_KErrNone(r);
    r=TheFs.MkDir(_L("\\F32-TST\\"));
    test((r==KErrNone)||(r==KErrAlreadyExists));
    r=TheFs.MkDir(_L("\\F32-TST\\BENCH_DELETE\\"));
    test((r==KErrNone)||(r==KErrAlreadyExists));
    TBuf8<8> WriteData =_L8("Wibbleuy");
    for (TInt i=0; i<maxEntry; i++)
    {
        TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
        baseName.AppendNum(i);
        r=f.Replace(TheFs,baseName,EFileWrite);
        test_KErrNone(r);
        r = f.SetSize(K3GB);
        test_KErrNone(r);
        r=f.Write((K3GB-30),WriteData);
        test_KErrNone(r);
        f.Flush();
        f.Close();
    }

    test.Printf(_L("Test all entries have been created successfully\n"));
    TBuf8<8> ReadData;
    TInt64 Size=0;
    for (TInt j=0; j<=maxEntry; j++)
    {
        TFileName baseName=_L("\\F32-TST\\BENCH_DELETE\\FILE");
        baseName.AppendNum(j);

        TInt r=f.Open(TheFs,baseName,EFileRead);
        if (r!=KErrNone)
        {
            test_Value(r, r == KErrNotFound && j==maxEntry);
            return;
        }
        ReadData.FillZ();
        r=f.Read((K3GB-30),ReadData);
        test_KErrNone(r);
        test(f.Size(Size)==KErrNone);
        test(K3GB == Size);
        test(ReadData==WriteData);
        f.Close();
    }
}
Ejemplo n.º 18
0
RFileTest& RFileTest::WriteE(TInt aPos,TInt aLen)
//
// Write to the file. Expected to fail.
//
	{

	test.Printf(_L("%S writeE %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
	TInt r=RFile::Write(aPos,Pattern,aLen);
	test_Value(r, r == KErrLocked);
	return(*this);
	}
Ejemplo n.º 19
0
RFileTest& RFileTest::SizeE(TInt aSize)
//
// Set the size of the file. Expected to fail.
//
	{

	test.Printf(_L("%S sizeE  %08x\n"),&iName,aSize);
	TInt r=RFile::SetSize(aSize);
	test_Value(r, r == KErrLocked);
	return(*this);
	}
Ejemplo n.º 20
0
static void CallTests()
//
// Do tests relative to session path
//
	{
	
//	Set up an array of valid TDateTimes and TTimes to be tested for Y2K compliance

	TDateTime validDateTime[KMaxValidDateTimes];
	TTime validTime[KMaxValidDateTimes];
	TInt r;
	TInt i=0;

	for (;i<KMaxValidDateTimes;i++)
		{
	//	Dummy time is used to initialise validDateTime[i] before calling SetX()
		r=validDateTime[i].Set(1998,EJune,23,11,11,11,0);
		test_KErrNone(r);
		r=validDateTime[i].SetYear(testYearValid[i]);
		test_KErrNone(r);
		r=validDateTime[i].SetMonth(testMonthValid[i]);
		test_KErrNone(r);
		r=validDateTime[i].SetDay(testDayValid[i]);
		test_KErrNone(r);
		validTime[i]=validDateTime[i];
		}

//	Set up an array of invalid TDateTimes and TTimes to be tested for Y2K compliance

	TDateTime invalidDateTime[KMaxInvalidDateTimes];
	TTime invalidTime[KMaxInvalidDateTimes];
	TTimeIntervalDays extraDay(1);

	for (i=0;i<KMaxInvalidDateTimes;i++)
		{
	//	Dummy time is used to initialise validDateTime[i] before calling SetX()
		r=invalidDateTime[i].Set(1998,EJune,22,11,11,11,0);
		test_KErrNone(r);
		r=invalidDateTime[i].SetYear(testYearInvalid[i]);
		test_KErrNone(r);
		r=invalidDateTime[i].SetMonth(testMonthInvalid[i]);
		test_KErrNone(r);
		r=invalidDateTime[i].SetDay(testDayInvalid[i]);
		test_Value(r, r == KErrGeneral);		//	This will fail because it is an invalid date
		r=invalidDateTime[i].SetDay(testDayInvalid[i]-1);
		test_KErrNone(r);			//	Set it one day less 
		invalidTime[i]=invalidDateTime[i];
		invalidTime[i]+=extraDay;	//	Add on an extra day.  This should bump the
		}							//	date onto the next month, NOT set the day
									//	to the invalid date in invalidDateTime[i]
										
	TestValidDates(&validDateTime[0],&validTime[0]);
	TestInvalidDates(&invalidDateTime[0],&invalidTime[0]);		
	}
Ejemplo n.º 21
0
RFileTest& RFileTest::ReadE(TInt aPos,TInt aLen)
//
// Read from the file. Expected to fail.
//
	{

	test.Printf(_L("%S readE  %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
	TInt r=RFile::Read(aPos,Buffer,aLen);
	test_Value(r, r == KErrLocked);
	return(*this);
	}
Ejemplo n.º 22
0
RFileTest& RFileTest::UnLockEA(TInt aPos,TInt aLen)
//
// Unlock the file. Expected to fail with KErrArgument.
//
	{

	test.Printf(_L("%S ulock  %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
	TInt r=RFile::UnLock(aPos,aLen);
	test_Value(r, r == KErrArgument);
	return(*this);
	}
Ejemplo n.º 23
0
RFileTest& RFileTest::LockE(TInt aPos,TInt aLen)
//
// Set a lock on the file. Expected to fail.
//
	{

	test.Printf(_L("%S lockE  %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
	TInt r=RFile::Lock(aPos,aLen);
	test_Value(r, r == KErrLocked);
	return(*this);
	}
Ejemplo n.º 24
0
void TSessionTest::MakeAndDeleteFiles()
//
// Create and delete large files in a randomish order
//
	{

	test.Start(_L("Create and delete large files"));
	TInt r=iFs.MkDirAll(_L("\\SESSION_TEST\\SMALLDIRECTORY\\"));
	test_Value(r, r==KErrNone || r==KErrAlreadyExists);
	TBuf<128> fileName=_L("\\SESSION_TEST\\SMALLDIRECTORY\\FILE");
	r=CreateFileX(fileName,0,iFs);
	test_KErrNone(r);
	r=CreateFileX(fileName,1,iFs);
	test_KErrNone(r);
	r=DeleteFileX(fileName,0,iFs);	
	test_KErrNone(r);
	r=CreateFileX(fileName,2,iFs);
	test_KErrNone(r);
	r=CreateFileX(fileName,1,iFs);
	test_KErrNone(r);
	r=CreateFileX(fileName,3,iFs);
	test_KErrNone(r);
	r=DeleteFileX(fileName,1,iFs);	
	test_KErrNone(r);
	r=CreateFileX(fileName,4,iFs);
	test_KErrNone(r);
	r=DeleteFileX(fileName,2,iFs);	
	test_KErrNone(r);
	r=DeleteFileX(fileName,3,iFs);	
	test_KErrNone(r);
	r=DeleteFileX(fileName,4,iFs);	
	test_KErrNone(r);
	r=CreateFileX(fileName,1,iFs);
	test_KErrNone(r);
	r=DeleteFileX(fileName,1,iFs);	
	test_KErrNone(r);

	r=iFs.CheckDisk(fileName);
	test_Value(r, r==KErrNone || r==KErrNotSupported);
	test.End();
	}
Ejemplo n.º 25
0
LOCAL_C void CleanDirs()
//
// Remove system and private directories for scan with and without DC
// (note that the \Private directory may not be able to be removed at this
// point if it contains other directories, so failing with "in use" is
// permitted in this case).
//
	{
	TInt r;
	r = TheFs.RmDir(_L("\\normal\\one\\"));
	test_KErrNone(r);
	r = TheFs.RmDir(_L("\\normal\\two\\"));
	test_KErrNone(r);
	r = TheFs.RmDir(_L("\\normal\\"));
	test_KErrNone(r);
	r = TheFs.RmDir(_L("\\sys\\one\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\sys\\two\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\sys\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\private\\one\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\private\\two\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\private\\"));
	test_Value(r, r == KErrPermissionDenied);
	r = TheFs.RmDir(_L("\\ZZZZZZ\\"));
	test_KErrNone(r);
	}
Ejemplo n.º 26
0
LOCAL_C TChar MountTestFileSystem(TInt aDrive)
//
// Mount a new CTestFileSystem on the drive under test
//
	{
	TInt r;
	TBuf<64> b;
	TChar c;
	r=TheFs.DriveToChar(aDrive,c);
	test_KErrNone(r);
	b.Format(_L("Mount test file system on %c:"),(TUint)c);
	test.Next(b);

	r=TheFs.AddFileSystem(KFsFile);
	test_Value(r, r == KErrNone || r==KErrAlreadyExists);

	r=TheFs.FileSystemName(gOldFsName,aDrive);
	test_Value(r, r == KErrNone || r==KErrNotFound);

	TDriveInfo drv;
	r = TheFs.Drive(drv, aDrive);
	test_KErrNone(r);

	gNoMedia = (drv.iType == EMediaUnknown || drv.iType == EMediaNotPresent);

	if (gOldFsName.Length() > 0)
		{
		TTest::Printf(_L("Dismount %C: %S"), (TUint)c, &gOldFsName);
		r=TheFs.DismountFileSystem(gOldFsName,aDrive);
		test_KErrNone(r);
		}

	r=TheFs.MountFileSystem(KFsName,aDrive);
	test_KErrNone(r);

	r=TheFs.FileSystemName(gNewFsName,aDrive);
	test_KErrNone(r);
	test(gNewFsName.CompareF(KFsName)==0);
	return c;
	}
Ejemplo n.º 27
0
LOCAL_C void privateRFiletest()
//
//
//
	{

	r=TheFs.SetSessionPath(pritestname);
	test_Value(r, r == KErrPermissionDenied);

	r=file1.Temp(TheFs,pritestname,fromTemp,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);

	TBuf<25> prifilename;
	prifilename.Append(pritestname);
	prifilename.Append(KFileSys);

	r=file1.Create(TheFs,prifilename,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);


	r=file1.Open(TheFs,prifilename,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);

	
	r=file1.Open(TheFs,prifilename,EFileRead);
	test_Value(r, r == KErrPermissionDenied);


	r=file1.Replace(TheFs,prifilename,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);

	}
Ejemplo n.º 28
0
LOCAL_C void resourceRFiletest()
//
//
//
	{
//RFile testing with session path set to //resource//
	r=TheFs.SetSessionPath(restestname);
	test_KErrNone(r);

	r=file1.Temp(TheFs,restestname,fromTemp,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Create(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileRead|EFileShareReadersOnly);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileRead);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOrWriters|EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	r=file1.Open(TheFs,KFileRes,EFileShareReadersOnly);
	test_KErrNone(r);

	r=file1.ChangeMode(EFileShareExclusive);	
	test_KErrNone(r);

	//this operation is prevented as you can not open a file for write access in the resource directory
	r=file1.Rename(KFileRes3);
	test_Value(r, r == KErrPermissionDenied || r==KErrAccessDenied);
	file1.Close();

	r=file1.Replace(TheFs,KFileRes,EFileWrite);
	test_Value(r, r == KErrPermissionDenied);
	file1.Close();

	}
Ejemplo n.º 29
0
void TSessionTest::FillUpDisk()
//
// Test that a full disk is ok
//
	{

	test.Start(_L("Fill disk to capacity"));
	TInt r=iFs.MkDirAll(_L("\\SESSION_TEST\\BIGDIRECTORY\\"));
	test_Value(r, r==KErrNone || r==KErrAlreadyExists);
	TInt count=0;
	TFileName sessionPath;
	r=iFs.SessionPath(sessionPath);
	test_KErrNone(r);
	TBuf<128> fileName=_L("\\SESSION_TEST\\BIGDIRECTORY\\FILE");
	FOREVER
		{
		TInt r=CreateFileX(fileName,count,iFs);
		if (r==KErrDiskFull)
			break;
		test_KErrNone(r);
		count++;
 #if defined(__WINS__)
		if (count==32 && sessionPath[0]=='C') // Don't fill up disk on NT
			break;
 #endif
		}

	r=iFs.CheckDisk(fileName);
	test_Value(r, r==KErrNone || r==KErrNotSupported);

	while(count--)
		DeleteFileX(fileName,count,iFs);

	r=iFs.CheckDisk(fileName);
	test_Value(r, r==KErrNone || r==KErrNotSupported);

	test.End();
	}
Ejemplo n.º 30
0
void CreateTestDirectory(const TDesC& aSessionPath)
//
// Create directory for test
//
	{
	TParsePtrC path(aSessionPath);
	test(path.DrivePresent()==EFalse);
	TInt r=TheFs.SetSessionPath(aSessionPath);
	test_KErrNone(r);
	r=TheFs.SessionPath(gSessionPath);
	test_KErrNone(r);
	r=TheFs.MkDirAll(gSessionPath);
	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
	}