[Libreoffice-commits] .: 2 commits - sal/qa

Caolán McNamara caolan at kemper.freedesktop.org
Wed Feb 9 02:31:20 PST 2011


 sal/qa/osl/condition/osl_Condition.cxx |   37 +-------
 sal/qa/osl/file/osl_File.cxx           |  151 ---------------------------------
 sal/qa/osl/module/osl_Module.cxx       |   13 --
 3 files changed, 9 insertions(+), 192 deletions(-)

New commits:
commit b3907ed6534f2b9f2cf751933039b3c56e01ef73
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 9 10:17:54 2011 +0000

    don't try and remove /tmp

diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index cee96da..52fce31 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -48,14 +48,6 @@
 #include <cppunit/plugin/TestPlugIn.h>
 #include "postextstl.h"
 
-// #ifdef WNT
-// #   define UNICODE
-// #	define WIN32_LEAN_AND_MEAN
-// #	include <windows.h>
-// #   include <tchar.h>
-// #endif
-
-
 using namespace osl;
 using namespace rtl;
 
@@ -940,38 +932,6 @@ namespace osl_FileBase
     };// class SystemPath_FileURL
 
 
-    // test code.
-
-  /*    void getSystemPathFromFileURL::check_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr)
-    {
-        // PRE: URL as String
-        rtl::OUString suURL;
-        rtl::OUString suStr;
-        suURL = rtl::OStringToOUString(_sURL, RTL_TEXTENCODING_UTF8);
-        ::osl::FileBase::RC nError =  osl::FileBase::getSystemPathFromFileURL( suURL, suStr ); // start with /
-
-        // if the given string is gt length 0,
-        // we check also this string
-        rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
-        rtl::OString sError = errorToString(nError);
-        printf("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sURL.getStr(), sStr.getStr(), sError.getStr() );
-
-        // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
-        // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
-        // printf("UTF8: %s\n", sStr.getStr() );
-
-        if (_sAssumeResultStr.getLength() > 0)
-        {
-            sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr);
-            CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong",
-                                    nError == _nAssumeError && bStrAreEqual == sal_True );
-        }
-        else
-        {
-            CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError );
-        }
-    }*/
-
     // if bDirection==sal_True, check getSystemPathFromFileURL
     // if bDirection==sal_False, check getFileURLFromSystemPath
     void SystemPath_FileURL::check_SystemPath_FileURL(rtl::OString const& _sSource, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr, sal_Bool bDirection)
@@ -6277,84 +6237,6 @@ inline ::rtl::OUString getCurrentPID(  )
 }
 
 
