itemize.test 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #! /bin/sh
  2. # Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
  3. # This program is distributable under the terms of the GNU GPL (see
  4. # COPYING).
  5. # Test the output of various copy commands to ensure itemized output
  6. # and double-verbose output is correct.
  7. . "$suitedir/rsync.fns"
  8. to2dir="$tmpdir/to2"
  9. chkfile="$scratchdir/rsync.chk"
  10. outfile="$scratchdir/rsync.out"
  11. makepath "$fromdir/foo"
  12. makepath "$fromdir/bar/baz"
  13. cp -p "$srcdir/configure.ac" "$fromdir/foo/config1"
  14. cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
  15. cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
  16. chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
  17. umask 0
  18. ln -s ../bar/baz/rsync "$fromdir/foo/sym"
  19. umask 022
  20. ln "$fromdir/foo/config1" "$fromdir/foo/extra"
  21. rm -f "$to2dir"
  22. # Check if rsync is set to hard-link symlinks.
  23. if egrep '^#define CAN_HARDLINK_SYMLINK 1' config.h >/dev/null; then
  24. L=hL
  25. else
  26. L=cL
  27. fi
  28. # Check if rsync can preserve time on symlinks
  29. case "$RSYNC" in
  30. *protocol=2*)
  31. T=.T
  32. ;;
  33. *)
  34. if $RSYNC --version | grep ", symtimes" >/dev/null; then
  35. T=.t
  36. else
  37. T=.T
  38. fi
  39. ;;
  40. esac
  41. $RSYNC -iplr "$fromdir/" "$todir/" \
  42. | tee "$outfile"
  43. cat <<EOT >"$chkfile"
  44. cd$all_plus ./
  45. cd$all_plus bar/
  46. cd$all_plus bar/baz/
  47. >f$all_plus bar/baz/rsync
  48. cd$all_plus foo/
  49. >f$all_plus foo/config1
  50. >f$all_plus foo/config2
  51. >f$all_plus foo/extra
  52. cL$all_plus foo/sym -> ../bar/baz/rsync
  53. EOT
  54. diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
  55. # Ensure there are no accidental directory-time problems.
  56. $RSYNC -a -f '-! */' "$fromdir/" "$todir"
  57. cp -p "$srcdir/configure.ac" "$fromdir/foo/config2"
  58. chmod 601 "$fromdir/foo/config2"
  59. $RSYNC -iplrH "$fromdir/" "$todir/" \
  60. | tee "$outfile"
  61. cat <<EOT >"$chkfile"
  62. >f..T.$dots bar/baz/rsync
  63. >f..T.$dots foo/config1
  64. >f.sTp$dots foo/config2
  65. hf..T.$dots foo/extra => foo/config1
  66. EOT
  67. diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
  68. $RSYNC -a -f '-! */' "$fromdir/" "$todir"
  69. sleep 1 # For directory mod below to ensure time difference
  70. rm "$todir/foo/sym"
  71. umask 0
  72. ln -s ../bar/baz "$todir/foo/sym"
  73. umask 022
  74. cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
  75. chmod 600 "$fromdir/foo/config2"
  76. chmod 777 "$todir/bar/baz/rsync"
  77. $RSYNC -iplrtc "$fromdir/" "$todir/" \
  78. | tee "$outfile"
  79. cat <<EOT >"$chkfile"
  80. .f..tp$dots bar/baz/rsync
  81. .d..t.$dots foo/
  82. .f..t.$dots foo/config1
  83. >fcstp$dots foo/config2
  84. cLc$T.$dots foo/sym -> ../bar/baz/rsync
  85. EOT
  86. diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
  87. cp -p "$srcdir/configure.ac" "$fromdir/foo/config2"
  88. chmod 600 "$fromdir/foo/config2"
  89. # Lack of -t is for unchanged hard-link stress-test!
  90. $RSYNC -vvplrH "$fromdir/" "$todir/" \
  91. | tee "$outfile"
  92. filter_outfile
  93. cat <<EOT >"$chkfile"
  94. bar/baz/rsync is uptodate
  95. foo/config1 is uptodate
  96. foo/config2
  97. foo/extra is uptodate
  98. foo/sym is uptodate
  99. EOT
  100. diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
  101. chmod 747 "$todir/bar/baz/rsync"
  102. $RSYNC -a -f '-! */' "$fromdir/" "$todir"
  103. $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
  104. | tee "$outfile"
  105. filter_outfile
  106. cat <<EOT >"$chkfile"
  107. .d$allspace ./
  108. .d$allspace bar/
  109. .d$allspace bar/baz/
  110. .f...p$dots bar/baz/rsync
  111. .d$allspace foo/
  112. .f$allspace foo/config1
  113. >f..t.$dots foo/config2
  114. hf$allspace foo/extra
  115. .L$allspace foo/sym -> ../bar/baz/rsync
  116. EOT
  117. diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
  118. chmod 757 "$todir/foo/config1"
  119. touch "$todir/foo/config2"
  120. $RSYNC -vplrtH "$fromdir/" "$todir/" \
  121. | tee "$outfile"
  122. filter_outfile
  123. cat <<EOT >"$chkfile"
  124. foo/config2
  125. EOT
  126. diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
  127. chmod 757 "$todir/foo/config1"
  128. touch "$todir/foo/config2"
  129. $RSYNC -iplrtH "$fromdir/" "$todir/" \
  130. | tee "$outfile"
  131. cat <<EOT >"$chkfile"
  132. .f...p$dots foo/config1
  133. >f..t.$dots foo/config2
  134. EOT
  135. diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
  136. $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
  137. | tee "$outfile"
  138. filter_outfile
  139. case `tail -1 "$outfile"` in
  140. cLc.t*)
  141. sym_dots="c.t.$dots"
  142. L_sym_dots="cL$sym_dots"
  143. is_uptodate='-> ../bar/baz/rsync'
  144. echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
  145. L=cL
  146. ;;
  147. *)
  148. sym_dots="$allspace"
  149. L_sym_dots=".L$allspace"
  150. is_uptodate='is uptodate'
  151. touch "$chkfile.extra"
  152. ;;
  153. esac
  154. cat <<EOT >"$chkfile"
  155. cd$allspace ./
  156. cd$allspace bar/
  157. cd$allspace bar/baz/
  158. cf$allspace bar/baz/rsync
  159. cd$allspace foo/
  160. cf$allspace foo/config1
  161. cf$allspace foo/config2
  162. hf$allspace foo/extra => foo/config1
  163. cL$sym_dots foo/sym -> ../bar/baz/rsync
  164. EOT
  165. diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
  166. rm -rf "$to2dir"
  167. $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
  168. | tee "$outfile"
  169. cat - "$chkfile.extra" <<EOT >"$chkfile"
  170. hf$allspace foo/extra => foo/config1
  171. EOT
  172. diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
  173. rm -rf "$to2dir"
  174. $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
  175. | tee "$outfile"
  176. filter_outfile
  177. cat <<EOT >"$chkfile"
  178. ./ is uptodate
  179. bar/ is uptodate
  180. bar/baz/ is uptodate
  181. bar/baz/rsync is uptodate
  182. foo/ is uptodate
  183. foo/config1 is uptodate
  184. foo/config2 is uptodate
  185. foo/extra => foo/config1
  186. foo/sym $is_uptodate
  187. EOT
  188. diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
  189. rm -rf "$to2dir"
  190. $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
  191. | tee "$outfile"
  192. filter_outfile
  193. cat <<EOT >"$chkfile"
  194. cd$allspace ./
  195. cd$allspace bar/
  196. cd$allspace bar/baz/
  197. hf$allspace bar/baz/rsync
  198. cd$allspace foo/
  199. hf$allspace foo/config1
  200. hf$allspace foo/config2
  201. hf$allspace foo/extra => foo/config1
  202. $L$sym_dots foo/sym -> ../bar/baz/rsync
  203. EOT
  204. diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
  205. rm -rf "$to2dir"
  206. $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
  207. | tee "$outfile"
  208. cat - "$chkfile.extra" <<EOT >"$chkfile"
  209. EOT
  210. diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
  211. rm -rf "$to2dir"
  212. $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
  213. | tee "$outfile"
  214. cat - "$chkfile.extra" <<EOT >"$chkfile"
  215. EOT
  216. diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
  217. rm -rf "$to2dir"
  218. $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
  219. | tee "$outfile"
  220. filter_outfile
  221. cat <<EOT >"$chkfile"
  222. ./ is uptodate
  223. bar/ is uptodate
  224. bar/baz/ is uptodate
  225. bar/baz/rsync is uptodate
  226. foo/ is uptodate
  227. foo/config1 is uptodate
  228. foo/config2 is uptodate
  229. foo/extra is uptodate
  230. foo/sym $is_uptodate
  231. EOT
  232. diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
  233. rm -rf "$to2dir"
  234. $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
  235. | tee "$outfile"
  236. filter_outfile
  237. cat <<EOT >"$chkfile"
  238. cd$allspace ./
  239. cd$allspace bar/
  240. cd$allspace bar/baz/
  241. .f$allspace bar/baz/rsync
  242. cd$allspace foo/
  243. .f$allspace foo/config1
  244. .f$allspace foo/config2
  245. .f$allspace foo/extra
  246. $L_sym_dots foo/sym -> ../bar/baz/rsync
  247. EOT
  248. diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
  249. rm -rf "$to2dir"
  250. $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
  251. | tee "$outfile"
  252. cat - "$chkfile.extra" <<EOT >"$chkfile"
  253. EOT
  254. diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
  255. rm -rf "$to2dir"
  256. $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
  257. | tee "$outfile"
  258. filter_outfile
  259. cat <<EOT >"$chkfile"
  260. ./ is uptodate
  261. bar/ is uptodate
  262. bar/baz/ is uptodate
  263. bar/baz/rsync is uptodate
  264. foo/ is uptodate
  265. foo/config1 is uptodate
  266. foo/config2 is uptodate
  267. foo/extra is uptodate
  268. foo/sym $is_uptodate
  269. EOT
  270. diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
  271. # The script would have aborted on error, so getting here means we've won.
  272. exit 0