Commit | Line | Data |
---|---|---|
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 | ||
12 | RSYNC="$rsync_bin" | |
13 | ||
3a4c683f MP |
14 | . "$suitedir/rsync.fns" |
15 | ||
16 | hands_setup | |
068a7221 MP |
17 | |
18 | checkit() { | |
19 | testnum=`expr 0${testnum} + 1` | |
20 | log=${LOG}.${testnum} | |
21 | failed= | |
22 | echo "Running: \"$1\"" >${log} | |
23 | echo "">>${log} | |
24 | eval "$1" >>${log} 2>&1 | |
25 | status=$? | |
26 | if [ $status != 0 ]; then | |
27 | failed="YES"; | |
28 | fi | |
29 | echo "-------------">>${log} | |
30 | echo "check how the files compare with diff:">>${log} | |
31 | echo "">>${log} | |
32 | diff -ur $2 $3 >>${log} 2>&1 || failed=YES | |
33 | echo "-------------">>${log} | |
34 | echo "check how the directory listings compare with diff:">>${log} | |
35 | echo "">>${log} | |
36 | ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log} | |
37 | ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log} | |
38 | diff -u ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES | |
39 | if [ -z "${failed}" ] ; then | |
e340a820 | 40 | echo "${ECHO_T} done." |
068a7221 MP |
41 | rm $log |
42 | return 0 | |
43 | else | |
44 | if test -n "${Debian}" ; then | |
45 | cat ${log} | |
46 | rm ${log} | |
47 | else | |
e340a820 | 48 | echo "${ECHO_T} FAILED (test # ${testnum} status=$status).\a" |
068a7221 MP |
49 | fi |
50 | return 1 | |
51 | fi | |
52 | } | |
53 | ||
54 | ||
55 | checkforlogs() { | |
56 | # skip it if we're under debian-test | |
57 | if test -n "${Debian}" ; then return 0 ; fi | |
58 | ||
59 | if [ -f $1 ] ; then | |
60 | cat <<EOF | |
61 | ||
62 | Failures have occured. | |
63 | ||
64 | You can find the output of the tests in these files: | |
65 | $@ | |
068a7221 | 66 | EOF |
09ec75a6 | 67 | exit 1 |
068a7221 MP |
68 | else |
69 | ||
70 | rm -rf ${TMP} | |
71 | echo "" | |
72 | echo "Tests Completed Successfully :-)" | |
73 | fi | |
74 | } | |
75 | ||
76 | # Main script starts here | |
77 | ||
78 | runtest "basic operation" 'checkit "$RSYNC -av ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
79 | ||
80 | ln ${FROM}/pslist ${FROM}/dir | |
81 | runtest "hard links" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
82 | ||
83 | rm ${TO}/${F1} | |
84 | runtest "one file" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
85 | ||
86 | echo "extra line" >> ${TO}/${F1} | |
87 | runtest "extra data" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
88 | ||
89 | cp ${FROM}/${F1} ${TO}/ThisShouldGo | |
90 | runtest " --delete" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
91 | ||
92 | 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 | |
93 | mkdir -p ${LONGDIR} | |
94 | date > ${LONGDIR}/1 | |
95 | ls -la / > ${LONGDIR}/2 | |
96 | runtest "long paths" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}' | |
97 | ||
068a7221 MP |
98 | rm -rf ${TO} |
99 | mkdir -p ${FROM}2/dir/subdir | |
100 | cp -a ${FROM}/dir/subdir/subsubdir ${FROM}2/dir/subdir | |
101 | cp ${FROM}/dir/* ${FROM}2/dir 2>/dev/null | |
102 | runtest "excludes" 'checkit "$RSYNC -vv -Hlrt --delete --include /dir/ --include /dir/\* --include /dir/\*/subsubdir --include /dir/\*/subsubdir/\*\* --exclude \*\* ${FROM}/dir ${TO}" ${FROM}2/ ${TO}' | |
103 | rm -r ${FROM}2 | |
104 | ||
105 | checkforlogs ${LOG}.? |