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

Lubos Lunak llunak at kemper.freedesktop.org
Mon Apr 2 10:07:04 PDT 2012


 sal/qa/osl/security/osl_Security.cxx     |   94 +++++++++++++++++--------------
 sal/qa/osl/security/osl_Security_Const.h |   19 ------
 2 files changed, 55 insertions(+), 58 deletions(-)

New commits:
commit a7eb227cfcd783ffdccdcec9b56451fb54c26eb6
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Apr 2 18:59:53 2012 +0200

    fix crude command line arguments handling

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 223c5f9..92b9fe4 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -38,6 +38,7 @@
 #endif
 #include <osl_Security_Const.h>
 #include <osl/thread.h>
+#include <rtl/process.h>
 #include <rtl/strbuf.hxx>
 
 using namespace osl;
@@ -353,7 +354,7 @@ class MyTestPlugInImpl: public CPPUNIT_NS::TestPlugInDefaultImpl
 
 
 void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
-                   const CPPUNIT_NS::PlugInParameters & parameters)
+                   const CPPUNIT_NS::PlugInParameters & )
 {
     /// start message
     t_print("#Initializing ...\n" );
@@ -633,44 +634,53 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
         t_print("Administrator.\n" );
 
     /// get and display forwarded text if available.
-    aStringForward = ::rtl::OUString::createFromAscii( parameters.getCommandLine().c_str() );
-    if ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
+    rtl::OUString args[ 3 ];
+    int argsCount = 0;
+    sal_uInt32 n = rtl_getAppCommandArgCount();
+    // skip first, that's the module name
+    for (sal_uInt32 i = 1; i < n; ++i)
     {
-        sal_Int32 nFirstSpacePoint = aStringForward.indexOf( (sal_Unicode)' ' );;
-        sal_Int32 nLastSpacePoint = aStringForward.lastIndexOf( (sal_Unicode)' ' );;
-        if ( nFirstSpacePoint == nLastSpacePoint )
-        /// only forwarded two parameters, username and password.
+        rtl::OUString arg;
+        rtl_getAppCommandArg(i, &arg.pData);
+        if( !arg.isEmpty() && arg[ 0 ] == '-' )
+            continue;
+        if( argsCount >= 3 )
         {
-            aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
-            t_print("\n#Forwarded username: ");
-            printUString( aLogonUser);
-
-            aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, aStringForward.getLength( ) - 1 );
-            t_print("#Forwarded password: ");
-            for (int i = nFirstSpacePoint+1; i <= aStringForward.getLength()-1; ++i)
-                t_print("*");
-            t_print("\n" );
-        }
-        else
-        /// forwarded three parameters, username, password and fileserver.
-        {
-            aLogonUser = aStringForward.copy( 0, nFirstSpacePoint );
-            t_print("#Forwarded username: ");
-            printUString( aLogonUser);
-
-            aLogonPasswd = aStringForward.copy( nFirstSpacePoint +1, nLastSpacePoint );
-            t_print("#Forwarded password: ");
-            for (int i = nFirstSpacePoint+1; i <= nLastSpacePoint; ++i)
-                t_print("*");
-            t_print("\n" );
-
-            aFileServer = aStringForward.copy( nLastSpacePoint +1, aStringForward.getLength( ) - 1 );
-            t_print("#Forwarded FileServer: ");
-            printUString( aFileServer );
-
+            SAL_WARN( "sal", "Too many test arguments" );
+            continue;
         }
+        args[ argsCount++ ] = arg;
+    }
+    /// only forwarded two parameters, username and password.
+    if( argsCount == 2 )
+    {
+        aLogonUser = args[ 0 ];
+        t_print("\n#Forwarded username: ");
+        printUString( aLogonUser);
+
+        aLogonPasswd = args[ 1 ];
+        t_print("#Forwarded password: ");
+        for (int i = 0; i < aLogonPasswd.getLength(); ++i)
+            t_print("*");
+        t_print("\n" );
+    }
+    else if( argsCount == 3 )
+    /// forwarded three parameters, username, password and fileserver.
+    {
+        aLogonUser = args[ 0 ];
+        t_print("#Forwarded username: ");
+        printUString( aLogonUser);
+
+        aLogonPasswd = args[ 1 ];
+        t_print("#Forwarded password: ");
+        for (int i = 0; i < aLogonPasswd.getLength(); ++i)
+            t_print("*");
+        t_print("\n" );
+
+        aFileServer = args[ 2 ];
+        t_print("#Forwarded FileServer: ");
+        printUString( aFileServer );
     }
