Pino Toscano
2019-Dec-16 10:20 UTC
[Libguestfs] [PATCH 0/2] tests: simpler way to use configure results
Add a single shell script to hold results of configure. Pino Toscano (2): build: add an empty config.sh tests: switch to config.sh for xmllint .gitignore | 4 +--- config.sh.in | 22 +++++++++++++++++++ configure.ac | 7 +----- ...luks.sh.in => test-virt-inspector-luks.sh} | 2 +- ...inspector.sh.in => test-virt-inspector.sh} | 2 +- .../{test-xmllint.sh.in => test-xmllint.sh} | 2 +- tests/test-functions.sh | 3 +++ 7 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 config.sh.in rename inspector/{test-virt-inspector-luks.sh.in => test-virt-inspector-luks.sh} (94%) rename inspector/{test-virt-inspector.sh.in => test-virt-inspector.sh} (95%) rename inspector/{test-xmllint.sh.in => test-xmllint.sh} (93%) -- 2.23.0
This helper script will contain variables with results of configure checks, so other scripts can source it. Source it automatically in test-functions.sh, so every test can already make use of it. --- .gitignore | 1 + config.sh.in | 20 ++++++++++++++++++++ configure.ac | 1 + tests/test-functions.sh | 3 +++ 4 files changed, 25 insertions(+) create mode 100644 config.sh.in diff --git a/.gitignore b/.gitignore index 03930f1c7..bd8c13954 100644 --- a/.gitignore +++ b/.gitignore @@ -127,6 +127,7 @@ Makefile.in /config.h /config.h.in /config.log +/config.sh /config.status /config.sub /configure diff --git a/config.sh.in b/config.sh.in new file mode 100644 index 000000000..061871a3c --- /dev/null +++ b/config.sh.in @@ -0,0 +1,20 @@ +#!/bin/bash - +# (C) Copyright 2019 Red Hat Inc. +# @configure_input@ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This shell script contains the results of some configure checks, +# mostly used in other shell scripts. diff --git a/configure.ac b/configure.ac index f05a45252..774f78586 100644 --- a/configure.ac +++ b/configure.ac @@ -252,6 +252,7 @@ AC_CONFIG_FILES([Makefile common/utils/Makefile common/visit/Makefile common/windows/Makefile + config.sh csharp/Makefile customize/Makefile daemon/daemon_config.ml diff --git a/tests/test-functions.sh b/tests/test-functions.sh index 5510b01e9..e93baeaab 100755 --- a/tests/test-functions.sh +++ b/tests/test-functions.sh @@ -33,6 +33,9 @@ export LANG=C # parameters, so we eval those to define the variables. while [ $# -ge 1 ]; do eval "$1"; shift; done +# Configure check results. +source $abs_top_builddir/config.sh + # Skip if $SKIP_<script_name> environment variable is set. # Every test should call this function first. skip_if_skipped () -- 2.23.0
Pino Toscano
2019-Dec-16 10:20 UTC
[Libguestfs] [PATCH 2/2] tests: switch to config.sh for xmllint
Instead of generating test scripts from configure with the path of xmllint, export that path in config.sh, so the tests can be static scripts again. --- .gitignore | 3 --- config.sh.in | 2 ++ configure.ac | 6 ------ ...irt-inspector-luks.sh.in => test-virt-inspector-luks.sh} | 2 +- .../{test-virt-inspector.sh.in => test-virt-inspector.sh} | 2 +- inspector/{test-xmllint.sh.in => test-xmllint.sh} | 2 +- 6 files changed, 5 insertions(+), 12 deletions(-) rename inspector/{test-virt-inspector-luks.sh.in => test-virt-inspector-luks.sh} (94%) rename inspector/{test-virt-inspector.sh.in => test-virt-inspector.sh} (95%) rename inspector/{test-xmllint.sh.in => test-xmllint.sh} (93%) diff --git a/.gitignore b/.gitignore index bd8c13954..8dfd2895c 100644 --- a/.gitignore +++ b/.gitignore @@ -309,9 +309,6 @@ Makefile.in /haskell/Guestfs.hs /inspector/actual-*.xml /inspector/stamp-virt-inspector.pod -/inspector/test-virt-inspector.sh -/inspector/test-virt-inspector-luks.sh -/inspector/test-xmllint.sh /inspector/virt-inspector /inspector/virt-inspector.1 /installcheck.sh diff --git a/config.sh.in b/config.sh.in index 061871a3c..c777f096c 100644 --- a/config.sh.in +++ b/config.sh.in @@ -18,3 +18,5 @@ # This shell script contains the results of some configure checks, # mostly used in other shell scripts. + +export XMLLINT="@XMLLINT@" diff --git a/configure.ac b/configure.ac index 774f78586..64f352323 100644 --- a/configure.ac +++ b/configure.ac @@ -197,12 +197,6 @@ mkdir -p \ dnl http://www.mail-archive.com/automake@gnu.org/msg10204.html AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance], [chmod +x,-w appliance/libguestfs-make-fixed-appliance]) -AC_CONFIG_FILES([inspector/test-xmllint.sh], - [chmod +x,-w inspector/test-xmllint.sh]) -AC_CONFIG_FILES([inspector/test-virt-inspector.sh], - [chmod +x,-w inspector/test-virt-inspector.sh]) -AC_CONFIG_FILES([inspector/test-virt-inspector-luks.sh], - [chmod +x,-w inspector/test-virt-inspector-luks.sh]) AC_CONFIG_FILES([installcheck.sh], [chmod +x,-w installcheck.sh]) AC_CONFIG_FILES([ocaml-dep.sh], diff --git a/inspector/test-virt-inspector-luks.sh.in b/inspector/test-virt-inspector-luks.sh similarity index 94% rename from inspector/test-virt-inspector-luks.sh.in rename to inspector/test-virt-inspector-luks.sh index 2d713f16b..9cb062ec4 100755 --- a/inspector/test-virt-inspector-luks.sh.in +++ b/inspector/test-virt-inspector-luks.sh @@ -35,7 +35,7 @@ if [ -s "$f" ]; then echo FEDORA | $VG virt-inspector --keys-from-stdin --format=raw -a "$f" > "actual-$b.xml" # Check the generated output validate the schema. - @XMLLINT@ --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml" + $XMLLINT --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml" # This 'diff' command will fail (because of -e option) if there # are any differences. diff -ur $diff_ignore "expected-$b.xml" "actual-$b.xml" diff --git a/inspector/test-virt-inspector.sh.in b/inspector/test-virt-inspector.sh similarity index 95% rename from inspector/test-virt-inspector.sh.in rename to inspector/test-virt-inspector.sh index 191f6fbc0..139e68e42 100755 --- a/inspector/test-virt-inspector.sh.in +++ b/inspector/test-virt-inspector.sh @@ -31,7 +31,7 @@ for f in ../test-data/phony-guests/{debian,fedora,ubuntu,archlinux,coreos,window b=$(basename "$f" .xml) $VG virt-inspector --format=raw -a "$f" > "actual-$b.xml" # Check the generated output validate the schema. - @XMLLINT@ --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml" + $XMLLINT --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml" # This 'diff' command will fail (because of -e option) if there # are any differences. diff -ur $diff_ignore "expected-$b.xml" "actual-$b.xml" diff --git a/inspector/test-xmllint.sh.in b/inspector/test-xmllint.sh similarity index 93% rename from inspector/test-xmllint.sh.in rename to inspector/test-xmllint.sh index 24ca515bb..0de37f860 100755 --- a/inspector/test-xmllint.sh.in +++ b/inspector/test-xmllint.sh @@ -22,5 +22,5 @@ $TEST_FUNCTIONS skip_if_skipped for f in $srcdir/example-*.xml; do - @XMLLINT@ --noout --relaxng $srcdir/virt-inspector.rng $f + $XMLLINT --noout --relaxng $srcdir/virt-inspector.rng $f done -- 2.23.0
Richard W.M. Jones
2019-Dec-16 14:42 UTC
Re: [Libguestfs] [PATCH 2/2] tests: switch to config.sh for xmllint
Same as previous series for libguestfs, so ACK series too. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/