diff options
Diffstat (limited to 'sal/qa/osl')
-rw-r--r-- | sal/qa/osl/condition/osl_Condition.cxx | 21 | ||||
-rw-r--r-- | sal/qa/osl/file/osl_File.cxx | 1110 | ||||
-rw-r--r-- | sal/qa/osl/module/osl_Module.cxx | 96 | ||||
-rw-r--r-- | sal/qa/osl/mutex/osl_Mutex.cxx | 23 | ||||
-rw-r--r-- | sal/qa/osl/process/osl_Thread.cxx | 92 | ||||
-rw-r--r-- | sal/qa/osl/process/osl_process.cxx | 257 | ||||
-rw-r--r-- | sal/qa/osl/security/osl_Security.cxx | 10 |
7 files changed, 2 insertions, 1607 deletions
diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx index 1f1a14b180e7..160a4d5374bf 100644 --- a/sal/qa/osl/condition/osl_Condition.cxx +++ b/sal/qa/osl/condition/osl_Condition.cxx @@ -25,27 +25,6 @@ using namespace osl; using namespace rtl; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf("TRUE!\n" ): printf("FALSE!\n" ); -} - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - enum ConditionType { thread_type_set, diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index fcf3a8b15739..8a16c605fdba 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -100,133 +100,6 @@ rtl::OString errorToStr( ::osl::FileBase::RC const& nError) return suBuf; } -/** print a file type name. -*/ -inline void printFileType( const ::osl::FileStatus::Type nType ) -{ - printf( "#printFileType# " ); - switch ( nType ) { - case ::osl::FileStatus::Directory: - printf( "This file is a: Directory.\n" ); - break; - case ::osl::FileStatus::Volume: - printf( "This file is a: volume device.\n" ); - break; - case ::osl::FileStatus::Regular: - printf( "This file is a: regular file.\n" ); - break; - case ::osl::FileStatus::Fifo: - printf( "This file is a: fifo.\n" ); - break; - case ::osl::FileStatus::Socket: - printf( "This file is a: socket.\n" ); - break; - case ::osl::FileStatus::Link: - printf( "This file is a: link file.\n" ); - break; - case ::osl::FileStatus::Special: - printf( "This file is a: special.\n" ); - break; - case ::osl::FileStatus::Unknown: - printf( "The file type is unknown %d \n", nType ); - break; - } -} - -/** print a file attributes. -*/ -inline void printFileAttributes( const sal_Int64 nAttributes ) -{ - printf( "#printFileAttributes# This file is a: (" ); - if ( ( nAttributes | osl_File_Attribute_ReadOnly ) == nAttributes ) - printf( " ReadOnly " ); - if ( ( nAttributes | osl_File_Attribute_Hidden ) == nAttributes ) - printf( " Hidden " ); - if ( ( nAttributes | osl_File_Attribute_Executable ) == nAttributes ) - printf( " Executable " ); - if ( ( nAttributes | osl_File_Attribute_GrpWrite ) == nAttributes ) - printf( " GrpWrite " ); - if ( ( nAttributes | osl_File_Attribute_GrpRead ) == nAttributes ) - printf( " GrpRead " ); - if ( ( nAttributes | osl_File_Attribute_GrpExe ) == nAttributes ) - printf( " GrpExe " ); - if ( ( nAttributes | osl_File_Attribute_OwnWrite ) == nAttributes ) - printf( " OwnWrite " ); - if ( ( nAttributes | osl_File_Attribute_OwnRead ) == nAttributes ) - printf( " OwnRead " ); - if ( ( nAttributes | osl_File_Attribute_OwnExe ) == nAttributes ) - printf( " OwnExe " ); - if ( ( nAttributes | osl_File_Attribute_OthWrite ) == nAttributes ) - printf( " OthWrite " ); - if ( ( nAttributes | osl_File_Attribute_OthRead ) == nAttributes ) - printf( " OthRead " ); - if ( ( nAttributes | osl_File_Attribute_OthExe ) == nAttributes ) - printf( " OthExe " ); - printf( ") file!\n" ); -} - -/** print an output wrong message. -*/ -inline void printError( const ::osl::FileBase::RC nError ) -{ - printf( "#printError# " ); - printf( "%s\n", errorToStr(nError).getStr() ); -} - -/** print an signed Integer Number. -*/ -inline void printInt( sal_Int64 i ) -{ - printf( "#printInt_i64# " ); - printf( "The Integer64 is %" SAL_PRIdINT64 "\n", i); -} - -/** print an unsigned Integer Number. -*/ -inline void printInt( sal_uInt64 i ) -{ - printf( "#printInt_u64# " ); - printf( "The unsigned Integer64 is %" SAL_PRIuUINT64 "\n", i); -} - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf( "#printBool# " ); - bOk ? printf( "YES!\n" ): printf( "NO!\n" ); -} - -/** print struct TimeValue in local time format. -*/ -inline void printTime( TimeValue *tv ) -{ - oslDateTime *pDateTime = ( oslDateTime* )malloc( sizeof( oslDateTime ) ) ; - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pDateTime != NULL ); - TimeValue *pLocalTV = ( TimeValue* )malloc( sizeof( TimeValue ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pLocalTV != NULL ); - - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_getLocalTimeFromSystemTime ",sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_gepDateTimeFromTimeValue ",sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime ) ); - - printf( "#printTime# " ); - printf( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year); - switch ( pDateTime->DayOfWeek ) - { - case 0: printf("Sun. "); break; - case 1: printf("Mon. "); break; - case 2: printf("Tue. "); break; - case 3: printf("Wed. "); break; - case 4: printf("Thu. "); break; - case 5: printf("Fri. "); break; - case 6: printf("Sat. "); break; - } - printf( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, (int) pDateTime->NanoSeconds); - - free( pDateTime ); - free( pLocalTV ); -} - /** compare two TimeValue, unit is "ms", since Windows time precision is better than UNX. */ /* FIXME: the above assertion is bogus */ @@ -237,20 +110,6 @@ inline void printTime( TimeValue *tv ) # define delta 1800 //time precision, 1.8s #endif -inline sal_Int64 t_abs64(sal_Int64 _nValue) -{ - // std::abs() seems to have some ambiguity problems (so-texas) - // return abs(_nValue); - printf("t_abs64(%ld)\n", (long) _nValue); - // CPPUNIT_ASSERT(_nValue < 2147483647); - - if (_nValue < 0) - { - _nValue = -_nValue; - } - return _nValue; -} - inline bool t_compareTime( TimeValue *m_aEndTime, TimeValue *m_aStartTime, sal_Int32 nDelta) { // sal_uInt64 uTimeValue; @@ -296,25 +155,6 @@ inline bool compareFileName( const ::rtl::OUString & ustr1, const ::rtl::OUStrin return bOk; } -/** compare a OUString and an ASCII file name. -*/ -inline bool compareFileName( const ::rtl::OUString & ustr, const sal_Char *astr ) -{ - (void)ustr; - ::rtl::OUString ustr1 = rtl::OUString::createFromAscii( astr ); - bool bOk = ustr1.equalsIgnoreAsciiCase( ustr1 ); // TODO: does it really compare with the same var? - - return bOk; -} - -/** simple version to judge if a file name or directory name is a URL or a system path, just to see if it - is start with "file:///";. -*/ -inline bool isURL( const sal_Char *pathname ) -{ - return ( 0 == strncmp( pathname, FILE_PREFIX, sizeof( FILE_PREFIX ) - 1 ) ); -} - /** simple version to judge if a file name or directory name is a URL or a system path, just to see if it is start with "file:///";. */ @@ -464,49 +304,6 @@ typedef enum { osl_Check_Mode_WriteAccess } oslCheckMode; -// not used here -inline bool checkFile( const ::rtl::OUString & str, oslCheckMode nCheckMode ) -{ - ::osl::FileBase::RC nError1, nError2; - ::osl::File testFile( str ); - bool bCheckResult; - - bCheckResult = false; - nError1 = testFile.open ( osl_File_OpenFlag_Read ); - if ( ( ::osl::FileBase::E_NOENT != nError1 ) && ( ::osl::FileBase::E_ACCES != nError1 ) ){ - - switch ( nCheckMode ) { - case osl_Check_Mode_Exist: - /// check if the file is exist. - if ( ::osl::FileBase::E_None == nError1 ) - bCheckResult = true; - break; - case osl_Check_Mode_OpenAccess: - /// check if the file is openable. - if ( ::osl::FileBase::E_None == nError1 ) - bCheckResult = true; - break; - case osl_Check_Mode_WriteAccess: - /// check the file name and whether it can be written. - /// write chars into the file. - sal_uInt64 nCount_write; - nError2 = testFile.write( pBuffer_Char, 10, nCount_write ); - if ( ::osl::FileBase::E_None == nError2 ) - bCheckResult = true; - break; - - default: - bCheckResult = false; - }/// swith - - nError2 = testFile.close(); - CPPUNIT_ASSERT_MESSAGE( " in CheckFile() function, close file ", nError2 == FileBase::E_None ); - - } - - return bCheckResult; -} - //check if the file exist inline bool ifFileExist( const ::rtl::OUString & str ) { @@ -1439,879 +1236,6 @@ namespace osl_FileBase CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" ); }// namespace osl_FileBase -// Beginning of the test cases for VolumeInfo class - -namespace osl_VolumeInfo -{ - - // testing the method - // VolumeInfo( sal_uInt32 nMask ): _nMask( nMask ) - - class ctors : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1, nError2; - - ::osl::VolumeDevice aVolumeDevice1; - - public: - ctors() :nError1(FileBase::E_None),nError2(FileBase::E_None) {} - // initialization - void setUp() SAL_OVERRIDE - { - } - - void tearDown() SAL_OVERRIDE - { - } - - // test code. - void ctors_001() - { - ::osl::VolumeInfo aVolumeInfo( 0 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty", - ( 0 == uiTotalSpace ) && - ( 0 == uiMaxPathLength ) && - compareFileName( aUStr, aNullURL ) ); - } - -#if ( defined UNX ) - void ctors_002() - { - ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_TotalSpace | - osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FileSystemName ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - //CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields", - ( 0 != uiTotalSpace ) && - ( 0 != uiUsedSpace ) && - compareFileName( aUStr, "nfs" ) ); - } -#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void ctors_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )", - 1 == 1 ); - } -#endif - - void ctors_003() - { - - sal_Int32 mask1 = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo1( mask1 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 ); - CPPUNIT_ASSERT( aVolumeInfo1.isValid( mask1 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace(); - aUStr = aVolumeInfo1.getFileSystemName(); - - sal_Int32 mask2 = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo2( mask2 ); - nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 ); - CPPUNIT_ASSERT( aVolumeInfo2.isValid( mask2 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError2 ); - - sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)", - ( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && - compareFileName( aUStr, aNullURL ) ); - } - - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_001 ); - CPPUNIT_TEST( ctors_002 ); - CPPUNIT_TEST( ctors_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class ctors - - // testing the method - // inline sal_Bool isValid( sal_uInt32 nMask ) const - - class isValid : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - isValid() :nError1(FileBase::E_None) {} - // initialization - void setUp() SAL_OVERRIDE - { - } - - void tearDown() SAL_OVERRIDE - { - - } - - // test code. - void isValid_001() - { - sal_Int32 mask = 0; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified.", - aVolumeInfo.isValid( mask ) ); - } - -#if ( defined UNX ) - void isValid_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes | osl_VolumeInfo_Mask_TotalSpace | osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_MaxNameLength | - osl_VolumeInfo_Mask_MaxPathLength | osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.", - aVolumeInfo.isValid( mask ) ); - } -#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void isValid_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.( Windows version )", - 1 == 1 ); - } -#endif - - void isValid_003() - { - ::osl::VolumeDevice aVolumeDevice1; - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk1 = aVolumeInfo.isValid( mask ); - - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk2 = aVolumeInfo.isValid( mask ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: osl_VolumeInfo_Mask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass", - bOk1 && bOk2 ); - } - - CPPUNIT_TEST_SUITE( isValid ); - CPPUNIT_TEST( isValid_001 ); - CPPUNIT_TEST( isValid_002 ); - CPPUNIT_TEST( isValid_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class isValid - - // testing the method - // inline sal_Bool getRemoteFlag() const - - class getRemoteFlag : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - getRemoteFlag() :nError1(FileBase::E_None) {} - // test code. - void getRemoteFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoteFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is not remote.", - !bOk ); - } - - #if ( defined UNX ) //remote Volume is different in Solaris and Windows - void getRemoteFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoteFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Solaris version ).", - bOk ); - } -#else //Windows version - void getRemoteFlag_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getRemoteFlag ); - CPPUNIT_TEST( getRemoteFlag_001 ); - CPPUNIT_TEST( getRemoteFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRemoteFlag - - // testing the method - // inline sal_Bool getRemoveableFlag() const - - class getRemoveableFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getRemoveableFlag() :nError1(FileBase::E_None) {} - // test code. - void getRemoveableFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoveableFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is not removable.", - !bOk ); - } - - void getRemoveableFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoveableFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getRemoveableFlag ); - CPPUNIT_TEST( getRemoveableFlag_001 ); - CPPUNIT_TEST( getRemoveableFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRemoveableFlag - - // testing the method - // inline sal_Bool getCompactDiscFlag() const - - class getCompactDiscFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getCompactDiscFlag() :nError1(FileBase::E_None) {} - // test code. - void getCompactDiscFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getCompactDiscFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a volume device which is not a cdrom.", - !bOk ); - } - - void getCompactDiscFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL6, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getCompactDiscFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getCompactDiscFlag ); - CPPUNIT_TEST( getCompactDiscFlag_001 ); - CPPUNIT_TEST( getCompactDiscFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getCompactDiscFlag - - // testing the method - // inline sal_Bool getFloppyDiskFlag() const - - class getFloppyDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFloppyDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getFloppyDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFloppyDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk.", - !bOk ); - } - - void getFloppyDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFloppyDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getFloppyDiskFlag ); - CPPUNIT_TEST( getFloppyDiskFlag_001 ); - CPPUNIT_TEST( getFloppyDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFloppyDiskFlag - - // testing the method - // inline sal_Bool getFixedDiskFlag() const - - class getFixedDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFixedDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getFixedDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFixedDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a volume device which is not a fixed disk.", - !bOk ); - } - - void getFixedDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFixedDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getFixedDiskFlag ); - CPPUNIT_TEST( getFixedDiskFlag_001 ); - CPPUNIT_TEST( getFixedDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFixedDiskFlag - - // testing the method - // inline sal_Bool getRAMDiskFlag() const - - class getRAMDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getRAMDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getRAMDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRAMDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: get a volume device which is not a RAM disk.", - !bOk ); - } - - void getRAMDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRAMDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32).", - bOk ); - } - CPPUNIT_TEST_SUITE( getRAMDiskFlag ); - CPPUNIT_TEST( getRAMDiskFlag_001 ); - CPPUNIT_TEST( getRAMDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRAMDiskFlag - - // testing the method - // inline sal_uInt64 getTotalSpace() const - - class getTotalSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getTotalSpace() :nError1(FileBase::E_None) {} - // test code. - void getTotalSpace_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0", - 0 != uiTotalSpace ); - } - - #if defined( UNX ) - void getTotalSpace_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of /proc, it should be 0", - 0 == uiTotalSpace ); - } -#else /// Windows version, in Windows, there is no /proc directory - void getTotalSpace_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not applicable for /proc( Windows version )", - 1 == 1 ); - } -#endif - -#if defined(SOLARIS) - void getTotalSpace_003() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 TotalSpace = aStatFS.f_frsize * aStatFS.f_blocks ; - - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass", - uiTotalSpace == TotalSpace ); - } -#else /// Windows version - void getTotalSpace_003() - { - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getTotalSpace ); - CPPUNIT_TEST( getTotalSpace_001 ); - CPPUNIT_TEST( getTotalSpace_002 ); - CPPUNIT_TEST( getTotalSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getTotalSpace - - // testing the method - // inline sal_uInt64 getFreeSpace() const - - class getFreeSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFreeSpace() :nError1(FileBase::E_None) {} - // test code. - void getFreeSpace_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0", - 0 != uiFreeSpace ); - } - -#if defined( UNX ) - void getFreeSpace_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of /proc, it should be 0", - 0 == uiFreeSpace ); - } -#else /// Windows version, in Windows, there is no /proc directory - void getFreeSpace_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not applicable for /proc( Windows version )", - 1 == 1 ); - } -#endif - -#if defined(SOLARIS) - void getFreeSpace_003() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 FreeSpace = aStatFS.f_bfree * aStatFS.f_frsize ; - - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass", - uiFreeSpace == FreeSpace ); - } -#else //Windows version - void getFreeSpace_003() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getFreeSpace ); - CPPUNIT_TEST( getFreeSpace_001 ); - CPPUNIT_TEST( getFreeSpace_002 ); - CPPUNIT_TEST( getFreeSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFreeSpace - - // testing the method - // inline sal_uInt64 getUsedSpace() const - - class getUsedSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getUsedSpace() :nError1(FileBase::E_None) {} - // test code. - void getUsedSpace_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0", - 0 != uiUsedSpace ); - } - -#if defined( UNX ) - void getUsedSpace_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of /proc, it should be 0", - 0 == uiUsedSpace ); - } -#else /// Windows version, in Windows, there is no /proc directory - void getUsedSpace_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not applicable for /proc( Windows version )", - 1 == 1 ); - } -#endif - -#if defined(SOLARIS) - void getUsedSpace_003() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 UsedSpace = ( aStatFS.f_blocks - aStatFS.f_bavail ) * aStatFS.f_frsize; - - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass", - uiUsedSpace == UsedSpace ); - } -#else //Windows version - void getUsedSpace_003() - { - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getUsedSpace ); - CPPUNIT_TEST( getUsedSpace_001 ); - CPPUNIT_TEST( getUsedSpace_002 ); - CPPUNIT_TEST( getUsedSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getUsedSpace - - // testing the method - // inline sal_uInt32 getMaxNameLength() const - - class getMaxNameLength : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getMaxNameLength() :nError1(FileBase::E_None) {} - // test code. - void getMaxNameLength_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt32 uiMaxNameLength = aVolumeInfo.getMaxNameLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0", - 0 != uiMaxNameLength ); - } - -#if defined(UNX) && !defined(ANDROID) - void getMaxNameLength_002() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 MaxNameLength = aStatFS.f_namemax; - - sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiMaxNameLength = aVolumeInfo.getMaxNameLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength", - uiMaxNameLength == MaxNameLength ); - } -#else //Windows version - void getMaxNameLength_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getMaxNameLength ); - CPPUNIT_TEST( getMaxNameLength_001 ); - CPPUNIT_TEST( getMaxNameLength_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getMaxNameLength - - // testing the method - // inline sal_uInt32 getMaxPathLength() const - - class getMaxPathLength : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getMaxPathLength() :nError1(FileBase::E_None) {} - // test code. - void getMaxPathLength_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0", - 0 != uiMaxPathLength ); - } - -#if ( defined UNX ) - void getMaxPathLength_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength", - uiMaxPathLength == PATH_MAX ); - } -#else //Windows version - void getMaxPathLength_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getMaxPathLength ); - CPPUNIT_TEST( getMaxPathLength_001 ); - CPPUNIT_TEST( getMaxPathLength_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getMaxPathLength - - // testing the method - // inline ::rtl::OUString getFileSystemName() const - - class getFileSystemName : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - getFileSystemName() :nError1(FileBase::E_None) {} - // test code. - void getFileSystemName_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string", - !compareFileName( aNullURL, aUStr ) ); - } - -#if defined(SOLARIS) - void getFileSystemName_002() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_Char * astrFileSystemName = aStatFS.f_basetype; - - sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName", - sal_True == compareFileName( aUStr, astrFileSystemName ) ); - } -#else //Windows version - void getFileSystemName_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getFileSystemName ); - CPPUNIT_TEST( getFileSystemName_001 ); - CPPUNIT_TEST( getFileSystemName_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFileSystemName - - // testing the method - // inline VolumeDevice getDeviceHandle() const - - class getDeviceHandle : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - getDeviceHandle() :nError1(FileBase::E_None) {} - // test code. - void getDeviceHandle_001() - { - ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_Attributes ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle() ); - bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath() ); - - CPPUNIT_ASSERT_MESSAGE( "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX).", - !bOk ); - } - - CPPUNIT_TEST_SUITE( getDeviceHandle ); - CPPUNIT_TEST( getDeviceHandle_001 ); - CPPUNIT_TEST_SUITE_END(); - };// class getDeviceHandle - - /*CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::ctors, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::isValid, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoteFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoveableFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getCompactDiscFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFloppyDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFixedDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRAMDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getTotalSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFreeSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getUsedSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxNameLength, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxPathLength, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFileSystemName, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getDeviceHandle, "osl_VolumeInfo" );*/ -}// namespace osl_VolumeInfo - -// Beginning of the test cases for VolumeDevice class - namespace osl_FileStatus { @@ -4162,15 +3086,6 @@ namespace osl_File CPPUNIT_ASSERT_MESSAGE( "test for copy function: the dest file exist", nFilePointer == 200 ); } - //copyLink has not been impletmented yet - void copy_007() - { -#if ( defined UNX ) - - CPPUNIT_ASSERT_MESSAGE( "test for copy function: source file is link file", - ::osl::FileBase::E_INVAL == nError1 ); -#endif - } CPPUNIT_TEST_SUITE( copy ); CPPUNIT_TEST( copy_001 ); @@ -4305,30 +3220,7 @@ namespace osl_File (::osl::FileBase::E_None == nError1 ) && (::osl::FileBase::E_EXIST == nError2 ) ); } - // oldpath and newpath are not on the same filesystem.EXDEV,no such error no on Solaris, only on linux - void move_008() - { - CPPUNIT_ASSERT_MESSAGE( "oldpath and newpath are not on the same filesystem, should error returns", - ::osl::FileBase::E_None == nError1 ); - } //bugid# 115420, after the bug fix, add the case - void move_009() - { - //create directory $TEMP/tmpname. - createTestDirectory( aTmpName6 ); - //create directory $TEMP/tmpname/tmpdir - createTestDirectory( aTmpName8 ); - //move directory $TEMP/tmpname to $TEMP/tmpname/tmpdir/tmpname - rtl::OUString newName = aTmpName8 + "/tmpname"; - nError1 = ::osl::File::move( aTmpName3, newName ); - //deleteTestDirectory( newName + "/tmpname" ); - //deleteTestDirectory( newName ); - deleteTestDirectory( aTmpName8 ); - deleteTestDirectory( aTmpName6 ); - CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to it's subdirectory", - ::osl::FileBase::E_None != nError1 ); - } - CPPUNIT_TEST_SUITE( move ); CPPUNIT_TEST( move_001 ); CPPUNIT_TEST( move_002 ); @@ -4337,8 +3229,6 @@ namespace osl_File CPPUNIT_TEST( move_005 ); CPPUNIT_TEST( move_006 ); CPPUNIT_TEST( move_007 ); - // CPPUNIT_TEST( move_008 ); - //CPPUNIT_TEST( move_009 ); CPPUNIT_TEST_SUITE_END(); };// class move diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index 43387045af37..1612662cbeee 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -27,27 +27,6 @@ using ::rtl::OUString; using ::rtl::OUStringToOString; using ::rtl::OString; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf( "TRUE!\n" ) : printf( "FALSE!\n" ); -} - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - /** get dll file URL. */ inline ::rtl::OUString getDllURL( void ) @@ -66,81 +45,6 @@ inline ::rtl::OUString getDllURL( void ) return dllPath; } -inline bool isURL( const ::rtl::OUString& pathname ) -{ - return pathname.startsWith( "file:///" ); -} - -/** create a temp test directory using OUString name of full qualified URL or system path. -*/ -inline void createTestDirectory( const ::rtl::OUString& dirname ) -{ - ::rtl::OUString aPathURL = dirname.copy( 0 ); - ::osl::FileBase::RC nError; - - if ( !isURL( dirname ) ) - ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL - nError = ::osl::Directory::create( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In createTestDirectory Function: creation: ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) ); -} - -/** delete a temp test directory using OUString name of full qualified URL or system path. -*/ -inline void deleteTestDirectory( const ::rtl::OUString& dirname ) -{ - ::rtl::OUString aPathURL = dirname.copy( 0 ); - ::osl::FileBase::RC nError; - if ( !isURL( dirname ) ) - ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL - - ::osl::Directory testDir( aPathURL ); - if ( testDir.isOpen( ) ) - { - testDir.close( ); //close if still open. - } - - nError = ::osl::Directory::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestDirectory function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); -} - -//check if the file exist -inline bool ifFileExist( const ::rtl::OUString & str ) -{ - ::rtl::OUString aUStr; - if ( isURL( str ) ) - ::osl::FileBase::getSystemPathFromFileURL( str, aUStr ); - else - return false; - - ::osl::File strFile( aUStr ); - ::osl::FileBase::RC nError = strFile.open( osl_File_OpenFlag_Read ); - if ( ::File::E_NOENT == nError ) - return false; - else{ - strFile.close( ); - return true; - } -} - -/** detete a temp test file using OUString name. -*/ -inline void deleteTestFile( const ::rtl::OUString& filename ) -{ - ::rtl::OUString aPathURL = filename.copy( 0 ); - ::osl::FileBase::RC nError; - - if ( !isURL( filename ) ) - ::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL - - nError = ::osl::File::setAttributes( aPathURL, osl_File_Attribute_GrpWrite| osl_File_Attribute_OwnWrite| osl_File_Attribute_OthWrite ); // if readonly, make writtenable. - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: set writtenable ", ( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError ) ); - - nError = ::osl::File::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); -} - -// test code start here - namespace osl_Module { diff --git a/sal/qa/osl/mutex/osl_Mutex.cxx b/sal/qa/osl/mutex/osl_Mutex.cxx index e06acee5e542..e0747f337bf6 100644 --- a/sal/qa/osl/mutex/osl_Mutex.cxx +++ b/sal/qa/osl/mutex/osl_Mutex.cxx @@ -29,27 +29,6 @@ using namespace osl; using namespace rtl; -// helper functions - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf("YES!\n" ): printf("NO!\n" ); -} - /** pause nSec seconds helper function. */ namespace ThreadHelper @@ -848,6 +827,7 @@ namespace osl_ResettableGuard bRes && bRes1 ); } +#ifdef LINUX void reset_002( ) { Mutex aMutex; @@ -864,6 +844,7 @@ namespace osl_ResettableGuard CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset, release after clear and reset, on Solaris, the mutex can be release without acquire, so it can not passed on (SOLARIS), but not the reason for reset_002", !bRes && bRes1 ); } +#endif CPPUNIT_TEST_SUITE(reset); CPPUNIT_TEST(reset_001); diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index 4778ea1989ca..f5f43140e2eb 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -326,53 +326,6 @@ public: }; -/** call suspend in the run method -*/ -class OSuspendThread : public Thread -{ - ThreadSafeValue<sal_Int32> m_aFlag; -public: - OSuspendThread(){ m_bSuspend = false; } - sal_Int32 getValue() { return m_aFlag.getValue(); } - void setSuspend() - { - m_bSuspend = true; - } - virtual void SAL_CALL suspend() SAL_OVERRIDE - { - m_aFlag.acquire(); - ::osl::Thread::suspend(); - m_aFlag.release(); - } -protected: - bool m_bSuspend; - void SAL_CALL run() SAL_OVERRIDE - { - //if the thread should terminate, schedule return false - while (schedule()) - { - m_aFlag.addValue(1); - - ThreadHelper::thread_sleep_tenth_sec(1); - if (m_bSuspend) - { - suspend(); - m_bSuspend = false; - } - } - } -public: - - virtual ~OSuspendThread() - { - if (isRunning()) - { - t_print("error: not terminated.\n"); - } - } - -}; - /** no call schedule in the run method */ class ONoScheduleThread : public Thread @@ -686,46 +639,6 @@ namespace osl_Thread ); } - /** suspend a thread in it's worker-function, the ALGORITHM is same as suspend_001 - reason of deadlocked I think: no schedule can schedule other threads to go on excuting - */ - void suspend_002() - { - OSuspendThread* aThread = new OSuspendThread(); - bool bRes = aThread->create(); - CPPUNIT_ASSERT_MESSAGE ( "Can't start thread!", bRes ); - // first the thread run for some seconds, but not terminate - sal_Int32 nValue = 0; - //while (1) - //{ - ThreadHelper::thread_sleep_tenth_sec(3); - nValue = aThread->getValue(); // (1) - t_print(" getValue is %d !", (int) nValue ); - if (nValue >= 2) - { - aThread->setSuspend(); - //break; - } - //} - t_print(" after while!"); - // the value just after calling suspend - nValue = aThread->getValue(); // (2) - - ThreadHelper::thread_sleep_tenth_sec(3); - t_print(" after sleep!"); - // the value after waiting 3 seconds - sal_Int32 nLaterValue = aThread->getValue(); // (3) - - //resumeAndWaitThread(aThread); - aThread->resume(); - termAndJoinThread(aThread); - delete aThread; - - CPPUNIT_ASSERT_MESSAGE( - "Suspend the thread", - bRes && nValue == nLaterValue - ); - } CPPUNIT_TEST_SUITE(suspend); CPPUNIT_TEST(suspend_001); @@ -1632,13 +1545,8 @@ namespace osl_Thread } - void getCurrentIdentifier_002() - { - } - CPPUNIT_TEST_SUITE(getCurrentIdentifier); CPPUNIT_TEST(getCurrentIdentifier_001); - //CPPUNIT_TEST(getCurrentIdentifier_002); CPPUNIT_TEST_SUITE_END(); }; // class getCurrentIdentifier diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index db6d19c382ff..79e728324019 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -26,8 +26,6 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/plugin/TestPlugIn.h> -#define t_print printf - #include <osl/process.h> #include <osl/file.hxx> #include <osl/thread.h> @@ -76,17 +74,6 @@ using ::rtl::OUString; using ::rtl::OUStringToOString; using ::rtl::OString; -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - t_print("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - t_print("%s\n", aString.getStr( ) ); -} - /** get binary Path. */ inline ::rtl::OUString getExecutablePath( void ) @@ -101,211 +88,6 @@ inline ::rtl::OUString getExecutablePath( void ) //rtl::OUString CWD = getExecutablePath(); -class Test_osl_joinProcess : public CppUnit::TestFixture -{ - const OUString join_param_; - const OUString wait_time_; - OUString suCWD; - OUString suExecutableFileURL; - - rtl_uString* parameters_[2]; - int parameters_count_; - -public: - - Test_osl_joinProcess() : - join_param_(OUString("-join")), - wait_time_(OUString("1")), - parameters_count_(2) - { - parameters_[0] = join_param_.pData; - parameters_[1] = wait_time_.pData; - suCWD = getExecutablePath(); - suExecutableFileURL = suCWD; - suExecutableFileURL += rtl::OUString("/"); - suExecutableFileURL += EXECUTABLE_NAME; - } - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_TimedOut - -------------------------------------*/ - - void osl_joinProcessWithTimeout_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - TimeValue timeout; - timeout.Seconds = 1; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned without timeout failure", - osl_Process_E_TimedOut, osl_error - ); - - osl_error = osl_terminateProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_terminateProcess failed", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_None - -------------------------------------*/ - - void osl_joinProcessWithTimeout_without_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - TimeValue timeout; - timeout.Seconds = 10; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify an infinite timeout - -------------------------------------*/ - - void osl_joinProcessWithTimeout_infinite() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = osl_joinProcessWithTimeout(process, NULL); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process using osl_joinProcess - -------------------------------------*/ - - void osl_joinProcess() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = ::osl_joinProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcess returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - CPPUNIT_TEST_SUITE(Test_osl_joinProcess); - CPPUNIT_TEST(osl_joinProcessWithTimeout_timeout_failure); - CPPUNIT_TEST(osl_joinProcessWithTimeout_without_timeout_failure); - CPPUNIT_TEST(osl_joinProcessWithTimeout_infinite); - CPPUNIT_TEST(osl_joinProcess); - CPPUNIT_TEST_SUITE_END(); -}; - typedef std::vector<std::string, rtl::Allocator<std::string> > string_container_t; typedef string_container_t::const_iterator string_container_const_iter_t; typedef string_container_t::iterator string_container_iter_t; @@ -684,42 +466,6 @@ public: osl_freeProcessHandle(process); } - void osl_execProc_exe_name_in_argument_list() - { - rtl_uString* params[3]; - - params[0] = suExecutableFileURL.pData; - params[1] = env_param_.pData; - params[2] = temp_file_path_.pData; - oslProcess process; - oslProcessError osl_error = osl_executeProcess( - NULL, - params, - 3, - osl_Process_NORMAL, - NULL, - suCWD.pData, - NULL, - 0, - &process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = ::osl_joinProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcess returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - CPPUNIT_TEST_SUITE(Test_osl_executeProcess); //TODO: Repair these under windows. #ifndef WNT @@ -728,12 +474,9 @@ public: #endif CPPUNIT_TEST(osl_execProc_test_batch); ///TODO: Repair test (or tested function ;-) - test fails. - // CPPUNIT_TEST(osl_execProc_exe_name_in_argument_list); CPPUNIT_TEST_SUITE_END(); }; -// register test suites -//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_osl_joinProcess, "Test_osl_joinProcess"); CPPUNIT_TEST_SUITE_REGISTRATION(Test_osl_executeProcess); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 14e339e027ef..15089c3c5a6b 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -31,16 +31,6 @@ using namespace osl; using namespace rtl; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - //t_print("#printBool# " ); - bOk ? t_print("TRUE!\n" ): t_print("FALSE!\n" ); -} - /** print a UNI_CODE String. */ inline void printUString( const ::rtl::OUString & str ) |