Don't pause at end of tests.
[rsync/rsync.git] / testsuite / hands.test
CommitLineData
068a7221
MP
1#!/bin/sh
2
3# Copyright (C) 1998,1999 Philip Hands <phil@hands.com>
4#
5# This program is distributable under the terms of the GNU GPL (see COPYING)
6#
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.
9#
10#
11
12RSYNC="$rsync_bin"
13
14 runtest() {
15 echo -n "Test $1: "
16 eval "$2"
17 }
18 printmsg() {
19 echo ""
20 echo "**** ${1}^G ****"
21 echo ""
22 }
23
24TMP=/tmp/rsync-test.$$
25FROM=${TMP}/from
26TO=${TMP}/to
27F1=text1
28LOG=${TMP}/log
29
30mkdir $TMP
31mkdir $FROM
32mkdir $TO
33
34# set up test data
35touch ${FROM}/empty
36mkdir ${FROM}/emptydir
37ps ax > ${FROM}/pslist
38echo -n "This file has no trailing lf" > ${FROM}/nolf
39ln -s nolf ${FROM}/nolf-symlink
40cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1}
41mkdir ${FROM}/dir
42cp ${FROM}/${F1} ${FROM}/dir
43mkdir ${FROM}/dir/subdir
44mkdir ${FROM}/dir/subdir/subsubdir
45ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
46mkdir ${FROM}/dir/subdir/subsubdir2
47ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
48
49checkit() {
50 testnum=`expr 0${testnum} + 1`
51 log=${LOG}.${testnum}
52 failed=
53 echo "Running: \"$1\"" >${log}
54 echo "">>${log}
55 eval "$1" >>${log} 2>&1
56 status=$?
57 if [ $status != 0 ]; then
58 failed="YES";
59 fi
60 echo "-------------">>${log}
61 echo "check how the files compare with diff:">>${log}
62 echo "">>${log}
63 diff -ur $2 $3 >>${log} 2>&1 || failed=YES
64 echo "-------------">>${log}
65 echo "check how the directory listings compare with diff:">>${log}
66 echo "">>${log}
67 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
68 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
69 diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
70 if [ -z "${failed}" ] ; then
71 echo " done."
72 rm $log
73 return 0
74 else
75 if test -n "${Debian}" ; then
76 cat ${log}
77 rm ${log}
78 else
79 echo " FAILED (test # ${testnum} status=$status).\a"
80 fi
81 return 1
82 fi
83}
84
85
86checkforlogs() {
87 # skip it if we're under debian-test
88 if test -n "${Debian}" ; then return 0 ; fi
89
90 if [ -f $1 ] ; then
91 cat <<EOF
92
93Failures have occured.
94
95You can find the output of the tests in these files:
96 $@
068a7221 97EOF
09ec75a6 98 exit 1
068a7221
MP
99 else
100
101 rm -rf ${TMP}
102 echo ""
103 echo "Tests Completed Successfully :-)"
104 fi
105}
106
107# Main script starts here
108
109runtest "basic operation" 'checkit "$RSYNC -av ${FROM}/ ${TO}" ${FROM}/ ${TO}'
110
111ln ${FROM}/pslist ${FROM}/dir
112runtest "hard links" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
113
114rm ${TO}/${F1}
115runtest "one file" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
116
117echo "extra line" >> ${TO}/${F1}
118runtest "extra data" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
119
120cp ${FROM}/${F1} ${TO}/ThisShouldGo
121runtest " --delete" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
122
123LONGDIR=${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
124mkdir -p ${LONGDIR}
125date > ${LONGDIR}/1
126ls -la / > ${LONGDIR}/2
127runtest "long paths" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
128
129if type ssh >/dev/null 2>&1; then
130 if [ "`ssh -o'BatchMode yes' localhost echo yes 2>/dev/null`" = "yes" ]; then
131 rm -rf ${TO}
132 runtest "ssh: basic test" 'checkit "$RSYNC -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
133
134 mv ${TO}/${F1} ${TO}/ThisShouldGo
135 runtest "ssh: renamed file" 'checkit "$RSYNC --delete -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
136 else
137 printmsg "Skipping SSH tests because ssh conection to localhost not authorised"
138 fi
139else
140 printmsg "Skipping SSH tests because ssh is not in the path"
141fi
142
143rm -rf ${TO}
144mkdir -p ${FROM}2/dir/subdir
145cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir
146cp ${FROM}/dir/* ${FROM}2/dir 2>/dev/null
147runtest "excludes" 'checkit "$RSYNC -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}'
148rm -r ${FROM}2
149
150checkforlogs ${LOG}.?