The --with-rsync-path configure option was using the wrong configure
[rsync/rsync.git] / test.sh
CommitLineData
d3394de1 1#!/bin/sh
ddddf27b 2
c8313794 3# Copyright (C) 1998,1999 Philip Hands <phil@hands.com>
ddddf27b
AT
4#
5# This program is distributable under the terms of the GNU GPL (see COPYING)
6#
5806b30f 7# This is a simple test script that tests a few rsync
ddddf27b
AT
8# features to make sure I haven't broken them before a release.
9#
10#
5806b30f 11
c8313794
AT
12# check if we are running under debian-test, and change behaviour to suit
13if test -n "${DEBIANTEST_LIB}" ; then
14 # make sure rsync is installed
15 test -e /usr/bin/rsync || exit 0
16
17 . ${DEBIANTEST_LIB}/functions.sh
18 Debian=1
19else
20 cat <<EOF
8c3b0473
AT
21
22This set of tests is not completely portable. It is intended for developers
23not for end users. You may experience failures on some platforms that
24do not indicate a problem with rsync.
25
26EOF
8b35435f
AT
27
28RSYNC=`pwd`/rsync
29
c8313794
AT
30 runtest() {
31 echo -n "Test $1: "
32 eval "$2"
33 }
34 printmsg() {
35 echo ""
36 echo "**** ${1}^G ****"
37 echo ""
38 }
39fi
8c3b0473 40
5806b30f 41TMP=/tmp/rsync-test.$$
ddddf27b
AT
42FROM=${TMP}/from
43TO=${TMP}/to
44F1=text1
45LOG=${TMP}/log
5806b30f
AT
46
47mkdir $TMP
ddddf27b
AT
48mkdir $FROM
49mkdir $TO
50
51# set up test data
52touch ${FROM}/empty
53mkdir ${FROM}/emptydir
54ps ax > ${FROM}/pslist
55echo -n "This file has no trailing lf" > ${FROM}/nolf
56ln -s nolf ${FROM}/nolf-symlink
57cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1}
58mkdir ${FROM}/dir
59cp ${FROM}/${F1} ${FROM}/dir
c8313794
AT
60mkdir ${FROM}/dir/subdir
61mkdir ${FROM}/dir/subdir/subsubdir
62ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
63mkdir ${FROM}/dir/subdir/subsubdir2
64ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
ddddf27b
AT
65
66checkit() {
c8313794
AT
67 testnum=`expr 0${testnum} + 1`
68 log=${LOG}.${testnum}
ddddf27b
AT
69 failed=
70 echo "Running: \"$1\"" >${log}
71 echo "">>${log}
bd36966b
AT
72 eval "$1" >>${log} 2>&1
73 status=$?
74 if [ $status != 0 ]; then
75 failed="YES";
76 fi
ddddf27b
AT
77 echo "-------------">>${log}
78 echo "check how the files compare with diff:">>${log}
79 echo "">>${log}
c8313794 80 diff -ur $2 $3 >>${log} 2>&1 || failed=YES
ddddf27b
AT
81 echo "-------------">>${log}
82 echo "check how the directory listings compare with diff:">>${log}
83 echo "">>${log}
c8313794
AT
84 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
85 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
86 diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
ddddf27b 87 if [ -z "${failed}" ] ; then
c8313794 88 test -z "${Debian}" && echo " done."
ddddf27b 89 rm $log
c8313794 90 return 0
ddddf27b 91 else
c8313794
AT
92 if test -n "${Debian}" ; then
93 cat ${log}
94 rm ${log}
95 else
bd36966b 96 echo " FAILED (test # ${testnum} status=$status).\a"
c8313794
AT
97 fi
98 return 1
ddddf27b
AT
99 fi
100}
101
c8313794 102
ddddf27b 103checkforlogs() {
c8313794
AT
104 # skip it if we're under debian-test
105 if test -n "${Debian}" ; then return 0 ; fi
106
ddddf27b
AT
107 if [ -f $1 ] ; then
108 cat <<EOF
109
110Failures have occured.
111
112You can find the output of the tests in these files:
113 $@
114
115Please hit <RETURN>
116EOF
117 read input
118 else
5806b30f 119
ddddf27b
AT
120 rm -rf ${TMP}
121 echo ""
122 echo "Tests Completed Successfully :-)"
123 fi
5806b30f
AT
124}
125
ddddf27b
AT
126# Main script starts here
127
8b35435f 128runtest "basic operation" 'checkit "$RSYNC -av ${FROM}/ ${TO}" ${FROM}/ ${TO}'
ddddf27b
AT
129
130ln ${FROM}/pslist ${FROM}/dir
8b35435f 131runtest "hard links" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
ddddf27b
AT
132
133rm ${TO}/${F1}
8b35435f 134runtest "one file" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
ddddf27b
AT
135
136echo "extra line" >> ${TO}/${F1}
8b35435f 137runtest "extra data" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
ddddf27b
AT
138
139cp ${FROM}/${F1} ${TO}/ThisShouldGo
8b35435f 140runtest " --delete" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
ddddf27b 141
35f69d8a
AT
142LONGDIR=${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
143mkdir -p ${LONGDIR}
144date > ${LONGDIR}/1
145ls -la / > ${LONGDIR}/2
8b35435f 146runtest "long paths" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
35f69d8a 147
c8313794
AT
148if type ssh >/dev/null 2>&1; then
149 if [ "`ssh -o'BatchMode yes' localhost echo yes 2>/dev/null`" = "yes" ]; then
150 rm -rf ${TO}
8b35435f 151 runtest "ssh: basic test" 'checkit "$RSYNC -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
ddddf27b 152
c8313794 153 mv ${TO}/${F1} ${TO}/ThisShouldGo
8b35435f 154 runtest "ssh: renamed file" 'checkit "$RSYNC --delete -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
c8313794
AT
155 else
156 printmsg "Skipping SSH tests because ssh conection to localhost not authorised"
157 fi
ddddf27b 158else
c8313794 159 printmsg "Skipping SSH tests because ssh is not in the path"
ddddf27b
AT
160fi
161
c8313794
AT
162rm -rf ${TO}
163mkdir -p ${FROM}2/dir/subdir
164cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir
a2edb26c 165cp ${FROM}/dir/* ${FROM}2/dir 2>/dev/null
8b35435f 166runtest "excludes" 'checkit "$RSYNC -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}'
c8313794
AT
167rm -r ${FROM}2
168
ddddf27b 169checkforlogs ${LOG}.?