Changeset 3376

Show
Ignore:
Timestamp:
06/19/08 09:23:51 (3 months ago)
Author:
JimLi
Message:

Add file helper functions for testing. This should replace ugly
system() call to improve the portability of the testsuite.
Also deal with the situation which the name of GNU diff is gdiff
in Solaris

osync_bool osync_testing_file_copy(const char *source, const char *dest)
osync_bool osync_testing_diff(const char *file1, const char *file2)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CMakeLists.txt

    r3346 r3376  
    5454ENDIF ( CHECK_FOUND AND OPENSYNC_UNITTESTS ) 
    5555 
     56IF ( CMAKE_SYSTEM_NAME MATCHES SunOS ) 
     57        SET( HAVE_SOLARIS 1 ) 
     58ENDIF (CMAKE_SYSTEM_NAME MATCHES SunOS ) 
     59 
    5660##############################################  
    5761 
  • trunk/config.h.cmake

    r3143 r3376  
    2020 
    2121#cmakedefine HAVE_FLOCK 
     22#cmakedefine HAVE_SOLARIS 
    2223 
    2324#define OPENSYNC_TESTDATA "${CMAKE_CURRENT_SOURCE_DIR}/tests/data" 
  • trunk/tests/support.c

    r3354 r3376  
    621621} 
    622622 
     623/*! @brief Copy files 
     624 * 
     625 * @param source source filename 
     626 * @param dest destination filename 
     627 * @returns TRUE on success, FALSE otherwise 
     628 * 
     629 */ 
     630osync_bool osync_testing_file_copy(const char *source, const char *dest) 
     631{ 
     632        gchar *cmd; 
     633        int ret; 
     634 
     635        cmd = g_strdup_printf("cp %s %s", source, dest); 
     636        ret = system(cmd); 
     637        g_free(cmd); 
     638 
     639        return ret; 
     640} 
     641 
     642/*! @brief Find differences between two files 
     643 * 
     644 * @param source source filename 
     645 * @param dest destination filename 
     646 * @returns TRUE on success, FALSE otherwise 
     647 * 
     648 */ 
     649osync_bool osync_testing_diff(const char *file1, const char *file2) 
     650{ 
     651        gchar *cmd; 
     652        int ret; 
     653 
     654        cmd = g_strdup_printf("test \"x`(" DIFF " -x \".*\" %s %s)`\" = \"x\"", file1, file2); 
     655        ret = system(cmd); 
     656        g_free(cmd); 
     657 
     658        return ret; 
     659} 
     660 
    623661/*! @brief Creates a simple OSyncPluginConfig with a single resource. 
    624662 *         If config is not null the ressource information gets added. 
  • trunk/tests/support.h

    r3354 r3376  
    9292osync_bool osync_testing_file_remove(const char *file); 
    9393osync_bool osync_testing_file_chmod(const char *file, int mode); 
     94osync_bool osync_testing_file_copy(const char *source, const char *dest); 
     95osync_bool osync_testing_diff(const char *file1, const char *file2); 
    9496 
    9597/* Plugin config helper */ 
    9698OSyncPluginConfig *simple_plugin_config(OSyncPluginConfig *config, const char *path, const char *objformat, const char *format_config); 
    9799 
     100/* gdiff is GNU diff in Solaris */ 
     101#ifdef HAVE_SOLARIS 
     102#define DIFF "gdiff" 
     103#else 
     104#define DIFF "diff" 
     105#endif 
     106