-
     t_print("#\n#Initialization Done.\n" );
 
 }
commit 174a1d3c3da7457884a2f79016e8a9375fd5297e
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Apr 2 18:41:12 2012 +0200

    fix very ... uhm ... inventive and confusing use of empty string

diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx
index 4a0a1a9..223c5f9 100644
--- a/sal/qa/osl/security/osl_Security.cxx
+++ b/sal/qa/osl/security/osl_Security.cxx
@@ -129,12 +129,12 @@ namespace osl_Security
 
 
         SAL_CPPUNIT_TEST_SUITE( logonUser );
-        if  ( !aStringForward.equals( aNullUrl )  && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) ==  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
+        if  ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) ==  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
         /// if user name and passwd are forwarded
         {
             CPPUNIT_TEST( logonUser_user_pwd );
         }
-        if  ( !aStringForward.equals( aNullUrl )  && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) !=  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
+        if  ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 && ( aStringForward.indexOf( ( sal_Unicode ) ' ' ) !=  aStringForward.lastIndexOf( ( sal_Unicode ) ' ' ) ) )
         /// if user name and passwd and file server are forwarded
         {
             CPPUNIT_TEST( logonUser_user_pwd_server );
@@ -597,31 +597,31 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
     t_print("#\n#Retrived system information is below:\n");
 
     t_print("Computer Name:              ");
-    if ( strComputerName == aNullUrl )
+    if ( strComputerName.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strComputerName );
 
     t_print("Current User Name:          ");
-    if ( strUserName == aNullUrl )
+    if ( strUserName.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strUserName );
 
     t_print("Current User Home Directory:");
-    if ( strHomeDirectory == aNullUrl )
+    if ( strHomeDirectory.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strHomeDirectory );
 
     t_print("Current Config Directory:   ");
-    if ( strConfigDirectory == aNullUrl )
+    if ( strConfigDirectory.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strConfigDirectory );
 
     t_print("Current UserID:             ");
-    if ( strUserID == aNullUrl )
+    if ( strUserID.isEmpty())
         t_print("Not retrived\n" );
     else
         printUString( strUserID );
@@ -634,7 +634,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *,
 
     /// get and display forwarded text if available.
     aStringForward = ::rtl::OUString::createFromAscii( parameters.getCommandLine().c_str() );
-    if ( !aStringForward.equals( aNullUrl ) && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
+    if ( !aStringForward.isEmpty() && aStringForward.indexOf( (sal_Unicode)' ' ) != -1 )
     {
         sal_Int32 nFirstSpacePoint = aStringForward.indexOf( (sal_Unicode)' ' );;
         sal_Int32 nLastSpacePoint = aStringForward.lastIndexOf( (sal_Unicode)' ' );;
diff --git a/sal/qa/osl/security/osl_Security_Const.h b/sal/qa/osl/security/osl_Security_Const.h
index 0c3a242..4eca51c 100644
--- a/sal/qa/osl/security/osl_Security_Const.h
+++ b/sal/qa/osl/security/osl_Security_Const.h
@@ -59,22 +59,9 @@
 #define BUFSIZE 1024
 const char pTestString[17] = "Sun Microsystems";
 
-
-#define OSLTEST_DECLARE_USTRING( str_name, str_value ) \
-    ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( str_value )
-
-//------------------------------------------------------------------------
-// condition names
-//------------------------------------------------------------------------
-
-// Intentionally different from the aNullURL in osl_File_Const.h to avoid
-// duplicate symbols as all the unit tests here get linked together for iOS...
-
-OSLTEST_DECLARE_USTRING( NullUrl,  "" );
-
-::rtl::OUString aLogonUser( aNullUrl ), aLogonPasswd( aNullUrl ), aFileServer( aNullUrl ), aStringForward( aNullUrl );
-::rtl::OUString strUserName( aNullUrl ) , strComputerName( aNullUrl ) , strHomeDirectory( aNullUrl );
-::rtl::OUString strConfigDirectory( aNullUrl ), strUserID( aNullUrl );
+::rtl::OUString aLogonUser, aLogonPasswd, aFileServer, aStringForward;
+::rtl::OUString strUserName, strComputerName, strHomeDirectory;
+::rtl::OUString strConfigDirectory, strUserID;
 
 sal_Bool isAdmin = sal_False;
 


More information about the Libreoffice-commits mailing list