diff -r c1f20ce4abcf -r 3e88ff8f41d5 kerneltest/f32test/filesystem/fat/b_fat32.cpp --- a/kerneltest/f32test/filesystem/fat/b_fat32.cpp Tue Aug 31 16:34:26 2010 +0300 +++ b/kerneltest/f32test/filesystem/fat/b_fat32.cpp Wed Sep 01 12:34:56 2010 +0100 @@ -15,7 +15,6 @@ // // -#define __E32TEST_EXTENSION__ #include #include #include @@ -149,10 +148,10 @@ { pos += TheBootSector.ReservedSectors() * TheBootSector.BytesPerSector(); TInt r=TheDisk.Open(TheFs,gSessionPath[0]-'A'); - test_KErrNone(r); + test(r==KErrNone); TPtr8 buf(&data[0], 4); r=TheDisk.Read(pos, buf); - test_KErrNone(r); + test(r==KErrNone); TheDisk.Close(); } @@ -186,15 +185,15 @@ pos += TheBootSector.ReservedSectors() * TheBootSector.BytesPerSector(); TInt r=TheDisk.Open(TheFs,gSessionPath[0]-'A'); - test_KErrNone(r); + test(r==KErrNone); TUint8 data[4]; TPtr8 buf(&data[0], 4); r=TheDisk.Read(pos, buf); - test_KErrNone(r); + test(r==KErrNone); data[3] &= 0x0F; data[3] |= 0xA0; r=TheDisk.Write(pos, buf); - test_KErrNone(r); + test(r==KErrNone); TheDisk.Close(); } @@ -469,9 +468,9 @@ test(buf!=NULL); TPtr8 ptr=buf->Des(); TInt r=TheDisk.Open(TheFs,gSessionPath[0]-'A'); - test_KErrNone(r); + test(r==KErrNone); r=TheDisk.Read(ClusterToByte(cluster), ptr); - test_KErrNone(r); + test(r==KErrNone); TheDisk.Close(); RDebug::Print(_L("Cluster %d @ 0x%08X:"), cluster, ClusterToByte(cluster)); DumpDirCluster(ptr.Ptr()); @@ -500,12 +499,12 @@ test(buf!=NULL); TPtr8 ptr=buf->Des(); TInt r=TheDisk.Open(TheFs,gSessionPath[0]-'A'); - test_KErrNone(r); + test(r==KErrNone); RDebug::Print(_L("--------------- ROOT DIR ------------------")); for (TInt i = 0; i < num; i++) { r=TheDisk.Read(pos, ptr); - test_KErrNone(r); + test(r==KErrNone); if (!DumpDirEntry(ent, ptr.Ptr())) break; pos += KSizeOfFatDirEntry; @@ -764,7 +763,7 @@ } TInt r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); test(ReadWriteDWord(pos,mask,aValue)==KErrNone); TheDisk.Close(); } @@ -1084,7 +1083,7 @@ Error(_L("Error deleting file"),r); RDebug::Print(_L("File removed")); r=TheFs.CheckDisk(gSessionPath); - test_KErrNone(r); + test(r==KErrNone); } static void TestFatEntry(TUint16 aFileSize,TInt aCorruptFatCluster) @@ -1097,22 +1096,22 @@ FormatPack(); r=TheFile.Replace(TheFs,_L("\\CORRUPT2.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); TheBuffer.SetLength(aFileSize); Mem::Fill(&TheBuffer[0],aFileSize,'A'); r=TheFile.Write(TheBuffer); - test_KErrNone(r); + test(r==KErrNone); TheFile.Close(); FatWrite(gFirstDataCluster,aCorruptFatCluster); TInt pos=0; r=TheFile.Open(TheFs,_L("\\CORRUPT2.TMP"),EFileRead|EFileWrite); - test_Value(r, r == KErrNone || r==KErrCorrupt); + test(r==KErrNone || r==KErrCorrupt); if (r==KErrNone) { r=TheFile.Seek(ESeekStart,pos); - test_KErrNone(r); + test(r==KErrNone); r=TheFile.Write(TheBuffer); if ((gDriveCacheFlags & EFileCacheWriteOn) && (r == KErrNone)) @@ -1130,9 +1129,9 @@ pos=0; r=TheFile.Open(TheFs,_L("\\CORRUPT2.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); r=TheFile.Seek(ESeekStart,pos); - test_KErrNone(r); + test(r==KErrNone); r=TheFile.Write(TheBuffer); if ((gDriveCacheFlags & EFileCacheWriteOn) && (r == KErrNone)) @@ -1172,15 +1171,15 @@ TheBuffer.SetLength(anInitialSize); Mem::Fill(&TheBuffer[0],anInitialSize,'A'); r=TheFile.Write(TheBuffer); - test_KErrNone(r); + test(r==KErrNone); TheFile.Close(); r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); TPtr8 sectorBuf((TUint8*)pBuffer1->Ptr(),TheBootSector.BytesPerSector()); TInt pos = gRootDirStart; r=TheDisk.Read(pos,sectorBuf); - test_KErrNone(r); + test(r==KErrNone); TFatDirEntry* pE=(TFatDirEntry*)pBuffer1->Ptr(); while (pE->IsVFatEntry()) // UNICODE entries are VFat by definition pE++; @@ -1194,16 +1193,16 @@ //-- the data TheDisk.Close(); r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); pos=0; TPtr8 buffer1(pBuffer1->Des()); r=TheDisk.Read(pos,buffer1); - test_KErrNone(r); + test(r==KErrNone); TheDisk.Close(); r=TheFs.Entry(_L("\\CORRUPT1.TMP"),TheEntry); - test_Value(r, r == KErrNone || r==KErrCorrupt); + test(r==KErrNone || r==KErrCorrupt); TTime saveTime=TheEntry.iModified; if (r!=KErrNone) saveTime.HomeTime(); @@ -1222,11 +1221,11 @@ } r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); pos=0; TPtr8 buffer2(pBuffer2->Des()); r=TheDisk.Read(pos,buffer2); - test_KErrNone(r); + test(r==KErrNone); //-- this bit is dodgy. The buffers may differ because of volume finalisation stuff //-- FAT[1] and FSInfo sectors @@ -1234,9 +1233,9 @@ TheDisk.Close(); r=TheFs.SetModified(_L("\\CORRUPT1.TMP"),saveTime); - test_Value(r, r == KErrNone || r==KErrCorrupt); + test(r==KErrNone || r==KErrCorrupt); r=TheFs.Entry(_L("\\CORRUPT1.TMP"),TheEntry); - test_Value(r, r == KErrNone || r==KErrCorrupt); + test(r==KErrNone || r==KErrCorrupt); } static void TestBounds() @@ -1248,7 +1247,7 @@ test(TheFs.Volume(TheVolumeInfo,CurrentDrive())==KErrNone); TInt64 size=TheVolumeInfo.iSize; TInt r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); TPtr8 buffer(pBuffer1->Des()); TInt64 pos=size - 2*buffer.MaxLength(); TInt inc=buffer.MaxLength(); @@ -1257,7 +1256,7 @@ TPtr8 tempbuf((TUint8*)pBuffer1->Ptr(),inc); r=TheDisk.Read(pos,tempbuf); test.Printf(_L("Read %08X:%08X len %d r %d\r"), I64HIGH(pos),I64LOW(pos), inc, r); - test_Value(r, r == KErrNone || r==KErrCorrupt); + test(r==KErrNone || r==KErrCorrupt); if (r==KErrNone) pos+=inc; else @@ -1295,7 +1294,7 @@ TInt expect = (lpos+bsize-1 < maxpos ? KErrNone : KErrCorrupt); r=TheDisk.Read(lpos, temp); RDebug::Print(_L("Read %08X:%08X result %d \r"), I64HIGH(lpos), I64LOW(lpos), r); - test_Value(r, r == expect); + test(r==expect); } } } @@ -1391,37 +1390,37 @@ TInt r; r=f.Replace(TheFs,_L("\\GOBLIN.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(4*gBytesPerCluster); // 4 Clusters f.Close(); r=f.Replace(TheFs,_L("\\WIZARD.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(5*gBytesPerCluster); // 5 Clusters f.Close(); r=f.Replace(TheFs,_L("\\TROLL.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(3*gBytesPerCluster); // 3 Clusters f.Close(); r=f.Replace(TheFs,_L("\\GNOME.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(10*gBytesPerCluster); // 10 Clusters f.Close(); r=f.Replace(TheFs,_L("\\CYCLOPS.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(gBytesPerCluster); // 1 Cluster f.Close(); r=f.Replace(TheFs,_L("\\PIXIE.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); f.SetSize(gBytesPerCluster); // 1 Cluster f.Close(); r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); TPtr8 sectorBuf((TUint8*)pBuffer1->Ptr(),TheBootSector.BytesPerSector()); TInt pos = gRootDirStart; test(TheDisk.Read(pos,sectorBuf)==KErrNone); @@ -1480,17 +1479,17 @@ test(name==_L8("PIXIE TMP")); r=TheFs.Delete(_L("\\GOBLIN.TMP")); - test_KErrNone(r); + test(r==KErrNone); r=TheFs.Delete(_L("\\WIZARD.TMP")); - test_KErrNone(r); + test(r==KErrNone); r=TheFs.Delete(_L("\\TROLL.TMP")); - test_KErrNone(r); + test(r==KErrNone); r=TheFs.Delete(_L("\\GNOME.TMP")); - test_KErrNone(r); + test(r==KErrNone); r=TheFs.Delete(_L("\\CYCLOPS.TMP")); - test_KErrNone(r); + test(r==KErrNone); r=TheFs.Delete(_L("\\PIXIE.TMP")); - test_KErrNone(r); + test(r==KErrNone); FormatPack(); @@ -1505,7 +1504,7 @@ test.Printf(_L("Checking cluster %02d, parent %d: \"%S\"\n"), aNewClust, aParentClust, &aName); TInt r=TheFs.MkDir(aName); - test_Value(r, r == KErrNone || r==KErrAlreadyExists); + test(r==KErrNone || r==KErrAlreadyExists); TInt pos=ClusterToByte(aNewClust); TPtr8 sectorBuf((TUint8*)pBuffer1->Ptr(),gBytesPerCluster); @@ -1671,7 +1670,7 @@ } r = f.Create(TheFs, _L("\\123456.78"), EFileRead|EFileWrite); - test_Value(r, r == KErrDirFull); + test(r==KErrDirFull); f.Close(); @@ -1679,22 +1678,22 @@ for (i=0;i calcsize) { @@ -1795,7 +1794,7 @@ fileName=_L("\\File"); fileName.AppendNum(i); r=f[i].Create(TheFs,fileName,0); - test_KErrNone(r); + test(r==KErrNone); } TInt maxTotalSize=1048576; @@ -1808,7 +1807,7 @@ { TInt randSize=Math::Rand(gSeed)%maxFileSize; r=f[i].SetSize(randSize); - test_KErrNone(r); + test(r==KErrNone); } test.Printf(_L("Countdown .. %d \r"),maxIterations); } @@ -1821,12 +1820,12 @@ { TInt size=0; r=f[i].Size(size); - test_KErrNone(r); + test(r==KErrNone); totalSize+=((size+gBytesPerCluster-1)/gBytesPerCluster)*gBytesPerCluster; } r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); if (gDiskType == EFat32) volInfo.iSize -= gBytesPerCluster; // root dir is part of the 'size' if (volInfo.iSize-volInfo.iFree!=totalSize) @@ -1847,13 +1846,13 @@ fileName=_L("\\File"); fileName.AppendNum(i); r=TheFs.Delete(fileName); - test_KErrNone(r); + test(r==KErrNone); } r=TheFs.Volume(volInfo); if (gDiskType == EFat32) volInfo.iSize -= gBytesPerCluster; // root dir is part of the 'size' - test_KErrNone(r); + test(r==KErrNone); test(volInfo.iSize-volInfo.iFree==0); MakeDir(gSessionPath); @@ -1871,7 +1870,7 @@ r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); if (gDiskType == EFat32) volInfo.iSize -= gBytesPerCluster; // root dir is part of the 'size' test.Printf(_L("volInfo.iSize = %ld\n"), volInfo.iSize); @@ -1887,7 +1886,7 @@ CreateFatEntry(gSessionPath, EFalse); r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); if (gDiskType == EFat32) volInfo.iSize -= gBytesPerCluster; // root dir is part of the 'size' test.Printf(_L("volInfo.iSize = %ld\n"), volInfo.iSize); @@ -1901,10 +1900,10 @@ CFileMan* fMan=CFileMan::NewL(TheFs); r=fMan->RmDir(gSessionPath); - test_KErrNone(r); + test(r==KErrNone); delete fMan; r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); if (gDiskType == EFat32) volInfo.iSize -= gBytesPerCluster; // root dir is part of the 'size' if (volInfo.iSize-volInfo.iFree!=0) @@ -1936,22 +1935,22 @@ buffer.Replace(0,11,_L8("TEST1 ")); TInt r=TheDisk.Open(TheFs,CurrentDrive()); - test_KErrNone(r); + test(r==KErrNone); r=TheDisk.Write(pos,buffer); - test_KErrNone(r); + test(r==KErrNone); TheDisk.Close(); r=TheDir.Open(TheFs,_L("\\"),KEntryAttMaskSupported); - test_KErrNone(r); + test(r==KErrNone); r=TheDir.Read(TheEntry); - test_KErrNone(r); + test(r==KErrNone); test(TheEntry.iName==_L("TEST1")); r=TheDir.Read(TheEntry); - test_Value(r, r == KErrEof); + test(r==KErrEof); TheDir.Close(); r=TheFs.SetSessionPath(_L("\\")); - test_KErrNone(r); + test(r==KErrNone); TEntry e; r=TheFs.Entry(_L("TEST1"),e); if(e.iName!=_L("TEST1")) @@ -1986,9 +1985,9 @@ TInt r=TheDisk.Open(TheFs,CurrentDrive()); if (r != KErrNone) test.Printf(_L("Error %d opening on %C"), r, (TUint)gDriveToTest); - test_KErrNone(r); + test(r==KErrNone); r=TheDisk.Read(0, boot); - test_KErrNone(r); + test(r==KErrNone); TUint32 val = GetValue(boot, 510, 2); RDebug::Print(_L("BPB magic number = 0x%X\n"), val); test(aTestOnly || val == 0xAA55); @@ -2114,7 +2113,7 @@ for(i=0; i<=20; i++) { r = TheFile.Write(TheBuffer); - test_KErrNone(r); + test(r==KErrNone); } TheFile.Close(); @@ -2471,7 +2470,7 @@ testVal.iSectorsPerCluster, testVal.iRootDirEntries); TInt r = fatAlignment.AdjustFirstDataSectorAlignment(testVal.iBlockSize); - test_KErrNone(r); + test (r == KErrNone); fatAlignment.Display(); } @@ -2584,7 +2583,7 @@ TVolumeInfo volInfo; r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); TInt64 spaceToUse = volInfo.iFree - gBytesPerCluster; // whole disk except 1 cluster @@ -2598,42 +2597,42 @@ { TFileName tempName; r=f.Temp(TheFs,_L("\\"),tempName,EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); r=f.SetSize(K1GigaByte); - test_KErrNone(r); + test(r==KErrNone); f.Close(); spaceToUse -= K1GigaByte; tempfiles++; } r=f.Replace(TheFs,_L("\\USESPACE.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); r=f.SetSize((TInt)spaceToUse); - test_KErrNone(r); + test(r==KErrNone); f.Close(); r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); test.Printf(_L("After fill, volInfo.iSize %ld volInfo.iFree %ld\n"), volInfo.iSize, volInfo.iFree); test(volInfo.iFree==gBytesPerCluster); // check we have 1 cluster free r=f.Replace(TheFs,_L("\\FILE.TMP"),EFileRead|EFileWrite); - test_KErrNone(r); + test(r==KErrNone); r=f.SetSize(2*gBytesPerCluster); // 2 clusters (will fail since there's not space) - test_Value(r, r == KErrDiskFull); + test(r==KErrDiskFull); f.Close(); r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); test(volInfo.iFree==gBytesPerCluster); // check we still have 1 cluster free r=f.Replace(TheFs,_L("\\USESPACE.TMP"),EFileRead|EFileWrite); // truncate file to 0 - test_KErrNone(r); + test(r==KErrNone); f.Close(); r=TheFs.Volume(volInfo); - test_KErrNone(r); + test(r==KErrNone); test(volInfo.iFree==(spaceToUse+gBytesPerCluster)); // check we've freed up the space from USESPACE plus one cluster @@ -2643,7 +2642,7 @@ //-- read 1 sector of the root dir. r = MediaRawRead(TheFs, CurrentDrive(), rootDirpos, TheBootSector.BytesPerSector(), TheBuffer); - test_KErrNone(r); + test(r == KErrNone); const TFatDirEntry* pE=(TFatDirEntry*)TheBuffer.Ptr(); while (tempfiles-- > 0) @@ -2690,7 +2689,7 @@ TInt drvNum; TInt r=TheFs.CharToDrive(gDriveToTest,drvNum); - test_KErrNone(r); + test(r==KErrNone); if (!Is_Fat(TheFs,drvNum)) { @@ -2705,7 +2704,7 @@ // check this is not the internal ram drive TVolumeInfo v; r=TheFs.Volume(v, drvNum); - test_KErrNone(r); + test(r==KErrNone); TBool isRamDrive = v.iDrive.iMediaAtt&KMediaAttVariableSize; gSessionPath[0] = (TText)gDriveToTest;