[Libreoffice-commits] core.git: sal/CppunitTest_sal_osl.mk sal/qa

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 3 08:09:51 UTC 2019


 sal/CppunitTest_sal_osl.mk       |    3 +
 sal/qa/osl/file/osl_File.cxx     |   26 +++++++++-----
 sal/qa/osl/file/osl_File_Const.h |   68 +++++++++++++++++++++++----------------
 3 files changed, 60 insertions(+), 37 deletions(-)

New commits:
commit 5a77636c9a638c86fd3de3afb6e88cf48f987b6a
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Wed Nov 27 13:13:48 2019 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Dec 3 09:08:32 2019 +0100

    WIN enable osl_File.cxx part of CppUnitTest_sal_osl
    
    This just disables open::open_004 test on Windows, as this returns
    E_NOENT on Windows, but I think the assert is correct. There is
    also test-getsystempathfromfileurl.cxx, which seems to overlap?
    
    The test now uses osl::FileBase::getTempDirURL to find the system
    temporary directory, insted of hardcoded defaults.
    
    This also includes reverts the following commits:
    
    * "remove unused Exist from oslCheckMode enum"
      commit 4ca9e8fa3a040c18221c947a651469a89029282e.
    * "CppunitTest_sal_osl_file fails on Windows"
      commit 4603028bc4e2cdacd32da073a82a42ba1fc549a8
    
    Change-Id: Ib7fc4c13f8159a240d4e20c26f61d84204e4261b
    Reviewed-on: https://gerrit.libreoffice.org/83901
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/sal/CppunitTest_sal_osl.mk b/sal/CppunitTest_sal_osl.mk
index d96ab2d41483..2e4b77509f56 100644
--- a/sal/CppunitTest_sal_osl.mk
+++ b/sal/CppunitTest_sal_osl.mk
@@ -12,7 +12,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sal_osl))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sal_osl,\
 	sal/qa/osl/condition/osl_Condition \
-	$(if $(filter $(OS),WNT),,sal/qa/osl/file/osl_File) \
+	sal/qa/osl/file/osl_File \
 	sal/qa/osl/file/osl_old_test_file \
 	sal/qa/osl/file/test_cpy_wrt_file \
 	sal/qa/osl/getsystempathfromfileurl/test-getsystempathfromfileurl \
@@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sal_osl,\
 
 $(eval $(call gb_CppunitTest_use_libraries,sal_osl,\
 	sal \
+	tl \
 ))
 
 # the test uses the library created by Module_DLL
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 036f31b886a1..28f63b3055c3 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -30,6 +30,8 @@
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/plugin/TestPlugIn.h>
 
+#include <tools/urlobj.hxx>
+
 #include <memory>
 
 #ifdef _WIN32
