[augeas-devel] [PATCH 3/4] Test that getting and setting the root node works

lutter at redhat.com lutter at redhat.com
Wed Jan 12 02:05:17 UTC 2011


From: David Lutterkort <lutter at redhat.com>

This tests the same thing that test-get.sh tests, but in a much more
reliable fashion
---
 src/augtool.c                     |    2 ++
 tests/Makefile.am                 |    2 +-
 tests/test-augtool-modify-root.sh |   27 +++++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletions(-)
 create mode 100755 tests/test-augtool-modify-root.sh

diff --git a/src/augtool.c b/src/augtool.c
index 4b89622..7de8e9d 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -59,6 +59,8 @@ static char *cleanstr(char *path, const char sep) {
 }
 
 static char *cleanpath(char *path) {
+    if (STREQ(path, "/"))
+        return path;
     return cleanstr(path, SEP);
 }
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4b9b39c..be510a8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -130,7 +130,7 @@ check_SCRIPTS = \
   test-put-symlink.sh test-save-empty.sh test-mv.sh \
   test-bug-1.sh test-idempotent.sh test-preserve.sh \
   test-events-saved.sh test-save-mode.sh test-unlink-error.sh \
-  test-augtool-empty-line.sh
+  test-augtool-empty-line.sh test-augtool-modify-root.sh
 
 EXTRA_DIST = \
   augtest $(AUGTESTS) root lens-test-1 \
diff --git a/tests/test-augtool-modify-root.sh b/tests/test-augtool-modify-root.sh
new file mode 100755
index 0000000..b102965
--- /dev/null
+++ b/tests/test-augtool-modify-root.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+# Make sure changing the value of root works
+
+exp="/ = root"
+
+act=$(augtool --noautoload 2>&1 <<EOF
+set / root
+get /
+quit
+EOF
+)
+result=$?
+
+if [ $result -ne 0 ]; then
+    echo "augtool failed"
+    exit 1
+fi
+
+if [ "$act" != "$exp" ]; then
+    echo "augtool produced unexpected output:"
+    echo "Expected:"
+    echo "$exp"
+    echo "Actual:"
+    echo "$act"
+    exit 1
+fi
-- 
1.7.3.4




More information about the augeas-devel mailing list