3 # Copyright (C) 2001 by Martin Pool <mbp@samba.org>
5 # General-purpose test functions for rsync.
15 echo $ECHO_N "Test $1: $ECHO_C"
24 [ -d $FROM ] || mkdir $FROM
25 [ -d $TO ] || mkdir $TO
29 mkdir ${FROM}/emptydir
31 # a few hundred lines of test
32 ls -lR / | head -200 > ${FROM}/filelist
34 # This might fail on systems that don't have -n
35 echo $ECHO_N "This file has no trailing lf$ECHO_C" > ${FROM}/nolf
36 ln -s nolf ${FROM}/nolf-symlink
37 cat $srcdir/*.c | head -2000 > ${FROM}/${F1}
39 cp ${FROM}/${F1} ${FROM}/dir
40 mkdir ${FROM}/dir/subdir
41 mkdir ${FROM}/dir/subdir/subsubdir
42 ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
43 mkdir ${FROM}/dir/subdir/subsubdir2
44 ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
48 ###########################
49 # Run a test (in '$1') then compare directories $2 and $3 to see if
50 # there are any difference. If there are, explain them.
55 # the log accumulates all output; we only display it if there
58 echo "Running: \"$1\"" >${log}
60 eval "$1" >>${log} 2>&1
62 if [ $status != 0 ]; then
66 echo "-------------">>${log}
67 echo "check how the files compare with diff:">>${log}
69 diff -cr $2 $3 >>${log} 2>&1 || failed=YES
70 echo "-------------">>${log}
71 echo "check how the directory listings compare with diff:">>${log}
73 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
74 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
75 diff -c ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
76 if [ -z "${failed}" ] ; then
77 echo "${ECHO_T} done."
81 echo "${ECHO_T} failed!"
89 # In fact, we need a more general feature of capturing all stderr/log files,
90 # and dumping them if something goes wrong.
93 # skip it if we're under debian-test
94 if test -n "${Debian}" ; then return 0 ; fi
96 if [ -f $1 -a -s $1 ] ; then
97 echo "Failures have occurred. $1 follows:" >&2
104 build_rsyncd_conf() {
105 # Build an appropriate configuration file
106 conf="$scratchdir/test-rsyncd.conf"
107 echo "building configuration $conf"
110 pidfile="$scratchdir/rsyncd.pid"
111 logfile="$scratchdir/rsyncd.log"
114 # rsyncd configuration file autogenerated by $0
118 hosts allow = localhost, 127.0.0.1
121 [test-from] = $scratchdir/daemon-from/
124 [test-to] = $scratchdir/daemon-to/