static void DriveSpaceReport() { TheTest.Printf(_L("Drive space report:\n")); TVolumeInfo volInfo; TheFsSession.Volume(volInfo, EDriveC); TheTest.Printf(_L("Volume C: Free Space: %D\n"), volInfo.iFree); TheTest.Printf(_L("Volume C: Total Size: %D\n"), volInfo.iSize); TheFsSession.Volume(volInfo, EDriveZ); TheTest.Printf(_L("Volume Z: Free Space: %D\n"), volInfo.iFree); TheTest.Printf(_L("Volume Z: Total Size: %D\n"), volInfo.iSize); }
void TTestMsBlock::tFileAccess() { test.Start(_L("tFileAccess\n")); test.Next(_L("DriveInfo")); PrintDrvInfo(fsSession, msDrive->DriveNumber()); TVolumeInfo volInfo; TInt err = fsSession.Volume(volInfo); test(err == KErrNone); test.Printf(_L("Memory 'in use' = %lx\n"), (volInfo.iSize - volInfo.iFree)); test.Printf(_L("volInfo.iSize = %lx\n"), volInfo.iSize); test.Printf(_L("volInfo.iFree = %lx\n"), volInfo.iFree); //-- 1. create a file _LIT(KFile, "\\test_file.file"); const TUint KFileSz = 54321; test.Next(_L("Write file\n")); err = CreateCheckableStuffedFile(fsSession, KFile, KFileSz); test_KErrNone(err); //-- 2. verify the file, just in case. test.Next(_L("Verify file\n")); err = VerifyCheckableFile(fsSession, KFile); test_KErrNone(err); //-- 3. delete the file test.Next(_L("Delete file\n")); fsSession.Delete(KFile); test.End(); }
// ----------------------------------------------------------------------------- // CbsUtils::VolumeCriticalLevelCheckL // Leaves with KErrDiskFull if writing aBytesToWrite bytes // to the RAM File System would reduce the free space on RAM // under the critical level. // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CbsUtils::VolumeCriticalLevelCheckL( const TDesC& aFileName, TInt aBytesToWrite, const RFs& aFs ) { // Convert file name to a volume number TInt volumeNumber; aFs.CharToDrive( aFileName[0], volumeNumber ); // Find out if the volume has enough free space TVolumeInfo volume; User::LeaveIfError( aFs.Volume( volume, volumeNumber ) ); if ( volume.iFree < aBytesToWrite ) { User::Leave( KErrDiskFull ); } }
// ----------------------------------------------------------------------------- // CSdDisk::CheckDiskSpace() // This method checks free disk space // // Method is the almost the same than FreeSpaceL(RFs* aFs, TInt aDrive) in sysutil.cpp // ----------------------------------------------------------------------------- TReal64 CSdDisk::CheckDiskSpace(RFs& aFs) { // RDebug::Print(_L("Shareddatatest ## CheckDiskSpace")); TInt err = KErrNone; TVolumeInfo vinfo; err = aFs.Volume(vinfo, EDriveC); if ( err != KErrNone ) { RDebug::Print(_L("Shareddatatest ## Error = %d"), err); User::LeaveIfError(err); } // RDebug::Print(_L("Shareddatatest ## Disk space: %f "), TReal64(vinfo.iFree)); return TReal64(vinfo.iFree); }
void DisplayVolumeInfo() { TVolumeInfo volInfo; TInt err = fsSession.Volume(volInfo); test(err == KErrNone); if (volInfo.iSize-volInfo.iFree != 0) { test.Printf(_L("Memory 'in use' after a full format = %ld\n"),(volInfo.iSize-volInfo.iFree)); test.Printf(_L("volInfo.iSize = %ld\n"),volInfo.iSize); test.Printf(_L("volInfo.iFree = %ld\n"),volInfo.iFree); } test.Next(_L("CheckDisk")); err = fsSession.CheckDisk(msDrive->GetSessionPath()); test(err == KErrNone); test.Next(_L("ScanDrive")); err = fsSession.ScanDrive(msDrive->GetSessionPath()); test(err == KErrNone); }
void TTestMsBlock::tLastLbaAccessL() { test.Start(_L("tLastLbaAccess\n")); test.Next(_L("tLastLbaAccess\n")); TInt driveNumber = msDrive->DriveNumber(); TVolumeInfo volInfo; TInt err = fsSession.Volume(volInfo); test(err == KErrNone); test.Printf(_L("Memory 'in use' = 0x%lx (0x%x)\n"), (volInfo.iSize - volInfo.iFree), (volInfo.iSize - volInfo.iFree)/KBlockSize); test.Printf(_L("volInfo.iSize = 0x%lx (0x%x)\n"), volInfo.iSize, volInfo.iSize/KBlockSize); test.Printf(_L("volInfo.iFree = 0x%lx (0x%x)\n"), volInfo.iFree, volInfo.iFree/KBlockSize); TLba lba = volInfo.iSize/KBlockSize; RBlockTargetMedia media(driveNumber); media.OpenL(); TInt writeRes = KErrNone; TInt readRes = KErrNone; test.Printf(_L("LBA=%x\n"), lba); for (;writeRes == KErrNone && readRes == KErrNone; lba++) { writeRes = media.WriteBlock(lba); readRes = media.ReadBlock(lba); } test.Printf(_L("LBA=%x ERR Write=%d Read=%d\n"), lba, writeRes, readRes); media.Close(); test.End(); }
int main(int argc, char *argv[]) { QFile logfile2("C:/i8910tuninglog.txt"); QTextStream log2(&logfile2); if (!logfile2.open(QIODevice::Append | QIODevice::WriteOnly)) return 1; #ifdef Q_OS_SYMBIAN QApplication::setGraphicsSystem("openvg"); #endif QApplication app(argc, argv); #ifdef Q_OS_SYMBIAN //LEAVES IF E: DRIVE IS BUSY (I.E. PHONE IS PLUGGED IN USB MASS STORAGE MODE) RFs fsSession; CleanupClosePushL(fsSession); User::LeaveIfError(fsSession.Connect()); TVolumeInfo volumeInfo; TInt err=fsSession.Volume(volumeInfo,EDriveE); if (err==KErrNotReady) { fsSession.Close(); CleanupStack::PopAndDestroy(); QPixmap pixmap(":/images/exitsplash.png"); QSplashScreen splash(pixmap); splash.showFullScreen(); User::After(5000000); app.quit(); } fsSession.Close(); CleanupStack::PopAndDestroy(); #endif QPixmap pixmap(":/images/splashscreen.png"); QSplashScreen splash(pixmap); splash.showFullScreen(); QFontDatabase fontdb; int bella = fontdb.addApplicationFont("E:/data/SymbianTuning/SegoeWP.ttf"); qDebug() << QString::number(bella); QFont fontnew = fontdb.font("Segoe WP", "Normal", 7); app.setFont(fontnew); QDeclarativeView view; #ifdef Q_OS_SYMBIAN //view.setAttribute(Qt::WA_NoSystemBackground); #endif view.rootContext()->setContextProperty("i8910tuning", new i8910tuning(0, &logfile2, &log2)); view.setSource(QUrl("qrc:/Page.qml")); QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit())); #ifdef Q_OS_SYMBIAN CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); TRAPD(error, if (appUi) { // Lock application orientation into landscape appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); } );
LOCAL_C TInt testAsyncAccess(TAny* aData) // /// Test read file handling. /// /// @param aData pointer to the thread data area { TThreadData& data = *(TThreadData*)aData; TFileName fileName = data.iFile; TBool dowrite = (data.iData != NULL); TBuf8<KBufLen>* buffer = gBufferArr[data.iNum]; TRequestStatus* status = gStatusArr[data.iNum]; RFs myFs; TInt r = myFs.Connect(); TEST(r==KErrNone); r = myFs.SetSessionPath(gSessionPath); if (r != KErrNone) TTest::Fail(HERE, _L("SetSessionPath returned %d"), r); TVolumeInfo vol; TInt drv; r = myFs.CharToDrive(fileName[0], drv); if (r != KErrNone) TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r); r = myFs.Volume(vol, drv); if (r != KErrNone) TTest::Fail(HERE, _L("Volume() returned %d"), r); TInt64 maxwrite = vol.iFree / 2 - KBufLen; if (maxwrite < KBufLen*2) TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"), TInt(vol.iFree/1024)); RFile f; RTimer timer; TRequestStatus tstat; TTime startTime; TTime endTime; TTimeIntervalMicroSeconds timeTaken; TInt wrnum = 0; TInt rdnum = 0; TInt opnum = 0; TInt opfin = 0; TInt i; timer.CreateLocal(); if (dowrite) { r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite); TEST(r==KErrNone); // wait for both tasks to have a chance to complete opening the files User::After(1000); for (i = 0; i < KNumBuf; i++) buffer[i].Fill('_', KBufLen); timer.After(tstat, KTimeBM * KSecond); startTime.HomeTime(); while (tstat == KRequestPending) { TInt pos = TInt((wrnum * KBufLen) % maxwrite); TInt bnum = opnum++ % KNumBuf; f.Write(pos, buffer[bnum], status[bnum]); if (opnum - opfin > KMaxLag) { while (status[opfin % KNumBuf] == KRequestPending) User::WaitForRequest(status[opfin % KNumBuf]); opfin++; } ++wrnum; } while (opfin < opnum) { while (status[opfin % KNumBuf] == KRequestPending) User::WaitForRequest(status[opfin % KNumBuf]); opfin++; } endTime.HomeTime(); TTimeIntervalMicroSeconds timeTaken=endTime.MicroSecondsFrom(startTime); TInt64 dtime = timeTaken.Int64(); TInt64 dsize = wrnum * KBufLen * TInt64(KSecond); TInt32 speed = TInt32((dsize + dtime/2) / dtime); AddStats(gWrStats, dsize, dtime); TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"), wrnum, TInt32(dtime)/1000, speed); } else { r = f.Open(myFs, fileName, EFileStreamText); TEST(r==KErrNone); timer.After(tstat, KTimeBM * KSecond); startTime.HomeTime(); while (tstat == KRequestPending) { TInt pos = TInt((rdnum * KBufLen) % maxwrite); TInt bnum = opnum++ % KNumBuf; f.Read(pos, buffer[bnum], status[bnum]); if (opnum - opfin > KMaxLag) { User::WaitForRequest(status[opfin++ % KNumBuf]); } ++rdnum; } while (opfin < opnum) { if (status[opfin % KNumBuf] == KRequestPending) User::WaitForRequest(status[opfin % KNumBuf]); opfin++; } endTime.HomeTime(); timeTaken=endTime.MicroSecondsFrom(startTime); TInt64 dtime = timeTaken.Int64(); TInt64 dsize = rdnum * KBufLen * TInt64(KSecond); TInt32 speed = TInt32((dsize + dtime/2) / dtime); AddStats(gRdStats, dsize, dtime); // wait to allow the dust to settle User::After(KSecond); TTest::Printf(_L("%8d reads in %6d mS = %8d bytes per second\n"), rdnum, TInt32(dtime)/1000, speed); myFs.Delete(fileName); } timer.Cancel(); timer.Close(); f.Close(); myFs.Close(); return r; }
bool LongStream::freeSpace( const QString &path, int min) { unsigned long long boundary = minFree; if (min >= 0) boundary = min; QString partitionPath = tempDir() + "/."; if (!path.isEmpty()) partitionPath = path; #if defined(Q_OS_SYMBIAN) bool result(false); RFs fsSession; TInt rv; if ((rv = fsSession.Connect()) != KErrNone) { qDebug() << "Unable to connect to FS:" << rv; } else { TParse parse; TPtrC name(path.utf16(), path.length()); if ((rv = fsSession.Parse(name, parse)) != KErrNone) { qDebug() << "Unable to parse:" << path << rv; } else { TInt drive; if ((rv = fsSession.CharToDrive(parse.Drive()[0], drive)) != KErrNone) { qDebug() << "Unable to convert:" << QString::fromUtf16(parse.Drive().Ptr(), parse.Drive().Length()) << rv; } else { TVolumeInfo info; if ((rv = fsSession.Volume(info, drive)) != KErrNone) { qDebug() << "Unable to volume:" << drive << rv; } else { result = (info.iFree > boundary); } } } fsSession.Close(); } return result; #elif !defined(Q_OS_WIN) struct statfs stats; statfs(partitionPath.toLocal8Bit(), &stats); unsigned long long bavail = ((unsigned long long)stats.f_bavail); unsigned long long bsize = ((unsigned long long)stats.f_bsize); return ((bavail * bsize) > boundary); #else // MS recommend the use of GetDiskFreeSpaceEx, but this is not available on early versions // of windows 95. GetDiskFreeSpace is unable to report free space larger than 2GB, but we're // only concerned with much smaller amounts of free space, so this is not a hindrance. DWORD bytesPerSector(0); DWORD sectorsPerCluster(0); DWORD freeClusters(0); DWORD totalClusters(0); if (::GetDiskFreeSpace(partitionPath.utf16(), &bytesPerSector, §orsPerCluster, &freeClusters, &totalClusters) == FALSE) { qWarning() << "Unable to get free disk space:" << partitionPath; } return ((bytesPerSector * sectorsPerCluster * freeClusters) > boundary); #endif }
// Member for thread function TInt CSMPSoakThread::DoSMPStressDeviceThread() { RTest test(_L("SMPStressDeviceThread")); test.Start(_L("SMPStressDeviceThread")); RTimer timer; RFs session; TFileName sessionPath; test_KErrNone(timer.CreateLocal()); TRequestStatus s; TDesC** ptrDevices = (TDesC**) (iThreadData.listPtr); PRINT ((_L("Devices Number %d [%s]\n"), ptrDevices[0]->Length(), ptrDevices[0]->Ptr())); for (TInt i = 1; ptrDevices[i] ; i++) PRINT ((_L("LDD%d=%s "),i,ptrDevices[i]->Ptr())); PRINT (_L("\n")); FOREVER { for (TInt i = 0; i < ptrDevices[0]->Length(); i++) { TText driveLetter = (*ptrDevices[0])[i]; PRINT ((_L("Device %c\n"),driveLetter)); test_KErrNone(session.Connect()); sessionPath=(_L("?:\\SESSION_TEST\\")); sessionPath[0]=driveLetter; test_KErrNone(session.SetSessionPath(sessionPath)); TInt driveNumber; test_KErrNone(session.CharToDrive(driveLetter, driveNumber)); TBuf<64> fileSystemName; test_KErrNone(session.FileSystemName(fileSystemName,driveNumber)); PRINT ((_L("File System Name %s\n"),fileSystemName.PtrZ())); TDriveInfo driveInfo; test_KErrNone(session.Drive(driveInfo, driveNumber)); TVolumeInfo volumeInfo; test_KErrNone(session.Volume(volumeInfo, driveNumber)); session.Close(); } for (TInt i = 1; ptrDevices[i] ; i += 2) { RDevice device; TInt r = User::LoadLogicalDevice(*ptrDevices[i]); if (r != KErrNone && r != KErrAlreadyExists) { test.Printf(_L("LDD %S not present\n"), ptrDevices[i]); continue; } test_KErrNone(device.Open(*ptrDevices[i+1])); TBuf8<64> deviceCaps; device.GetCaps(deviceCaps); TVersion deviceVersion; device.QueryVersionSupported(deviceVersion); device.Close(); } SetThreadPriority(); timer.After(s, iThreadData.delayTime*1000); User::WaitForRequest(s); test (s == KErrNone); if (gAbort) break; User::After(gPeriod); } timer.Close(); PRINT((_L("SMPStressDeviceThread MyTimer.Cancel() called\n"))); test.End(); test.Close(); return 0x00; }
TInt64 CFileEngine::GetFreeSpace(const TDesC& aDriveName) { TVolumeInfo info; RFs iFs; User::LeaveIfError(iFs.Connect()); info.iFree = 0; if (aDriveName.CompareF(_L("A")) == 0) { iFs.Volume(info, EDriveA); } else if(aDriveName.CompareF(_L("B")) == 0) { iFs.Volume(info, EDriveB); } else if(aDriveName.CompareF(_L("C")) == 0) { iFs.Volume(info, EDriveC); } else if(aDriveName.CompareF(_L("D")) == 0) { iFs.Volume(info, EDriveD); } else if(aDriveName.CompareF(_L("E")) == 0) { iFs.Volume(info, EDriveE); } else if(aDriveName.CompareF(_L("F")) == 0) { iFs.Volume(info, EDriveF); } else if(aDriveName.CompareF(_L("G")) == 0) { iFs.Volume(info, EDriveG); } else if(aDriveName.CompareF(_L("H")) == 0) { iFs.Volume(info, EDriveH); } else if(aDriveName.CompareF(_L("I")) == 0) { iFs.Volume(info, EDriveI); } else if(aDriveName.CompareF(_L("J")) == 0) { iFs.Volume(info, EDriveJ); } else if(aDriveName.CompareF(_L("K")) == 0) { iFs.Volume(info, EDriveK); } else if(aDriveName.CompareF(_L("L")) == 0) { iFs.Volume(info, EDriveL); } else if(aDriveName.CompareF(_L("M")) == 0) { iFs.Volume(info, EDriveM); } else if(aDriveName.CompareF(_L("N")) == 0) { iFs.Volume(info, EDriveN); } else if(aDriveName.CompareF(_L("O")) == 0) { iFs.Volume(info, EDriveO); } else if (aDriveName.CompareF(_L("P")) == 0) { iFs.Volume(info, EDriveP); } else if(aDriveName.CompareF(_L("Q")) == 0) { iFs.Volume(info, EDriveQ); } else if(aDriveName.CompareF(_L("R")) == 0) { iFs.Volume(info, EDriveR); } else if(aDriveName.CompareF(_L("S")) == 0) { iFs.Volume(info, EDriveS); } else if(aDriveName.CompareF(_L("T")) == 0) { iFs.Volume(info, EDriveT); } else if(aDriveName.CompareF(_L("U")) == 0) { iFs.Volume(info, EDriveU); } else if(aDriveName.CompareF(_L("V")) == 0) { iFs.Volume(info, EDriveV); } else if(aDriveName.CompareF(_L("W")) == 0) { iFs.Volume(info, EDriveW); } else if(aDriveName.CompareF(_L("X")) == 0) { iFs.Volume(info, EDriveX); } else if(aDriveName.CompareF(_L("Y")) == 0) { iFs.Volume(info, EDriveY); } else if(aDriveName.CompareF(_L("Z")) == 0) { iFs.Volume(info, EDriveZ); } else { return 0; } iFs.Close(); return (TInt64)info.iFree/1024; }
void CCamcTestClient_9::RunLTrappedL() { if ( iOpenReady ) { iOpenReady = EFalse; switch ( iAction ) { case K_Tc9_PrepareWhenControllerReadyWhitoutSetting: case K_Tc9_PrepareWhenControllerReadyOnlyVideoBitRateSetting: case K_Tc9_PrepareWhenControllerReadyOnlyVideoFrameSizeSetting: { break; } case K_TC9_NewFileNameWhenInternalStop: { iCamc->SetMaxClipSizeL(TC9_FILE_SIZE_LIMIT) ; break; } case K_TC9_NewFileNameWhenRecordSecondTimeMPEG4FileFormat: { iCamc->SetVideoFrameSizeL(TSize(352,288)); iCamc->SetVideoFrameRateL(TReal32(15)); iCamc->SetVideoBitRateL( TC9_VIDEO_BIT_RATE ); iCamc->SetAudioBitRateL(TInt( TC9_AUDIO_BIT_RATE_AAC )); break; } default: { // Set default parameters. They can be overwritten depending on the test case. iCamc->SetVideoFrameSizeL(TSize(176,144)); iCamc->SetVideoFrameRateL(TReal32(15)); iCamc->SetVideoBitRateL( TC9_VIDEO_BIT_RATE ); iCamc->SetAudioBitRateL(TInt( TC9_AUDIO_BIT_RATE )); break; } } switch ( iAction ) { case K_Tc9_PrepareWhenControllerReadyWhitoutSetting: { break; } case K_Tc9_PrepareWhenControllerReadyOnlyVideoBitRateSetting: { iCamc->SetVideoBitRateL(TInt(50000)); break; } case K_Tc9_PrepareWhenControllerReadyOnlyVideoFrameSizeSetting: { iCamc->SetVideoFrameSizeL(TSize(176,144)); break; } case K_Tc9_SetMaxClipSizeLWhenControllerReadySize0: { iCamc->SetMaxClipSizeL( 0 ); break; } case K_Tc9_SetMaxClipSizeLWhenControllerReadyKMMFNoMaxClipSize: { iCamc->SetMaxClipSizeL( KMMFNoMaxClipSize ); break; } case K_Tc9_OpenFileInAFolderNonExistent: { AddDriveLetterToPath(_L("non-existent-folder\\recordQCIF.3gp"), iFileName); TMMFFileParams params; params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iAction = K_Tc9_none; break; } default: { break; } } iCamc->Prepare(); } else if ( iPrepareReady ) { TBool record = EFalse; switch ( iAction ) { case K_Tc9_SetMaxClipSizeLWhenControllerReadySize0: case K_Tc9_SetMaxClipSizeLWhenControllerReadyKMMFNoMaxClipSize: { iPrepareReady = EFalse; iCamc->Record(); record = EFalse; break; } case K_TC9_NewFileNameWhenPreparedNotRecording: { if (!iNewFileName) { AddDriveLetterToPath(_L("NewFileName.3gp"),iFileName); TMMFFileParams params; params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iCamc->Prepare(); iAction = K_Tc9_none; } break; } case K_TC9_NewFileNameWhenInternalStop : { iPrepareReady = EFalse; iCamc->Record(); // No timer need, will eventually stop because of filesize limit. break; } default: { record = ETrue; break; } } if ( record ) { iPrepareReady = EFalse; iCamc->Record(); CTimer::After( iTimeout ); } } else if ( iRecordingReady ) { TBool close = EFalse; iRecordingReady = EFalse; TMMFFileParams params; switch ( iAction ) { case K_Tc9_RecordTimeAvailWhenRecordingReady: { // Compare if default size limit is correctly returned by // a RecordTimeAvailableL TTimeIntervalMicroSeconds timeRemaining = iCamc->RecordTimeAvailable(); TInt64 timeRemainingInSec = timeRemaining.Int64()/1E6; //Max time is 3600s = 60min PRINT((_L("CCamCTest_9::RecordTimeAvailable5: timeRemainingInSec: %d "), I64INT(timeRemainingInSec ))); // Duration value depends on available disk drive space. // Get the free space of the disk drive: RFs fsSession; fsSession.Connect(); TVolumeInfo volumeInfo; TInt err = fsSession.Volume(volumeInfo,EDriveC); fsSession.Close(); if (err) { User::Leave( KErrGeneral) ; } // Possible duration = available disk space/videobitrate TInt64 calculatedDuration = volumeInfo.iFree / TInt64((TC9_VIDEO_BIT_RATE+TC9_AUDIO_BIT_RATE)/8); // If there is more space than the max length of the video -> // set the calculatedDuration to max length if ( calculatedDuration > KMaxVideoLength) { calculatedDuration = KMaxVideoLength; } RDebug::Print(_L("CCamcTest_9::RecordTimeAvailable5 timeRemaining is %d "), I64INT(timeRemainingInSec )); RDebug::Print(_L("CCamcTest_9::RecordTimeAvailable5 calculatedDuration is %d "), I64INT(calculatedDuration ) ); // Allows 5% error margin: if ( ( timeRemainingInSec > calculatedDuration*1.05 ) || ( timeRemainingInSec < calculatedDuration*0.95 ) ) { RDebug::Print(_L("CCamcTest_9::RecordTimeAvailable5 is leaving, because timeRemaining != Calculated ") ); User::Leave( K_Tc9_ValueNotWithinRange ) ; } close = ETrue; break; } case K_TC9_NewFileNameWhenRecordSecondTime : { if (!iRecord2ndTime) { iRecord2ndTime =ETrue; AddDriveLetterToPath(_L("NewFileName.3gp"), iFileName ); params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iCamc->Prepare(); iAction = K_Tc9_none; } break; } case K_TC9_NewFileNameWhenRecordSecondTimeDiffFileFormat : { if (!iRecord2ndTime) { iRecord2ndTime =ETrue; AddDriveLetterToPath(_L("NewFileName.3g2"), iFileName ); params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iCamc->Prepare(); iAction = K_Tc9_none; } break; } case K_TC9_NewFileNameWhenRecordSecondTimeMPEG4FileFormat : { if (!iRecord2ndTime) { iRecord2ndTime =ETrue; AddDriveLetterToPath(_L("NewFileName.mp4"), iFileName ); params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iCamc->Prepare(); iAction = K_Tc9_none; } break; } case K_TC9_NewFileNameWhenInternalStop : { if (!iRecord2ndTime) { iRecord2ndTime =ETrue; AddDriveLetterToPath(_L("NewFileName.3gp"), iFileName ); params.iPath = iFileName; TPckgC<TMMFFileParams> pckg(params); TUid controllerUid = {0x101F8503}; // controller implementation interface uid TInt ret = iCamc->CustomCommandSync( TMMFMessageDestination( controllerUid, KMMFObjectHandleController ), ECamCControllerCCNewFilename, pckg, KNullDesC8); if (ret != 0) { User::Leave(K_Tc9_ValueNotExpected); } iCamc->Prepare(); } else { close = ETrue; } break; } default: { close = ETrue; break; } } if (close) { iCamc->Close(); iClosed = ETrue; CTimer::After( 1000 ); } } else { RunLContinuedL(); } if ( iClosed ) { iCamc->Stop(); CActiveScheduler::Stop(); } }
LOCAL_C TInt FillAndEmptyDiskThread(TAny* anId) // // The entry point for the 'FillAndEmptyDisk' thread. // { TInt thrdId=(TInt)anId; TInt pattern=(ThreadTestInfo[thrdId].iCycles)%2; TInt r; RFs f; r=f.Connect(); if (r!=KErrNone) { LogError( r, KConnect, KNullDesC, 0, 0 ); ThreadTestInfo[thrdId].iErrorInfo=6; return(r); } TInt i; #ifdef REUSE_THREAD while(!gRequestEnd) { #endif for (i=0;i<5;i++) // Create/Delete 5 files each time { if (CurrentlyFillingDisk) { TVolumeInfo v; r=f.Volume(v,gDriveNumber); if (r!=KErrNone) { ThreadTestInfo[thrdId].iErrorInfo=7; LogError( r, KVolInfo, KNullDesC, gDriveNumber, 0); f.Close(); return(r); } if (v.iFree<=(TheMetrics->KSpaceRequiredForMakeAndDelete+TheMetrics->KFillDiskFileSize)) CurrentlyFillingDisk=EFalse; else { TFileName fileName; r = MakeFileName(thrdId, FillDiskCount, f, fileName); if(r != KErrNone) { ThreadTestInfo[thrdId].iErrorInfo = 8; f.Close(); return(r); } r = CreateVerifyFileX(fileName, TheMetrics->KFillDiskFileSize, f, pattern); if (r!=KErrNone) { ThreadTestInfo[thrdId].iErrorInfo=9; f.Close(); return(r); } FillDiskCount++; } } else { if (FillDiskCount<=0) { CurrentlyFillingDisk=ETrue; FillDiskCount=0; FillDiskCycle++; } else { FillDiskCount--; TFileName fileName; r = MakeFileName(thrdId, FillDiskCount, f, fileName, EFalse); if(r != KErrNone) { ThreadTestInfo[thrdId].iErrorInfo = 10; f.Close(); return(r); } r = f.Delete(fileName); if (r!=KErrNone) { ThreadTestInfo[thrdId].iErrorInfo=11; LogError(r, KDelete, fileName,FillDiskCount, 0); f.Close(); return(r); } } } } #ifdef REUSE_THREAD ThreadTestInfo[thrdId].iCycles++; pattern = (ThreadTestInfo[thrdId].iCycles) % 2; } #endif f.Close(); return(KErrNone); }
//Gets the available space of the tested drive. static TInt64 FreeDiskSpaceL() { TVolumeInfo volInfoBefore; LEAVE_IF_ERROR(TheFs.Volume(volInfoBefore, KTestDrive)); return volInfoBefore.iFree; }
/** @SYMTestCaseID PDS-SQL-UT-4141 @SYMTestCaseDesc RFileBuf64::SetReadAheadSize() test. The test iterates over all existing drives. For each R/W drive a test file is created using RFileBuf64 class. Then the test collects information regarding the block size, cluster size and read buffer size and calls RFileBuf64::SetReadAheadSize() with these parameters to check how the read-ahead buffer size will be recalculated. @SYMTestActions RFileBuf64::SetReadAheadSize() test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMREQ REQ12106 REQ12109 */ void SetReadAheadSizeTest() { TheTest.Printf(_L("==================\r\n")); _LIT(KType1, "Not present"); _LIT(KType2, "Unknown"); _LIT(KType3, "Floppy"); _LIT(KType4, "Hard disk"); _LIT(KType5, "CD ROM"); _LIT(KType6, "RAM disk"); _LIT(KType7, "Flash"); _LIT(KType8, "ROM drive"); _LIT(KType9, "Remote drive"); _LIT(KType10,"NAND flash"); _LIT(KType11,"Rotating media"); for(TInt drive=EDriveA;drive<=EDriveZ;++drive) { TDriveInfo driveInfo; TInt err = TheFs.Drive(driveInfo, drive); if(err == KErrNone) { TVolumeInfo vinfo; err = TheFs.Volume(vinfo, drive); if(err == KErrNone) { TVolumeIOParamInfo vparam; err = TheFs.VolumeIOParam(drive, vparam); TEST2(err, KErrNone); TBuf8<128> vinfoex8; err = TheFs.QueryVolumeInfoExt(drive, EFileSystemSubType, vinfoex8); TEST2(err, KErrNone); TPtrC vinfoex((const TUint16*)(vinfoex8.Ptr() + 8), vinfoex8[0]); TPtrC KMediaTypeNames[] = {KType1(), KType2(), KType3(), KType4(), KType5(), KType6(), KType7(), KType8(), KType9(), KType10(), KType11()}; TheTest.Printf(_L("Drive: %C:, Type: %16.16S, File System: %8.8S, Size: %d Mb.\r\n"), 'A' + drive, &KMediaTypeNames[driveInfo.iType], &vinfoex, (TInt)(vinfo.iSize / (1024 * 1024))); TheTest.Printf(_L(" Size: %ld bytes.\r\n"), vinfo.iSize); TheTest.Printf(_L(" Block size=%d, Cluster size=%d, Read buffer size=%d.\r\n"), vparam.iBlockSize, vparam.iClusterSize, vparam.iRecReadBufSize); if(driveInfo.iType == EMediaRam || driveInfo.iType == EMediaHardDisk || driveInfo.iType == EMediaFlash || driveInfo.iType == EMediaNANDFlash) { TDriveUnit drvUnit(drive); TDriveName drvName = drvUnit.Name(); TParse parse; parse.Set(KTestFile2, &drvName, NULL); TheDbName.Copy(parse.FullName()); TRAP(err, BaflUtils::EnsurePathExistsL(TheFs, TheDbName)); if(err == KErrNone || err == KErrAlreadyExists) { (void)TheFs.Delete(TheDbName); RFileBuf64 fbuf64(8 * 1024); err = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err, KErrNone); TInt readAhead = fbuf64.SetReadAheadSize(vparam.iBlockSize, vparam.iRecReadBufSize); TheTest.Printf(_L(" Read-ahead size=%d.\r\n"), readAhead); fbuf64.Close(); (void)TheFs.Delete(TheDbName); } else { TheTest.Printf(_L("Drive %C. BaflUtils::EnsurePathExistsL() has failed with err=%d.\r\n"), 'A' + drive, err); } } } else { TheTest.Printf(_L("Drive %C. RFs::Volume() has failed with err=%d.\r\n"), 'A' + drive, err); } } else { TheTest.Printf(_L("Drive %C. RFs::Drive() has failed with err=%d.\r\n"), 'A' + drive, err); } } TheTest.Printf(_L("==================\r\n")); // RFileBuf64 fbuf64(8 * 1024);//buffer capacity = 8Kb //"ReadRecBufSize" defined and is power of two, the "BlockSize" is also defined and is power of two TInt err2 = fbuf64.Create(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); TInt blockSize = 4096; TInt readRecBufSize = 2048; TInt readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, readRecBufSize); fbuf64.Close(); //"ReadRecBufSize" defined and is power of two but is less than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 0; readRecBufSize = 128; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" defined and is power of two but is bigger than the buffer capacity err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = -10; readRecBufSize = fbuf64.iCapacity * 2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, fbuf64.iCapacity); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined but is less than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 512; readRecBufSize = 4000; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the default read-ahead value err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 4096; readRecBufSize = 4000; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, blockSize); fbuf64.Close(); //"ReadRecBufSize" defined but is not power of two, "BlockSize" defined and is bigger than the buffer capacity err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = fbuf64.iCapacity * 2; readRecBufSize = 1; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, fbuf64.iCapacity); fbuf64.Close(); //"ReadRecBufSize" negative, "BlockSize" defined but is not power of two err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = 1000; readRecBufSize = -2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); //"ReadRecBufSize" negative, "BlockSize" negative err2 = fbuf64.Open(TheFs, TheDbName, EFileRead | EFileWrite); TEST2(err2, KErrNone); blockSize = -1; readRecBufSize = -2; readAhead2 = fbuf64.SetReadAheadSize(blockSize, readRecBufSize); TEST2(readAhead2, RFileBuf64::KDefaultReadAheadSize); fbuf64.Close(); // (void)TheFs.Delete(TheDbName); }
// this function was copied from t_sdpartition.cpp TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum) { TInt r = fs.CharToDrive(aDriveChar, aDriveNum); test(r==KErrNone); TDriveInfo driveInfo; r = fs.Drive(driveInfo, aDriveNum); test(r==KErrNone); TVolumeInfo vi; r = fs.Volume(vi, aDriveNum); test(r==KErrNone); TMediaSerialNumber serialNum; r = fs.GetMediaSerialNumber(serialNum, aDriveNum); test(r==KErrNone); test.Printf(_L("Drive %C size %ld\n"), (char) aDriveChar, vi.iSize); TInt len = serialNum.Length(); test.Printf(_L("Serial number (len %d) :"), len); TInt n; for (n=0; n<len; n+=16) { TBuf16<16*3 +1> buf; for (TInt m=n; m<n+16; m++) { TBuf16<3> hexBuf; hexBuf.Format(_L("%02X "),serialNum[m]); buf.Append(hexBuf); } buf.Append(_L("\n")); test.Printf(buf); } TBusLocalDrive drv; TBool chg(EFalse); aLocalDriveNum = -1; TInt serialNumbersMatched = 0; for (n=0; n<KMaxLocalDrives; n++) { r = drv.Connect(n, chg); //for user area //RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r); continue; } TLocalDriveCapsV5Buf capsBuf; TLocalDriveCapsV5& caps = capsBuf(); r = drv.Caps(capsBuf); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r); continue; } //RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity); TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength); if (serialNum.Compare(localSerialNum) == 0) { serialNumbersMatched++; TBool sizeMatch = (vi.iSize < caps.iSize); test.Printf(_L("drive %d: Serial number match, size match: %S\n"), n, sizeMatch?&KYes:&KNo); if (sizeMatch) { aLocalDriveNum = n; drv.Disconnect(); break; } } drv.Disconnect(); } return aLocalDriveNum == -1?KErrNotFound:KErrNone; }
/** Function : ExecuteActionL Description : Entry point for the this test action in the test framework @internalTechnology @param : none @return : void @pre none @post none */ void CMtfTestActionSetDiskSpace::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetDiskSpace ); RFs fs; User::LeaveIfError(fs.Connect()); TInt newFreeValue = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0)); TestCase().INFO_PRINTF2(_L("Setting Drive C free disk space to %ld bytes."), newFreeValue); // // Check the current disk space available level... // TVolumeInfo volumeInfo; User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); TestCase().INFO_PRINTF2(_L(" Drive C currently has %ld bytes free."), volumeInfo.iFree); // // Check that this is possible... // if (volumeInfo.iFree < newFreeValue) { TestCase().INFO_PRINTF1(_L(" Drive C already has too little free space!")); User::Leave(KErrArgument); } // // Ensure the temporary directory exists... // TInt ret; ret = fs.MkDir(KTempDiskSpaceDirName); if (ret != KErrNone && ret != KErrAlreadyExists) { User::Leave(ret); } // // Work out how many files to create and their sizes. A full temp file is // 1GB in size, the last temp file will handle the remainder. Then loop // through and create them all... // TInt64 maxSizeOfTempFile = (1024*1024*1024); TInt64 diskSpaceToReserve = volumeInfo.iFree - newFreeValue; TInt64 numOfFullTempFiles = (diskSpaceToReserve / maxSizeOfTempFile); TInt64 lastTempFileSize = (diskSpaceToReserve % maxSizeOfTempFile); TBuf<32> tempFileName; RFile file; for(TInt fileNum = 1; fileNum <= numOfFullTempFiles; fileNum++) { tempFileName.Copy(KTempDiskSpaceDirName); tempFileName.AppendFormat(_L("reserved.%d"), fileNum); TestCase().INFO_PRINTF3(_L(" Creating %S of %ld bytes."), &tempFileName, maxSizeOfTempFile); User::LeaveIfError(file.Replace(fs, tempFileName, EFileWrite)); User::LeaveIfError(file.SetSize(maxSizeOfTempFile)); file.Close(); } if (lastTempFileSize > 0) { User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); TestCase().INFO_PRINTF2(_L(" Drive C now has %ld bytes free."), volumeInfo.iFree); if( lastTempFileSize > volumeInfo.iFree ) { lastTempFileSize = volumeInfo.iFree; } tempFileName.Copy(KTempDiskSpaceDirName); tempFileName.AppendFormat(_L("reserved.%d"), numOfFullTempFiles+1); TestCase().INFO_PRINTF3(_L(" Creating %S of %ld bytes."), &tempFileName, lastTempFileSize); User::LeaveIfError(file.Replace(fs, tempFileName, EFileWrite)); User::LeaveIfError(file.SetSize(lastTempFileSize)); file.Close(); } // // Recheck the free space now... // User::LeaveIfError(fs.Volume(volumeInfo, EDriveC)); TestCase().INFO_PRINTF2(_L(" Drive C now has %ld bytes free."), volumeInfo.iFree); fs.Close(); TestCase().INFO_PRINTF2( _L("Test Action %S completed."), &KTestActionSetDiskSpace ); TestCase().ActionCompletedL( *this ); }