Improved the daemon testing, including adding a test to ensure that
[rsync/rsync.git] / testsuite / daemon.test
CommitLineData
232ce2b2
MP
1#!/bin/sh
2
3# Copyright (C) 2001 by Martin Pool <mbp@samba.org>
4
5# This program is distributable under the terms of the GNU GPL (see
6# COPYING)
7
8fef0245
MP
8# We don't really want to start the server listening, because that
9# might interfere with the security or operation of the test machine.
10# Instead we use the fake-connect feature to dynamically assign a pair
11# of ports.
232ce2b2
MP
12
13# Having started the server we try some basic operations against it:
14
15# getting a list of module
16# listing files in a module
17# retrieving a module
18# uploading to a module
19# checking the log file
20# password authentication
21
c13ad7ec 22. "$suitedir/rsync.fns"
232ce2b2 23
0e9c3564
WD
24chkfile="$scratchdir/rsync.chk"
25outfile="$scratchdir/rsync.out"
26
276cc455 27SSH="src/support/lsh --no-cd"
0e9c3564
WD
28DIR_REPL='s/^\(d[^ ]*\) *[0-9][0-9]* /\1 DIR /'
29LS_REPL='s;[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9];####/##/## ##:##:##;'
d1c06c21 30
3aae15ec 31build_rsyncd_conf
232ce2b2 32
0e9c3564
WD
33makepath "$fromdir/foo" "$fromdir/bar/baz"
34makepath "$todir"
35echo one >"$fromdir/foo/one"
36echo two >"$fromdir/bar/two"
37echo three >"$fromdir/bar/baz/three"
38
d1c06c21
WD
39cd "$scratchdir"
40
41ln -s test-rsyncd.conf rsyncd.conf
42
09ad9053
WD
43confopt=''
44case `id -u` in
450)
46 # Root needs to specify the config file, or it uses /etc/rsyncd.conf.
47 echo "Forcing --config=$conf"
48 confopt=" --config=$conf"
49 ;;
50esac
51
276cc455 52$RSYNC -ve "$SSH" --rsync-path="$RSYNC$confopt" localhost::
d1c06c21 53
06464f55 54RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
6cd7888e 55export RSYNC_CONNECT_PROG
232ce2b2 56
0e9c3564
WD
57$RSYNC -v localhost:: \
58 | tee "$outfile"
59# These have a space-padded 15-char name, then a tab, then a comment.
60sed 's/NOCOMMENT//' <<EOT >"$chkfile"
61test-from r/o
62test-to r/w
63test-scratch NOCOMMENT
64EOT
65diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
66
67$RSYNC -r localhost::test-hidden \
68 | sed "$DIR_REPL" | sed "$LS_REPL" \
69 | tee "$outfile"
70cat <<EOT >"$chkfile"
71drwxr-xr-x DIR ####/##/## ##:##:## .
72drwxr-xr-x DIR ####/##/## ##:##:## bar
73-rw-r--r-- 4 ####/##/## ##:##:## bar/two
74drwxr-xr-x DIR ####/##/## ##:##:## bar/baz
75-rw-r--r-- 6 ####/##/## ##:##:## bar/baz/three
76drwxr-xr-x DIR ####/##/## ##:##:## foo
77-rw-r--r-- 4 ####/##/## ##:##:## foo/one
78EOT
79diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
80
81$RSYNC -r localhost::test-from/f* \
82 | sed "$DIR_REPL" | sed "$LS_REPL" \
83 | tee "$outfile"
84cat <<EOT >"$chkfile"
85drwxr-xr-x DIR ####/##/## ##:##:## foo
86-rw-r--r-- 4 ####/##/## ##:##:## foo/one
87EOT
88diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
89