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 | 12 | |
8c3b0473 AT |
13 | cat <<EOF |
14 | ||
15 | This set of tests is not completely portable. It is intended for developers | |
16 | not for end users. You may experience failures on some platforms that | |
17 | do not indicate a problem with rsync. | |
18 | ||
19 | EOF | |
20 | ||
5806b30f AT |
21 | export PATH=.:$PATH |
22 | TMP=/tmp/rsync-test.$$ | |
ddddf27b AT |
23 | FROM=${TMP}/from |
24 | TO=${TMP}/to | |
25 | F1=text1 | |
26 | LOG=${TMP}/log | |
5806b30f AT |
27 | |
28 | mkdir $TMP | |
ddddf27b AT |
29 | mkdir $FROM |
30 | mkdir $TO | |
31 | ||
32 | # set up test data | |
33 | touch ${FROM}/empty | |
34 | mkdir ${FROM}/emptydir | |
35 | ps ax > ${FROM}/pslist | |
36 | echo -n "This file has no trailing lf" > ${FROM}/nolf | |
37 | ln -s nolf ${FROM}/nolf-symlink | |
38 | cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1} | |
39 | mkdir ${FROM}/dir | |
40 | cp ${FROM}/${F1} ${FROM}/dir | |
41 | ||
42 | checkit() { | |
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 | ||
68 | checkforlogs() { | |
69 | if [ -f $1 ] ; then | |
70 | cat <<EOF | |
71 | ||
72 | Failures have occured. | |
73 | ||
74 | You can find the output of the tests in these files: | |
75 | $@ | |
76 | ||
77 | Please hit <RETURN> | |
78 | EOF | |
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 | ||
90 | checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
91 | 1 "basic operation" | |
92 | ||
93 | ln ${FROM}/pslist ${FROM}/dir | |
94 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
95 | 2 "hard links" | |
96 | ||
97 | rm ${TO}/${F1} | |
98 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
99 | 3 "one file" | |
100 | ||
101 | echo "extra line" >> ${TO}/${F1} | |
102 | checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
103 | 4 "extra data" | |
104 | ||
105 | cp ${FROM}/${F1} ${TO}/ThisShouldGo | |
106 | checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
107 | 5 " --delete" | |
108 | ||
35f69d8a AT |
109 | 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 |
110 | mkdir -p ${LONGDIR} | |
111 | date > ${LONGDIR}/1 | |
112 | ls -la / > ${LONGDIR}/2 | |
113 | checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \ | |
114 | 6 "long paths" | |
115 | ||
ddddf27b AT |
116 | if type ssh >/dev/null ; then |
117 | rm -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 |
124 | else |
125 | echo "" | |
d3394de1 | 126 | echo "**** Skipping SSH tests because ssh is not in the path\a ****" |
ddddf27b AT |
127 | echo "" |
128 | fi | |
129 | ||
130 | checkforlogs ${LOG}.? |