kerneltest/f32test/server/t_cp_plugintest.cpp
changeset 109 b3a1d9898418
parent 0 a41df078684a
child 206 ced41fd9a298
child 257 3e88ff8f41d5
child 269 d57b86b1867a
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
    43     }
    43     }
    44 
    44 
    45 void ReadBootSector(TFatBootSector& aBootSector)
    45 void ReadBootSector(TFatBootSector& aBootSector)
    46 	{
    46 	{
    47     TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
    47     TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
    48     test(nRes == KErrNone);
    48     test_KErrNone(nRes);
    49 
    49 
    50     if(!aBootSector.IsValid())
    50     if(!aBootSector.IsValid())
    51         {
    51         {
    52         test.Printf(_L("Wrong bootsector! Dump:\n"));
    52         test.Printf(_L("Wrong bootsector! Dump:\n"));
    53         aBootSector.PrintDebugInfo();
    53         aBootSector.PrintDebugInfo();
    71 	longDirNamePath += aLongName;
    71 	longDirNamePath += aLongName;
    72 	longDirNamePath.Append('\\');
    72 	longDirNamePath.Append('\\');
    73 
    73 
    74 	// Create new directory and check creation
    74 	// Create new directory and check creation
    75 	TInt r = TheFs.MkDir(longDirNamePath);
    75 	TInt r = TheFs.MkDir(longDirNamePath);
    76 	test(r==KErrNone);
    76 	test_KErrNone(r);
    77 	
    77 	
    78 	TUint dumUint=0;
    78 	TUint dumUint=0;
    79 	CDir* dumDir;
    79 	CDir* dumDir;
    80 	r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
    80 	r= TheFs.GetDir(longDirNamePath, dumUint, dumUint, dumDir);
    81 	test(r==KErrNone);
    81 	test_KErrNone(r);
    82 	test_NotNull(dumDir);
    82 	test_NotNull(dumDir);
    83 	delete dumDir;
    83 	delete dumDir;
    84 
    84 
    85 	// Check short name
    85 	// Check short name
    86 	r = TheFs.GetShortName(longDirNamePath, shortName);
    86 	r = TheFs.GetShortName(longDirNamePath, shortName);
    87 	test(r==KErrNone);
    87 	test_KErrNone(r);
    88 	r = shortName.Compare(aShortName);
    88 	r = shortName.Compare(aShortName);
    89 	test(r==0);
    89 	test_Value(r, r == 0);
    90 	
    90 	
    91 	// Check long name
    91 	// Check long name
    92 	shortDirNamePath = gSessionPath;
    92 	shortDirNamePath = gSessionPath;
    93 	shortDirNamePath += shortName;
    93 	shortDirNamePath += shortName;
    94 	shortDirNamePath.Append('\\');
    94 	shortDirNamePath.Append('\\');
    95 	r = TheFs.GetLongName(shortDirNamePath, longName);
    95 	r = TheFs.GetLongName(shortDirNamePath, longName);
    96 	test(r==KErrNone);
    96 	test_KErrNone(r);
    97 	r = longName.Compare(aLongName);
    97 	r = longName.Compare(aLongName);
    98 	test(r==0);
    98 	test_Value(r, r == 0);
    99 
    99 
   100 	r = TheFs.RmDir(longDirNamePath);
   100 	r = TheFs.RmDir(longDirNamePath);
   101 	test(r==KErrNone);
   101 	test_KErrNone(r);
   102 	}
   102 	}
   103 
   103 
   104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
   104 void doFileNameTest(const TDesC& aLongName, const TDesC& aShortName)
   105 	{
   105 	{
   106 	TFileName lgnFullPath;
   106 	TFileName lgnFullPath;
   107 	TFileName shnFullPath;
   107 	TFileName shnFullPath;
   108 	TFileName lgn;
   108 	TFileName lgn;
   109 	TFileName shn;
   109 	TFileName shn;
   110 
   110 
   111 	TInt r = TheFs.SessionPath(gSessionPath);
   111 	TInt r = TheFs.SessionPath(gSessionPath);
   112 	test(r==KErrNone);
   112 	test_KErrNone(r);
   113 	lgnFullPath = gSessionPath;
   113 	lgnFullPath = gSessionPath;
   114 	lgnFullPath += aLongName;
   114 	lgnFullPath += aLongName;
   115 	
   115 	
   116 	MakeFile_CPTest(lgnFullPath);
   116 	MakeFile_CPTest(lgnFullPath);
   117 	// Check short name	
   117 	// Check short name	
   118 	r = TheFs.GetShortName(lgnFullPath, shn);
   118 	r = TheFs.GetShortName(lgnFullPath, shn);
   119 	test(r==KErrNone);
   119 	test_KErrNone(r);
   120 	r = shn.Compare(aShortName);
   120 	r = shn.Compare(aShortName);
   121 	test(r==0);
   121 	test_Value(r, r == 0);
   122 
   122 
   123 	// Check long name	
   123 	// Check long name	
   124 	shnFullPath = gSessionPath;
   124 	shnFullPath = gSessionPath;
   125 	shnFullPath += aShortName;
   125 	shnFullPath += aShortName;
   126 
   126 
   127 	r = TheFs.GetLongName(shnFullPath, lgn);
   127 	r = TheFs.GetLongName(shnFullPath, lgn);
   128 	test(r==KErrNone);
   128 	test_KErrNone(r);
   129 	r = lgn.Compare(aLongName);
   129 	r = lgn.Compare(aLongName);
   130 	test(r==0);
   130 	test_Value(r, r == 0);
   131 
   131 
   132 	r = TheFs.Delete(lgnFullPath);
   132 	r = TheFs.Delete(lgnFullPath);
   133 	test(r==KErrNone);
   133 	test_KErrNone(r);
   134 
   134 
   135 	}
   135 	}
   136 #endif //_DEBUG || _DEBUG_RELEASE
   136 #endif //_DEBUG || _DEBUG_RELEASE
   137 
   137 
   138 //----------------------------------------------------------------------------------------------
   138 //----------------------------------------------------------------------------------------------
   158 	{
   158 	{
   159 	test.Next(_L("Test unicode volume labels"));
   159 	test.Next(_L("Test unicode volume labels"));
   160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   160 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   161 
   161 
   162 	TInt r = TheFs.SessionPath(gSessionPath);
   162 	TInt r = TheFs.SessionPath(gSessionPath);
   163 	test(r==KErrNone);
   163 	test_KErrNone(r);
   164 	TInt driveNum;
   164 	TInt driveNum;
   165 	r = TheFs.CharToDrive(gSessionPath[0], driveNum);
   165 	r = TheFs.CharToDrive(gSessionPath[0], driveNum);
   166 	test(r==KErrNone);
   166 	test_KErrNone(r);
   167 
   167 
   168 	// Retrieves the original volume label
   168 	// Retrieves the original volume label
   169 	TVolumeInfo vInfo;
   169 	TVolumeInfo vInfo;
   170 	r = TheFs.Volume(vInfo, driveNum);
   170 	r = TheFs.Volume(vInfo, driveNum);
   171 	const TInt KVolumeLabelSize = 11;
   171 	const TInt KVolumeLabelSize = 11;
   173 
   173 
   174 	// Tests setting volume label with unicode characters
   174 	// Tests setting volume label with unicode characters
   175 	_LIT(KUnicodeVolumeLabel, 		"\x65B0\x65B0\x65B0");
   175 	_LIT(KUnicodeVolumeLabel, 		"\x65B0\x65B0\x65B0");
   176 
   176 
   177 	r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
   177 	r = TheFs.SetVolumeLabel(KUnicodeVolumeLabel, driveNum);
   178 	test(r==KErrNone);
   178 	test_KErrNone(r);
   179 	r = TheFs.Volume(vInfo, driveNum);
   179 	r = TheFs.Volume(vInfo, driveNum);
   180 	test(r==KErrNone);
   180 	test_KErrNone(r);
   181 	r = vInfo.iName.Compare(KUnicodeVolumeLabel);
   181 	r = vInfo.iName.Compare(KUnicodeVolumeLabel);
   182 	test(r==KErrNone);
   182 	test_KErrNone(r);
   183 
   183 
   184 	// Tests setting volume label with unicode characters that bigger than 11 bytes
   184 	// Tests setting volume label with unicode characters that bigger than 11 bytes
   185 	_LIT(KVolumeLabelOverflow,		"\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
   185 	_LIT(KVolumeLabelOverflow,		"\x65B0\x65B0\x65B0\x65B0\x65B0\x65B0");
   186 	r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
   186 	r = TheFs.SetVolumeLabel(KVolumeLabelOverflow, driveNum);
   187 	test(r==KErrOverflow);
   187 	test_Value(r, r == KErrOverflow);
   188 
   188 
   189 	// Sets back the original volume label
   189 	// Sets back the original volume label
   190 	r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
   190 	r = TheFs.SetVolumeLabel(originalVolumeLabel, driveNum);
   191 	test(r==KErrNone);
   191 	test_KErrNone(r);
   192 	r = TheFs.Volume(vInfo, driveNum);
   192 	r = TheFs.Volume(vInfo, driveNum);
   193 	test(r==KErrNone);
   193 	test_KErrNone(r);
   194 	r = vInfo.iName.Compare(originalVolumeLabel);
   194 	r = vInfo.iName.Compare(originalVolumeLabel);
   195 	test(r==0);
   195 	test_Value(r, r == 0);
   196 #else
   196 #else
   197 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   197 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   198 #endif  // _DEBUG) || _DEBUG_RELEASE
   198 #endif  // _DEBUG) || _DEBUG_RELEASE
   199 	}
   199 	}
   200 
   200 
   430 	TFileName sn;
   430 	TFileName sn;
   431 	TInt r;	
   431 	TInt r;	
   432 	MakeFile_CPTest(KTestFileName4C8B);
   432 	MakeFile_CPTest(KTestFileName4C8B);
   433 	MakeFile_CPTest(KTestFileName7C11B);
   433 	MakeFile_CPTest(KTestFileName7C11B);
   434 	r = TheFs.GetShortName(KTestFileName7C11B, sn);
   434 	r = TheFs.GetShortName(KTestFileName7C11B, sn);
   435 	test(r==KErrNone);
   435 	test_KErrNone(r);
   436 	r = sn.Compare(KTestFileName7C11B_short);
   436 	r = sn.Compare(KTestFileName7C11B_short);
   437 	test(r==0);
   437 	test_Value(r, r == 0);
   438 
   438 
   439 
   439 
   440 	MakeFile_CPTest(KTestFileName8C12B);
   440 	MakeFile_CPTest(KTestFileName8C12B);
   441 	r = TheFs.GetShortName(KTestFileName8C12B, sn);
   441 	r = TheFs.GetShortName(KTestFileName8C12B, sn);
   442 	test(r==KErrNone);
   442 	test_KErrNone(r);
   443 	r = sn.Compare(KTestFileName8C12B_short);
   443 	r = sn.Compare(KTestFileName8C12B_short);
   444 	test(r==0);
   444 	test_Value(r, r == 0);
   445 
   445 
   446 	r = TheFs.Delete(KTestFileName4C8B);
   446 	r = TheFs.Delete(KTestFileName4C8B);
   447 	test(r==KErrNone);
   447 	test_KErrNone(r);
   448 		
   448 		
   449 	r = TheFs.Delete(KTestFileName7C11B);
   449 	r = TheFs.Delete(KTestFileName7C11B);
   450 	test(r==KErrNone);
   450 	test_KErrNone(r);
   451 		
   451 		
   452 	r = TheFs.Delete(KTestFileName8C12B);
   452 	r = TheFs.Delete(KTestFileName8C12B);
   453 	test(r==KErrNone);
   453 	test_KErrNone(r);
   454 
   454 
   455 #else
   455 #else
   456 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   456 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   457 #endif  // _DEBUG) || _DEBUG_RELEASE
   457 #endif  // _DEBUG) || _DEBUG_RELEASE
   458 	}
   458 	}
   507 	MakeDir(KTestDirName7C11B);
   507 	MakeDir(KTestDirName7C11B);
   508 	
   508 	
   509 	TFileName sn;
   509 	TFileName sn;
   510 	
   510 	
   511 	r = TheFs.GetShortName(KTestDirName7C11B, sn);
   511 	r = TheFs.GetShortName(KTestDirName7C11B, sn);
   512 	test(r==KErrNone);
   512 	test_KErrNone(r);
   513 	r = sn.Compare(KTestDirName7C11B_short);
   513 	r = sn.Compare(KTestDirName7C11B_short);
   514 	test(r==0);
   514 	test_Value(r, r == 0);
   515 
   515 
   516 	MakeDir(KTestDirName8C12B);
   516 	MakeDir(KTestDirName8C12B);
   517 	r = TheFs.GetShortName(KTestDirName8C12B, sn);
   517 	r = TheFs.GetShortName(KTestDirName8C12B, sn);
   518 	test(r==KErrNone);
   518 	test_KErrNone(r);
   519 	r = sn.Compare(KTestDirName8C12B_short);
   519 	r = sn.Compare(KTestDirName8C12B_short);
   520 	test(r==0);
   520 	test_Value(r, r == 0);
   521 
   521 
   522 #else
   522 #else
   523 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   523 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   524 #endif  // _DEBUG) || _DEBUG_RELEASE
   524 #endif  // _DEBUG) || _DEBUG_RELEASE
   525 	}
   525 	}
   550 
   550 
   551 	TInt r;
   551 	TInt r;
   552 	MakeFile_CPTest(KTestFilePathAndName);
   552 	MakeFile_CPTest(KTestFilePathAndName);
   553 	TFileName sn;
   553 	TFileName sn;
   554 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
   554 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
   555 	test(r==KErrNone);
   555 	test_KErrNone(r);
   556 	r = sn.Compare(KTestFileShortName);
   556 	r = sn.Compare(KTestFileShortName);
   557 	test(r==0);
   557 	test_Value(r, r == 0);
   558 
   558 
   559 #else
   559 #else
   560 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   560 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   561 #endif  // _DEBUG) || _DEBUG_RELEASE
   561 #endif  // _DEBUG) || _DEBUG_RELEASE
   562 	}
   562 	}
   585 	TInt r;
   585 	TInt r;
   586 	MakeFile_CPTest(KTestFilePathAndName);
   586 	MakeFile_CPTest(KTestFilePathAndName);
   587 	
   587 	
   588 	TFileName sn;
   588 	TFileName sn;
   589 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
   589 	r = TheFs.GetShortName(KTestFilePathAndName, sn);
   590 	test(r==KErrNone);
   590 	test_KErrNone(r);
   591 	r = sn.Compare(KTestFileName);
   591 	r = sn.Compare(KTestFileName);
   592 	test(r==0);
   592 	test_Value(r, r == 0);
   593 	TFileName ln;
   593 	TFileName ln;
   594 	r = TheFs.GetLongName(KTestFilePathAndName, ln);
   594 	r = TheFs.GetLongName(KTestFilePathAndName, ln);
   595 	test(r==KErrNone);
   595 	test_KErrNone(r);
   596 	r = ln.Compare(KTestFileName);
   596 	r = ln.Compare(KTestFileName);
   597 	test(r==0);
   597 	test_Value(r, r == 0);
   598 
   598 
   599 #else
   599 #else
   600 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   600 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   601 #endif  
   601 #endif  
   602 	}
   602 	}
   622 
   622 
   623 	RFile file;
   623 	RFile file;
   624 	TFileName fn = _L("\\ABCD");
   624 	TFileName fn = _L("\\ABCD");
   625 	
   625 	
   626 	TInt r=file.Create(TheFs,fn,EFileRead);
   626 	TInt r=file.Create(TheFs,fn,EFileRead);
   627 	test(r==KErrNone);
   627 	test_KErrNone(r);
   628 	file.Close();
   628 	file.Close();
   629 
   629 
   630 	//	Assume this file is the first entry in the root directory
   630 	//	Assume this file is the first entry in the root directory
   631 	r=TheDisk.Open(TheFs,CurrentDrive());
   631 	r=TheDisk.Open(TheFs,CurrentDrive());
   632 	test(r==KErrNone);
   632 	test_KErrNone(r);
   633 	
   633 	
   634     //-- read the 1st dir entry, it should be a DOS entry 
   634     //-- read the 1st dir entry, it should be a DOS entry 
   635     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   635     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   636     
   636     
   637     TFatDirEntry fatEntry1;
   637     TFatDirEntry fatEntry1;
   663 	fn[3] = 0x96C5;
   663 	fn[3] = 0x96C5;
   664 	fn[4] = 0x6CBB;
   664 	fn[4] = 0x6CBB;
   665 	
   665 	
   666 	TEntry entry;
   666 	TEntry entry;
   667 	TInt err = TheFs.Entry(fn, entry);
   667 	TInt err = TheFs.Entry(fn, entry);
   668 	test(err==KErrNone);
   668 	test_KErrNone(err);
   669 	err = TheFs.Delete(fn);
   669 	err = TheFs.Delete(fn);
   670 	test(err==KErrNone);
   670 	test_KErrNone(err);
   671 #else
   671 #else
   672 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   672 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   673 #endif  // _DEBUG) || _DEBUG_RELEASE
   673 #endif  // _DEBUG) || _DEBUG_RELEASE
   674 	}
   674 	}
   675 
   675 
   695 	RFile file;
   695 	RFile file;
   696 	TFileName fn = _L("\\AB");
   696 	TFileName fn = _L("\\AB");
   697 	
   697 	
   698 	test.Next(_L("create file \"AB\" under root directory"));
   698 	test.Next(_L("create file \"AB\" under root directory"));
   699 	TInt r=file.Create(TheFs,fn,EFileRead);
   699 	TInt r=file.Create(TheFs,fn,EFileRead);
   700 	test(r==KErrNone);
   700 	test_KErrNone(r);
   701 	file.Close();
   701 	file.Close();
   702 
   702 
   703 	test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
   703 	test.Next(_L("manually change file name to \"0x7F0x450x7F0x45\" via raw disk accessing"));
   704 	//	Assume this file is the first entry in the root directory
   704 	//	Assume this file is the first entry in the root directory
   705 	r=TheDisk.Open(TheFs,CurrentDrive());
   705 	r=TheDisk.Open(TheFs,CurrentDrive());
   706 	test(r==KErrNone);
   706 	test_KErrNone(r);
   707 	
   707 	
   708     //-- read the first dir entry, it should be a DOS entry 
   708     //-- read the first dir entry, it should be a DOS entry 
   709     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   709     const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   710     
   710     
   711     TFatDirEntry fatEntry1;
   711     TFatDirEntry fatEntry1;
   781 	MakeFile_CPTest(fn);
   781 	MakeFile_CPTest(fn);
   782 	
   782 	
   783 	_LIT(KShortName, "\x3055\x307E\x3056~1");
   783 	_LIT(KShortName, "\x3055\x307E\x3056~1");
   784 	TFileName sn;
   784 	TFileName sn;
   785 	r = TheFs.GetShortName(fn, sn);
   785 	r = TheFs.GetShortName(fn, sn);
   786 	test(r==KErrNone);
   786 	test_KErrNone(r);
   787 	r = sn.Compare(KShortName);
   787 	r = sn.Compare(KShortName);
   788 	test(r==0);
   788 	test_Value(r, r == 0);
   789 	
   789 	
   790 	r = TheFs.ScanDrive(_L("gSessionPath"));
   790 	r = TheFs.ScanDrive(_L("gSessionPath"));
   791 	test(r==KErrNone);
   791 	test_KErrNone(r);
   792 
   792 
   793 	r = TheFs.Delete(fn);
   793 	r = TheFs.Delete(fn);
   794 	test(r == KErrNone);
   794 	test_KErrNone(r);
   795 #else
   795 #else
   796 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   796 	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   797 #endif  // _DEBUG) || _DEBUG_RELEASE
   797 #endif  // _DEBUG) || _DEBUG_RELEASE
   798 	}
   798 	}
   799 
   799