3 # Copyright (C) 2001 by Martin Pool <mbp@samba.org>
5 # General-purpose test functions for rsync.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version
9 # 2 as published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 echo $ECHO_N "Test $1: $ECHO_C"
39 # Build test directories TO and FROM, with FROM full of files.
42 [ -d $FROM ] || mkdir $FROM
43 [ -d $TO ] || mkdir $TO
45 # On some BSD systems, the umask affects the mode of created
46 # symlinks, even though the mode apparently has no effect on how
47 # the links behave in the future, and it cannot be changed using
48 # chmod! rsync always sets its umask to 000 so that it can
49 # accurately recreate permissions, but this script is probably run
50 # with a different umask.
52 # This causes a little problem that "ls -l" of the two will not be
53 # the same. So, we need to set our umask before doing any creations.
57 mkdir ${FROM}/emptydir
59 # a few hundred lines of test
60 ls -lR / | head -200 > ${FROM}/filelist
62 # This might fail on systems that don't have -n
63 echo $ECHO_N "This file has no trailing lf$ECHO_C" > ${FROM}/nolf
65 ln -s nolf ${FROM}/nolf-symlink
68 cat $srcdir/*.c | head -2000 > ${FROM}/${F1}
70 cp ${FROM}/${F1} ${FROM}/dir
71 mkdir ${FROM}/dir/subdir
72 mkdir ${FROM}/dir/subdir/subsubdir
73 ls -ltr /etc > ${FROM}/dir/subdir/subsubdir/etc-ltr-list
74 mkdir ${FROM}/dir/subdir/subsubdir2
75 ls -lt /bin > ${FROM}/dir/subdir/subsubdir2/bin-lt-list
80 ###########################
81 # Run a test (in '$1') then compare directories $2 and $3 to see if
82 # there are any difference. If there are, explain them.
87 # the log accumulates all output; we only display it if there
90 echo "Running: \"$1\"" >${log}
92 eval "$1" >>${log} 2>&1
94 if [ $status != 0 ]; then
98 echo "-------------">>${log}
99 echo "check how the files compare with diff:">>${log}
101 diff -cr $2 $3 >>${log} 2>&1 || failed=YES
102 echo "-------------">>${log}
103 echo "check how the directory listings compare with diff:">>${log}
105 ( cd $2 ; ls -laR ) > ${TMP}/ls-from 2>>${log}
106 ( cd $3 ; ls -laR ) > ${TMP}/ls-to 2>>${log}
107 diff -c ${TMP}/ls-from ${TMP}/ls-to >>${log} 2>&1 || failed=YES
108 if [ -z "${failed}" ] ; then
109 echo "${ECHO_T} done."
113 echo "${ECHO_T} failed!"
121 # In fact, we need a more general feature of capturing all stderr/log files,
122 # and dumping them if something goes wrong.
125 # skip it if we're under debian-test
126 if test -n "${Debian}" ; then return 0 ; fi
128 if [ -f $1 -a -s $1 ] ; then
129 echo "Failures have occurred. $1 follows:" >&2
136 build_rsyncd_conf() {
137 # Build an appropriate configuration file
138 conf="$scratchdir/test-rsyncd.conf"
139 echo "building configuration $conf"
142 pidfile="$scratchdir/rsyncd.pid"
143 logfile="$scratchdir/rsyncd.log"
146 # rsyncd configuration file autogenerated by $0
150 hosts allow = localhost, 127.0.0.1
153 [test-from] = $scratchdir/daemon-from/
156 [test-to] = $scratchdir/daemon-to/