Bump to 1.14.1
[platform/upstream/augeas.git] / tests / test-augprint.sh
1 #!/bin/bash
2
3 # Test that augprint produces the expected output, and that the output
4 # can be used to reconstruct the original file
5
6
7 test_augprint_files=$abs_top_srcdir/tests/test-augprint
8
9 export AUGEAS_ROOT=$abs_top_builddir/build/test-augprint
10 export AUGEAS_LENS_LIB=$abs_top_srcdir/lenses
11
12 # ------------- /etc/hosts ------------
13 mkdir -p $AUGEAS_ROOT/etc
14 cp --no-preserve=mode --recursive $test_augprint_files/etc/ $AUGEAS_ROOT/
15
16 output=$AUGEAS_ROOT/etc.hosts.augprint
17 AUGEAS_ROOT=$test_augprint_files augprint --pretty --verbose /etc/hosts > $output
18 augtool --load-file=/etc/hosts -f  $output --autosave 1>/dev/null
19 # Check that output matches expected output
20 diff -bu    $test_augprint_files/etc.hosts.pretty.augprint $output || exit 1
21 # Check that file is unchanged
22 diff -bu -B $test_augprint_files/etc/hosts $AUGEAS_ROOT/etc/hosts || exit 1
23
24 AUGEAS_ROOT=$test_augprint_files augprint --regexp=2 /etc/hosts > $output
25 augtool --load-file=/etc/hosts -f  $output --autosave 1>/dev/null
26 # Check that output matches expected output
27 diff -bu    $test_augprint_files/etc.hosts.regexp.augprint $output || exit 1
28 # Check that file is unchanged
29 diff -bu -B $test_augprint_files/etc/hosts $AUGEAS_ROOT/etc/hosts || exit 1
30
31 # ------------- /etc/squid/squid.conf and /etc/pam,d/systemd-auth  ------------
32 for test_file in /etc/squid/squid.conf /etc/pam.d/system-auth ; do
33         mkdir -p $(dirname $AUGEAS_ROOT/$test_file)
34   output=${test_file//\//.}
35   output=${AUGEAS_ROOT}/${output#.}.augprint
36         AUGEAS_ROOT=$test_augprint_files augprint $test_file > $output
37         augtool --load-file=$test_file -f $output --autosave 1>/dev/null
38         # Check that file is unchanged
39         diff -bu -B $test_augprint_files/$test_file $AUGEAS_ROOT/$test_file || exit 1
40 done
41