3 # Test that we can write into a bind mount placed at PATH.augnew with the
4 # copy_if_rename_fails flag.
5 # This requires that EXDEV or EBUSY is returned from rename(2) to activate the
6 # code path, so set up a bind mount on Linux.
8 if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then
9 echo "Test can only be run as root on Linux to create bind mounts"
13 ROOT=$abs_top_builddir/build/test-put-mount-augnew
14 LENSES=$abs_top_srcdir/lenses
17 HOSTS_AUGNEW=${HOSTS}.augnew
18 TARGET=$ROOT/other/real_hosts
21 mkdir -p $(dirname $HOSTS)
22 mkdir -p $(dirname $TARGET)
24 echo 127.0.0.1 localhost > $HOSTS
25 touch $TARGET $HOSTS_AUGNEW
27 mount --bind $TARGET $HOSTS_AUGNEW
33 HOSTS_SUM=$(sum $HOSTS)
35 augtool --nostdinc -I $LENSES -r $ROOT --new <<EOF
36 set /augeas/save/copy_if_rename_fails 1
37 set /files/etc/hosts/1/alias myhost
42 if [ ! -f $HOSTS ] ; then
43 echo "/etc/hosts is no longer a regular file"
46 if [ ! "x${HOSTS_SUM}" = "x$(sum $HOSTS)" ]; then
47 echo "/etc/hosts has changed"
50 if [ ! "x${HOSTS_SUM}" = "x$(sum $HOSTS)" ]; then
51 echo "/etc/hosts has changed"
55 if [ ! -s $HOSTS_AUGNEW ]; then
56 echo "/etc/hosts.augnew is empty"
59 if [ ! -s $TARGET ]; then
60 echo "/other/real_hosts is empty"
64 if ! grep myhost $TARGET >/dev/null; then
65 echo "/other/real_hosts does not contain the modification"