@@ -282,6 +284,7 @@ namespace {
 /** Check for the file and directory access right.
 */
 enum class oslCheckMode {
+    Exist,
     OpenAccess,
     ReadAccess,
     WriteAccess
@@ -334,6 +337,10 @@ static bool checkDirectory(const OUString& str, oslCheckMode nCheckMode)
     {
         switch (nCheckMode)
         {
+            case oslCheckMode::Exist:
+                if (rc == ::osl::FileBase::E_None)
+                    bCheckResult = true;
+                break;
             case oslCheckMode::OpenAccess:
                 if (rc == osl::FileBase::E_None)
                     bCheckResult = true;
@@ -1086,6 +1093,7 @@ namespace osl_FileBase
          void searchFileURL_002()
         {
             /* search file is passed by system filename */
+            OUString aRootSys = INetURLObject(aTempDirectoryURL).GetLastName();
             nError1 = osl::FileBase::searchFileURL(aTempDirectorySys, aRootSys, aUStr);
             bool bOk1 = compareFileName(aUStr, aTempDirectoryURL);
             /* search file is passed by full qualified file URL */
@@ -1120,7 +1128,7 @@ namespace osl_FileBase
 
         void searchFileURL_003()
         {
-            OUString aSystemPathList(TEST_PLATFORM_ROOT ":" TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP ":" TEST_PLATFORM_ROOT "system/path");
+            OUString aSystemPathList(aRootSys + PATH_LIST_DELIMITER + aTempDirectorySys + PATH_LIST_DELIMITER + aRootSys + "system/path");
             nError1 = osl::FileBase::searchFileURL(aUserDirectoryURL, aSystemPathList, aUStr);
             bool bOk = compareFileName(aUStr, aUserDirectoryURL);
             CPPUNIT_ASSERT_EQUAL_MESSAGE("test for searchFileURL function: search directory is a list of system paths",
@@ -1131,7 +1139,7 @@ namespace osl_FileBase
 
         void searchFileURL_004()
         {
-            OUString aSystemPathList(TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name");
+            OUString aSystemPathList(aRootSys + PATH_LIST_DELIMITER + aTempDirectorySys + PATH_LIST_DELIMITER + aRootSys + "system/path/../name");
             nError1 = osl::FileBase::searchFileURL(aUserDirectoryURL, aSystemPathList, aUStr);
             bool bOk = compareFileName(aUStr, aUserDirectoryURL);
             CPPUNIT_ASSERT_EQUAL_MESSAGE("test for searchFileURL function: search directory is a list of system paths",
@@ -4134,8 +4142,10 @@ namespace osl_Directory
                 CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, nError2);
             }
 
+#ifndef _WIN32 // returns E_NOENT on Windows
             CPPUNIT_ASSERT_MESSAGE("test for open function: open a file instead of a directory",
                                      (osl::FileBase::E_NOTDIR == nError1) || (osl::FileBase::E_ACCES == nError1));
+#endif
         }
 
         CPPUNIT_TEST_SUITE(open);
@@ -4693,11 +4703,9 @@ namespace osl_Directory
             VolumeInfo aVolumeInfo(mask);
             // call getVolumeInfo here
 
-            // LLA: OUString aRootSysURL;
-            // LLA: nError1 = osl::File::getFileURLFromSystemPath(aRootSys, aRootSysURL);
-            // LLA:
-            // LLA: CPPUNIT_ASSERT_MESSAGE("can't convert root path to file url",
-            // LLA:                         (osl::FileBase::E_NONE == nError1));
+            OUString aRootSysURL;
+            nError1 = osl::File::getFileURLFromSystemPath(aRootSys, aRootSysURL);
+            CPPUNIT_ASSERT_EQUAL_MESSAGE("can't convert root path to file url", osl::FileBase::E_None, nError1);
 
             nError1 = Directory::getVolumeInfo(aRootSys, aVolumeInfo);
 
@@ -5169,11 +5177,11 @@ public:
                 deleteTestFile(aTmpName6);
             if (ifFileExist(aTmpName4) == sal_True)
                 deleteTestFile(aTmpName4);
-            if (checkDirectory(aTmpName4, osl_Check_Mode_Exist) == sal_True)
+            if (checkDirectory(aTmpName4, oslCheckMode::Exist) == sal_True)
                 deleteTestDirectory(aTmpName4);
             if (ifFileExist(aTmpName3) == sal_True)
                 deleteTestFile(aTmpName3);
-            if (checkDirectory(aTmpName3, osl_Check_Mode_Exist) == sal_True)
+            if (checkDirectory(aTmpName3, oslCheckMode::Exist) == sal_True)
                 deleteTestDirectory(aTmpName3);
 
             OUString aUStr(aUserDirectoryURL);
diff --git a/sal/qa/osl/file/osl_File_Const.h b/sal/qa/osl/file/osl_File_Const.h
index 40bb81fb807a..d1dff529dfb2 100644
--- a/sal/qa/osl/file/osl_File_Const.h
+++ b/sal/qa/osl/file/osl_File_Const.h
@@ -27,6 +27,24 @@
 
 #include <rtl/ustring.hxx>
 
+#include <cppunit/extensions/HelperMacros.h>
+
+static OUString getTempDirectoryURL_()
+{
+    OUString aDir;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("couldn't get system temp URL",
+        osl::FileBase::E_None, osl::FileBase::getTempDirURL(aDir));
+    return aDir;
+}
+
+static OUString getTempDirectorySys_()
+{
+    OUString aDir;
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("couldn't get system temp directory",
+        osl::FileBase::E_None, osl::FileBase::getSystemPathFromFileURL(getTempDirectoryURL_(), aDir));
+    return aDir;
+}
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -77,9 +95,7 @@ const sal_Char pBuffer_Blank[]  = "";
 #        include <sys/statvfs.h>
 #   endif
 #   include <sys/types.h>
-#   define TEST_PLATFORM        ""
 #   define TEST_PLATFORM_ROOT   "/"
-#   define TEST_PLATFORM_TEMP   "tmp"
 #   define PATH_LIST_DELIMITER  ":"
 #   define PATH_SEPARATOR       "/"
 #endif
@@ -87,9 +103,7 @@ const sal_Char pBuffer_Blank[]  = "";
 #if defined(_WIN32)                      // Windows
 #       include <io.h>
 #   define PATH_MAX             MAX_PATH
-#   define TEST_PLATFORM        "c:/"
 #   define TEST_PLATFORM_ROOT   "c:/"
-#   define TEST_PLATFORM_TEMP   "temp"
 #   define PATH_LIST_DELIMITER  ";"
 #   define PATH_SEPARATOR       "/"
 #endif
@@ -99,49 +113,49 @@ const sal_Char pBuffer_Blank[]  = "";
 OUString aNullURL( "" );
 OUString aSlashURL( PATH_SEPARATOR );
 OUString aPreURL( FILE_PREFIX );
-OUString aRootURL( FILE_PREFIX TEST_PLATFORM );
+OUString aRootURL( FILE_PREFIX TEST_PLATFORM_ROOT );
 
-OUString aTempDirectoryURL( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
-OUString aTempDirectorySys( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
-OUString aUserDirectoryURL( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
-OUString aUserDirectorySys( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
+OUString aTempDirectorySys(getTempDirectorySys_());
+OUString aTempDirectoryURL(getTempDirectoryURL_());
+OUString aUserDirectorySys( aTempDirectorySys + "" );
+OUString aUserDirectoryURL( aTempDirectoryURL + "" );
 
 // common used URL:temp, canonical, root, relative, link,etc
 
-OUString aCanURL1( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
+OUString aCanURL1( aTempDirectoryURL +  "/canonical.name" );
 OUString aCanURL2(
     RTL_CONSTASCII_USTRINGPARAM("ca@#;+.,$///78no\0ni..name"));
 OUString aCanURL3( "ca@#;+.,$//tmp/678nonical//name" );
 OUString aCanURL4( "canonical.name" );
 OUString aTmpName1( "tmpdir" );
 OUString aTmpName2( "tmpname" );
-OUString aTmpName3( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
-OUString aTmpName4( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
-OUString aTmpName5( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
-OUString aTmpName6( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
-OUString aTmpName7( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/noaccess" );
-OUString aTmpName8( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
-OUString aTmpName9( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
-OUString aTmpName10(RTL_CONSTASCII_USTRINGPARAM( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030" ));
+OUString aTmpName3( aTempDirectoryURL + "/tmpdir" );
+OUString aTmpName4( aTempDirectoryURL + "/tmpdir/tmpname" );
+OUString aTmpName5( aTempDirectoryURL + "/tmpdir/../tmpdir/./tmpname" );
+OUString aTmpName6( aTempDirectoryURL + "/tmpname" );
+OUString aTmpName7( aTempDirectoryURL + "/noaccess" );
+OUString aTmpName8( aTempDirectoryURL + "/tmpname/tmpdir" );
+OUString aTmpName9( aTempDirectoryURL + "/tmpdir/../tmpdir/./" );
+OUString aTmpName10(aTempDirectoryURL + "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030");
 
 OUString aRelURL1( "relative/file1" );
 OUString aRelURL2( "relative/./file2" );
 OUString aRelURL3( "relative/../file3" );
 OUString aRelURL4( "././relative/../file4" );
-OUString aRelURL5( TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
-OUString aLnkURL1( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
+OUString aRelURL5( aTempDirectoryURL + "/./../"     );
+OUString aLnkURL1( aTempDirectoryURL + "/link.file" );
 OUString aHidURL1( ".hiddenfile" );
 
 // common used System Path:temp, root,etc
 
 OUString aRootSys( TEST_PLATFORM_ROOT );
-OUString aSysPath1( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
-OUString aSysPath2( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
-OUString aSysPath3( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
-OUString aSysPath4( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
-OUString aSysPath5(RTL_CONSTASCII_USTRINGPARAM( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030" ));
-OUString aSysPathLnk( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/link.file" );
-OUString aFifoSys( TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
+OUString aSysPath1( aTempDirectorySys + "/system.path" );
+OUString aSysPath2( aTempDirectorySys + "/system/path" );
+OUString aSysPath3( aTempDirectorySys + "/tmpdir" );
+OUString aSysPath4( aTempDirectorySys + "/tmpname" );
+OUString aSysPath5( aTempDirectorySys + "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030" );
+OUString aSysPathLnk( aTempDirectorySys + "/link.file" );
+OUString aFifoSys( aTempDirectorySys + "/tmpdir/fifo" );
 
 // FileType URL, we pick some canonical file in corresponding system for test:
 // socket, link, etc.


More information about the Libreoffice-commits mailing list