[augeas-devel] [PATCH 4/4] Replace augtest by test-augtool.sh

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


From: David Lutterkort <lutter at redhat.com>

This removes the silly dependency on Ruby, since augtest was the only
Ruby script in the whole source tree.

The test files for test-augtool.sh live in tests/test-augtool, and are
functionally identical to the Ruby test files tests/*.rb. The only
exception is that test-root.rb has been removed - it tested something that
is better tested in test-xpath.c

The new test-augtool.sh test is also a little more efficient in that it
only copies the file needed by a test into the root, and only sets the lens
for that file up for loading. This reduces the runtime of the tests from ~
30s on my machine to under 2s.
---
 tests/Makefile.am                            |    6 +-
 tests/aliases-add-value.rb                   |   19 -----
 tests/aliases-change-value.rb                |   17 ----
 tests/augtest                                |  109 --------------------------
 tests/get-root.rb                            |    4 -
 tests/grub-change-default.rb                 |   18 ----
 tests/grub-rm-entry.rb                       |   27 -------
 tests/grub-setm-newvalues.rb                 |   33 --------
 tests/ini-yum-change.rb                      |   18 ----
 tests/ini-yum-newkey.rb                      |   14 ----
 tests/ini-yum-newsec.rb                      |   15 ----
 tests/ini-yum-rmkey.rb                       |   16 ----
 tests/rec-append-record.rb                   |   19 -----
 tests/rec-hosts-add.rb                       |   19 -----
 tests/rec-hosts-reorder-new.rb               |   29 -------
 tests/rec-hosts-reorder.rb                   |   25 ------
 tests/rec-hosts-rm-hosts.rb                  |   19 -----
 tests/rec-initdefault.rb                     |   25 ------
 tests/rec-ins-record.rb                      |   19 -----
 tests/rec-mod-field.rb                       |   17 ----
 tests/rec-rm-inner-field.rb                  |   16 ----
 tests/rec-rm-record.rb                       |   16 ----
 tests/rec-rm-tail-field.rb                   |   18 ----
 tests/sshd-add-acceptenv.rb                  |   21 -----
 tests/test-augtool.sh                        |   81 +++++++++++++++++++
 tests/test-augtool/aliases-add-value.sh      |   19 +++++
 tests/test-augtool/aliases-change-value.sh   |   17 ++++
 tests/test-augtool/grub-change-default.sh    |   18 ++++
 tests/test-augtool/grub-rm-entry.sh          |   26 ++++++
 tests/test-augtool/grub-setm-newvalues.sh    |   33 ++++++++
 tests/test-augtool/ini-yum-change.sh         |   18 ++++
 tests/test-augtool/ini-yum-newkey.sh         |   14 ++++
 tests/test-augtool/ini-yum-newsec.sh         |   15 ++++
 tests/test-augtool/ini-yum-rmkey.sh          |   16 ++++
 tests/test-augtool/rec-append-record.sh      |   18 ++++
 tests/test-augtool/rec-hosts-add.sh          |   17 ++++
 tests/test-augtool/rec-hosts-reorder-new.sh  |   31 +++++++
 tests/test-augtool/rec-hosts-reorder.sh      |   25 ++++++
 tests/test-augtool/rec-hosts-rm-hosts.sh     |   18 ++++
 tests/test-augtool/rec-initdefault.sh        |   20 +++++
 tests/test-augtool/rec-ins-record.sh         |   19 +++++
 tests/test-augtool/rec-mod-field.sh          |   17 ++++
 tests/test-augtool/rec-rm-inner-field.sh     |   15 ++++
 tests/test-augtool/rec-rm-record.sh          |   15 ++++
 tests/test-augtool/rec-rm-tail-field.sh      |   15 ++++
 tests/test-augtool/sshd-add-acceptenv.sh     |   18 ++++
 tests/test-augtool/yum.repos-setm-enabled.sh |   27 +++++++
 tests/yum.repos-setm-enabled.rb              |   27 -------
 48 files changed, 515 insertions(+), 563 deletions(-)
 delete mode 100644 tests/aliases-add-value.rb
 delete mode 100644 tests/aliases-change-value.rb
 delete mode 100755 tests/augtest
 delete mode 100644 tests/get-root.rb
 delete mode 100644 tests/grub-change-default.rb
 delete mode 100644 tests/grub-rm-entry.rb
 delete mode 100644 tests/grub-setm-newvalues.rb
 delete mode 100644 tests/ini-yum-change.rb
 delete mode 100644 tests/ini-yum-newkey.rb
 delete mode 100644 tests/ini-yum-newsec.rb
 delete mode 100644 tests/ini-yum-rmkey.rb
 delete mode 100644 tests/rec-append-record.rb
 delete mode 100644 tests/rec-hosts-add.rb
 delete mode 100644 tests/rec-hosts-reorder-new.rb
 delete mode 100644 tests/rec-hosts-reorder.rb
 delete mode 100644 tests/rec-hosts-rm-hosts.rb
 delete mode 100644 tests/rec-initdefault.rb
 delete mode 100644 tests/rec-ins-record.rb
 delete mode 100644 tests/rec-mod-field.rb
 delete mode 100644 tests/rec-rm-inner-field.rb
 delete mode 100644 tests/rec-rm-record.rb
 delete mode 100644 tests/rec-rm-tail-field.rb
 delete mode 100644 tests/sshd-add-acceptenv.rb
 create mode 100755 tests/test-augtool.sh
 create mode 100644 tests/test-augtool/aliases-add-value.sh
 create mode 100644 tests/test-augtool/aliases-change-value.sh
 create mode 100644 tests/test-augtool/grub-change-default.sh
 create mode 100644 tests/test-augtool/grub-rm-entry.sh
 create mode 100644 tests/test-augtool/grub-setm-newvalues.sh
 create mode 100644 tests/test-augtool/ini-yum-change.sh
 create mode 100644 tests/test-augtool/ini-yum-newkey.sh
 create mode 100644 tests/test-augtool/ini-yum-newsec.sh
 create mode 100644 tests/test-augtool/ini-yum-rmkey.sh
 create mode 100644 tests/test-augtool/rec-append-record.sh
 create mode 100644 tests/test-augtool/rec-hosts-add.sh
 create mode 100644 tests/test-augtool/rec-hosts-reorder-new.sh
 create mode 100644 tests/test-augtool/rec-hosts-reorder.sh
 create mode 100644 tests/test-augtool/rec-hosts-rm-hosts.sh
 create mode 100644 tests/test-augtool/rec-initdefault.sh
 create mode 100644 tests/test-augtool/rec-ins-record.sh
 create mode 100644 tests/test-augtool/rec-mod-field.sh
 create mode 100644 tests/test-augtool/rec-rm-inner-field.sh
 create mode 100644 tests/test-augtool/rec-rm-record.sh
 create mode 100644 tests/test-augtool/rec-rm-tail-field.sh
 create mode 100644 tests/test-augtool/sshd-add-acceptenv.sh
 create mode 100644 tests/test-augtool/yum.repos-setm-enabled.sh
 delete mode 100644 tests/yum.repos-setm-enabled.rb

diff --git a/tests/Makefile.am b/tests/Makefile.am
index be510a8..8578ffa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -126,14 +126,14 @@ $(lens_tests): lens-test-1
 check_SCRIPTS = \
   test-interpreter.sh \
   $(lens_tests) \
-  test-get.sh \
+  test-get.sh test-augtool.sh \
   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-modify-root.sh
 
 EXTRA_DIST = \
-  augtest $(AUGTESTS) root lens-test-1 \
+  $(AUGTESTS) root lens-test-1 \
   $(check_SCRIPTS) $(wildcard modules/*.aug) xpath.tests
 
 noinst_SCRIPTS = $(check_SCRIPTS)
@@ -146,7 +146,7 @@ TESTS_ENVIRONMENT = \
   abs_top_srcdir='$(abs_top_srcdir)' \
   LANG=en_US
 
-TESTS = augtest $(check_SCRIPTS) $(check_PROGRAMS)
+TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
 
 INCLUDES = -I$(top_srcdir)/src
 
diff --git a/tests/aliases-add-value.rb b/tests/aliases-add-value.rb
deleted file mode 100644
index 965f33d..0000000
--- a/tests/aliases-add-value.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-commands="
-ins value after /files/etc/aliases/1/value[last()]
-set /files/etc/aliases/1/value[last()] barbar
-save
-"
-
-diff["/etc/aliases"] = <<TXT
---- /etc/aliases
-+++ /etc/aliases.augnew
-@@ -8,7 +8,7 @@
- #
-
- # Basic system aliases -- these MUST be present.
--mailer-daemon:\tpostmaster
-+mailer-daemon:\tpostmaster, barbar
- postmaster:\troot
-
- # General redirections for pseudo accounts.
-TXT
diff --git a/tests/aliases-change-value.rb b/tests/aliases-change-value.rb
deleted file mode 100644
index 1acff2b..0000000
--- a/tests/aliases-change-value.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-commands="
-set /files/etc/aliases/3/value[2] ruth
-save
-"
-diff["/etc/aliases"] = <<TXT
---- /etc/aliases
-+++ /etc/aliases.augnew
-@@ -12,7 +12,7 @@
- postmaster:\troot
-
- # General redirections for pseudo accounts.
--bin:\t\troot, adm
-+bin:\t\troot, ruth
- daemon:\t\troot
- adm:\t\troot
-
-TXT
diff --git a/tests/augtest b/tests/augtest
deleted file mode 100755
index 762eb90..0000000
--- a/tests/augtest
+++ /dev/null
@@ -1,109 +0,0 @@
-#! /usr/bin/env ruby
-
-# Read a file with a test description, run augtool against it and
-# look at the diff between the original file and the .augnew file
-# The test description can contain the following:
-# commands - a string that is fed to augtool
-# diff     - a hash mapping file names to the diff between that
-#            file and the .augnew file
-# echo     - boolean, when true show the whole ouput of augtool
-# refresh  - boolean, when true print bad diffs in a form
-#            that can be easily cut&pasted back into the test description
-
-require 'find'
-require 'fileutils'
-
-def augnew?(path)
-    File::file?(path) && File::fnmatch?("*.augnew", File::basename(path))
-end
-
-TOP_DIR=File::join(File::dirname(__FILE__), "..")
-TOP_BUILDDIR=ENV["abs_top_builddir"] || TOP_DIR
-TOP_SRCDIR=ENV["abs_top_srcdir"] || TOP_DIR
-
-TEST_DIR=File::join(TOP_SRCDIR, "tests")
-
-AUGEAS_ROOT=File::join(TOP_BUILDDIR, "build", "augtest")
-AUGEAS_LENS_LIB=File::join(TOP_SRCDIR, "lenses")
-
-ENV["AUGEAS_ROOT"] = AUGEAS_ROOT
-ENV["AUGEAS_LENS_LIB"] = AUGEAS_LENS_LIB
-
-args=ARGV
-if args.size == 0
-    args = Dir::glob("#{TEST_DIR}/*.rb").sort
-end
-
-WIDTH = args.inject(0) do |max, arg|
-  s = File::basename(arg, ".rb").size
-  (s > max) ? s : max
-end
-status = 0
-
-args.each do |test|
-    if File::directory?(AUGEAS_ROOT)
-        FileUtils::rm_rf(AUGEAS_ROOT)
-    end
-    FileUtils::mkdir_p(AUGEAS_ROOT)
-    FileUtils::cp_r(File::join(TEST_DIR, "root", "."), AUGEAS_ROOT)
-    Find.find(AUGEAS_ROOT) do |path|
-        if augnew?(path)
-            File::delete(path)
-        end
-    end
-    commands = nil
-    diff = {}
-    echo=false
-    refresh=false
-    skip=false
-
-    eval(IO::read(test))
-    redir = echo ? "" : "> /dev/null"
-    printf("Test %-#{WIDTH}s ... ", File::basename(test, ".rb"))
-    unless skip
-        IO.popen("augtool --nostdinc -n #{redir}", "w") do |io|
-            io.print(commands)
-            io.puts("\nquit")
-        end
-        success=$?.success?
-        msgs = []
-        diff.each do |file, exp|
-            file = File::join(AUGEAS_ROOT, file).gsub(%r{//}, '/')
-            if ! File::exist?("#{file}.augnew")
-                msgs << "Expected file #{file}.augnew"
-                success=false
-            else
-                act=`diff -u #{file} #{file}.augnew | sed -e 's/^ $//'`
-                act.gsub!(/^(--- #{file}).*$/, '\1')
-                act.gsub!(/^(\+\+\+ #{file}\.augnew).*$/, '\1')
-                act.gsub!(/^(---|\+\+\+) (#{AUGEAS_ROOT})/, '\1 ');
-                if ! exp.nil? && act != exp
-                    success=false
-                    if ! refresh
-                        msgs << act
-                    else
-                        msgs << act.gsub(/\t/, '\\t')
-                    end
-                end
-            end
-        end
-        files = diff.keys.collect { |f| File::join(AUGEAS_ROOT, "#{f}.augnew").gsub(%r{//}, '/') }
-        Find.find(AUGEAS_ROOT) do |path|
-            if augnew?(path) && ! files.include?(path)
-                success=false
-                msgs << "Unexpected file #{path}"
-            end
-        end
-    end
-    if skip
-        puts "SKIPPED"
-    elsif success
-        puts "OK"
-    else
-        puts "FAIL"
-        status = 1
-        msgs.each { |m| puts m }
-    end
-end
-
-exit(status)
diff --git a/tests/get-root.rb b/tests/get-root.rb
deleted file mode 100644
index 29c5d95..0000000
--- a/tests/get-root.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# This used to segfault
-commands="
-get /
-"
diff --git a/tests/grub-change-default.rb b/tests/grub-change-default.rb
deleted file mode 100644
index 8c5cf8e..0000000
--- a/tests/grub-change-default.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-commands="
-set /files/etc/grub.conf/default 2
-save
-"
-
-diff["/etc/grub.conf"] = <<TXT
---- /etc/grub.conf
-+++ /etc/grub.conf.augnew
-@@ -7,7 +7,7 @@
- #          kernel /vmlinuz-version ro root=/dev/vg00/lv00
- #          initrd /initrd-version.img
- #boot=/dev/sda
--default=0
-+default=2
- timeout=5
- splashimage=(hd0,0)/grub/splash.xpm.gz
- hiddenmenu
-TXT
diff --git a/tests/grub-rm-entry.rb b/tests/grub-rm-entry.rb
deleted file mode 100644
index c17b64b..0000000
--- a/tests/grub-rm-entry.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-refresh=true
-commands="
-rm /files/etc/grub.conf/title[2]
-save
-"
-
-diff["/etc/grub.conf"] = <<TXT
---- /etc/grub.conf
-+++ /etc/grub.conf.augnew
-@@ -15,10 +15,6 @@
- \troot (hd0,0)
- \tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
- \tinitrd /initrd-2.6.24.4-64.fc8.img
--title Fedora (2.6.24.3-50.fc8)
--\troot (hd0,0)
--\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
--\tinitrd /initrd-2.6.24.3-50.fc8.img
- title Fedora (2.6.21.7-3.fc8xen)
- \troot (hd0,0)
- \tkernel /xen.gz-2.6.21.7-3.fc8
-@@ -28,4 +24,4 @@
- \troot (hd0,0)
- \tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
- \tinitrd /initrd-2.6.24.3-34.fc8.img
--        savedefault
-+\tsavedefault
-TXT
diff --git a/tests/grub-setm-newvalues.rb b/tests/grub-setm-newvalues.rb
deleted file mode 100644
index 0397dd7..0000000
--- a/tests/grub-setm-newvalues.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# add console values to multiple kernel entries
-commands="
-setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] tty0
-setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] ttyS0,9600n8
-save
-"
-
-diff["/etc/grub.conf"]= <<TXT
---- /etc/grub.conf
-+++ /etc/grub.conf.augnew
-@@ -13,11 +13,11 @@
- hiddenmenu
- title Fedora (2.6.24.4-64.fc8)
- 	root (hd0,0)
--	kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
-+	kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
- 	initrd /initrd-2.6.24.4-64.fc8.img
- title Fedora (2.6.24.3-50.fc8)
- 	root (hd0,0)
--	kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
-+	kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
- 	initrd /initrd-2.6.24.3-50.fc8.img
- title Fedora (2.6.21.7-3.fc8xen)
- 	root (hd0,0)
-@@ -26,6 +26,6 @@
- 	module /initrd-2.6.21.7-3.fc8xen.img
- title Fedora (2.6.24.3-34.fc8)
- 	root (hd0,0)
--	kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
-+	kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
- 	initrd /initrd-2.6.24.3-34.fc8.img
-         savedefault
-TXT
diff --git a/tests/ini-yum-change.rb b/tests/ini-yum-change.rb
deleted file mode 100644
index fc4c7ec..0000000
--- a/tests/ini-yum-change.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-commands="
-set /files/etc/yum.conf/main/debuglevel 99
-save
-"
-
-diff["/etc/yum.conf"] = <<TXT
---- /etc/yum.conf
-+++ /etc/yum.conf.augnew
-@@ -1,7 +1,7 @@
- [main]
- cachedir=/var/cache/yum
- keepcache=0
--debuglevel=2
-+debuglevel=99
- logfile=/var/log/yum.log
- exactarch=1
- obsoletes=1
-TXT
diff --git a/tests/ini-yum-newkey.rb b/tests/ini-yum-newkey.rb
deleted file mode 100644
index 17fe897..0000000
--- a/tests/ini-yum-newkey.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-commands="
-set /files/etc/yum.conf/main/newparam newval
-save
-"
-
-diff["/etc/yum.conf"] = <<TXT
---- /etc/yum.conf
-+++ /etc/yum.conf.augnew
-@@ -13,3 +13,4 @@
-
- # PUT YOUR REPOS HERE OR IN separate files named file.repo
- # in /etc/yum.repos.d
-+newparam=newval
-TXT
diff --git a/tests/ini-yum-newsec.rb b/tests/ini-yum-newsec.rb
deleted file mode 100644
index 27f9465..0000000
--- a/tests/ini-yum-newsec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-commands="
-set /files/etc/yum.conf/other/newparam newval
-save
-"
-
-diff["/etc/yum.conf"] = <<TXT
---- /etc/yum.conf
-+++ /etc/yum.conf.augnew
-@@ -13,3 +13,5 @@
-
- # PUT YOUR REPOS HERE OR IN separate files named file.repo
- # in /etc/yum.repos.d
-+[other]
-+newparam=newval
-TXT
diff --git a/tests/ini-yum-rmkey.rb b/tests/ini-yum-rmkey.rb
deleted file mode 100644
index 8ea31a6..0000000
--- a/tests/ini-yum-rmkey.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-commands="
-rm /files/etc/yum.conf/main/keepcache
-save
-"
-
-diff["/etc/yum.conf"] = <<TXT
---- /etc/yum.conf
-+++ /etc/yum.conf.augnew
-@@ -1,6 +1,5 @@
- [main]
- cachedir=/var/cache/yum
--keepcache=0
- debuglevel=2
- logfile=/var/log/yum.log
- exactarch=1
-TXT
diff --git a/tests/rec-append-record.rb b/tests/rec-append-record.rb
deleted file mode 100644
index 3f9d33e..0000000
--- a/tests/rec-append-record.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# Convenience to save some typing
-entry_last = "/files/etc/pam.d/newrole/10000"
-commands="
-ins entry after #{entry_last}
-set #{entry_last}/type auth
-set #{entry_last}/control include
-set #{entry_last}/module system-auth
-save
-"
-
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -3,3 +3,4 @@
- account    include\tsystem-auth
- password   include\tsystem-auth
- session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-+auth\tinclude\tsystem-auth
-TXT
diff --git a/tests/rec-hosts-add.rb b/tests/rec-hosts-add.rb
deleted file mode 100644
index c761a9e..0000000
--- a/tests/rec-hosts-add.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# Note that aliases must be set (to NULL here), otherwise the tree
-# is not syntactically correct and can not be saved
-commands="
-ins 10000 before /files/etc/hosts/2
-set /files/etc/hosts/10000/ipaddr 192.168.0.1
-set /files/etc/hosts/10000/canonical pigiron.example.com
-save
-"
-refresh=true
-diff["/etc/hosts"] = <<TXT
---- /etc/hosts
-+++ /etc/hosts.augnew
-@@ -3,4 +3,5 @@
- 127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
- #172.31.122.254   granny.watzmann.net granny puppet
- #172.31.122.1     galia.watzmann.net galia
-+192.168.0.1\tpigiron.example.com
- 172.31.122.14   orange.watzmann.net orange
-TXT
diff --git a/tests/rec-hosts-reorder-new.rb b/tests/rec-hosts-reorder-new.rb
deleted file mode 100644
index 025c2b0..0000000
--- a/tests/rec-hosts-reorder-new.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-# Delete the first hosts entry and then add it back into the tree as
-# a new entry.
-# Since we add the same entry, but under a new key (10000 instead of 0),
-# all the seaprators are set to their defaults. That is why the separator
-# between localhost.localdomain and localhost changes from a '\t' to a ' '
-# If we used the old key '0' to insert back in, we'd have an exact move of
-# the line. That is checked by rec-hosts-reorder
-commands="
-rm /files/etc/hosts/1
-set /files/etc/hosts/10000/ipaddr 127.0.0.1
-set /files/etc/hosts/10000/canonical localhost.localdomain
-set /files/etc/hosts/10000/alias[1] localhost
-set /files/etc/hosts/10000/alias[2] galia.watzmann.net
-set /files/etc/hosts/10000/alias[3] galia
-save
-"
-
-diff["/etc/hosts"] = <<TXT
---- /etc/hosts
-+++ /etc/hosts.augnew
-@@ -1,6 +1,6 @@
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
--127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
- #172.31.122.254   granny.watzmann.net granny puppet
- #172.31.122.1     galia.watzmann.net galia
- 172.31.122.14   orange.watzmann.net orange
-+127.0.0.1\tlocalhost.localdomain localhost galia.watzmann.net galia
-TXT
diff --git a/tests/rec-hosts-reorder.rb b/tests/rec-hosts-reorder.rb
deleted file mode 100644
index 0b4983d..0000000
--- a/tests/rec-hosts-reorder.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# Delete the first hosts entry and then add it back into the tree
-# Because of how nodes are ordered, this should be equivalent to
-# moving the corresponding line to the end of the file
-commands="
-rm /files/etc/hosts/1
-set /files/etc/hosts/1/ipaddr 127.0.0.1
-set /files/etc/hosts/1/canonical localhost.localdomain
-set /files/etc/hosts/1/alias[1] localhost
-set /files/etc/hosts/1/alias[2] galia.watzmann.net
-set /files/etc/hosts/1/alias[3] galia
-save
-"
-
-diff["/etc/hosts"] = <<TXT
---- /etc/hosts
-+++ /etc/hosts.augnew
-@@ -1,6 +1,6 @@
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
--127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
- #172.31.122.254   granny.watzmann.net granny puppet
- #172.31.122.1     galia.watzmann.net galia
- 172.31.122.14   orange.watzmann.net orange
-+127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
-TXT
diff --git a/tests/rec-hosts-rm-hosts.rb b/tests/rec-hosts-rm-hosts.rb
deleted file mode 100644
index 691ca90..0000000
--- a/tests/rec-hosts-rm-hosts.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# This will leave /etc/hosts with nothing but comments and whitespace
-refresh=true
-commands = "
-rm /files/etc/hosts/1
-rm /files/etc/hosts/2
-save
-"
-
-diff["/etc/hosts"] = <<TXT
---- /etc/hosts
-+++ /etc/hosts.augnew
-@@ -1,6 +1,4 @@
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
--127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
- #172.31.122.254   granny.watzmann.net granny puppet
- #172.31.122.1     galia.watzmann.net galia
--172.31.122.14   orange.watzmann.net orange
-TXT
diff --git a/tests/rec-initdefault.rb b/tests/rec-initdefault.rb
deleted file mode 100644
index 300d9b1..0000000
--- a/tests/rec-initdefault.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# Change the initdefault
-#
-# Note that we would really like to query for the node whose 'action' is
-# initdefault and then set its 'runlevels' sibling. That's not possible,
-# mostly because the testing framework and augtool are too simplistic to do
-# that. Would be easy with a shell script
-
-commands="
-set /files/etc/inittab/id/runlevels 3
-save
-"
-
-diff["/etc/inittab"] = <<TXT
---- /etc/inittab
-+++ /etc/inittab.augnew
-@@ -15,7 +15,7 @@
- #   5 - X11
- #   6 - reboot (Do NOT set initdefault to this)
- #
--id:5:initdefault:
-+id:3:initdefault:
-
- # System initialization.
- si::sysinit:/etc/rc.d/rc.sysinit
-TXT
diff --git a/tests/rec-ins-record.rb b/tests/rec-ins-record.rb
deleted file mode 100644
index 13ced5b..0000000
--- a/tests/rec-ins-record.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-commands="
-ins 10000 before /files/etc/pam.d/newrole/3
-set /files/etc/pam.d/newrole/10000/type session
-set /files/etc/pam.d/newrole/10000/control include
-set /files/etc/pam.d/newrole/10000/module system-auth
-save
-"
-
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -1,5 +1,6 @@
- #%PAM-1.0
- auth       include\tsystem-auth
- account    include\tsystem-auth
-+session\tinclude\tsystem-auth
- password   include\tsystem-auth
- session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-TXT
diff --git a/tests/rec-mod-field.rb b/tests/rec-mod-field.rb
deleted file mode 100644
index 87d6b84..0000000
--- a/tests/rec-mod-field.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-commands="
-set /files/etc/pam.d/newrole/3/module other_module
-set /files/etc/pam.d/newrole/3/argument other_module_opts
-save
-"
-
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -1,5 +1,5 @@
- #%PAM-1.0
- auth       include\tsystem-auth
- account    include\tsystem-auth
--password   include\tsystem-auth
-+password   include\tother_module\tother_module_opts
- session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-TXT
diff --git a/tests/rec-rm-inner-field.rb b/tests/rec-rm-inner-field.rb
deleted file mode 100644
index df9a994..0000000
--- a/tests/rec-rm-inner-field.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-commands="
-rm /files/etc/pam.d/newrole/4/argument
-save
-"
-
-diff = {}
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -2,4 +2,4 @@
- auth       include\tsystem-auth
- account    include\tsystem-auth
- password   include\tsystem-auth
--session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-+session    required\tpam_namespace.so
-TXT
diff --git a/tests/rec-rm-record.rb b/tests/rec-rm-record.rb
deleted file mode 100644
index 362528a..0000000
--- a/tests/rec-rm-record.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- ruby -*-
-commands="
-rm /files/etc/pam.d/newrole/1
-save
-"
-
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -1,5 +1,4 @@
- #%PAM-1.0
--auth       include\tsystem-auth
- account    include\tsystem-auth
- password   include\tsystem-auth
- session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-TXT
diff --git a/tests/rec-rm-tail-field.rb b/tests/rec-rm-tail-field.rb
deleted file mode 100644
index d95c6d5..0000000
--- a/tests/rec-rm-tail-field.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# -*- ruby -*-
-commands="
-rm /files/etc/pam.d/newrole/4/argument
-save
-"
-refresh = 1
-
-diff = {}
-diff["/etc/pam.d/newrole"] = <<TXT
---- /etc/pam.d/newrole
-+++ /etc/pam.d/newrole.augnew
-@@ -2,4 +2,4 @@
- auth       include\tsystem-auth
- account    include\tsystem-auth
- password   include\tsystem-auth
--session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
-+session    required\tpam_namespace.so
-TXT
diff --git a/tests/sshd-add-acceptenv.rb b/tests/sshd-add-acceptenv.rb
deleted file mode 100644
index 480c039..0000000
--- a/tests/sshd-add-acceptenv.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# Note that aliases must be set (to NULL here), otherwise the tree
-# is not syntactically correct and can not be saved
-commands="
-set /files/etc/ssh/sshd_config/AcceptEnv[3]/10000 FOO
-save
-"
-
-refresh=true
-diff["/etc/ssh/sshd_config"] = <<TXT
---- /etc/ssh/sshd_config
-+++ /etc/ssh/sshd_config.augnew
-@@ -93,7 +93,7 @@
- # Accept locale-related environment variables
- AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
- AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
--AcceptEnv LC_IDENTIFICATION LC_ALL
-+AcceptEnv LC_IDENTIFICATION LC_ALL FOO
- #AllowTcpForwarding yes
- #GatewayPorts no
- #X11Forwarding no
-TXT
diff --git a/tests/test-augtool.sh b/tests/test-augtool.sh
new file mode 100755
index 0000000..2ff6ec0
--- /dev/null
+++ b/tests/test-augtool.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+
+TOP_DIR=$(cd $(dirname $0)/.. && pwd)
+TOP_BUILDDIR="$abs_top_builddir"
+[ -z "$TOP_BUILDDIR" ] && TOP_BUILDDIR="$TOP_DIR"
+TOP_SRCDIR="$abs_top_srcdir"
+[ -z "$TOP_SRCDIR" ] && TOP_SRCDIR="$TOP_DIR"
+
+TEST_DIR="$TOP_SRCDIR/tests"
+
+export PATH="$TOP_BUILDDIR/src:${PATH}"
+
+export AUGEAS_ROOT="$TOP_BUILDDIR/build/test-augtool"
+export AUGEAS_LENS_LIB="$TOP_SRCDIR/lenses"
+
+function fail() {
+    [ -z "$failed" ] && echo FAIL
+    failed=yes
+    echo "$@"
+    result=1
+}
+
+# Without args, run all tests
+if [ $# -eq 0 ] ; then
+    args="$TEST_DIR/test-augtool/*.sh"
+else
+    args="$@"
+fi
+
+result=0
+
+for tst in $args; do
+    unset failed
+
+    printf "%-40s ... " $(basename $tst .sh)
+
+    # Read in test variables. The variables we understand are
+    # echo              - echo augtool commands if set to some value
+    # commands          - the commands to send to augtool
+    # lens              - the lens to use
+    # file              - the file that should be changed
+    # diff              - the expected diff
+    # refresh           - print diff in a form suitable for cut and paste
+    #                     into the test file if set to some value
+
+    unset echo commands lens file diff refresh
+    . $tst
+
+    # Setup test root from root/
+    [ -d "$AUGEAS_ROOT" ] && rm -rf "$AUGEAS_ROOT"
+    dest_dir="$AUGEAS_ROOT"$(dirname $file)
+    mkdir -p $dest_dir
+    cp -p "$TEST_DIR"/root/$file $dest_dir
+
+    [ -n "$echo" ] && echo="-e"
+
+    commands="set /augeas/load/Test/lens $lens
+set /augeas/load/Test/incl $file
+load
+$commands
+save
+quit"
+    echo "$commands" | augtool $echo --nostdinc --noautoload -n || fail "augtool failed"
+
+    abs_file="$AUGEAS_ROOT$file"
+    if [ ! -f "${abs_file}.augnew" ]; then
+        fail "Expected file $file.augnew"
+    else
+        act=$(diff -u "$abs_file" "${abs_file}.augnew" \
+            | sed -r -e "s/^ $//;s!^(---|\+\+\+) ${AUGEAS_ROOT}($file(\.augnew)?)(.*)\$!\1 \2!;s/\\t/\\\\t/g")
+
+        if [ "$act" != "$diff" ] ; then
+            fail "$act"
+        fi
+    fi
+    other_files=$(find "$AUGEAS_ROOT" -name \*.augnew -not -path "$abs_file.augnew")
+    [ -n "$other_files" ] && fail "Unexpected file(s) $other_files"
+    [ -z "$failed" ] && echo OK
+done
+
+exit $result
diff --git a/tests/test-augtool/aliases-add-value.sh b/tests/test-augtool/aliases-add-value.sh
new file mode 100644
index 0000000..24c2f9a
--- /dev/null
+++ b/tests/test-augtool/aliases-add-value.sh
@@ -0,0 +1,19 @@
+commands="
+ins value after /files/etc/aliases/1/value[last()]
+set /files/etc/aliases/1/value[last()] barbar
+"
+
+lens=Aliases.lns
+file="/etc/aliases"
+
+diff='--- /etc/aliases
++++ /etc/aliases.augnew
+@@ -8,7 +8,7 @@
+ #
+
+ # Basic system aliases -- these MUST be present.
+-mailer-daemon:\tpostmaster
++mailer-daemon:\tpostmaster, barbar
+ postmaster:\troot
+
+ # General redirections for pseudo accounts.'
diff --git a/tests/test-augtool/aliases-change-value.sh b/tests/test-augtool/aliases-change-value.sh
new file mode 100644
index 0000000..909f61f
--- /dev/null
+++ b/tests/test-augtool/aliases-change-value.sh
@@ -0,0 +1,17 @@
+commands="
+set /files/etc/aliases/3/value[2] ruth
+"
+
+lens=Aliases.lns
+file="/etc/aliases"
+
+diff='--- /etc/aliases
++++ /etc/aliases.augnew
+@@ -12,7 +12,7 @@
+ postmaster:\troot
+
+ # General redirections for pseudo accounts.
+-bin:\t\troot, adm
++bin:\t\troot, ruth
+ daemon:\t\troot
+ adm:\t\troot'
diff --git a/tests/test-augtool/grub-change-default.sh b/tests/test-augtool/grub-change-default.sh
new file mode 100644
index 0000000..a0a2e37
--- /dev/null
+++ b/tests/test-augtool/grub-change-default.sh
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/grub.conf/default 2
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -7,7 +7,7 @@
+ #          kernel /vmlinuz-version ro root=/dev/vg00/lv00
+ #          initrd /initrd-version.img
+ #boot=/dev/sda
+-default=0
++default=2
+ timeout=5
+ splashimage=(hd0,0)/grub/splash.xpm.gz
+ hiddenmenu'
diff --git a/tests/test-augtool/grub-rm-entry.sh b/tests/test-augtool/grub-rm-entry.sh
new file mode 100644
index 0000000..5ea0aa3
--- /dev/null
+++ b/tests/test-augtool/grub-rm-entry.sh
@@ -0,0 +1,26 @@
+commands="
+rm /files/etc/grub.conf/title[2]
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -15,10 +15,6 @@
+ \troot (hd0,0)
+ \tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
+ \tinitrd /initrd-2.6.24.4-64.fc8.img
+-title Fedora (2.6.24.3-50.fc8)
+-\troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
+-\tinitrd /initrd-2.6.24.3-50.fc8.img
+ title Fedora (2.6.21.7-3.fc8xen)
+ \troot (hd0,0)
+ \tkernel /xen.gz-2.6.21.7-3.fc8
+@@ -28,4 +24,4 @@
+ \troot (hd0,0)
+ \tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
+ \tinitrd /initrd-2.6.24.3-34.fc8.img
+-        savedefault
++\tsavedefault'
diff --git a/tests/test-augtool/grub-setm-newvalues.sh b/tests/test-augtool/grub-setm-newvalues.sh
new file mode 100644
index 0000000..a6d13c0
--- /dev/null
+++ b/tests/test-augtool/grub-setm-newvalues.sh
@@ -0,0 +1,33 @@
+# add console values to multiple kernel entries
+commands="
+setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] tty0
+setm /files/etc/grub.conf/*/kernel[. =~ regexp('.*2.6.24.*')] console[last()+1] ttyS0,9600n8
+"
+
+lens=Grub.lns
+file="/etc/grub.conf"
+
+diff='--- /etc/grub.conf
++++ /etc/grub.conf.augnew
+@@ -13,11 +13,11 @@
+ hiddenmenu
+ title Fedora (2.6.24.4-64.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.4-64.fc8.img
+ title Fedora (2.6.24.3-50.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.3-50.fc8.img
+ title Fedora (2.6.21.7-3.fc8xen)
+ \troot (hd0,0)
+@@ -26,6 +26,6 @@
+ \tmodule /initrd-2.6.21.7-3.fc8xen.img
+ title Fedora (2.6.24.3-34.fc8)
+ \troot (hd0,0)
+-\tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
++\tkernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00 console=tty0 console=ttyS0,9600n8
+ \tinitrd /initrd-2.6.24.3-34.fc8.img
+         savedefault'
diff --git a/tests/test-augtool/ini-yum-change.sh b/tests/test-augtool/ini-yum-change.sh
new file mode 100644
index 0000000..67075b3
--- /dev/null
+++ b/tests/test-augtool/ini-yum-change.sh
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/yum.conf/main/debuglevel 99
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -1,7 +1,7 @@
+ [main]
+ cachedir=/var/cache/yum
+ keepcache=0
+-debuglevel=2
++debuglevel=99
+ logfile=/var/log/yum.log
+ exactarch=1
+ obsoletes=1'
diff --git a/tests/test-augtool/ini-yum-newkey.sh b/tests/test-augtool/ini-yum-newkey.sh
new file mode 100644
index 0000000..ee9c432
--- /dev/null
+++ b/tests/test-augtool/ini-yum-newkey.sh
@@ -0,0 +1,14 @@
+commands="
+set /files/etc/yum.conf/main/newparam newval
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -13,3 +13,4 @@
+
+ # PUT YOUR REPOS HERE OR IN separate files named file.repo
+ # in /etc/yum.repos.d
++newparam=newval'
diff --git a/tests/test-augtool/ini-yum-newsec.sh b/tests/test-augtool/ini-yum-newsec.sh
new file mode 100644
index 0000000..8060dac
--- /dev/null
+++ b/tests/test-augtool/ini-yum-newsec.sh
@@ -0,0 +1,15 @@
+commands="
+set /files/etc/yum.conf/other/newparam newval
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -13,3 +13,5 @@
+
+ # PUT YOUR REPOS HERE OR IN separate files named file.repo
+ # in /etc/yum.repos.d
++[other]
++newparam=newval'
diff --git a/tests/test-augtool/ini-yum-rmkey.sh b/tests/test-augtool/ini-yum-rmkey.sh
new file mode 100644
index 0000000..3c24026
--- /dev/null
+++ b/tests/test-augtool/ini-yum-rmkey.sh
@@ -0,0 +1,16 @@
+commands="
+rm /files/etc/yum.conf/main/keepcache
+"
+
+lens=Yum.lns
+file="/etc/yum.conf"
+
+diff='--- /etc/yum.conf
++++ /etc/yum.conf.augnew
+@@ -1,6 +1,5 @@
+ [main]
+ cachedir=/var/cache/yum
+-keepcache=0
+ debuglevel=2
+ logfile=/var/log/yum.log
+ exactarch=1'
diff --git a/tests/test-augtool/rec-append-record.sh b/tests/test-augtool/rec-append-record.sh
new file mode 100644
index 0000000..976cc66
--- /dev/null
+++ b/tests/test-augtool/rec-append-record.sh
@@ -0,0 +1,18 @@
+commands='
+ins 01 after /files/etc/pam.d/newrole/*[last()]
+defvar new /files/etc/pam.d/newrole/*[last()]
+set $new/type auth
+set $new/control include
+set $new/module system-auth
+'
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -3,3 +3,4 @@
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++auth\tinclude\tsystem-auth'
diff --git a/tests/test-augtool/rec-hosts-add.sh b/tests/test-augtool/rec-hosts-add.sh
new file mode 100644
index 0000000..09b6f29
--- /dev/null
+++ b/tests/test-augtool/rec-hosts-add.sh
@@ -0,0 +1,17 @@
+commands='
+ins 10000 before /files/etc/hosts/2
+set /files/etc/hosts/10000/ipaddr 192.168.0.1
+set /files/etc/hosts/10000/canonical pigiron.example.com
+'
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -3,4 +3,5 @@
+ 127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
++192.168.0.1\tpigiron.example.com
+ 172.31.122.14   orange.watzmann.net orange'
diff --git a/tests/test-augtool/rec-hosts-reorder-new.sh b/tests/test-augtool/rec-hosts-reorder-new.sh
new file mode 100644
index 0000000..d917a06
--- /dev/null
+++ b/tests/test-augtool/rec-hosts-reorder-new.sh
@@ -0,0 +1,31 @@
+# Delete the first hosts entry and then add it back into the tree as
+# a new entry.
+#
+# Since we add the same entry, but under a new key (01 instead of 1), all
+# the separators are set to their defaults. That is why the separator
+# between localhost.localdomain and localhost changes from a '\t' to a ' '
+# If we used the old key '0' to insert back in, we'd have an exact move of
+# the line. That is checked by rec-hosts-reorder
+
+commands="
+rm /files/etc/hosts/1
+set /files/etc/hosts/01/ipaddr 127.0.0.1
+set /files/etc/hosts/01/canonical localhost.localdomain
+set /files/etc/hosts/01/alias[1] localhost
+set /files/etc/hosts/01/alias[2] galia.watzmann.net
+set /files/etc/hosts/01/alias[3] galia
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,6 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+ 172.31.122.14   orange.watzmann.net orange
++127.0.0.1\tlocalhost.localdomain localhost galia.watzmann.net galia'
diff --git a/tests/test-augtool/rec-hosts-reorder.sh b/tests/test-augtool/rec-hosts-reorder.sh
new file mode 100644
index 0000000..d763e87
--- /dev/null
+++ b/tests/test-augtool/rec-hosts-reorder.sh
@@ -0,0 +1,25 @@
+# Delete the first hosts entry and then add it back into the tree
+# Because of how nodes are ordered, this should be equivalent to
+# moving the corresponding line to the end of the file
+commands="
+rm /files/etc/hosts/1
+set /files/etc/hosts/1/ipaddr 127.0.0.1
+set /files/etc/hosts/1/canonical localhost.localdomain
+set /files/etc/hosts/1/alias[1] localhost
+set /files/etc/hosts/1/alias[2] galia.watzmann.net
+set /files/etc/hosts/1/alias[3] galia
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,6 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+ 172.31.122.14   orange.watzmann.net orange
++127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia'
diff --git a/tests/test-augtool/rec-hosts-rm-hosts.sh b/tests/test-augtool/rec-hosts-rm-hosts.sh
new file mode 100644
index 0000000..e4b2c2c
--- /dev/null
+++ b/tests/test-augtool/rec-hosts-rm-hosts.sh
@@ -0,0 +1,18 @@
+# This will leave /etc/hosts with nothing but comments and whitespace
+commands="
+rm /files/etc/hosts/1
+rm /files/etc/hosts/2
+"
+
+lens=Hosts.lns
+file="/etc/hosts"
+
+diff='--- /etc/hosts
++++ /etc/hosts.augnew
+@@ -1,6 +1,4 @@
+ # Do not remove the following line, or various programs
+ # that require network functionality will fail.
+-127.0.0.1\tlocalhost.localdomain\tlocalhost galia.watzmann.net galia
+ #172.31.122.254   granny.watzmann.net granny puppet
+ #172.31.122.1     galia.watzmann.net galia
+-172.31.122.14   orange.watzmann.net orange'
diff --git a/tests/test-augtool/rec-initdefault.sh b/tests/test-augtool/rec-initdefault.sh
new file mode 100644
index 0000000..190a271
--- /dev/null
+++ b/tests/test-augtool/rec-initdefault.sh
@@ -0,0 +1,20 @@
+# Change the initdefault
+
+commands="
+set /files/etc/inittab/*[action = 'initdefault']/runlevels 3
+"
+
+lens=Inittab.lns
+file="/etc/inittab"
+
+diff='--- /etc/inittab
++++ /etc/inittab.augnew
+@@ -15,7 +15,7 @@
+ #   5 - X11
+ #   6 - reboot (Do NOT set initdefault to this)
+ #
+-id:5:initdefault:
++id:3:initdefault:
+
+ # System initialization.
+ si::sysinit:/etc/rc.d/rc.sysinit'
diff --git a/tests/test-augtool/rec-ins-record.sh b/tests/test-augtool/rec-ins-record.sh
new file mode 100644
index 0000000..7caf7ef
--- /dev/null
+++ b/tests/test-augtool/rec-ins-record.sh
@@ -0,0 +1,19 @@
+commands="
+ins 10000 before /files/etc/pam.d/newrole/3
+set /files/etc/pam.d/newrole/10000/type session
+set /files/etc/pam.d/newrole/10000/control include
+set /files/etc/pam.d/newrole/10000/module system-auth
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,6 @@
+ #%PAM-1.0
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
++session\tinclude\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-mod-field.sh b/tests/test-augtool/rec-mod-field.sh
new file mode 100644
index 0000000..47624db
--- /dev/null
+++ b/tests/test-augtool/rec-mod-field.sh
@@ -0,0 +1,17 @@
+commands="
+set /files/etc/pam.d/newrole/3/module other_module
+set /files/etc/pam.d/newrole/3/argument other_module_opts
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,5 @@
+ #%PAM-1.0
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+-password   include\tsystem-auth
++password   include\tother_module\tother_module_opts
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-rm-inner-field.sh b/tests/test-augtool/rec-rm-inner-field.sh
new file mode 100644
index 0000000..bdfa6d7
--- /dev/null
+++ b/tests/test-augtool/rec-rm-inner-field.sh
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/4/argument
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -2,4 +2,4 @@
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+-session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++session    required\tpam_namespace.so'
diff --git a/tests/test-augtool/rec-rm-record.sh b/tests/test-augtool/rec-rm-record.sh
new file mode 100644
index 0000000..16721b4
--- /dev/null
+++ b/tests/test-augtool/rec-rm-record.sh
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/1
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -1,5 +1,4 @@
+ #%PAM-1.0
+-auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+ session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close'
diff --git a/tests/test-augtool/rec-rm-tail-field.sh b/tests/test-augtool/rec-rm-tail-field.sh
new file mode 100644
index 0000000..bdfa6d7
--- /dev/null
+++ b/tests/test-augtool/rec-rm-tail-field.sh
@@ -0,0 +1,15 @@
+commands="
+rm /files/etc/pam.d/newrole/4/argument
+"
+
+lens=Pam.lns
+file="/etc/pam.d/newrole"
+
+diff='--- /etc/pam.d/newrole
++++ /etc/pam.d/newrole.augnew
+@@ -2,4 +2,4 @@
+ auth       include\tsystem-auth
+ account    include\tsystem-auth
+ password   include\tsystem-auth
+-session    required\tpam_namespace.so unmnt_remnt no_unmount_on_close
++session    required\tpam_namespace.so'
diff --git a/tests/test-augtool/sshd-add-acceptenv.sh b/tests/test-augtool/sshd-add-acceptenv.sh
new file mode 100644
index 0000000..7b44476
--- /dev/null
+++ b/tests/test-augtool/sshd-add-acceptenv.sh
@@ -0,0 +1,18 @@
+commands="
+set /files/etc/ssh/sshd_config/AcceptEnv[3]/01 FOO
+"
+
+lens=Sshd.lns
+file="/etc/ssh/sshd_config"
+
+diff='--- /etc/ssh/sshd_config
++++ /etc/ssh/sshd_config.augnew
+@@ -93,7 +93,7 @@
+ # Accept locale-related environment variables
+ AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
+ AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
+-AcceptEnv LC_IDENTIFICATION LC_ALL
++AcceptEnv LC_IDENTIFICATION LC_ALL FOO
+ #AllowTcpForwarding yes
+ #GatewayPorts no
+ #X11Forwarding no'
diff --git a/tests/test-augtool/yum.repos-setm-enabled.sh b/tests/test-augtool/yum.repos-setm-enabled.sh
new file mode 100644
index 0000000..efc32de
--- /dev/null
+++ b/tests/test-augtool/yum.repos-setm-enabled.sh
@@ -0,0 +1,27 @@
+# set all existing repos to enabled
+commands="
+setm /files/etc/yum.repos.d/fedora.repo/* enabled 1
+"
+
+lens=Yum.lns
+file="/etc/yum.repos.d/fedora.repo"
+
+diff='--- /etc/yum.repos.d/fedora.repo
++++ /etc/yum.repos.d/fedora.repo.augnew
+@@ -12,7 +12,7 @@
+ failovermethod=priority
+ #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
+ mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
+-enabled=0
++enabled=1
+ gpgcheck=1
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
+
+@@ -21,6 +21,6 @@
+ failovermethod=priority
+ #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
+ mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
+-enabled=0
++enabled=1
+ gpgcheck=1
+ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY'
diff --git a/tests/yum.repos-setm-enabled.rb b/tests/yum.repos-setm-enabled.rb
deleted file mode 100644
index f7eae1a..0000000
--- a/tests/yum.repos-setm-enabled.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# set all existing repos to enabled
-commands="
-setm /files/etc/yum.repos.d/fedora.repo/* enabled 1
-save
-"
-
-diff["/etc/yum.repos.d/fedora.repo"] = <<TXT
---- /etc/yum.repos.d/fedora.repo
-+++ /etc/yum.repos.d/fedora.repo.augnew
-@@ -12,7 +12,7 @@
- failovermethod=priority
- #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
- mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
--enabled=0
-+enabled=1
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
-
-@@ -21,6 +21,6 @@
- failovermethod=priority
- #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
- mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
--enabled=0
-+enabled=1
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
-TXT
-- 
1.7.3.4




More information about the augeas-devel mailing list