LCOV - code coverage report
Current view: top level - sal/qa/osl/file - osl_File_Const.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 47 47 100.0 %
Date: 2015-06-13 12:38:46 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( ( str_value ) )
     107             : 
     108             : #define OSLTEST_DECLARE_UTF8(str_name, str_value ) \
     109             :     ::rtl::OUString a##str_name = ::rtl::Uri::decode( ::rtl::OUString( str_value ), rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)
     110             : 
     111             : // OS independent file definition
     112             : 
     113           1 : OSLTEST_DECLARE( NullURL,  "" );
     114           1 : OSLTEST_DECLARE( SlashURL, PATH_SEPARATOR );
     115           1 : OSLTEST_DECLARE( PreURL, FILE_PREFIX );
     116           1 : OSLTEST_DECLARE( RootURL,  FILE_PREFIX TEST_PLATFORM );
     117             : 
     118           1 : OSLTEST_DECLARE( TempDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP );
     119           1 : OSLTEST_DECLARE( TempDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP );
     120           1 : OSLTEST_DECLARE( UserDirectoryURL,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "" );
     121           1 : OSLTEST_DECLARE( UserDirectorySys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "" );
     122             : 
     123             : // common used URL:temp, canonical, root, relative, link,etc
     124             : 
     125           1 : OSLTEST_DECLARE( CanURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/canonical.name" );
     126           1 : rtl::OUString aCanURL2(
     127           1 :     RTL_CONSTASCII_USTRINGPARAM("ca@#;+.,$///78no\0ni..name"));
     128           1 : OSLTEST_DECLARE( CanURL3,  "ca@#;+.,$//tmp/678nonical//name" );
     129           1 : OSLTEST_DECLARE( CanURL4,  "canonical.name" );
     130           1 : OSLTEST_DECLARE( TmpName1, "tmpdir" );
     131           1 : OSLTEST_DECLARE( TmpName2, "tmpname" );
     132           1 : OSLTEST_DECLARE( TmpName3, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir" );
     133           1 : OSLTEST_DECLARE( TmpName4, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/tmpname" );
     134           1 : OSLTEST_DECLARE( TmpName5, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./tmpname" );
     135           1 : OSLTEST_DECLARE( TmpName6, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname" );
     136           1 : OSLTEST_DECLARE( TmpName7, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/noaccess" );
     137           1 : OSLTEST_DECLARE( TmpName8, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpname/tmpdir" );
     138           1 : OSLTEST_DECLARE( TmpName9, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/tmpdir/../tmpdir/./" );
     139           1 : OSLTEST_DECLARE_UTF8( TmpName10, FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
     140             : 
     141           1 : OSLTEST_DECLARE( RelURL1,  "relative/file1" );
     142           1 : OSLTEST_DECLARE( RelURL2,  "relative/./file2" );
     143           1 : OSLTEST_DECLARE( RelURL3,  "relative/../file3" );
     144           1 : OSLTEST_DECLARE( RelURL4,  "././relative/../file4" );
     145           1 : OSLTEST_DECLARE( RelURL5,  TEST_PLATFORM_TEMP "/./../" TEST_PLATFORM_TEMP );
     146           1 : OSLTEST_DECLARE( LnkURL1,  FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/link.file" );
     147           1 : OSLTEST_DECLARE( HidURL1,  ".hiddenfile" );
     148             : 
     149             : // common used System Path:temp, root,etc
     150             : 
     151           1 : OSLTEST_DECLARE( RootSys,  TEST_PLATFORM_ROOT );
     152           1 : OSLTEST_DECLARE( SysPath1, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system.path" );
     153           1 : OSLTEST_DECLARE( SysPath2, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/system/path" );
     154           1 : OSLTEST_DECLARE( SysPath3, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir" );
     155           1 : OSLTEST_DECLARE( SysPath4, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpname" );
     156           1 : OSLTEST_DECLARE_UTF8( SysPath5, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030" );
     157           1 : OSLTEST_DECLARE( SysPathLnk, TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/link.file" );
     158           1 : OSLTEST_DECLARE( FifoSys,  TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP "/tmpdir/fifo" );
     159             : 
     160             : // FileType URL, we pick some canonical file in corresponding system for test:
     161             : // socket, link, etc.
     162             : // Note that this may be changed in the different platform, so be careful to use.
     163             : 
     164             : #if ( defined UNX )                                                    //          Unix
     165           1 : OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "dev/ccv");                    //socket    Solaris/Linux
     166           1 : OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "devices/pseudo/tcp@0:tcp");   //special   Solaris/Linux
     167           1 : OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "lib" );                       //link      Solaris
     168             : #else                                                                  //          Windows
     169             : OSLTEST_DECLARE( TypeURL1,  FILE_PREFIX "" );
     170             : OSLTEST_DECLARE( TypeURL2,  FILE_PREFIX "" );
     171             : OSLTEST_DECLARE( TypeURL3,  FILE_PREFIX "" );
     172             : #endif
     173             : 
     174             : // Volume device URL, we pick some canonical volume device for test:
     175             : // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
     176             : 
     177             : #if ( defined UNX )                                     //          Unix
     178           1 : OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "");            //ufs       Solaris/Linux
     179             : #ifdef SOLARIS
     180             : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/fd" );     //fd        Solaris
     181             : #else
     182           1 : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "dev/floppy/0u1440" );  //fd0       Linux
     183             : #endif
     184           1 : OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "proc" );       //proc      Solaris/Linux
     185           1 : OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "staroffice" ); //nfs       Solaris/Linux
     186           1 : OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "tmp" );        //tmpfs     Solaris
     187           1 : OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "cdrom" );      //cd        Solaris
     188             : #else                                                   //          Windows
     189             : OSLTEST_DECLARE( VolURL1,  FILE_PREFIX  "c:/" );
     190             : OSLTEST_DECLARE( VolURL2,  FILE_PREFIX  "a:/" );
     191             : OSLTEST_DECLARE( VolURL3,  FILE_PREFIX  "" );
     192             : OSLTEST_DECLARE( VolURL4,  FILE_PREFIX  "" );
     193             : OSLTEST_DECLARE( VolURL5,  FILE_PREFIX  "c:/temp" );
     194             : OSLTEST_DECLARE( VolURL6,  FILE_PREFIX  "e:/" );
     195             : #endif
     196             : 
     197             : #ifdef __cplusplus
     198             : }
     199             : #endif
     200             : 
     201             : #endif // INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11