Matt's executability test with a few tweaks (e.g. to avoid using
[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 P600='^-rw-------'
13 P604='^-rw----r--'
14 P700='^-rwx------'
15 P705='^-rwx---r-x'
16
17 check_perms() {
18     $TOOLDIR/tls "$1" | grep "$2" >/dev/null
19 }
20
21 # Put some files in the From directory
22 mkdir "$fromdir"
23 cat <<EOF >"$fromdir/1"
24 #!/bin/sh
25 echo 'Program One!'
26 EOF
27 cat <<EOF >"$fromdir/2"
28 #!/bin/sh
29 echo 'Program Two!'
30 EOF
31
32 chmod 700 "$fromdir/1" || test_skipped "Can't chmod"
33 chmod 600 "$fromdir/2"
34
35 $RSYNC -rvv "$fromdir/" "$todir/"
36
37 check_perms "$todir/1" $P700 || test_fail "After initial transfer: to/1 should have 700 permissions"
38 check_perms "$todir/2" $P600 || test_fail "After initial transfer: to/2 should have 600 permissions"
39
40 # Mix up the permissions a bit
41 chmod 600 "$fromdir/1"
42 chmod 601 "$fromdir/2"
43 chmod 604 "$todir/2"
44
45 $RSYNC -rvv "$fromdir/" "$todir/"
46
47 # No -E, so nothing should have changed
48 check_perms "$todir/1" $P700 || test_fail "After update without -E: to/1 should still have 700 permissions"
49 check_perms "$todir/2" $P604 || test_fail "After update without -E: to/2 should still have 604 permissions"
50
51 $RSYNC -rvvE "$fromdir/" "$todir/"
52
53 # Now things should have happened!
54 check_perms "$todir/1" $P600 || test_fail "After update with -E: to/1 should now have 600 permissions"
55 check_perms "$todir/2" $P705 || test_fail "After update with -E: to/2 should now have 705 permissions"
56
57 # Hooray
58 exit 0