From: <svn...@op...> - 2009-04-01 21:58:02
|
Author: scriptor Date: Wed Apr 1 23:57:55 2009 New Revision: 5511 URL: http://www.opensync.org/changeset/5511 Log: Further tests. Added: plugins/ldap-sync/tests/check_osynctool_add_file_and_slowsync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_ldif_and_slowsync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_slowsync (contents, props changed) plugins/ldap-sync/tests/contact1.xml_modified plugins/ldap-sync/tests/contact2.xml_modified plugins/ldap-sync/tests/event1.xml_modified plugins/ldap-sync/tests/note1.xml_modified plugins/ldap-sync/tests/note2.xml_modified plugins/ldap-sync/tests/todo1.xml_modified Modified: plugins/ldap-sync/tests/CMakeLists.txt plugins/ldap-sync/tests/check_osynctool_common.inc plugins/ldap-sync/tests/contact1.xml plugins/ldap-sync/tests/test.conf Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Wed Apr 1 23:56:44 2009 (r5510) +++ plugins/ldap-sync/tests/CMakeLists.txt Wed Apr 1 23:57:55 2009 (r5511) @@ -271,7 +271,7 @@ # present, the script removes them. # Otherwise the first test trying to add an already exising DN will fail # just because of "Already exists (68)" error. -ADD_TEST( remove_test_ldifs ${TESTDIR}/remove_test_ldifs ) +ADD_TEST( remove_test_ldifs1 ${TESTDIR}/remove_test_ldifs ) IF (LDAPADD_EXECUTABLE) @@ -451,26 +451,46 @@ IF (LDAPMODIFY_EXECUTABLE) IF (LDAPDELETE_EXECUTABLE) - ADD_TEST( osynctool_add_contact1_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.ldif" ) + ADD_TEST( osynctool_add_contact1_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.ldif" ) - #ADD_TEST( osynctool_add_contact2_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.ldif" ) + #ADD_TEST( osynctool_add_contact2_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.ldif" ) - ADD_TEST( osynctool_add_event_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.ldif" ) + ADD_TEST( osynctool_add_event_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.ldif" ) - ADD_TEST( osynctool_add_todo_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.ldif" ) + ADD_TEST( osynctool_add_todo_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.ldif" ) - ADD_TEST( osynctool_add_note_ldif ${TESTDIR}/check_osynctool_add_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.ldif" ) + ADD_TEST( osynctool_add_note_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.ldif" ) - ADD_TEST( osynctool_add_contact1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" ) + ADD_TEST( osynctool_add_contact1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" ) - ADD_TEST( osynctool_add_contact2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" ) + ADD_TEST( osynctool_add_contact2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" ) - ADD_TEST( osynctool_add_event_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.xml" ) + ADD_TEST( osynctool_add_event_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.xml" ) - ADD_TEST( osynctool_add_todo_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.xml" ) + ADD_TEST( osynctool_add_todo_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.xml" ) - ADD_TEST( osynctool_add_note_xmlfile ${TESTDIR}/check_osynctool_add_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.xml" ) + ADD_TEST( osynctool_add_note1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.xml" ) + + ADD_TEST( osynctool_add_note2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note2.xml" ) + + + + ADD_TEST( remove_test_ldifs2 ${TESTDIR}/remove_test_ldifs ) + + + + ADD_TEST( osynctool_add_modify_delete_contact1_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" "${TESTDIR}/contact1.xml_modified" ) + + ADD_TEST( osynctool_add_modify_delete_contact2_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" "${TESTDIR}/contact2.xml_modified" ) + + ADD_TEST( osynctool_add_modify_delete_event_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" "${TESTDIR}/event1.xml" "${TESTDIR}/event1.xml_modified" ) + + ADD_TEST( osynctool_add_modify_delete_todo_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" "${TESTDIR}/todo1.xml" "${TESTDIR}/todo1.xml_modified" ) + + ADD_TEST( osynctool_add_modify_delete_note1_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.xml" "${TESTDIR}/note1.xml_modified" ) + + ADD_TEST( osynctool_add_modify_delete_note2_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note2.xml" "${TESTDIR}/note2.xml_modified" ) ENDIF (LDAPDELETE_EXECUTABLE) Added: plugins/ldap-sync/tests/check_osynctool_add_file_and_slowsync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_file_and_slowsync Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,108 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +XMLFILE="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + if test ! -d "$TRACE_FILES"; then + mkdir -p "$TRACE_FILES" + fi + export OSYNC_TRACE="$TRACE_FILES" +fi + + +if test -z "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add XML file +add_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_ldif_and_slowsync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_ldif_and_slowsync Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,108 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +LDIF="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + if test ! -d "$TRACE_FILES"; then + mkdir -p "$TRACE_FILES" + fi + export OSYNC_TRACE="$TRACE_FILES" +fi + +if test -z "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \$LDIF is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +run_ldapadd "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_slowsync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_ldif_and_valgrind_and_slowsync Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,115 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +LDIF="$4" + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + if test ! -d "$TRACE_FILES"; then + mkdir -p "$TRACE_FILES" + fi + export OSYNC_TRACE="$TRACE_FILES" +fi + +if test -z "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \$LDIF is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$VALGRIND"; then + echo "$FILE:$LINENO: ERROR: \$VALGRIND is empty. Exiting."; + exit 1; +fi + + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + +# Add *.ldif +run_ldapadd "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +# osynctool should synchronize only one particular object type: +enable_only "$OBJECTTYPE" + +# Trigger synchronization +valgrind_slow_sync "$OBJECTTYPE" +rv=$? + +# Shut down test group +epilogue + + +exit $rv Modified: plugins/ldap-sync/tests/check_osynctool_common.inc ============================================================================== --- plugins/ldap-sync/tests/check_osynctool_common.inc Wed Apr 1 23:56:44 2009 (r5510) +++ plugins/ldap-sync/tests/check_osynctool_common.inc Wed Apr 1 23:57:55 2009 (r5511) @@ -1,4 +1,4 @@ -GROUPNAME="sync_test_group" +# GROUPNAME="sync_test_group" check_plugin_available() { @@ -573,7 +573,6 @@ rm -f "$CONTACT1_FILE"; fi - if test -z "$CONTACT2_FILE"; then echo "${FUNCNAME}(): ERROR: \$CONTACT2_FILE is empty. Ignoring." elif test -f "$CONTACT2_FILE"; then @@ -678,6 +677,148 @@ if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting." + exit 1 + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + if test -z "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \$xmlfile is empty. Exiting." + exit 1 + fi + + if test ! -f "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \"$xmlfile\" could not be found. Exiting." + exit 1 + fi + + if test ! -r "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \"$xmlfile\" could be found, but it is not readable. Exiting." + exit 1 + fi + + + + + if test "$objtype" == "contact"; then + cp -f "$xmlfile" $CONTACT1_FILE + + elif test "$objtype" == "event"; then + cp -f "$xmlfile" $EVENT1_FILE + + elif test "$objtype" == "todo"; then + cp -f "$xmlfile" $TODO1_FILE + + elif test "$objtype" == "note"; then + cp -f "$xmlfile" $NOTE1_FILE + + fi +} + + + + + + + +check_presence_of_file() +{ + objtype="$1" + xmlfile="$2" + + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting." + exit 1 + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + if test -z "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \$xmlfile is empty. Exiting." + exit 1 + fi + + if test ! -f "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \"$xmlfile\" could not be found. Exiting." + exit 1 + fi + + if test ! -r "$xmlfile"; then + echo "${FUNCNAME}(): ERROR: \"$xmlfile\" could be found, but it is not readable. Exiting." + exit 1 + fi + + + + if test "$objtype" == "contact"; then + if test ! -f "$CONTACT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$CONTACT1_FILE\" could NOT be found." + return 1 + fi + + if test ! -r "$CONTACT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$CONTACT1_FILE\" could be found, but it is not readable." + return 1 + fi + + elif test "$objtype" == "event"; then + if test ! -f "$EVENT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$EVENT1_FILE\" could NOT be found." + return 1 + fi + + if test ! -r "$EVENT1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$EVENT1_FILE\" could be found, but it is not readable." + return 1 + fi + + elif test "$objtype" == "todo"; then + if test ! -f "$TODO1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$TODO1_FILE\" could NOT be found." + return 1 + fi + + if test ! -r "$TODO1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$TODO1_FILE\" could be found, but it is not readable." + return 1 + fi + + elif test "$objtype" == "note"; then + if test ! -f "$NOTE1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$NOTE1_FILE\" could NOT be found." + return 1 + fi + + if test ! -r "$NOTE1_FILE"; then + echo "${FUNCNAME}(): ERROR: \"$NOTE1_FILE\" could be found, but it is not readable." + return 1 + fi + + fi +} + + + + + + + +modify_file() +{ + objtype="$1" + xmlfile="$2" + newfile="$3" + + + if test -z "$objtype"; then echo "$FILE:$LINENO: ERROR: \$objtype is empty. Exiting." exit 1 fi @@ -703,29 +844,40 @@ fi + if test -z "$newfile"; then + echo "$FILE:$LINENO: ERROR: \$newfile is empty. Exiting." + exit 1 + fi + + if test ! -f "$newfile"; then + echo "$FILE:$LINENO: ERROR: \"$newfile\" could not be found. Exiting." + exit 1 + fi + + if test ! -r "$newfile"; then + echo "$FILE:$LINENO: ERROR: \"$newfile\" could be found, but it is not readable. Exiting." + exit 1 + fi + + -# if test "$objtype" == "contact"; then -# remove_contact_files -# elif test "$objtype" == "event"; then -# remove_event1_file -# elif test "$objtype" == "todo"; then -# remove_todo1_file -# elif test "$objtype" == "note"; then -# remove_note_files -# fi if test "$objtype" == "contact"; then - cp -f "$xmlfile" $CONTACT1_FILE + rm -f "$CONTACT1_FILE" + cp -f "$newfile" $CONTACT1_FILE elif test "$objtype" == "event"; then - cp -f "$xmlfile" $EVENT1_FILE + rm -f "$EVENT1_FILE" + cp -f "$newfile" $EVENT1_FILE elif test "$objtype" == "todo"; then - cp -f "$xmlfile" $TODO1_FILE + rm -f "$TODO1_FILE" + cp -f "$newfile" $TODO1_FILE elif test "$objtype" == "note"; then - cp -f "$xmlfile" $NOTE1_FILE + rm -f "$NOTE1_FILE" + cp -f "$newfile" $NOTE1_FILE fi } @@ -734,6 +886,60 @@ +delete_file() +{ + objtype="$1" + xmlfile="$2" + + + if test -z "$objtype"; then + echo "$FILE:$LINENO: ERROR: \$objtype is empty. Exiting." + exit 1 + fi + + if test "$objtype" != "contact" -a "$objtype" != "event" -a "$objtype" != "todo" -a "$objtype" != "note"; then + echo "${FUNCNAME}(): ERROR: \"$objtype\" is wrong: \$objtype can only be either \"contact\" or \"event\" or \"todo\" or \"note\". Exiting." + exit 1; + fi + + if test -z "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \$xmlfile is empty. Exiting." + exit 1 + fi + + if test ! -f "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \"$xmlfile\" could not be found. Exiting." + exit 1 + fi + + if test ! -r "$xmlfile"; then + echo "$FILE:$LINENO: ERROR: \"$xmlfile\" could be found, but it is not readable. Exiting." + exit 1 + fi + + + + + if test "$objtype" == "contact"; then + rm -f "$CONTACT1_FILE" + + elif test "$objtype" == "event"; then + rm -f "$EVENT1_FILE" + + elif test "$objtype" == "todo"; then + rm -f "$TODO1_FILE" + + elif test "$objtype" == "note"; then + rm -f "$NOTE1_FILE" + + fi +} + + + + + + enable_only() { objtype="$1" @@ -839,6 +1045,64 @@ +fast_sync() +{ + group="$GROUPNAME" + objtype="$1" + + + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + + $OSYNCTOOL --configdir "$TMPDIR" --sync "$group" --always-accept-forecast --conflict 2 + + +} + + + + + + + + + + valgrind_slow_sync() { group="$GROUPNAME" @@ -898,3 +1162,64 @@ } + + + +valgrind_fast_sync() +{ + group="$GROUPNAME" + objtype="$1" + + + if test -z "$group"; then + echo "${FUNCNAME}(): ERROR: \$group is empty. Exiting."; + exit 1; + fi + + + if test -z "$objtype"; then + echo "${FUNCNAME}(): ERROR: \$objtype is empty. Exiting."; + exit 1; + fi + + + if test -z "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL is empty. Exiting." + exit 1; + fi + + if test ! -f "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does not exist. Exiting." + exit 1; + fi + + if test ! -x "$OSYNCTOOL"; then + echo "${FUNCNAME}(): ERROR: \$OSYNCTOOL does exist, but it is not executable. Exiting." + exit 1; + fi + + if test -z "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is empty. Exiting." + exit 1; + fi + + if test ! -d "$TMPDIR"; then + echo "${FUNCNAME}(): ERROR: \$TMPDIR is not a directory. Exiting." + exit 1; + fi + + if test -z "$VALGRIND"; then + echo "$FILE:$LINENO: ERROR: \$VALGRIND is empty. Exiting."; + exit 1; + fi + + + if test -n "$SUPPRESSION_FILE" -a -f "$SUPPRESSION_FILE" -a -r "$SUPPRESSION_FILE"; then + VALGRIND="$VALGRIND --suppressions=$SUPPRESSION_FILE" + fi + + + + $VALGRIND $OSYNCTOOL --configdir "$TMPDIR" --sync "$group" --always-accept-forecast --conflict 2 + +} Modified: plugins/ldap-sync/tests/contact1.xml ============================================================================== --- plugins/ldap-sync/tests/contact1.xml Wed Apr 1 23:56:44 2009 (r5510) +++ plugins/ldap-sync/tests/contact1.xml Wed Apr 1 23:57:55 2009 (r5511) @@ -18,15 +18,6 @@ <PostalCode>111111</PostalCode> <Country>Germany</Country> </Address> - <Address Location="Work"> - <PostOfficeBox>111111</PostOfficeBox> - <ExtendedAddress>Berlin</ExtendedAddress> - <Street>Me at work</Street> - <Locality>Berlin</Locality> - <Region>Berlin</Region> - <PostalCode>111111</PostalCode> - <Country>Germania</Country> - </Address> <AddressLabel Location="Home"> <Content>Me at home Kuhpoedelskoog Added: plugins/ldap-sync/tests/contact1.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/contact1.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,139 @@ +<?xml version="1.0"?> +<contact> + <Address Location="Home"> + <PostOfficeBox>333333</PostOfficeBox> + <ExtendedAddress>Kuhpoedelskoog</ExtendedAddress> + <Street>Me at home</Street> + <Locality>Kuhpoedelskoog</Locality> + <Region>Saxonia inferior</Region> + <PostalCode>444444</PostalCode> + <Country>Germania</Country> + </Address> + <Address Location="Work"> + <PostOfficeBox>222222</PostOfficeBox> + <ExtendedAddress>Berlin</ExtendedAddress> + <Street>Me at work</Street> + <Locality>Berlin</Locality> + <Region>Berlin</Region> + <PostalCode>222222</PostalCode> + <Country>Germany</Country> + </Address> + <AddressLabel Location="Home"> + <Content>Me at home +Kuhpoedelskoog +Kuhpoedelskoog, Saxonia inferior +444444 +444444 +Germania</Content> + </AddressLabel> + <AddressLabel Location="Work"> + <Content>Me at work +Berlin +Berlin, Berlin +111111 +111111 +Germany</Content> + </AddressLabel> + <Anniversary> + <Content>20090331</Content> + </Anniversary> + <Assistant> + <Content>Healthy, keen, eager like hell.</Content> + </Assistant> + <Birthday> + <Content>20090301</Content> + </Birthday> + <BlogUrl> + <Content>https://blog.example.com</Content> + </BlogUrl> + <CalendarUrl> + <Content>https://calendar.example.com</Content> + </CalendarUrl> + <Categories> + <Category>Hot Contacts</Category> + </Categories> + <EMail Location="Other" UI-Slot="3"> + <Content>us...@ot...</Content> + </EMail> + <EMail Location="Home" UI-Slot="2"> + <Content>us...@ho...</Content> + </EMail> + <EMail Location="Work" UI-Slot="1"> + <Content>us...@wo...</Content> + </EMail> + <FileAs> + <Content>user2</Content> + </FileAs> + <FormattedName> + <Content>user2</Content> + </FormattedName> + <FreeBusyUrl> + <Content>http://freebusy.example.com</Content> + </FreeBusyUrl> + <IM-AIM Location="Home" UI-Slot="1"> + <Content>aim_account</Content> + </IM-AIM> + <IM-ICQ Location="Home" UI-Slot="4"> + <Content>icq_account</Content> + </IM-ICQ> + <IM-MSN Location="Home" UI-Slot="3"> + <Content>msn_account</Content> + </IM-MSN> + <IM-Yahoo Location="Home" UI-Slot="2"> + <Content>yahoo_account</Content> + </IM-Yahoo> + <Manager> + <Content>Vanished</Content> + </Manager> + <Name> + <FirstName>user2</FirstName> + </Name> + <Nickname> + <Content>two</Content> + </Nickname> + <Note> + <Content>Ok, let's write some notes...</Content> + </Note> + <Organization> + <Name>Creative Co</Name> + <Unit>Studio</Unit> + <Unit>The other building</Unit> + </Organization> + <Profession> + <Content>Creator</Content> + </Profession> + <Revision> + <Content>20090323T172004Z</Content> + </Revision> + <Spouse> + <Content>Betty</Content> + </Spouse> + <Telephone Location="Work" UI-Slot="4"> + <Content>0000000004</Content> + </Telephone> + <Telephone Type="Cellular" UI-Slot="3"> + <Content>0000000003</Content> + </Telephone> + <Telephone Location="Home" UI-Slot="2"> + <Content>0000000002</Content> + </Telephone> + <Telephone Location="Work" UI-Slot="1"> + <Content>0000000001</Content> + </Telephone> + <Title> + <Content>Emperor</Content> + </Title> + <Uid> + <Content>pas-id-49C7C3710000002B</Content> + </Uid> + <Url> + <Content>http://www.example.com</Content> + </Url> + <VideoUrl> + <Content>http://video_chat.example.com</Content> + </VideoUrl> + <WantsHtml> + <Content>TRUE</Content> + </WantsHtml> +</contact> + Added: plugins/ldap-sync/tests/contact2.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/contact2.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,127 @@ +<?xml version="1.0"?> +<contact> + <Address Location="Home"> + <Locality>Kuhpoedelskoog</Locality> + <Region>Saxonia inferior</Region> + <PostalCode>333333</PostalCode> + <Country>Germania</Country> + </Address> + <Address Location="Work"> + <Locality>Kuhpoedelskoog</Locality> + <Region>Saxonia inferior</Region> + <PostalCode>333333</PostalCode> + <Country>Germania</Country> + </Address> + <AddressLabel Location="Work"> + <Content>Kuhpoedelskoog, Saxonia inferior +333333 +Germania</Content> + </AddressLabel> + <AddressLabel Location="Home"> + <Content>Kuhpoedelskoog, Saxonia inferior +333333 +Germania</Content> + </AddressLabel> + <Anniversary> + <Content>20090306</Content> + </Anniversary> + <Assistant> + <Content>Dodgy, half-conscious, not really present in this world.</Content> + </Assistant> + <Birthday> + <Content>20090301</Content> + </Birthday> + <BlogUrl> + <Content>http://blog.example.com/</Content> + </BlogUrl> + <CalendarUrl> + <Content>http://calendar.example.com/</Content> + </CalendarUrl> + <Categories> + <Category>Miscellaneous</Category> + </Categories> + <EMail Location="Work" UI-Slot="3"> + <Content>us...@wo...</Content> + </EMail> + <EMail Location="Home" UI-Slot="2"> + <Content>us...@ho...</Content> + </EMail> + <EMail Location="Other" UI-Slot="1"> + <Content>us...@ot...</Content> + </EMail> + <FileAs> + <Content>user1</Content> + </FileAs> + <FormattedName> + <Content>user1</Content> + </FormattedName> + <FreeBusyUrl> + <Content>http://freebusy.example.com/</Content> + </FreeBusyUrl> + <IM-AIM Location="Home" UI-Slot="1"> + <Content>aim_account</Content> + </IM-AIM> + <IM-ICQ Location="Home" UI-Slot="4"> + <Content>icq_account</Content> + </IM-ICQ> + <IM-MSN Location="Home" UI-Slot="3"> + <Content>msn_account</Content> + </IM-MSN> + <IM-Yahoo Location="Home" UI-Slot="2"> + <Content>yahoo_account</Content> + </IM-Yahoo> + <Manager> + <Content>vanished</Content> + </Manager> + <Name> + <FirstName>user1</FirstName> + </Name> + <Nickname> + <Content>one</Content> + </Nickname> + <Note> + <Content>Thinking of what could I write as notes...</Content> + </Note> + <Organization> + <Name>creative.com</Name> + <Unit>controlling</Unit> + <Unit>The other building.</Unit> + </Organization> + <Profession> + <Content>creator</Content> + </Profession> + <Revision> + <Content>20090322T123606Z</Content> + </Revision> + <Spouse> + <Content>betty</Content> + </Spouse> + <Telephone Location="Work" UI-Slot="4"> + <Content>0000000000004</Content> + </Telephone> + <Telephone Type="Cellular" UI-Slot="3"> + <Content>0000000000002</Content> + </Telephone> + <Telephone Location="Home" UI-Slot="2"> + <Content>0000000000001</Content> + </Telephone> + <Telephone Location="Work" UI-Slot="1"> + <Content>0000000000003</Content> + </Telephone> + <Title> + <Content>Emperor</Content> + </Title> + <Uid> + <Content>pas-id-49C62FB900000022</Content> + </Uid> + <Url> + <Content>http://www.example.com/</Content> + </Url> + <VideoUrl> + <Content>http://videochat.example.com/</Content> + </VideoUrl> + <WantsHtml> + <Content>TRUE</Content> + </WantsHtml> +</contact> + Added: plugins/ldap-sync/tests/event1.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/event1.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,88 @@ +<?xml version="1.0"?> +<event> + <AlarmDisplay Value="DURATION" RelatedType="START"> + <AlarmAction>DISPLAY</AlarmAction> + <AlarmDescription>Appointment no. 1</AlarmDescription> + <AlarmTrigger>-PT15M</AlarmTrigger> + </AlarmDisplay> + <Categories> + <Category>Miscellaneous</Category> + </Categories> + <Class> + <Content>PRIVATE</Content> + </Class> + <Created> + <Content>20090322T135232</Content> + </Created> + <DateCalendarCreated> + <Content>20090320T204925Z</Content> + </DateCalendarCreated> + <DateEnd TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <Content>20090320T223000</Content> + </DateEnd> + <DateStarted TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <Content>20090320T220000</Content> + </DateStarted> + <Description> + <Content>This appointment reoccures. It has been slightly modified. And it has an alarm.</Content> + </Description> + <LastModified> + <Content>20090401T135232</Content> + </LastModified> + <Location> + <Content>Over there.</Content> + </Location> + <Method> + <Content>PUBLISH</Content> + </Method> + <ProductID> + <Content>-//Ximian//NONSGML Evolution Calendar//EN</Content> + </ProductID> + <RecurrenceRule> + <Frequency>DAILY</Frequency> + <Count>2</Count> + <Interval>1</Interval> + </RecurrenceRule> + <Sequence> + <Content>2</Content> + </Sequence> + <Summary> + <Content>Appointment no. 1</Content> + </Summary> + <TimeTransparency> + <Content>OPAQUE</Content> + </TimeTransparency> + <Timezone TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <X-Location>Europe/Berlin</X-Location> + </Timezone> + <TimezoneComponent TZComponent="Standard" TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <DateTimeStart>19701025T020000</DateTimeStart> + <TZName>CET</TZName> + <TZOffsetFrom>+0200</TZOffsetFrom> + <TZOffsetTo>+0100</TZOffsetTo> + </TimezoneComponent> + <TimezoneComponent TZComponent="Daylight" TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <DateTimeStart>19700329T030000</DateTimeStart> + <TZName>CEST</TZName> + <TZOffsetFrom>+0100</TZOffsetFrom> + <TZOffsetTo>+0200</TZOffsetTo> + </TimezoneComponent> + <TimezoneRule TZComponent="Standard" TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <Frequency>YEARLY</Frequency> + <Count>0</Count> + <Interval>1</Interval> + <ByDay>-1SU</ByDay> + <ByMonth>10</ByMonth> + </TimezoneRule> + <TimezoneRule TZComponent="Daylight" TimezoneID="/softwarestudio.org/Tzfile/Europe/Berlin"> + <Frequency>YEARLY</Frequency> + <Count>0</Count> + <Interval>1</Interval> + <ByDay>-1SU</ByDay> + <ByMonth>3</ByMonth> + </TimezoneRule> + <Uid> + <Content>200...@ho...</Content> + </Uid> +</event> + Added: plugins/ldap-sync/tests/note1.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/note1.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<note> + <Categories> + <Category>Waiting</Category> + </Categories> + <Class> + <Content>PRIVATE</Content> + </Class> + <Created> + <Content>20090317T211814</Content> + </Created> + <DateCalendarCreated> + <Content>20090228T003924Z</Content> + </DateCalendarCreated> + <DateStarted Value="DATE"> + <Content>20090228</Content> + </DateStarted> + <Description> + <Content>This is my first memo. </Content> + </Description> + <LastModified> + <Content>20090401T211814</Content> + </LastModified> + <Method> + <Content>PUBLISH</Content> + </Method> + <ProductID> + <Content>-//Ximian//NONSGML Evolution Calendar//EN</Content> + </ProductID> + <Sequence> + <Content>1</Content> + </Sequence> + <Summary> + <Content>First memo. In a slightly modified form.</Content> + </Summary> + <Uid> + <Content>200...@ho...</Content> + </Uid> +</note> Added: plugins/ldap-sync/tests/note2.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/note2.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<note> + <Attach> + <Content>file:///home/user1/.evolution/memos/local/system/200...@ho...-file</Content> + </Attach> + <Categories> + <Category>development</Category> + </Categories> + <Class> + <Content>PRIVATE</Content> + </Class> + <Created> + <Content>20090103T144254</Content> + </Created> + <DateCalendarCreated> + <Content>20090103T144254Z</Content> + </DateCalendarCreated> + <DateStarted Value="DATE"> + <Content>20090103</Content> + </DateStarted> + <Description> + <Content>This is my first memo in evolution. It is confidential. With an attachment of 9 bytes.</Content> + </Description> + <LastModified> + <Content>20090401T144755</Content> + </LastModified> + <Method> + <Content>PUBLISH</Content> + </Method> + <ProductID> + <Content>-//Ximian//NONSGML Evolution Calendar//EN</Content> + </ProductID> + <Sequence> + <Content>1</Content> + </Sequence> + <Summary> + <Content>1st memo. In a slightly modified form.</Content> + </Summary> +<Uid> + <Content>200...@ho...</Content> + </Uid> +</note> + Modified: plugins/ldap-sync/tests/test.conf ============================================================================== --- plugins/ldap-sync/tests/test.conf Wed Apr 1 23:56:44 2009 (r5510) +++ plugins/ldap-sync/tests/test.conf Wed Apr 1 23:57:55 2009 (r5511) @@ -31,6 +31,8 @@ NOTE1_FILE='/tmp/file_note/200...@ho...' NOTE2_FILE='/tmp/file_note/200...@ho...' +GROUPNAME="sync_test_group" + ########## Without leak checking: VALGRIND="valgrind --db-attach=no --num-callers=30 --gen-suppressions=all --leak-check=no --show-reachable=yes --error-exitcode=1 --track-origins=yes" Added: plugins/ldap-sync/tests/todo1.xml_modified ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/todo1.xml_modified Wed Apr 1 23:57:55 2009 (r5511) @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<todo> + <Categories> + <Category>Phone Calls</Category> + </Categories> + <Class> + <Content>PRIVATE</Content> + </Class> + <Created> + <Content>20090325T135501</Content> + </Created> + <DateCalendarCreated> + <Content>20090325T135501Z</Content> + </DateCalendarCreated> + <DateStarted Value="DATE"> + <Content>20090301</Content> + </DateStarted> + <Description> + <Content>This is the very first task.</Content> + </Description> + <Due Value="DATE"> + <Content>20090328</Content> + </Due> + <LastModified> + <Content>20090401T135622</Content> + </LastModified> + <Method> + <Content>PUBLISH</Content> + </Method> + <PercentComplete> + <Content>30</Content> + </PercentComplete> + <Priority> + <Content>1</Content> + </Priority> + <ProductID> + <Content>-//Ximian//NONSGML Evolution Calendar//EN</Content> + </ProductID> + <Sequence> + <Content>1</Content> + </Sequence> + <Summary> + <Content>Task no. 1</Content> + </Summary> + <Uid> + <Content>200...@ho...</Content> + </Uid> +</todo> + |