syslog support in rsync daemon has been broken since I added the "log
[rsync/rsync.git] / test.sh
CommitLineData
d3394de1 1#!/bin/sh
ddddf27b
AT
2
3#
4# Copyright (C) 1998 Philip Hands <http://www.hands.com/~phil/>
5#
6# This program is distributable under the terms of the GNU GPL (see COPYING)
7#
5806b30f 8# This is a simple test script that tests a few rsync
ddddf27b
AT
9# features to make sure I haven't broken them before a release.
10#
11#
5806b30f 12
8c3b0473
AT
13cat <<EOF
14
15This set of tests is not completely portable. It is intended for developers
16not for end users. You may experience failures on some platforms that
17do not indicate a problem with rsync.
18
19EOF
20
5806b30f
AT
21export PATH=.:$PATH
22TMP=/tmp/rsync-test.$$
ddddf27b
AT
23FROM=${TMP}/from
24TO=${TMP}/to
25F1=text1
26LOG=${TMP}/log
5806b30f
AT
27
28mkdir $TMP
ddddf27b
AT
29mkdir $FROM
30mkdir $TO
31
32# set up test data
33touch ${FROM}/empty
34mkdir ${FROM}/emptydir
35ps ax > ${FROM}/pslist
36echo -n "This file has no trailing lf" > ${FROM}/nolf
37ln -s nolf ${FROM}/nolf-symlink
38cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1}
39mkdir ${FROM}/dir
40cp ${FROM}/${F1} ${FROM}/dir
41
42checkit() {
43 echo -n "Test $4: $5:"
44 log=${LOG}.$4
45 failed=
46 echo "Running: \"$1\"" >${log}
47 echo "">>${log}
48 eval "$1 || failed=YES" >>${log} 2>&1
49
50 echo "-------------">>${log}
51 echo "check how the files compare with diff:">>${log}
52 echo "">>${log}
53 diff -ur $2 $3 >>${log} || failed=YES
54 echo "-------------">>${log}
55 echo "check how the directory listings compare with diff:">>${log}
56 echo "">>${log}
57 ls -la $2 > ${TMP}/ls-from
58 ls -la $3 > ${TMP}/ls-to
59 diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} || failed=YES
60 if [ -z "${failed}" ] ; then
61 echo " done."
62 rm $log
63 else
d3394de1 64 echo " FAILED.\a"
ddddf27b
AT
65 fi
66}
67
68checkforlogs() {
69 if [ -f $1 ] ; then
70 cat <<EOF
71
72Failures have occured.
73
74You can find the output of the tests in these files:
75 $@
76
77Please hit <RETURN>
78EOF
79 read input
80 else
5806b30f 81
ddddf27b
AT
82 rm -rf ${TMP}
83 echo ""
84 echo "Tests Completed Successfully :-)"
85 fi
5806b30f
AT
86}
87
ddddf27b
AT
88# Main script starts here
89
90checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO} \
91 1 "basic operation"
92
93ln ${FROM}/pslist ${FROM}/dir
94checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
95 2 "hard links"
96
97rm ${TO}/${F1}
98checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
99 3 "one file"
100
101echo "extra line" >> ${TO}/${F1}
102checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
103 4 "extra data"
104
105cp ${FROM}/${F1} ${TO}/ThisShouldGo
106checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
107 5 " --delete"
108
35f69d8a
AT
109LONGDIR=${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
110mkdir -p ${LONGDIR}
111date > ${LONGDIR}/1
112ls -la / > ${LONGDIR}/2
113checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
114 6 "long paths"
115
ddddf27b
AT
116if type ssh >/dev/null ; then
117rm -rf ${TO}
118 checkit "rsync -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO} \
35f69d8a 119 7 "ssh: basic test"
ddddf27b
AT
120
121 mv ${TO}/${F1} ${TO}/ThisShouldGo
122 checkit "rsync --delete -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}\
35f69d8a 123 8 "ssh: renamed file"
ddddf27b
AT
124else
125 echo ""
d3394de1 126 echo "**** Skipping SSH tests because ssh is not in the path\a ****"
ddddf27b
AT
127 echo ""
128fi
129
130checkforlogs ${LOG}.?