diff --git a/ChangeLog b/ChangeLog index 9c3446b6a0..e1e8e95b0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Mon, 1 Dec 2008 16:01:54 +0100 Jim Meyering + + tests: daemon-conf: accommodate numeric-valued config params + This test would hang when failing to perturb the soon-to-be- + added numeric (and non-boolean) valued parameters, max_clients, + max_workers, min_workers. + * tests/daemon-conf: Require that all commented-out settings + in libvirtd.conf have the same form. Before, two parameters + were not being tested, since a space had snuck between the + leading "#" and the "param = value" parts. + Apply each RHS-value-perturbing transformation + separately, not in series. + Let VERBOSE=yes turn on debugging. + Be more verbose by default, since this is a relatively + long-running test. + * qemud/libvirtd.conf: Normalize the spacing around each setting + that is to be perturbed by tests/daemon-conf. + Mon, 1 Dec 2008 10:30:10 +0100 Jim Meyering uml: don't free an uninitialized variable diff --git a/qemud/libvirtd.conf b/qemud/libvirtd.conf index c3231859a5..a12a897a1d 100644 --- a/qemud/libvirtd.conf +++ b/qemud/libvirtd.conf @@ -1,7 +1,10 @@ # Master libvirt daemon configuration file # # For further information consult http://libvirt.org/format.html - +# +# NOTE: the tests/daemon-conf regression test script requires +# that each "PARAMETER = VALUE" line in this file have the parameter +# name just after a leading "#". ################################################################# # @@ -45,7 +48,7 @@ # Override the default configuration which binds to all network # interfaces. This can be a numeric IPv4/6 address, or hostname # -# listen_addr = "192.168.0.1" +#listen_addr = "192.168.0.1" # Flag toggling mDNS advertizement of the libvirt service. diff --git a/tests/daemon-conf b/tests/daemon-conf index db1f0d3b42..03189d5b87 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -1,6 +1,11 @@ #!/bin/sh # Get coverage of libvirtd's config-parsing code. +if test "$VERBOSE" = yes; then + set -x + libvirtd --version +fi + # Boilerplate code to set up a test directory, cd into it, # and to ensure we remove it upon completion. this_test_() { echo "./$0" | sed 's,.*/,,'; } @@ -12,8 +17,14 @@ trap '(exit $?); exit $?' 1 2 13 15 mkdir "$t_" || fail=1 cd "$t_" || fail=1 +conf="$abs_top_srcdir/qemud/libvirtd.conf" + +# Ensure that each commented out PARAMETER = VALUE line has the expected form. +grep '[a-z_] *= *[^ ]' "$conf" | grep -vE '^#[a-z_]+ = ' \ + && { echo "$0: found unexpected lines (above) in $conf" 1>&2; exit 1; } + # Start with the sample libvirtd.conf file, uncommenting all real directives. -sed -n 's/^#\([^ #]\)/\1/p' $abs_top_srcdir/qemud/libvirtd.conf > tmp.conf +sed -n 's/^#\([^ #]\)/\1/p' "$conf" > tmp.conf # Iterate through that list of directives, corrupting one RHS at a # time and running libvirtd with the resulting config. Each libvirtd @@ -22,16 +33,23 @@ n=$(wc -l < tmp.conf) i=1 while :; do param_name=$(sed -n "$i"'s/ = .*//p' tmp.conf) + printf "testing with corrupted config: $param_name\n" 1>&2 rhs=$(sed -n "$i"'s/.* = \(.*\)/\1/p' tmp.conf) f=in$i.conf - # Change an RHS that starts with '"' or '[' to "3". - # Change an RHS that starts with 0 or 1 to the string '"foo"'. - sed "$i"'s/ = [["].*/ = 3/;'"$i"'s/ = [01].*/ = "foo"/' tmp.conf > $f + case $rhs in + # Change an RHS that starts with '"' or '[' to "3". + [[\"]*) sed "$i"'s/ = [["].*/ = 3/' tmp.conf > $f;; + # Change an RHS that starts with a digit to the string '"foo"'. + [0-9]*) sed "$i"'s/ = [0-9].*/ = "foo"/' tmp.conf > $f;; + esac + + # Run libvirtd, expecting it to fail. libvirtd --config=$f 2> err && fail=1 + case $rhs in # '"'*) msg='should be a string';; '"'*) msg='invalid type: got long; expected string';; - [01]*) msg='invalid type: got string; expected long';; + [0-9]*) msg='invalid type: got string; expected long';; '['*) msg='must be a string or list of strings';; *) echo "unexpected RHS: $rhs" 1>&2; fail=1;; esac @@ -48,8 +66,10 @@ while :; do done # Run with the unmodified config file. +sleep_secs=2 +printf "running libvirtd with a valid config file ($sleep_secs seconds)\n" 1>&2 libvirtd --config=tmp.conf > log 2>&1 & pid=$! -sleep 2 +sleep $sleep_secs kill $pid # Expect an orderly shut-down and successful exit.