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"
25 # Build test directories TO and FROM, with FROM full of files.
28 [ -d $FROM ] || mkdir $FROM
29 [ -d $TO ] || mkdir $TO
31 # On some BSD systems, the umask affects the mode of created
32 # symlinks, even though the mode apparently has no effect on how
33 # the links behave in the future, and it cannot be changed using
34 # chmod! rsync always sets its umask to 000 so that it can
35 # accurately recreate permissions, but this script is probably run
36 # with a different umask.
38 # This causes a little problem that "ls -l" of the two will not be
39 # the same. So, we need to set our umask before doing any creations.
45 mkdir ${FROM}/emptydir
47 # a few hundred lines of test
48 ls -lR / | head -200 > ${FROM}/filelist
50 # This might fail on systems that don't have -n
51 echo $ECHO_N "This file has no trailing lf$ECHO_C" > ${FROM}/nolf
52 ln -s nolf ${FROM}/nolf-symlink
53 cat $srcdir/*.c | head -2000 > ${FROM}/${F1}
55 cp ${FROM}/${F1} ${FROM}/dir
56 mkdir ${FROM}/dir/subdir
57 mkdir ${FROM}/dir/subdir/subsubdir
58 ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
59 mkdir ${FROM}/dir/subdir/subsubdir2
60 ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
67 ###########################
68 # Run a test (in '$1') then compare directories $2 and $3 to see if
69 # there are any difference. If there are, explain them.
74 # the log accumulates all output; we only display it if there
77 echo "Running: \"$1\"" >${log}
79 eval "$1" >>${log} 2>&1
81 if [ $status != 0 ]; then
85 echo "-------------">>${log}
86 echo "check how the files compare with diff:">>${log}
88 diff -cr $2 $3 >>${log} 2>&1 || failed=YES
89 echo "-------------">>${log}
90 echo "check how the directory listings compare with diff:">>${log}
92 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
93 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
94 diff -c ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
95 if [ -z "${failed}" ] ; then
96 echo "${ECHO_T} done."
100 echo "${ECHO_T} failed!"
108 # In fact, we need a more general feature of capturing all stderr/log files,
109 # and dumping them if something goes wrong.
112 # skip it if we're under debian-test
113 if test -n "${Debian}" ; then return 0 ; fi
115 if [ -f $1 -a -s $1 ] ; then
116 echo "Failures have occurred. $1 follows:" >&2
123 build_rsyncd_conf() {
124 # Build an appropriate configuration file
125 conf="$scratchdir/test-rsyncd.conf"
126 echo "building configuration $conf"
129 pidfile="$scratchdir/rsyncd.pid"
130 logfile="$scratchdir/rsyncd.log"
133 # rsyncd configuration file autogenerated by $0
137 hosts allow = localhost, 127.0.0.1
140 [test-from] = $scratchdir/daemon-from/
143 [test-to] = $scratchdir/daemon-to/