configuration parsing and loading code for rsyncd. This is based
[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
AT
12
13export PATH=.:$PATH
14TMP=/tmp/rsync-test.$$
ddddf27b
AT
15FROM=${TMP}/from
16TO=${TMP}/to
17F1=text1
18LOG=${TMP}/log
5806b30f
AT
19
20mkdir $TMP
ddddf27b
AT
21mkdir $FROM
22mkdir $TO
23
24# set up test data
25touch ${FROM}/empty
26mkdir ${FROM}/emptydir
27ps ax > ${FROM}/pslist
28echo -n "This file has no trailing lf" > ${FROM}/nolf
29ln -s nolf ${FROM}/nolf-symlink
30cat /etc/inittab /etc/services /etc/resolv.conf > ${FROM}/${F1}
31mkdir ${FROM}/dir
32cp ${FROM}/${F1} ${FROM}/dir
33
34checkit() {
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
60checkforlogs() {
61 if [ -f $1 ] ; then
62 cat <<EOF
63
64Failures have occured.
65
66You can find the output of the tests in these files:
67 $@
68
69Please hit <RETURN>
70EOF
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
82checkit "rsync -av ${FROM}/ ${TO}" ${FROM}/ ${TO} \
83 1 "basic operation"
84
85ln ${FROM}/pslist ${FROM}/dir
86checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
87 2 "hard links"
88
89rm ${TO}/${F1}
90checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
91 3 "one file"
92
93echo "extra line" >> ${TO}/${F1}
94checkit "rsync -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
95 4 "extra data"
96
97cp ${FROM}/${F1} ${TO}/ThisShouldGo
98checkit "rsync --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO} \
99 5 " --delete"
100
101if type ssh >/dev/null ; then
102rm -rf ${TO}
103 checkit "rsync -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO} \
104 6 "ssh: basic test"
105
106 mv ${TO}/${F1} ${TO}/ThisShouldGo
107 checkit "rsync --delete -avH -e ssh ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}\
108 7 "ssh: renamed file"
109else
110 echo ""
d3394de1 111 echo "**** Skipping SSH tests because ssh is not in the path\a ****"
ddddf27b
AT
112 echo ""
113fi
114
115checkforlogs ${LOG}.?
116