Bump to 1.14.1
[platform/upstream/augeas.git] / tests / test-put-symlink.sh
1 #!/bin/sh
2
3 # Test that we correctly preserve symlinks when saving a file
4
5 ROOT=$abs_top_builddir/build/test-put-symlink
6 LENSES=$abs_top_srcdir/lenses
7 HOSTS=$ROOT/etc/hosts
8 REAL_HOSTS=$ROOT/other/hosts
9
10 rm -rf $ROOT
11 mkdir -p $(dirname $HOSTS)
12 mkdir -p $(dirname $REAL_HOSTS)
13
14 cat <<EOF > $REAL_HOSTS
15 127.0.0.1 localhost
16 EOF
17
18 (cd $(dirname $HOSTS) && ln -s ../other/hosts $(basename $HOSTS))
19
20 augtool --nostdinc -I $LENSES -b -r $ROOT > /dev/null <<EOF
21 set /files/etc/hosts/1/alias myhost
22 save
23 EOF
24
25 HOSTS_AUGSAVE=${HOSTS}.augsave
26 if [ ! -f $HOSTS_AUGSAVE ] ; then
27     echo "Missing /etc/hosts.augsave"
28     exit 1
29 fi
30 if [ -h $HOSTS_AUGSAVE ] ; then
31     echo "The file /etc/hosts.augsave is a symlink"
32     exit 1
33 fi
34 if [ ! -h $HOSTS ] ; then
35     echo "/etc/hosts is not a symbolic link"
36     exit 1
37 fi
38
39 LINK=$(readlink $HOSTS)
40 if [ "x$LINK" != "x../other/hosts" ] ; then
41     echo "/etc/hosts does not link to ../other/hosts"
42     exit 1
43 fi
44
45 if ! grep myhost $REAL_HOSTS >/dev/null; then
46     echo "/other/hosts does not contain the modification"
47     exit 1
48 fi