From 3a0ab0b7dc0bc040bcb641a6f2b0af3eb7aa0dc1 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 28 Apr 2023 16:28:28 +0000 Subject: [PATCH] Import rsync regress provided by Martin Cracauer so that bluhm@ can work improve it in tree. --- regress/usr.bin/rsync/Makefile | 6 ++ regress/usr.bin/rsync/conf.sh | 1 + regress/usr.bin/rsync/lib.sh | 90 +++++++++++++++++++ regress/usr.bin/rsync/runtests.sh | 11 +++ regress/usr.bin/rsync/test0_noslash.test | 20 +++++ regress/usr.bin/rsync/test10_perms.test | 29 ++++++ regress/usr.bin/rsync/test10b_perms.test | 26 ++++++ regress/usr.bin/rsync/test11_middlediff.test | 41 +++++++++ regress/usr.bin/rsync/test11b_middlediff.test | 44 +++++++++ regress/usr.bin/rsync/test12_inex.test | 20 +++++ regress/usr.bin/rsync/test12b_inex.test | 19 ++++ regress/usr.bin/rsync/test12c_inex.test | 19 ++++ regress/usr.bin/rsync/test1_minusa.test | 18 ++++ regress/usr.bin/rsync/test2_minusexclude.test | 22 +++++ regress/usr.bin/rsync/test3_minusexclude.test | 22 +++++ .../usr.bin/rsync/test3b_minusexclude.test | 22 +++++ .../usr.bin/rsync/test3c_minusexclude.test | 22 +++++ .../usr.bin/rsync/test3d_minusexclude.test | 22 +++++ .../usr.bin/rsync/test3e_minusexclude.test | 22 +++++ regress/usr.bin/rsync/test4_excludedir.test | 23 +++++ regress/usr.bin/rsync/test6_perms.test | 26 ++++++ regress/usr.bin/rsync/test6b_perms.test | 32 +++++++ regress/usr.bin/rsync/test7_symlinks.test | 26 ++++++ regress/usr.bin/rsync/test7b_symlinks.test | 23 +++++ regress/usr.bin/rsync/test8_times.test | 31 +++++++ regress/usr.bin/rsync/test8b_times.test | 31 +++++++ regress/usr.bin/rsync/test9_norecurse.test | 21 +++++ 27 files changed, 689 insertions(+) create mode 100644 regress/usr.bin/rsync/Makefile create mode 100644 regress/usr.bin/rsync/conf.sh create mode 100644 regress/usr.bin/rsync/lib.sh create mode 100644 regress/usr.bin/rsync/runtests.sh create mode 100644 regress/usr.bin/rsync/test0_noslash.test create mode 100644 regress/usr.bin/rsync/test10_perms.test create mode 100644 regress/usr.bin/rsync/test10b_perms.test create mode 100644 regress/usr.bin/rsync/test11_middlediff.test create mode 100644 regress/usr.bin/rsync/test11b_middlediff.test create mode 100644 regress/usr.bin/rsync/test12_inex.test create mode 100644 regress/usr.bin/rsync/test12b_inex.test create mode 100644 regress/usr.bin/rsync/test12c_inex.test create mode 100644 regress/usr.bin/rsync/test1_minusa.test create mode 100644 regress/usr.bin/rsync/test2_minusexclude.test create mode 100644 regress/usr.bin/rsync/test3_minusexclude.test create mode 100644 regress/usr.bin/rsync/test3b_minusexclude.test create mode 100644 regress/usr.bin/rsync/test3c_minusexclude.test create mode 100644 regress/usr.bin/rsync/test3d_minusexclude.test create mode 100644 regress/usr.bin/rsync/test3e_minusexclude.test create mode 100644 regress/usr.bin/rsync/test4_excludedir.test create mode 100644 regress/usr.bin/rsync/test6_perms.test create mode 100644 regress/usr.bin/rsync/test6b_perms.test create mode 100644 regress/usr.bin/rsync/test7_symlinks.test create mode 100644 regress/usr.bin/rsync/test7b_symlinks.test create mode 100644 regress/usr.bin/rsync/test8_times.test create mode 100644 regress/usr.bin/rsync/test8b_times.test create mode 100644 regress/usr.bin/rsync/test9_norecurse.test diff --git a/regress/usr.bin/rsync/Makefile b/regress/usr.bin/rsync/Makefile new file mode 100644 index 00000000000..13331159ecc --- /dev/null +++ b/regress/usr.bin/rsync/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2023/04/28 16:28:28 claudio Exp $ + +regress: + sh ${.CURDIR}/runtests.sh ${.CURDIR} + +.include diff --git a/regress/usr.bin/rsync/conf.sh b/regress/usr.bin/rsync/conf.sh new file mode 100644 index 00000000000..b446e239c70 --- /dev/null +++ b/regress/usr.bin/rsync/conf.sh @@ -0,0 +1 @@ +rsync=${rsync-openrsync} diff --git a/regress/usr.bin/rsync/lib.sh b/regress/usr.bin/rsync/lib.sh new file mode 100644 index 00000000000..37732b686d3 --- /dev/null +++ b/regress/usr.bin/rsync/lib.sh @@ -0,0 +1,90 @@ +#! /bin/sh + +set -u +set -e + +# Library of functions. +# Intended to be sourced by scripts (or interactive shells if you want). + +genfile_stdout_16m () +{ + seq -f%015g 1048576 +} +genfile_stdout_1m () +{ + seq -f%015g 65536 +} +genfile () +{ + #touch "$1" + genfile_stdout_1m > "$1" +} + +# makes a directory path and optionally a file in it. +# if you want the last element to be a directory, add / at the end +mkdirfile () +{ + case "$1" in + '') error that cannot work;; + */) mkdir -p "$1";; + */*) mkdir -p "${1%/*}"; genfile "$1";; + *) genfile "$1";; + esac +} + +mkdirsymlink () +{ + ( + mkdir -p "$1" + cd "$1" + ln -sf "$2" "$3" + ) +} + +# make a first interesting tree +generate_tree_1 () +{ + mkdirfile foo/bar/baz/one.txt + mkdirfile foo/bar/baz/one2.txt + mkdirfile 'foo/bar/baz/ two.txt' + mkdirfile 'foo/bar/baz/two 2.txt' + mkdirfile 'foo/bar/baz/two3.txt ' + mkdirsymlink foo/baz/ ../bar/baz/one.txt three.txt + mkdirfile one/two/three/four.txt + mkdirfile foo/five/one/two/five/blah.txt + mkdirfile foo/one/two/five/blah.txt +} + +# a frontend for find +# first argument is a dir to chdir to +findme () +{ + if [ $# -lt 2 ] ; then + echo usage: different 1>&2 + return 1 + fi + ( + cd "$1" ; shift + # Cut out the inode number and blocks used. + # Maybe later also cut out size in bytes for directories. + find "$@" -ls | sed 's/^ *[0-9]* *[0-9]* *//' | sort + ) +} + +# compare two trees. This will later be modular to pick between: +# - diff +# - find . -print0 | sort --zero-terminated | xargs -0 tar fc foo.tar +# - mtree +compare_trees () +{ + if [ $# -ne 2 ] ; then + echo usage: different 1>&2 + return 1 + fi + # files_and_permissions + findme "$1" . > find1 + findme "$2" . > find2 + diff -u find[12] + # file contents + diff -ru "$1" "$2" +} diff --git a/regress/usr.bin/rsync/runtests.sh b/regress/usr.bin/rsync/runtests.sh new file mode 100644 index 00000000000..190a9f09ea8 --- /dev/null +++ b/regress/usr.bin/rsync/runtests.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +for i in ${1}/*.test; do + echo $(basename ${i}) + tstdir=${1} sh ${i} + if [ "$?" -eq "0" ]; then + echo OK + else + echo FAIL + fi +done diff --git a/regress/usr.bin/rsync/test0_noslash.test b/regress/usr.bin/rsync/test0_noslash.test new file mode 100644 index 00000000000..4186b20a7de --- /dev/null +++ b/regress/usr.bin/rsync/test0_noslash.test @@ -0,0 +1,20 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +mkdir dir1 +cd dir1 +generate_tree_1 + +cd ../.. +$rsync -a dir1 dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test10_perms.test b/regress/usr.bin/rsync/test10_perms.test new file mode 100644 index 00000000000..e7570f19e50 --- /dev/null +++ b/regress/usr.bin/rsync/test10_perms.test @@ -0,0 +1,29 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +umask 022 +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +chmod 640 foo/bar/baz/one.txt +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +genfile one.txt +# we expect umask permissions after rsync +chmod 644 one.txt + +mkdir ../dir3 +cd ../dir3 +genfile one.txt +# we expect umask permissions after rsync +chmod 644 one.txt + +cd .. +# call -a without -p +$rsync -Dgorltr dir1/foo/bar/baz/one.txt dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test10b_perms.test b/regress/usr.bin/rsync/test10b_perms.test new file mode 100644 index 00000000000..4bce84baecd --- /dev/null +++ b/regress/usr.bin/rsync/test10b_perms.test @@ -0,0 +1,26 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +umask 022 +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +chmod 640 foo/bar/baz/one.txt +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +genfile one.txt +# we expect the file's original permissions (not umask) +# when the target did not exist. +chmod 640 one.txt + +mkdir ../dir3 + +cd .. +# call -a without -p +$rsync -Dgorltr dir1/foo/bar/baz/one.txt dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test11_middlediff.test b/regress/usr.bin/rsync/test11_middlediff.test new file mode 100644 index 00000000000..bef6f23e4e7 --- /dev/null +++ b/regress/usr.bin/rsync/test11_middlediff.test @@ -0,0 +1,41 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +umask 022 +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +rm foo/baz/three.txt +# make this file again the way we want it. +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo foo >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +rm foo/baz/three.txt +# make this file again the way we want it. +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo foo >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt + +mkdir ../dir3 +cd ../dir3 +generate_tree_1 +rm foo/baz/three.txt +# make this file different in the middle +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo bar >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt + +cd .. +# openrsync needs the --ignore-times here since it doesn't have +# a flag to force checksumming. +echo $rsync -a --ignore-times dir1/ dir3 +$rsync --rsync-path openrsync -a --ignore-times dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test11b_middlediff.test b/regress/usr.bin/rsync/test11b_middlediff.test new file mode 100644 index 00000000000..ce8fb6d17e5 --- /dev/null +++ b/regress/usr.bin/rsync/test11b_middlediff.test @@ -0,0 +1,44 @@ +#! /bin/sh + +# this test is a bit easier than test11 since the file size differs + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +umask 022 +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +rm foo/baz/three.txt +# make this file again the way we want it. +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo foo >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt +echo baz >> foo/bar/baz/one.txt +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +rm foo/baz/three.txt +# make this file again the way we want it. +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo foo >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt +echo baz >> foo/bar/baz/one.txt + +mkdir ../dir3 +cd ../dir3 +generate_tree_1 +rm foo/baz/three.txt +# make this file different in the middle +dd if=/dev/zero bs=1m count=1 status=none > foo/bar/baz/one.txt +echo bar >> foo/bar/baz/one.txt +dd if=/dev/zero bs=1m count=1 status=none >> foo/bar/baz/one.txt + +cd .. +# openrsync needs the --ignore-times here since it doesn't have +# a flag to force checksumming. +$rsync -a --ignore-times dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test12_inex.test b/regress/usr.bin/rsync/test12_inex.test new file mode 100644 index 00000000000..5e7597e40b8 --- /dev/null +++ b/regress/usr.bin/rsync/test12_inex.test @@ -0,0 +1,20 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +find . -type f \! -name '???.txt' -exec rm {} \; +rm foo/baz/three.txt + +cd .. +$rsync -a --include='???.txt' --include='*/' --exclude='*' dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test12b_inex.test b/regress/usr.bin/rsync/test12b_inex.test new file mode 100644 index 00000000000..0f7f8335d91 --- /dev/null +++ b/regress/usr.bin/rsync/test12b_inex.test @@ -0,0 +1,19 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +mkdirfile meh.txt +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +mkdirfile meh.txt + +cd .. +$rsync -a --exclude='*/' dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test12c_inex.test b/regress/usr.bin/rsync/test12c_inex.test new file mode 100644 index 00000000000..f2b4406396b --- /dev/null +++ b/regress/usr.bin/rsync/test12c_inex.test @@ -0,0 +1,19 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +find . -type f \! -name '*.txt' -exec rm {} \; + +cd .. +$rsync -a --include='*.txt' --include='*/' --exclude='*' dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test1_minusa.test b/regress/usr.bin/rsync/test1_minusa.test new file mode 100644 index 00000000000..1264f7ff1e7 --- /dev/null +++ b/regress/usr.bin/rsync/test1_minusa.test @@ -0,0 +1,18 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 + +cd .. +$rsync -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test2_minusexclude.test b/regress/usr.bin/rsync/test2_minusexclude.test new file mode 100644 index 00000000000..64d06437d64 --- /dev/null +++ b/regress/usr.bin/rsync/test2_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm one/two/three/four.txt + +cd .. +$rsync --exclude 'four.txt' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test3_minusexclude.test b/regress/usr.bin/rsync/test3_minusexclude.test new file mode 100644 index 00000000000..743acc5ae0d --- /dev/null +++ b/regress/usr.bin/rsync/test3_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm foo/bar/baz/' two.txt' + +cd .. +$rsync --exclude ' two.txt' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test3b_minusexclude.test b/regress/usr.bin/rsync/test3b_minusexclude.test new file mode 100644 index 00000000000..f22a2411460 --- /dev/null +++ b/regress/usr.bin/rsync/test3b_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm 'foo/bar/baz/ two.txt' + +cd .. +$rsync --exclude ' *' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test3c_minusexclude.test b/regress/usr.bin/rsync/test3c_minusexclude.test new file mode 100644 index 00000000000..cd66c066cca --- /dev/null +++ b/regress/usr.bin/rsync/test3c_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm foo/bar/baz/*' '* + +cd .. +$rsync --exclude '* *' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test3d_minusexclude.test b/regress/usr.bin/rsync/test3d_minusexclude.test new file mode 100644 index 00000000000..41e0f537e51 --- /dev/null +++ b/regress/usr.bin/rsync/test3d_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm foo/bar/baz/*' ' + +cd .. +$rsync --exclude '* ' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test3e_minusexclude.test b/regress/usr.bin/rsync/test3e_minusexclude.test new file mode 100644 index 00000000000..b92fe668890 --- /dev/null +++ b/regress/usr.bin/rsync/test3e_minusexclude.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm foo/bar/baz/two3.txt' ' + +cd .. +$rsync --exclude 'two3.txt ' -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test4_excludedir.test b/regress/usr.bin/rsync/test4_excludedir.test new file mode 100644 index 00000000000..5ab10bdb6b3 --- /dev/null +++ b/regress/usr.bin/rsync/test4_excludedir.test @@ -0,0 +1,23 @@ +#! /bin/sh + +# testing --exclude basics + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +# manually delete the file that should be missing after rsync +rm one/two/three/four.txt +rmdir one/two/three + +cd .. +$rsync --exclude two/three -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test6_perms.test b/regress/usr.bin/rsync/test6_perms.test new file mode 100644 index 00000000000..4c619fe6da1 --- /dev/null +++ b/regress/usr.bin/rsync/test6_perms.test @@ -0,0 +1,26 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 + +# Also make the target tree and mess up some permissions in there. +# We expect rsync to reset this to what dir1 has. +mkdir ../dir3 +cd ../dir3 +generate_tree_1 +chmod 600 foo/bar/baz/one.txt +chmod 070 foo/bar/baz/one2.txt + +cd .. +$rsync -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test6b_perms.test b/regress/usr.bin/rsync/test6b_perms.test new file mode 100644 index 00000000000..9a23281ad9a --- /dev/null +++ b/regress/usr.bin/rsync/test6b_perms.test @@ -0,0 +1,32 @@ +#! /bin/sh + +# Testing that rsync -a without -p indeed leaves permissions alone. +# Make the target tree and mess up some permissions in there. +# We expect rsync to NOT reset this to what dir1 has since we don't +# use -a. + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +chmod 600 foo/bar/baz/one.txt +chmod 777 foo/bar/baz/one2.txt + +mkdir ../dir3 +cd ../dir3 +generate_tree_1 +chmod 600 foo/bar/baz/one.txt +chmod 777 foo/bar/baz/one2.txt + +cd .. +# call -a without -p. +$rsync -Dglort dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test7_symlinks.test b/regress/usr.bin/rsync/test7_symlinks.test new file mode 100644 index 00000000000..760770d6f24 --- /dev/null +++ b/regress/usr.bin/rsync/test7_symlinks.test @@ -0,0 +1,26 @@ +#! /bin/sh + +# see end of file for comment + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 + +mkdir ../dir3 +cd ../dir3 +generate_tree_1 + +cd .. +# call -a without -l. +# pre-existing symlink should be gone? +$rsync --delete -Dgortp dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test7b_symlinks.test b/regress/usr.bin/rsync/test7b_symlinks.test new file mode 100644 index 00000000000..9ec81c692f0 --- /dev/null +++ b/regress/usr.bin/rsync/test7b_symlinks.test @@ -0,0 +1,23 @@ +#! /bin/sh + +# see end of file for comment + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +generate_tree_1 +rm foo/baz/three.txt + +cd .. +# call -a without -l. +# we expect no symlink to be in the target tree +$rsync -Dgortp dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test8_times.test b/regress/usr.bin/rsync/test8_times.test new file mode 100644 index 00000000000..3e806a61663 --- /dev/null +++ b/regress/usr.bin/rsync/test8_times.test @@ -0,0 +1,31 @@ +#! /bin/sh + +# testing modification time. This is tricky for two reasons: +# - BSD find only emits minutes granularity +# - the test might run less than a second, but the rsync +# protocol has 1 second roundoff in times +# So we set some time older than this software for some +# parts of the original tree. + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +touch -d 1975-10-21T01:01:01 foo +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +touch -d 1975-10-21T01:01:01 foo + +# test a - we want the time corrected +mkdir ../dir3 +cd ../dir3 +touch -d 1975-10-21T01:01:01 foo + +cd .. +# call -a +$rsync -Dgorltp dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test8b_times.test b/regress/usr.bin/rsync/test8b_times.test new file mode 100644 index 00000000000..9c8702d5d71 --- /dev/null +++ b/regress/usr.bin/rsync/test8b_times.test @@ -0,0 +1,31 @@ +#! /bin/sh + +# testing modification time. This is tricky for two reasons: +# - BSD find only emits minutes granularity +# - the test might run less than a second, but the rsync +# protocol has 1 second roundoff in times +# So we set some time older than this software for some +# parts of the original tree. + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +touch -d 1976-10-21T01:01:01 foo +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +touch foo + +# test b - we want the time set to the current time by rsync +mkdir ../dir3 +cd ../dir3 +touch -d 1975-10-21T01:01:01 foo + +cd .. +# call -a without -t +$rsync -Dgorlp dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test9_norecurse.test b/regress/usr.bin/rsync/test9_norecurse.test new file mode 100644 index 00000000000..a5b877e3b8c --- /dev/null +++ b/regress/usr.bin/rsync/test9_norecurse.test @@ -0,0 +1,21 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +mkdir dir1 +cd dir1 +generate_tree_1 +# make the tree we want to compare to +mkdir ../dir2 +cd ../dir2 +genfile one.txt + +mkdir ../dir3 + +cd .. +# call -a without -r +$rsync -Dgorltp dir1/foo/bar/baz/one.txt dir3 +compare_trees dir2 dir3 -- 2.20.1