Commit | Line | Data |
---|---|---|
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 AT |
12 | |
13 | export PATH=.:$PATH | |
14 | TMP=/tmp/rsync-test.$$ | |
ddddf27b AT |
15 | FROM=${TMP}/from |
16 | TO=${TMP}/to | |
17 | F1=text1 | |
18 | LOG=${TMP}/log | |
5806b30f AT |
19 | |
20 | mkdir $TMP | |
ddddf27b AT |
21 | mkdir $FROM |
22 | mkdir $TO | |
23 | ||
24 | # set up test data | |
25 | touch ${FROM}/empty | |
26 | mkdir ${FROM}/emptydir | |
27 | ps ax > ${FROM}/pslist | |
28 | echo -n "This file has no trailing lf" > ${FROM}/nolf | |
29 | ln -s nolf ${FROM}/nolf-symlink | |
30 | cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1} | |
31 | mkdir ${FROM}/dir | |
32 | cp ${FROM}/${F1} ${FROM}/dir | |
33 | ||
34 | checkit() { | |
35 | echo -n "Test $4: $5:" | |
36 | log=${LOG}.$4 | |
37 | failed= | |
38 | echo "Running: \"$1\"" >${log} | |
39 | echo "">>${log} | |
40 | eval "$1 || failed=YES" >>${log} 2>&1 | |
41 | ||
42 | echo "-------------">>${log} | |
43 | echo "check how the files compare with diff:">>${log} | |
44 | echo "">>${log} | |
45 | diff -ur $2 $3 >>${log} || failed=YES | |
46 | echo "-------------">>${log} | |
47 | echo "check how the directory listings compare with diff:">>${log} | |
48 | echo "">>${log} | |
49 | ls -la $2 > ${TMP}/ls-from | |
50 | ls -la $3 > ${TMP}/ls-to | |
51 | diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} || failed=YES | |
52 | if [ -z "${failed}" ] ; then | |
53 | echo " done." | |
54 | rm $log | |
55 | else | |
d3394de1 | 56 | echo " FAILED.\a" |
ddddf27b AT |
57 | fi |
58 | } | |
59 | ||
60 | checkforlogs() { | |
61 | if [ -f $1 ] ; then | |
62 | cat <<EOF | |
63 | ||
64 | Failures have occured. | |
65 | ||
66 | You can find the output of the tests in these files: | |
67 | $@ | |
68 | ||
69 | Please hit <RETURN> | |
70 | EOF | |
71 | read input | |
72 | else | |
5806b30f | 73 | |
ddddf27b AT |
74 | rm -rf ${TMP} |
75 | echo "" | |
76 | echo "Tests Completed Successfully :-)" | |
77 | fi | |
5806b30f AT |
78 | } |
79 | ||
ddddf27b AT |
80 | # Main script starts here |
81 | ||
82 | checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
83 | 1 "basic operation" | |
84 | ||
85 | ln ${FROM}/pslist ${FROM}/dir | |
86 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
87 | 2 "hard links" | |
88 | ||
89 | rm ${TO}/${F1} | |
90 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
91 | 3 "one file" | |
92 | ||
93 | echo "extra line" >> ${TO}/${F1} | |
94 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
95 | 4 "extra data" | |
96 | ||
97 | cp ${FROM}/${F1} ${TO}/ThisShouldGo | |
98 | checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
99 | 5 " --delete" | |
100 | ||
35f69d8a AT |
101 | 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 |
102 | mkdir -p ${LONGDIR} | |
103 | date > ${LONGDIR}/1 | |
104 | ls -la / > ${LONGDIR}/2 | |
105 | checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
106 | 6 "long paths" | |
107 | ||
ddddf27b AT |
108 | if type ssh >/dev/null ; then |
109 | rm -rf ${TO} | |
110 | checkit "rsync -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO} \ | |
35f69d8a | 111 | 7 "ssh: basic test" |
ddddf27b AT |
112 | |
113 | mv ${TO}/${F1} ${TO}/ThisShouldGo | |
114 | checkit "rsync --delete -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}\ | |
35f69d8a | 115 | 8 "ssh: renamed file" |
ddddf27b AT |
116 | else |
117 | echo "" | |
d3394de1 | 118 | echo "**** Skipping SSH tests because ssh is not in the path\a ****" |
ddddf27b AT |
119 | echo "" |
120 | fi | |
121 | ||
122 | checkforlogs ${LOG}.? |