Commit | Line | Data |
---|---|---|
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 |
13 | if 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 | |
19 | else | |
20 | cat <<EOF | |
8c3b0473 AT |
21 | |
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. | |
25 | ||
26 | EOF | |
c8313794 AT |
27 | export PATH=.:$PATH |
28 | runtest() { | |
29 | echo -n "Test $1: " | |
30 | eval "$2" | |
31 | } | |
32 | printmsg() { | |
33 | echo "" | |
34 | echo "**** ${1}^G ****" | |
35 | echo "" | |
36 | } | |
37 | fi | |
8c3b0473 | 38 | |
5806b30f | 39 | TMP=/tmp/rsync-test.$$ |
ddddf27b AT |
40 | FROM=${TMP}/from |
41 | TO=${TMP}/to | |
42 | F1=text1 | |
43 | LOG=${TMP}/log | |
5806b30f AT |
44 | |
45 | mkdir $TMP | |
ddddf27b AT |
46 | mkdir $FROM |
47 | mkdir $TO | |
48 | ||
49 | # set up test data | |
50 | touch ${FROM}/empty | |
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} | |
56 | mkdir ${FROM}/dir | |
57 | cp ${FROM}/${F1} ${FROM}/dir | |
c8313794 AT |
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 | |
ddddf27b AT |
63 | |
64 | checkit() { | |
c8313794 AT |
65 | testnum=`expr 0${testnum} + 1` |
66 | log=${LOG}.${testnum} | |
ddddf27b AT |
67 | failed= |
68 | echo "Running: \"$1\"" >${log} | |
69 | echo "">>${log} | |
70 | eval "$1 || failed=YES" >>${log} 2>&1 | |
71 | ||
72 | echo "-------------">>${log} | |
73 | echo "check how the files compare with diff:">>${log} | |
74 | echo "">>${log} | |
c8313794 | 75 | diff -ur $2 $3 >>${log} 2>&1 || failed=YES |
ddddf27b AT |
76 | echo "-------------">>${log} |
77 | echo "check how the directory listings compare with diff:">>${log} | |
78 | echo "">>${log} | |
c8313794 AT |
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 | |
ddddf27b | 82 | if [ -z "${failed}" ] ; then |
c8313794 | 83 | test -z "${Debian}" && echo " done." |
ddddf27b | 84 | rm $log |
c8313794 | 85 | return 0 |
ddddf27b | 86 | else |
c8313794 AT |
87 | if test -n "${Debian}" ; then |
88 | cat ${log} | |
89 | rm ${log} | |
90 | else | |
91 | echo " FAILED (test # ${testnum}).\a" | |
92 | fi | |
93 | return 1 | |
ddddf27b AT |
94 | fi |
95 | } | |
96 | ||
c8313794 | 97 | |
ddddf27b | 98 | checkforlogs() { |
c8313794 AT |
99 | # skip it if we're under debian-test |
100 | if test -n "${Debian}" ; then return 0 ; fi | |
101 | ||
ddddf27b AT |
102 | if [ -f $1 ] ; then |
103 | cat <<EOF | |
104 | ||
105 | Failures have occured. | |
106 | ||
107 | You can find the output of the tests in these files: | |
108 | $@ | |
109 | ||
110 | Please hit <RETURN> | |
111 | EOF | |
112 | read input | |
113 | else | |
5806b30f | 114 | |
ddddf27b AT |
115 | rm -rf ${TMP} |
116 | echo "" | |
117 | echo "Tests Completed Successfully :-)" | |
118 | fi | |
5806b30f AT |
119 | } |
120 | ||
ddddf27b AT |
121 | # Main script starts here |
122 | ||
c8313794 | 123 | runtest "basic operation" 'checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
ddddf27b AT |
124 | |
125 | ln ${FROM}/pslist ${FROM}/dir | |
c8313794 | 126 | runtest "hard links" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
ddddf27b AT |
127 | |
128 | rm ${TO}/${F1} | |
c8313794 | 129 | runtest "one file" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
ddddf27b AT |
130 | |
131 | echo "extra line" >> ${TO}/${F1} | |
c8313794 | 132 | runtest "extra data" 'checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
ddddf27b AT |
133 | |
134 | cp ${FROM}/${F1} ${TO}/ThisShouldGo | |
c8313794 | 135 | runtest " --delete" 'checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
ddddf27b | 136 | |
35f69d8a AT |
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 |
138 | mkdir -p ${LONGDIR} | |
139 | date > ${LONGDIR}/1 | |
140 | ls -la / > ${LONGDIR}/2 | |
c8313794 | 141 | runtest "long paths" 'checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' |
35f69d8a | 142 | |
c8313794 AT |
143 | if type ssh >/dev/null 2>&1; then |
144 | if [ "`ssh -o'BatchMode yes' localhost echo yes 2>/dev/null`" = "yes" ]; then | |
145 | rm -rf ${TO} | |
146 | runtest "ssh: basic test" 'checkit "rsync -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}' | |
ddddf27b | 147 | |
c8313794 AT |
148 | mv ${TO}/${F1} ${TO}/ThisShouldGo |
149 | runtest "ssh: renamed file" 'checkit "rsync --delete -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}' | |
150 | else | |
151 | printmsg "Skipping SSH tests because ssh conection to localhost not authorised" | |
152 | fi | |
ddddf27b | 153 | else |
c8313794 | 154 | printmsg "Skipping SSH tests because ssh is not in the path" |
ddddf27b AT |
155 | fi |
156 | ||
c8313794 AT |
157 | rm -rf ${TO} |
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}' | |
162 | rm -r ${FROM}2 | |
163 | ||
ddddf27b | 164 | checkforlogs ${LOG}.? |