Ejemplo n.º 1
0
void TestQuickFormat()
    {
    test.Start(_L("Test EQuickFormat"));
    TInt counter;
    RFormat format;

    TInt err = format.Open(fsSession, msDrive->GetSessionPath(), EQuickFormat, counter);
    test(err == KErrNone);
    while(counter)
        {
        err = format.Next(counter);
        test(err == KErrNone);
        }
    format.Close();
    DisplayVolumeInfo();
    test.End();
    }
Ejemplo n.º 2
0
GLDEF_C void Format(TInt aDrive)
//
// Format current drive
//
	{
	test.Next(_L("Format"));
	TBuf<4> driveBuf=_L("?:\\");
	driveBuf[0]=(TText)(aDrive+'A');
	RFormat format;
	TInt count;
	TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count);
	test_KErrNone(r);
	while(count)
		{
		TInt r=format.Next(count);
		test_KErrNone(r);
		}
	format.Close();
	}
Ejemplo n.º 3
0
void TestFullFormat()
    {
    test.Start(_L("Test EFullFormat"));
    TInt counter;
    RFormat format;

    TInt err = format.Open(fsSession, msDrive->GetSessionPath(), EFullFormat, counter);
    test(err == KErrNone);
    while(counter)
        {
        test.Printf(_L("."));
        err = format.Next(counter);
        test(err == KErrNone);
        }
    test.Printf(_L("\n\r"));

    format.Close();
    DisplayVolumeInfo();
    test.End();
    }
Ejemplo n.º 4
0
void TSessionTest::testInitialisation()
//
//	Tests that calls to CheckedClose() are OK, ie, tests bug fix
//
	{
	test.Next(_L("Test calls to CheckedClose are OK"));
	
	RFile file;
	RDir dir;
		
	TInt count;
	RFormat format;
	TInt r=format.Open(iFs,_L("Z:\\"),EFullFormat,count);

	test_Value(r, r==KErrAccessDenied || r==KErrInUse);
	
	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest1.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST2\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);		
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest2.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=dir.Open(iFs,_L("\\SESSION_TEST\\ERRORTEST3\\"),KEntryAttMatchMask);
	test_Value(r, r==KErrPathNotFound);		
	
	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest3.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);

	r=file.Open(iFs,_L("\\SESSION_TEST\\SessionTest4.txt"),EFileRead);
	test_Value(r, r==KErrNotFound);
	
	format.Close();
	dir.Close();
	file.Close();
	}
Ejemplo n.º 5
0
LOCAL_C void DoFormat()
//
// Format the ramdisk
//
	{

	TInt count;
	RFormat format;
#if defined(__WINS__)
	TInt r=format.Open(TheFs,_L("Y:\\"),EHighDensity,count);
#else
	TInt r=format.Open(TheFs,_L("C:\\"),EHighDensity,count);
#endif
	test_KErrNone(r);
	while(count)
		{
		r=format.Next(count);
		test_KErrNone(r);
		}
	format.Close();
	}
Ejemplo n.º 6
0
/** Formats the drive 

	@param aDrive 	Drive to be formatted
*/
void Format(TInt aDrive)
	{

	test.Next(_L("Format"));
	TBuf<4> driveBuf = _L("?:\\");
	driveBuf[0] = (TText)(aDrive+'A');
	RFormat format;
	TInt count, prevcount = 0;
	TInt r = format.Open(TheFs, driveBuf, EQuickFormat, count);
	TESTERROR(r);
	
	while(count)
		{
		TInt r = format.Next(count);
        if(count != prevcount)
	        {
			test.Printf(_L("."));
			prevcount = count;
			}
		TESTERROR(r);
		}

	format.Close();
	}
