daemon.test 2.6 KB

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