3 # Test that changing the value of a node causes the function modified() to return true
5 root=$abs_top_builddir/build/test-function-modified
9 mkdir -p $(dirname $hosts)
18 augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF >$root/output.1
19 set /files/etc/hosts/1/ipaddr 127.0.0.4
20 match /files/etc/hosts//*[modified()]
23 [ "$(cat $root/output.1)" = '/files/etc/hosts/1/ipaddr = 127.0.0.4' ] || exit 1
25 # An empty value should return true, even if none of the child nodes are modified
26 augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF >$root/output.2
27 set /files/etc/hosts/1 x
28 set /files/etc/hosts/1
29 match /files/etc/hosts//*[modified()]
32 [ "$(cat $root/output.2)" = '/files/etc/hosts/1 = (none)' ] || exit 1
34 # Test that changing a value does not change the parent node
35 # Test that adding a new node also marks the (new) parent node.
36 augtool --nostdinc -r $root -I $abs_top_srcdir/lenses > /dev/null <<EOF >$root/output.3
37 set /files/etc/hosts/1/ipaddr 127.1.1.1
38 set /files/etc/hosts/3/ipaddr 127.3.3.3
39 match /files/etc/hosts//*[modified()]
42 diff -q $root/output.3 - <<EOF || exit 1
43 /files/etc/hosts/3 = (none)
44 /files/etc/hosts/1/ipaddr = 127.1.1.1
45 /files/etc/hosts/3/ipaddr = 127.3.3.3