3 # Copyright (C) 1998,1999 Philip Hands <phil@hands.com>
5 # This program is distributable under the terms of the GNU GPL (see COPYING)
7 # This is a simple test script that tests a few rsync
8 # features to make sure I haven't broken them before a release.
12 # check if we are running under debian-test, and change behaviour to suit
13 if test -n "${DEBIANTEST_LIB}" ; then
14 # make sure rsync is installed
15 test -e /usr/bin/rsync || exit 0
17 . ${DEBIANTEST_LIB}/functions.sh
22 This set of tests is not completely portable. It is intended for developers
23 not for end users. You may experience failures on some platforms that
24 do not indicate a problem with rsync.
34 echo "**** ${1}^G ****"
39 TMP=/tmp/rsync-test.$$
51 mkdir ${FROM}/emptydir
52 ps ax > ${FROM}/pslist
53 echo -n "This file has no trailing lf" > ${FROM}/nolf
54 ln -s nolf ${FROM}/nolf-symlink
55 cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1}
57 cp ${FROM}/${F1} ${FROM}/dir
58 mkdir ${FROM}/dir/subdir
59 mkdir ${FROM}/dir/subdir/subsubdir
60 ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
61 mkdir ${FROM}/dir/subdir/subsubdir2
62 ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
65 testnum=`expr 0${testnum} + 1`
68 echo "Running: \"$1\"" >${log}
70 eval "$1 || failed=YES" >>${log} 2>&1
72 echo "-------------">>${log}
73 echo "check how the files compare with diff:">>${log}
75 diff -ur $2 $3 >>${log} 2>&1 || failed=YES
76 echo "-------------">>${log}
77 echo "check how the directory listings compare with diff:">>${log}
79 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
80 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
81 diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
82 if [ -z "${failed}" ] ; then
83 test -z "${Debian}" && echo " done."
87 if test -n "${Debian}" ; then
91 echo " FAILED (test # ${testnum}).
\a"
99 # skip it if we're under debian-test
100 if test -n "${Debian}" ; then return 0 ; fi
105 Failures have occured.
107 You can find the output of the tests in these files:
117 echo "Tests Completed Successfully :-)"
121 # Main script starts here
123 runtest "basic operation" 'checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO}'
125 ln ${FROM}/pslist ${FROM}/dir
126 runtest "hard links" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
129 runtest "one file" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
131 echo "extra line" >> ${TO}/${F1}
132 runtest "extra data" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
134 cp ${FROM}/${F1} ${TO}/ThisShouldGo
135 runtest " --delete" 'checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
137 LONGDIR=${FROM}/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job
140 ls -la / > ${LONGDIR}/2
141 runtest "long paths" 'checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
143 if type ssh >/dev/null 2>&1; then
144 if [ "`ssh -o'BatchMode yes' localhost echo yes 2>/dev/null`" = "yes" ]; then
146 runtest "ssh: basic test" 'checkit "rsync -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
148 mv ${TO}/${F1} ${TO}/ThisShouldGo
149 runtest "ssh: renamed file" 'checkit "rsync --delete -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
151 printmsg "Skipping SSH tests because ssh conection to localhost not authorised"
154 printmsg "Skipping SSH tests because ssh is not in the path"
158 mkdir -p ${FROM}2/dir/subdir
159 cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir
160 cp ${FROM}/dir/* ${FROM}2/dir 2>/dev/null
161 runtest "excludes" 'checkit "rsync -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}'
164 checkforlogs ${LOG}.?