Moved check_perms() into rsync.fns and tweaked how it is called.
[rsync/rsync.git] / testsuite / executability.test
1 #! /bin/sh
2
3 # This program is distributable under the terms of the GNU GPL see
4 # COPYING).
5
6 # Test the --executability or -E option. -- Matt McCutchen
7
8 . $srcdir/testsuite/rsync.fns
9
10 set -x
11
12 # Put some files in the From directory
13 mkdir "$fromdir"
14 cat <<EOF >"$fromdir/1"
15 #!/bin/sh
16 echo 'Program One!'
17 EOF
18 cat <<EOF >"$fromdir/2"
19 #!/bin/sh
20 echo 'Program Two!'
21 EOF
22
23 chmod 700 "$fromdir/1" || test_skipped "Can't chmod"
24 chmod 600 "$fromdir/2"
25
26 $RSYNC -rvv "$fromdir/" "$todir/"
27
28 check_perms "$todir/1" rwx------ || test_fail "After initial transfer: to/1 should have 700 permissions"
29 check_perms "$todir/2" rw------- || test_fail "After initial transfer: to/2 should have 600 permissions"
30
31 # Mix up the permissions a bit
32 chmod 600 "$fromdir/1"
33 chmod 601 "$fromdir/2"
34 chmod 604 "$todir/2"
35
36 $RSYNC -rvv "$fromdir/" "$todir/"
37
38 # No -E, so nothing should have changed
39 check_perms "$todir/1" rwx------ || test_fail "After update without -E: to/1 should still have 700 permissions"
40 check_perms "$todir/2" rw----r-- || test_fail "After update without -E: to/2 should still have 604 permissions"
41
42 $RSYNC -rvvE "$fromdir/" "$todir/"
43
44 # Now things should have happened!
45 check_perms "$todir/1" rw------- || test_fail "After update with -E: to/1 should now have 600 permissions"
46 check_perms "$todir/2" rwx---r-x || test_fail "After update with -E: to/2 should now have 705 permissions"
47
48 # Hooray
49 exit 0