-/** Insert Current PID to the URL to avoid access violation between multiuser execution.
-*/
-inline void insertPID( ::rtl::OUString & pathname )
-{
-    //~ check if the path contain the temp directory, do nothing changes if not;
-    if ( pathname.indexOf( aTempDirectoryURL ) && pathname.indexOf( aTempDirectorySys ) )
-        return;
-
-    //~ format pathname to TEMP/USERPID/URL style;
-    if ( !pathname.indexOf( aTempDirectoryURL ) )
-    {
-        ::rtl::OUString strPID( getCurrentPID( ) );
-        ::rtl::OUString pathLeft = aTempDirectoryURL.copy( 0 );
-        ::rtl::OUString pathRight = pathname.copy( aTempDirectoryURL.getLength( ) );
-        pathname = pathLeft.copy( 0 );
-        ( ( pathname += aSlashURL ) += strPID ) += pathRight;
-    }
-    else
-    {
-        ::rtl::OUString strPID( getCurrentPID( ) );
-        ::rtl::OUString pathLeft = aTempDirectorySys.copy( 0 );
-        ::rtl::OUString pathRight = pathname.copy( aTempDirectorySys.getLength( ) );
-        pathname = pathLeft.copy( 0 );
-        ( ( pathname += aSlashURL ) += strPID ) += pathRight;
-    }
-
-
-}
-
-#if 0
-/** to do some initialized work, we replace the NOADDITIONAL macro with the initialize work which
-      will check the file and directory existence. and set some variables for test use.
-      to simplify the initialize work, we seperate it into UNIX section and Windows section, the main task
-      of initialization is adapt all URL defined in osl_File_Const.h to TEMP/USERPID/URL style format,
-      since there may be an instance that multiuser execute test at the same time, and the temp file
-      may not be clean up in this case due to access right problem.
-*/
-void RegisterAdditionalFunctions( FktRegFuncPtr _pFunc )
-{
-    (void)_pFunc;
-    printf( "Initializing..." );
-
-    //~ make sure the c:\temp exist, if not, create it.
-#if ( defined WNT )
-    if ( checkDirectory( aTempDirectoryURL, osl_Check_Mode_Exist )  != sal_True ) {
-        printf( "\n#C:\\temp is not exist, now creating\n" );
-        createTestDirectory( aTempDirectoryURL );
-    };
-#endif
-
-    //~ make sure the c:\temp\PID or /tmp/PID exist, if not, create it. initialize the user directory.
-    ( aUserDirectoryURL += aSlashURL ) += getCurrentPID( );
-    ( aUserDirectorySys += aSlashURL ) += getCurrentPID( );
-
-    if ( checkDirectory( aUserDirectoryURL, osl_Check_Mode_Exist )  != sal_True ) {
-        createTestDirectory( aUserDirectoryURL );
-    }
-
-    //~ adapt all URL to the TEMP/USERPID/URL format;
-    insertPID( aCanURL1 );
-    insertPID( aTmpName3 );
-    insertPID( aTmpName4 );
-    insertPID( aTmpName5 );
-    insertPID( aTmpName6 );
-    insertPID( aTmpName8 );
-    insertPID( aTmpName9 );
-    insertPID( aLnkURL1 );
-    insertPID( aFifoSys );
-    insertPID( aSysPath1 );
-    insertPID( aSysPath2 );
-    insertPID( aSysPath3 );
-    insertPID( aSysPath4 );
-
-    printf( "Done.\n" );
-
-}
-#endif
-
 //~ do some clean up work after all test completed.
 class GlobalObject
 {
@@ -6363,13 +6245,6 @@ class GlobalObject
     {
         try
         {
-            //~ make sure the c:\temp\PID or /tmp/PID exist, if yes, delete it.
-            printf( "\n#Do some clean-ups ...\n" );
-            if ( checkDirectory( aUserDirectoryURL, osl_Check_Mode_Exist )  == sal_True ) {
-                deleteTestDirectory( aUserDirectoryURL );
-            }
-
-            // LLA: printf("after deleteTestDirectory\n");
             //~ special clean up task in Windows and Unix seperately;
 #if ( defined UNX ) || ( defined OS2 )
             //~ some clean up task  for UNIX OS
commit 5adf52a6ba3dddbf08f82e2f44f46b14b13c242c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Feb 9 09:17:04 2011 +0000

    quieten and quicken some of these tests

diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx
index 00f81b3..3d1036e 100644
--- a/sal/qa/osl/condition/osl_Condition.cxx
+++ b/sal/qa/osl/condition/osl_Condition.cxx
@@ -62,23 +62,6 @@ inline void printUString( const ::rtl::OUString & str )
     printf("%s\n", aString.getStr( ) );
 }
 
-/** wait _nSec seconds.
-*/
-void thread_sleep( sal_Int32 _nSec )
-{
-    /// print statement in thread process must use fflush() to force display.
-    printf("# wait %d seconds. ", (int) _nSec );
-    fflush( stdout );
-    
-#ifdef WNT                               //Windows
-    Sleep( _nSec * 1000 );
-#endif
-#if ( defined UNX ) || ( defined OS2 )   //Unix
-    sleep( _nSec );
-#endif
-    printf("# done\n" );
-}
-
 enum ConditionType
 {
     thread_type_set,
@@ -189,11 +172,10 @@ namespace osl_Condition
             
             ConditionThread myThread2( aCond, thread_type_set );
             myThread2.create();
-            thread_sleep(1);
-            bRes1 = myThread1.isRunning( );
-            bRes2 = aCond.check( );
             
             myThread1.join( );
+            bRes1 = myThread1.isRunning( );
+            bRes2 = aCond.check( );
             myThread2.join( );
         
             CPPUNIT_ASSERT_MESSAGE( "#test comment#: use one thread to set the condition in order to release another thread.", 
@@ -284,15 +266,14 @@ namespace osl_Condition
             cond1.set();
             cond2.set();
         
-osl::Condition::Result r1=cond1.wait(tv1);
-osl::Condition::Result r2=cond2.wait();
-osl::Condition::Result r3=cond3.wait(tv1);
-fprintf(stderr,"%d %d %d\n",r1,r2,r3);
+            osl::Condition::Result r1=cond1.wait(tv1);
+            osl::Condition::Result r2=cond2.wait();
+            osl::Condition::Result r3=cond3.wait(tv1);
+
             CPPUNIT_ASSERT_MESSAGE( "#test comment#: test three types of wait.", 
-                                    (cond1.wait(tv1) == ::osl::Condition::result_ok) &&
-                                    (cond2.wait() == ::osl::Condition::result_ok) &&
-                                    (cond3.wait(tv1) == ::osl::Condition::result_timeout) );
-            
+                                    (r1 == ::osl::Condition::result_ok) &&
+                                    (r2 == ::osl::Condition::result_ok) &&
+                                    (r3 == ::osl::Condition::result_timeout) );
         }
     
         void wait_002( )
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 85d31b9..cee96da 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -180,25 +180,6 @@ inline void printFileAttributes( const sal_Int64 nAttributes )
     printf( ") file!\n" );
 }
 
-/** print a UNI_CODE file name.
-*/
-inline void printFileName( const ::rtl::OUString & str )
-{
-    rtl::OString aString;
-
-    printf( "#printFileName_u# " );
-    aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
-    printf( "%s\n", aString.getStr( ) );
-}
-
-/** print a ASCII_CODE file name.
-*/
-inline void printFileName( const sal_Char * str )
-{
-    printf( "#printFileName_a# " );
-    printf( "%s\n", str );
-}
-
 /** print an output wrong message.
 */
 inline void printError( const ::osl::FileBase::RC nError )
@@ -465,10 +446,8 @@ inline void createTestDirectory( const ::rtl::OUString basename, const ::rtl::OU
 */
 inline void deleteTestDirectory( const ::rtl::OUString dirname )
 {
-    // LLA: printf("deleteTestDirectory\n");
     ::rtl::OUString     aPathURL   = dirname.copy( 0 );
     ::osl::FileBase::RC nError;
-    // LLA: printFileName(aPathURL);
     if ( !isURL( dirname ) )
         ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL
 
@@ -1482,7 +1461,6 @@ namespace osl_FileBase
         {
             nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL );
             ::osl::File testFile( *pUStr_FileURL );
-            //printFileName(*pUStr_FileURL);
             nError2 = testFile.open( osl_File_OpenFlag_Create );
             if ( osl::FileBase::E_EXIST == nError2 )  {
                 osl_closeFile( *pHandle );
@@ -2678,7 +2656,6 @@ namespace osl_FileStatus
                     sal_uInt32 mask_link = FileStatusMask_FileName | FileStatusMask_LinkTargetURL;
                     ::osl::FileStatus   rFileStatus( mask_link );
                     rItem_link.getFileStatus( rFileStatus );
-                    //printFileName( rFileStatus.getFileName( ) );
                     if ( compareFileName( rFileStatus.getFileName( ), aFileName) == sal_True )
                     {
                         //printf("find the link file");
@@ -2754,7 +2731,6 @@ namespace osl_FileStatus
             //        use $ROOT/staroffice as volume ---> use dev/fd as volume.
             // and get their directory item.
             createTestDirectory( aTmpName3 );
-            //printFileName( aTmpName2);
             createTestFile( aTmpName3, aTmpName2 );
             createTestDirectory( aTmpName3, aTmpName1 );
 
@@ -3023,7 +2999,6 @@ namespace osl_FileStatus
         {
             ::rtl::OUString aUserHiddenFileURL (RTL_CONSTASCII_USTRINGPARAM("file:///c:/AUTOEXEC.BAT"));
             nError = ::osl::DirectoryItem::get( aUserHiddenFileURL, rItem_hidden );
-            //printFileName( aUserHiddenFileURL );
             CPPUNIT_ASSERT_MESSAGE("get item fail", nError == FileBase::E_None );
               ::osl::FileStatus   rFileStatus( FileStatusMask_Attributes );
             nError = rItem_hidden.getFileStatus( rFileStatus );
@@ -4491,7 +4466,6 @@ namespace osl_File
         createTestDirectory( aTmpName8 );
         //move directory $TEMP/tmpname to $TEMP/tmpname/tmpdir/tmpname
         rtl::OUString newName = aTmpName8 + OUString(RTL_CONSTASCII_USTRINGPARAM("/tmpname"));
-        //printFileName( newName );
         nError1 = ::osl::File::move( aTmpName3, newName );
         //deleteTestDirectory( newName + OUString(RTL_CONSTASCII_USTRINGPARAM("/tmpname")) );
         //deleteTestDirectory( newName );
diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx
index 84c077d..914d678 100644
--- a/sal/qa/osl/module/osl_Module.cxx
+++ b/sal/qa/osl/module/osl_Module.cxx
@@ -80,17 +80,6 @@ inline ::rtl::OUString getDllURL( void )
     return dllPath;
 }
 
-/** print a UNI_CODE file name.
-*/
-inline void printFileName( const ::rtl::OUString & str )
-{
-    rtl::OString aString;
-
-    printf("#printFileName_u# " );
-    aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
-    printf("%s\n", aString.getStr( ) );
-}
-
 inline sal_Bool isURL( const ::rtl::OUString pathname )
 {
     ::rtl::OUString aPreURL( RTL_CONSTASCII_USTRINGPARAM("file:///") );
@@ -507,8 +496,6 @@ namespace osl_Module
             ::rtl::OUString aLibraryURL;
             bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL);
             aMod.unload();
-            printFileName( aLibraryURL );
-
             CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.",
                  sal_True == bRes && aLibraryURL.equalsIgnoreAsciiCase( getDllURL() ) );
 #endif


More information about the Libreoffice-commits mailing list