From: <svn...@op...> - 2009-04-07 18:55:30
|
Author: scriptor Date: Tue Apr 7 20:55:26 2009 New Revision: 5555 URL: http://www.opensync.org/changeset/5555 Log: Further tests. Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_valgrind_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_valgrind_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_valgrind_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_valgrind_and_sync (contents, props changed) Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_valgrind_and_sync Tue Apr 7 20:55:26 2009 (r5555) @@ -0,0 +1,204 @@ +#!/bin/bash + +set -x + +FILE=$0 +test_name="$1" +PLUGINNAME="ldap-sync" +PLUGINPATH="$2/src" +CFG="$3/src/$PLUGINNAME" +OBJECTTYPE="$4" +XMLFILE="$5" +MODIFIED_FILE="$6" + + + + + + +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 + + + + +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 -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 -z "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE\" 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_ldifs + + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + + +# Add XML file +echo -e "\n\n\nAdd XML file\n\n\n" +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: +echo -e "\n\n\nEnable just $OBJECTTYPE\n\n\n" +enable_only "$OBJECTTYPE" + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after an XML file has been added\n\n\n" +enable_trace_subdir "$test_name" "add" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + +verify_file_add "$XMLFILE" + + +# Modify the XML File +echo -e "\n\n\nModify XML file\n\n\n" +modify_file "$OBJECTTYPE" "$XMLFILE" "$MODIFIED_FILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + +echo -e "\n\n\n" +diff "$XMLFILE" "$MODIFIED_FILE" +echo -e "\n\n\n" + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the XML file has been modified\n\n\n" +enable_trace_subdir "$test_name" "modify" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (2)." + exit 1; +fi + + +# Delete the XML File +echo -e "\n\n\nDelete XML file\n\n\n" +delete_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the XML file has been deleted\n\n\n" +enable_trace_subdir "$test_name" "delete" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (3)." + exit 1; +fi +echo -e "\n\n\n" + + +verify_file_delete "$XMLFILE" + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv + +#vim:ts=2:sw=2 Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_valgrind_and_sync Tue Apr 7 20:55:26 2009 (r5555) @@ -0,0 +1,404 @@ +#!/bin/bash + +set -x + +FILE=$0 +test_name="$1" +PLUGINNAME="ldap-sync" +PLUGINPATH="$2/src" +CFG="$3/src/$PLUGINNAME" +XMLFILE_CONTACT="$4" +XMLFILE_EVENT="$5" +XMLFILE_TODO="$6" +XMLFILE_NOTE="$7" +MODIFIED_FILE_CONTACT="$8" +MODIFIED_FILE_EVENT="$9" +MODIFIED_FILE_TODO="${10}" +MODIFIED_FILE_NOTE="${11}" + + + +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 + + + + +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 -z "$XMLFILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_NOTE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + + + + + +if test -z "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_NOTE\" 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_ldifs + +# Remove entry from directory used by file-sync +remove_files + + +# Add XML files +echo -e "\n\n\nAdd XML files\n\n\n" +add_file "contact" "$XMLFILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "event" "$XMLFILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "todo" "$XMLFILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "note" "$XMLFILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + + + + + +# Trigger synchronization after ADD +echo -e "\n\n\nSynchronize after 4 XML files have been added\n\n\n" +enable_trace_subdir "$test_name" "add" +valgrind_fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been added." + exit $rv +fi + + +verify_file_add "$XMLFILE_CONTACT" +verify_file_add "$XMLFILE_EVENT" +verify_file_add "$XMLFILE_TODO" +verify_file_add "$XMLFILE_NOTE" + + +# Modify all of the 4 XML files +echo -e "\n\n\nModify 4 XML files\n\n\n" +modify_file "contact" "$XMLFILE_CONTACT" "$MODIFIED_FILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "event" "$XMLFILE_EVENT" "$MODIFIED_FILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "todo" "$XMLFILE_TODO" "$MODIFIED_FILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "note" "$XMLFILE_NOTE" "$MODIFIED_FILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + + + + + +# Trigger synchronization after MODIFY +echo -e "\n\n\nSynchronize after 4 XML files have been modified\n\n\n" +enable_trace_subdir "$test_name" "modify" +valgrind_fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been modified." + exit $rv +fi + + + + + + + +# Delete all of the 4 XML Files +echo -e "\n\n\nDelete 4 XML files\n\n\n" +delete_file "contact" "$XMLFILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "event" "$XMLFILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "todo" "$XMLFILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "note" "$XMLFILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + + + + + + + + +# Trigger synchronization after DELETE +echo -e "\n\n\nSynchronize after 4 XML files have been deleted\n\n\n" +enable_trace_subdir "$test_name" "delete" +valgrind_fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been deleted." + exit $rv +fi + + + + + +verify_file_delete "$XMLFILE_CONTACT" +verify_file_delete "$XMLFILE_EVENT" +verify_file_delete "$XMLFILE_TODO" +verify_file_delete "$XMLFILE_NOTE" + + + + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_valgrind_and_sync Tue Apr 7 20:55:26 2009 (r5555) @@ -0,0 +1,397 @@ +#!/bin/bash + +set -x + +FILE=$0 +test_name="$1" +PLUGINNAME="ldap-sync" +PLUGINPATH="$2/src" +CFG="$3/src/$PLUGINNAME" +LDIF_CONTACT="$4" +LDIF_EVENT="$5" +LDIF_TODO="$6" +LDIF_NOTE="$7" +ENTRYMODS_CONTACT="$8" +ENTRYMODS_EVENT="$9" +ENTRYMODS_TODO="${10}" +ENTRYMODS_NOTE="${11}" + + + +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 + + + + +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 -z "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_NOTE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + + + + + +if test -z "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_NOTE\" 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_ldifs + + +# Remove entry from directory used by file-sync +remove_files + + +# Add 4 LDIFs +echo -e "\n\n\nAdd 4 LDIFs\n\n\n" +run_ldapadd "$LDIF_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + + + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after 4 LDIFs have been added\n\n\n" +enable_trace_subdir "$test_name" "add" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +verify_ldif_add "$LDIF_CONTACT" +verify_ldif_add "$LDIF_EVENT" +verify_ldif_add "$LDIF_TODO" +verify_ldif_add "$LDIF_NOTE" + + +# Modify all of the 4 LDIFs +echo -e "\n\n\nModify 4 LDIFs\n\n\n" +run_ldapmodify "$ENTRYMODS_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after all of the 4 LDIFs have been modified\n\n\n" +enable_trace_subdir "$test_name" "modify" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (2)." + exit 1; +fi + + +# Delete all of the 4 LDIFs +echo -e "\n\n\nDelete all of the 4 LDIFs\n\n\n" +run_ldapdelete "$LDIF_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + + + + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIFs have been deleted\n\n\n" +enable_trace_subdir "$test_name" "delete" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (3)." + exit 1; +fi +echo -e "\n\n\n" + + + +verify_ldif_delete "$LDIF_CONTACT" +verify_ldif_delete "$LDIF_EVENT" +verify_ldif_delete "$LDIF_TODO" +verify_ldif_delete "$LDIF_NOTE" + + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv + +#vim:ts=2:sw=2 Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_valgrind_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_valgrind_and_sync Tue Apr 7 20:55:26 2009 (r5555) @@ -0,0 +1,198 @@ +#!/bin/bash + +set -x + +FILE=$0 +test_name="$1" +PLUGINNAME="ldap-sync" +PLUGINPATH="$2/src" +CFG="$3/src/$PLUGINNAME" +OBJECTTYPE="$4" +LDIF="$5" +ENTRYMODS="$6" + + + +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 + + + + +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 -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 "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS\" 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_ldifs + + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + + +# Add LDIF +echo -e "\n\n\nAdd LDIF\n\n\n" +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: +echo -e "\n\n\nEnable just $OBJECTTYPE\n\n\n" +enable_only "$OBJECTTYPE" + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after an LDIF has been added\n\n\n" +enable_trace_subdir "$test_name" "add" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + +verify_ldif_add "$LDIF" + +# Modify the LDIF +echo -e "\n\n\nModify LDIF\n\n\n" +run_ldapmodify "$ENTRYMODS" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIF has been modified\n\n\n" +enable_trace_subdir "$test_name" "modify" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Delete the LDIF +echo -e "\n\n\nDelete LDIF\n\n\n" +run_ldapdelete "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIF has been deleted\n\n\n" +enable_trace_subdir "$test_name" "delete" +valgrind_fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi +echo -e "\n\n\n" + + + +verify_ldif_delete "$LDIF" + + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv + +#vim:ts=2:sw=2 |