Ejemplo n.º 7
0
LOCAL_C void doComponentTest()
    //
    // Do the component test
    //
	{
#ifndef __NO_HEAP_CHECK
	__UHEAP_MARK;
#endif	

    TInt ret;
    test.Printf(_L("Start MountStart test. Be sure MMC card is inserted.\n"));
    // Parse the CommandLine argument: removal drive
    ParseCommandArguments();

    // Connect to the server
    LOG_AND_TEST(KErrNone,  fs.Connect());
	CleanupClosePushL(fs); 
	   
    // Convert drive letter to its numerical equivalent
	ret = fs.CharToDrive(driveLetter,removalDrvNo);
	LOG_AND_TEST(ret,  KErrNone);	

	// Load the logical device
	_LIT(KDriverFileName,"TESTUSBC.LDD");
	ret = User::LoadLogicalDevice(KDriverFileName);
	LOG_AND_TEST(KErrNone, ret);

    // Add MS file system
	_LIT(KMsFsFsy, "MSFS.FSY");
	LOG_AND_TEST(KErrNone, fs.AddFileSystem(KMsFsFsy));
	
    // Start Ms file system
    RUsbMassStorage usbMs;
    CleanupClosePushL(usbMs);

    TMassStorageConfig config;
    
    config.iVendorId.Copy(_L("vendorId"));
    config.iProductId.Copy(_L("productId"));
    config.iProductRev.Copy(_L("rev"));

	ret = usbMs.Connect();
    LOG_AND_TEST(KErrNone, ret);
  
    // Start usb mass storage device
    LOG_AND_TEST(KErrNone , usbMs.Start(config));

    // Format removable drive using FAT FS
    RFormat format;
    TBuf<2> removalDrive;
    removalDrive.Append(driveLetter);
    removalDrive.Append(':');
    TInt tracksRemaining;
    test.Printf(_L("Start MMC card formatting\n"));
    LOG_AND_TEST(KErrNone, format.Open(fs, removalDrive, EHighDensity|EQuickFormat, tracksRemaining));
    while (tracksRemaining)
        {
        test.Printf(_L("."));
        LOG_AND_TEST(KErrNone,  format.Next(tracksRemaining));
        }
    format.Close();
  	test.Printf(_L("\nDone!\n"));

    // Open a session to LDD
    test.Printf(_L("Open LDD\n"));
    LOG_AND_TEST(KErrNone, usbcClient.Open(0));

	test.Printf(_L("Creating CActiveScheduler\n"));
	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
	CleanupStack::PushL(sched);
	CActiveScheduler::Install(sched);
  	
	// Create a state machine
	CStateMachine* sm = CStateMachine::NewL();
	CleanupStack::PushL(sm);
    sm->AddState(EUsbMsDriveState_Disconnected);
    sm->AddState(EUsbMsDriveState_Connecting);
    sm->AddState(EUsbMsDriveState_Connected);
    sm->AddState(EUsbMsDriveState_Disconnecting);
    sm->AddState(EUsbMsDriveState_Active);
    sm->AddState(EUsbMsDriveState_Locked);
    sm->AddState(EUsbMsState_Written);
    sm->AddState(EUsbMsState_Read);
    
    sm->SetInitState(EUsbMsDriveState_Disconnected);

  	CPropertyHandler* driveStatusHandler 	= CMsDriveStatusHandler::NewLC(removalDrvNo, *sm);
  	CPropertyHandler* readStatusHandler 	= CMsReadStatusHandler::NewLC(removalDrvNo, *sm);
  	CPropertyHandler* writtenStatusHandler 	= CMsWrittenStatusHandler::NewLC(removalDrvNo, *sm);
  	
 	CPropertyWatch::NewLC(EUsbMsDriveState_DriveStatus, *driveStatusHandler);
 	CPropertyWatch::NewLC(EUsbMsDriveState_KBytesRead, *readStatusHandler);
 	CPropertyWatch::NewLC(EUsbMsDriveState_KBytesWritten, *writtenStatusHandler);
 	
	CActiveScheduler::Start();

	ret = usbMs.Stop();
	test.Printf(_L("usbMs.Stop returned %d\n"), ret);
	test(ret == KErrNone);
	usbMs.Close();
	// 1 sec delay for MSFS to stop
	User::After(1000000);
	ret = fs.RemoveFileSystem(KMsFs);
	test(ret == KErrNone || ret == KErrNotFound);
	test.Printf(_L("RemoveFileSystem returned %d\n"), ret);

	usbcClient.Close();
	ret = User::FreeLogicalDevice(_L("USBC"));
	test.Printf(_L("FreeLogicalDevice returned %d\n"), ret);
	test(ret == KErrNone);			

	CleanupStack::PopAndDestroy(3);	// 3 CPropertyWatches 
	CleanupStack::PopAndDestroy(3);	// 3 property status change handlers
	CleanupStack::PopAndDestroy(sm);
	CleanupStack::PopAndDestroy(sched);
	CleanupStack::PopAndDestroy(&usbMs);
	CleanupStack::PopAndDestroy(&fs);

#ifndef __NO_HEAP_CHECK
	__UHEAP_MARKEND;
#endif
	}
Ejemplo n.º 8
0
LOCAL_C void DiskAdminTest()
//
//	test diskadministration capabilitiy
//
	{
	r=TheFs.FileSystemName(fsname,gTheDriveNum);
	test_KErrNone(r);
	r = DismountFileSystem(TheFs, fsname, gTheDriveNum);
	test_KErrNone(r);
//	r=TheFs.RemoveFileSystem(fsname);	//can not test due to bug else where fix exists
//	test_Value(r, r == KErrPermissionDenied);
//	r=TheFs.AddFileSystem(fsname);
//	test_Value(r, r == KErrPermissionDenied);
	r = MountFileSystem(TheFs, fsname, gTheDriveNum);
	test_KErrNone(r);
	r=TheFs.SetDriveName(gTheDriveNum,KDriveName);
	test_KErrNone(r);
	r=TheFs.SetVolumeLabel(KVolLable, gTheDriveNum);
	test_Value(r, r == KErrNone || r==KErrNotSupported);

	systemRFstest();
	resourceRFstest();
	privateRFstest();
	privateSIDRFstest();
	privateFalseIDRFstest();

	systemRFiletest();
	resourceRFiletest();
	privateRFiletest();
	privateSIDRFiletest();
	privatefalseIDRFiletest();

//disk changes to sys and pri paths should have completed these
	test(aStat4 == KRequestPending);
	TheFs.NotifyChangeCancel(aStat4);
	test(aStat4==KErrCancel);
	
	User::WaitForRequest(aStat3);
	test(aStat1==KErrPermissionDenied);
	test(aStat2==KErrPermissionDenied);
	test(aStat3==KErrNone);
	
	r=TheFs.SetSessionPath(systestname);
	test_Value(r, r == KErrPermissionDenied);
	
//Test RRawDisk class
	r=rawdisk.Open(TheFs,gTheDriveNum);
	test_Value(r, r == KErrPermissionDenied);
	rawdisk.Close();

	RDirtest();

#ifdef __WINS__
	if (User::UpperCase(driveBuf[0]) != 'C')
#endif
		{
		//Test RFormat class
		r=format.Open(TheFs,driveBuf,EHighDensity,count);
		test_KErrNone(r);

		while(count)
			{
			TInt r=format.Next(count);
			test_KErrNone(r);
			}
		format.Close();
		}

	driveBuf[0]=(TText)gDriveToTest;
	r=TheFs.ScanDrive(driveBuf);
	test_Value(r, r == KErrNone || r==KErrNotSupported);
	r=TheFs.CheckDisk(driveBuf);
	test_Value(r, r == KErrNone || r==KErrNotSupported);
	}