LCOV - code coverage report
Current view: top level - sal/qa/osl/file - osl_File_Const.h (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 46 46 100.0 %
Date: 2014-11-03 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
      21             : #define INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
      22             : 
      23             : #include <stdlib.h>
      24             : #include <stdio.h>
      25             : #include <string.h>
      26             : #include <sal/types.h>
      27             : #include <rtl/textenc.h>
      28             : 
      29             : #include <rtl/ustring.hxx>
      30             : #include <rtl/uri.hxx>
      31             : 
      32             : #ifdef __cplusplus
      33             : extern "C"
      34             : {
      35             : #endif
      36             : 
      37             : // common used string resource
      38             : // these common used string will be used as assist resource in test
      39             : // they are mostly OS independent, some of the resource can be reused
      40             : // so, acommon test data repository will be better since it can be
      41             : // shared among all test code
      42             : 
      43             : const sal_Char pBuffer_Char[]   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
      44             : const sal_Char pBuffer_Number[] = "1234567890";
      45             : const sal_Char pBuffer_Blank[]  = "";
      46             : 
      47             : // OS dependent/independent definitions/includes
      48             : // we use FILE_PREFIX for URL prefix,
      49             : //        TEST_PLATFORM for test platform initial,
      50             : //        TEST_PLATFORM_ROOT for root dir in comrresponding platform,
      51             : //        TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
      52             : //        PATH_LIST_DELIMITER for separator of path list in comrresponding platform,
      53             : //        PATH_SEPARATOR for separator in URL or system path in comrresponding platform,
      54             : //        PATH_MAX/MAX_PATH for max path length in comrresponding platform,
      55             : 
      56             : // OS independent const definition
      57             : 
      58             : #   define FILE_PREFIX          "file:///"
      59             : #   define TEST_FILE_SIZE       1024
      60             : 
      61             : // OS dependent declaration and includes
      62             : 
      63             : #if ( defined UNX )  //Unix
      64             : #   include <unistd.h>
      65             : #   include <limits.h>
      66             : #   include <math.h>
      67             : #   include <errno.h>
      68             : #   include <fcntl.h>
      69             : #   include <sys/stat.h>
      70             : #   if !defined(MACOSX) && !defined(IOS) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined (DRAGONFLY)
      71             : #       include <sys/statfs.h>
      72             : #   else
      73             : #       include <sys/param.h>
      74             : #       include <sys/mount.h>
      75             : #   endif
      76             : #   if !defined(ANDROID)
      77             : #        include <sys/statvfs.h>
      78             : #   endif
      79             : #   include <sys/types.h>
      80             : #   define TEST_PLATFORM        ""
      81             : #   define TEST_PLATFORM_ROOT   "/"
      82             : #   define TEST_PLATFORM_TEMP   "tmp"
      83             : #   define PATH_LIST_DELIMITER  ":"
      84             : #   define PATH_SEPARATOR       "/"
      85             : #endif
      86             : 
      87             : #if (defined WNT )                      // Windows
      88             : #       include <tchar.h>
      89             : #       include <io.h>
      90             : #       include <stdio.h>
      91             : #       include <stdlib.h>
      92             : #   define PATH_MAX             MAX_PATH
      93             : #   define TEST_PLATFORM        "c:/"
      94             : #   define TEST_PLATFORM_ROOT   "c:/"
      95             : #   define TEST_PLATFORM_TEMP   "temp"
      96             : #   define PATH_LIST_DELIMITER  ";"
      97             : #   define PATH_SEPARATOR       "/"
      98             : #endif
      99             : 
     100             : // macro definition for the ASCII array/OUString declarations,
     101             : // we use p### for the ASCII array,
     102             : //        a### for the OUString,
     103             : //        n###Len for its length
     104             : 
     105             : #define OSLTEST_DECLARE( str_name, str_value ) \
     106             :     ::rtl::OUString a##str_name = rtl::OUString::createFromAscii( ( str_value ) )
     107             : 
     108             : #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
     109             :     ::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString::createFromAscii( ( str_value ) ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
     110             : 
     111             : // OS independent file definition
     112             : 
     113           2 : OSLTEST_DECLARE( NullURL,  "" );
     114           2 : OSLTEST_DECLARE( SlashURL, PATH_SEPARATOR );
     115           2 : OSLTEST_DECLARE( PreURL, FILE_PREFIX );
     116           2 : OSLTEST_DECLARE( RootURL,  FILE_PREFIX TEST_PLATFORM );
     117             : 
     118           2 : OSLTEST_DECLARE( TempDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
     119           2 : OSLTEST_DECLARE( TempDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
     120           2 : OSLTEST_DECLARE( UserDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
     121           2 : OSLTEST_DECLARE( UserDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
     122             : 
     123             : // common used URL:temp, canonical, root, relative, link,etc
     124             : 
     125           2 : OSLTEST_DECLARE( CanURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
     126           2 : OSLTEST_DECLARE( CanURL2,  "ca@#;+.,$///78no\0ni..name" );
     127           2 : OSLTEST_DECLARE( CanURL3,  "ca@#;+.,$//tmp/678nonical//name" );
     128           2 : OSLTEST_DECLARE( CanURL4,  "canonical.name" );
     129           2 : OSLTEST_DECLARE( TmpName1, "tmpdir" );
     130           2 : OSLTEST_DECLARE( TmpName2, "tmpname" );
     131           2 : OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
     132           2 : OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
     133           2 : OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
     134           2 : OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
     135           2 : OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/noaccess" );
     136           2 : OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
     137           2 : OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
     138           2 : OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
     139             : 
     140           2 : OSLTEST_DECLARE( RelURL1,  "relative/file1" );
     141           2 : OSLTEST_DECLARE( RelURL2,  "relative/./file2" );
     142           2 : OSLTEST_DECLARE( RelURL3,  "relative/../file3" );
     143           2 : OSLTEST_DECLARE( RelURL4,  "././relative/../file4" );
     144           2 : OSLTEST_DECLARE( RelURL5,  TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
     145           2 : OSLTEST_DECLARE( LnkURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
     146           2 : OSLTEST_DECLARE( HidURL1,  ".hiddenfile" );
     147             : 
     148             : // common used System Path:temp, root,etc
     149             : 
     150           2 : OSLTEST_DECLARE( RootSys,  TEST_PLATFORM_ROOT );
     151           2 : OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
     152           2 : OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
     153           2 : OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
     154           2 : OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
     155           2 : OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
     156           2 : OSLTEST_DECLARE( SysPathLnk, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/link.file" );
     157           2 : OSLTEST_DECLARE( FifoSys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
     158             : 
     159             : // FileType URL, we pick some canonical file in corresponding system for test:
     160             : // socket, link, etc.
     161             : // Note that this may be changed in the different platform, so be careful to use.
     162             : 
     163             : #if ( defined UNX )                                                    //          Unix
     164           2 : OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "dev/ccv");                    //socket    Solaris/Linux
     165           2 : OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "devices/pseudo/tcp@0:tcp");   //special   Solaris/Linux
     166           2 : OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "lib" );                       //link      Solaris
     167             : #else                                                                  //          Windows
     168             : OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "" );
     169             : OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "" );
     170             : OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "" );
     171             : #endif
     172             : 
     173             : // Volume device URL, we pick some canonical volume device for test:
     174             : // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
     175             : 
     176             : #if ( defined UNX )                                     //          Unix
     177           2 : OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "");            //ufs       Solaris/Linux
     178             : #ifdef SOLARIS
     179             : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/fd" );     //fd        Solaris
     180             : #else
     181           2 : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/floppy/0u1440" );  //fd0       Linux
     182             : #endif
     183           2 : OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "proc" );       //proc      Solaris/Linux
     184           2 : OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "staroffice" ); //nfs       Solaris/Linux
     185           2 : OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "tmp" );        //tmpfs     Solaris
     186           2 : OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "cdrom" );      //cd        Solaris
     187             : #else                                                   //          Windows
     188             : OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "c:/" );
     189             : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "a:/" );
     190             : OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "" );
     191             : OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "" );
     192             : OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "c:/temp" );
     193             : OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "e:/" );
     194             : #endif
     195             : 
     196             : #ifdef __cplusplus
     197             : }
     198             : #endif
     199             : 
     200             : #endif // INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10