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