Assorted collection of small improvements in making libguestfs build on non-Linux OSes; most of the changes impact tests though. Thanks, Pino Toscano (7): build: check the path of fuser, and use it in FUSE code tests: move guestfs-md5.sh to test-data v2v: tests: isolate SHA1 calculation in an own shared function v2v: tests: use guestfs-hashsums.sh for MD5 php: pass $(MAKE) to run-php-tests.sh build: check the path of true, and use it in tests build: improve GUESTFS_FIND_DB_TOOL macro fuse/guestunmount.c | 6 ++--- fuse/test-fuse.c | 2 +- m4/guestfs-find-db-tool.m4 | 7 +++--- m4/guestfs_progs.m4 | 8 +++++++ php/Makefile.am | 4 +++- php/run-php-tests.sh | 2 +- test-data/Makefile.am | 3 +++ test-data/guestfs-hashsums.sh | 43 +++++++++++++++++++++++++++++++++++ tests/qemu/Makefile.am | 1 - tests/qemu/guestfs-md5.sh | 30 ------------------------ tests/qemu/qemu-liveness.sh | 2 +- tests/qemu/qemu-snapshot-isolation.sh | 2 +- tests/regressions/rhbz790721.c | 2 +- v2v/test-v2v-i-ova-formats.sh | 4 +++- v2v/test-v2v-i-ova-gz.sh | 4 +++- v2v/test-v2v-i-ova-two-disks.sh | 6 +++-- v2v/test-v2v-i-ova.sh | 6 +++-- v2v/test-v2v-in-place.sh | 6 +++-- 18 files changed, 87 insertions(+), 51 deletions(-) create mode 100755 test-data/guestfs-hashsums.sh delete mode 100755 tests/qemu/guestfs-md5.sh -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 1/7] build: check the path of fuser, and use it in FUSE code
Check for the full path of fuser, and use it instead of hardcoding /sbin/fuser (which is still left as fallback). --- fuse/guestunmount.c | 6 +++--- fuse/test-fuse.c | 2 +- m4/guestfs_progs.m4 | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fuse/guestunmount.c b/fuse/guestunmount.c index fa6d5bb..8be9876 100644 --- a/fuse/guestunmount.c +++ b/fuse/guestunmount.c @@ -348,11 +348,11 @@ do_fuser (const char *mountpoint) exit (EXIT_FAILURE); } - if (pid == 0) { /* Child - run /sbin/fuser. */ + if (pid == 0) { /* Child - run fuser. */ #ifdef __linux__ - execlp ("/sbin/fuser", "fuser", "-v", "-m", mountpoint, NULL); + execlp (FUSER, "fuser", "-v", "-m", mountpoint, NULL); #else - execlp ("/sbin/fuser", "fuser", "-c", mountpoint, NULL); + execlp (FUSER, "fuser", "-c", mountpoint, NULL); #endif _exit (EXIT_FAILURE); } diff --git a/fuse/test-fuse.c b/fuse/test-fuse.c index 41ee947..95a2b3d 100644 --- a/fuse/test-fuse.c +++ b/fuse/test-fuse.c @@ -148,7 +148,7 @@ main (int argc, char *argv[]) ignore_value (chdir ("/")); /* Who's using the mountpoint? Should be no one. */ - snprintf (cmd, sizeof cmd, "/sbin/fuser %s", mountpoint); + snprintf (cmd, sizeof cmd, "%s %s", FUSER, mountpoint); printf ("%s\n", cmd); fflush (stdout); ignore_value (system (cmd)); diff --git a/m4/guestfs_progs.m4 b/m4/guestfs_progs.m4 index d4d1c34..0546b29 100644 --- a/m4/guestfs_progs.m4 +++ b/m4/guestfs_progs.m4 @@ -132,3 +132,7 @@ AS_IF([test "x$VALGRIND" != "xno"],[ ]) AC_SUBST([VG]) AM_SUBST_NOTMAKE([VG]) + +dnl Check for fuser (used in FUSE stuff). +AC_PATH_PROGS([FUSER],[fuser],[/sbin/fuser]) +AC_DEFINE_UNQUOTED([FUSER],["$FUSER"],[Name of fuser program.]) -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 2/7] tests: move guestfs-md5.sh to test-data
Move it to the test-data directory, giving it a more generic name so it can be used also for more than just md5; adjust qemu tests accordingly. This is just code motion, no behaviour change. --- test-data/Makefile.am | 3 +++ test-data/guestfs-hashsums.sh | 30 ++++++++++++++++++++++++++++++ tests/qemu/Makefile.am | 1 - tests/qemu/guestfs-md5.sh | 30 ------------------------------ tests/qemu/qemu-liveness.sh | 2 +- tests/qemu/qemu-snapshot-isolation.sh | 2 +- 6 files changed, 35 insertions(+), 33 deletions(-) create mode 100755 test-data/guestfs-hashsums.sh delete mode 100755 tests/qemu/guestfs-md5.sh diff --git a/test-data/Makefile.am b/test-data/Makefile.am index 0a9c65e..0c37c97 100644 --- a/test-data/Makefile.am +++ b/test-data/Makefile.am @@ -26,6 +26,9 @@ SUBDIRS += fake-virtio-win fake-virt-tools SUBDIRS += files SUBDIRS += . +EXTRA_DIST = \ + guestfs-hashsums.sh + # Build an ISO containing various files from the subdirectories, which # is used by tests/c-api and a few guestfish tests and regression # tests. diff --git a/test-data/guestfs-hashsums.sh b/test-data/guestfs-hashsums.sh new file mode 100755 index 0000000..79dbd67 --- /dev/null +++ b/test-data/guestfs-hashsums.sh @@ -0,0 +1,30 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2014 Red Hat Inc. +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +do_md5 () +{ + case "$(uname)" in + Linux) + md5sum "$1" | awk '{print $1}' + ;; + *) + echo "$0: unknown method to calculate MD5 of file on $(uname)" + exit 1 + ;; + esac +} diff --git a/tests/qemu/Makefile.am b/tests/qemu/Makefile.am index 6c72b18..091361f 100644 --- a/tests/qemu/Makefile.am +++ b/tests/qemu/Makefile.am @@ -30,7 +30,6 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test EXTRA_DIST = \ $(TESTS) \ - guestfs-md5.sh \ qemu-boot.c \ qemu-speed-test.c diff --git a/tests/qemu/guestfs-md5.sh b/tests/qemu/guestfs-md5.sh deleted file mode 100755 index 79dbd67..0000000 --- a/tests/qemu/guestfs-md5.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2014 Red Hat Inc. -# -# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -do_md5 () -{ - case "$(uname)" in - Linux) - md5sum "$1" | awk '{print $1}' - ;; - *) - echo "$0: unknown method to calculate MD5 of file on $(uname)" - exit 1 - ;; - esac -} diff --git a/tests/qemu/qemu-liveness.sh b/tests/qemu/qemu-liveness.sh index 7129bb2..fda3cc2 100755 --- a/tests/qemu/qemu-liveness.sh +++ b/tests/qemu/qemu-liveness.sh @@ -22,7 +22,7 @@ set -e -. $srcdir/guestfs-md5.sh +. $srcdir/../../test-data/guestfs-hashsums.sh rm -f liveness1.img diff --git a/tests/qemu/qemu-snapshot-isolation.sh b/tests/qemu/qemu-snapshot-isolation.sh index c217dc4..4d60e59 100755 --- a/tests/qemu/qemu-snapshot-isolation.sh +++ b/tests/qemu/qemu-snapshot-isolation.sh @@ -22,7 +22,7 @@ set -e -. $srcdir/guestfs-md5.sh +. $srcdir/../../test-data/guestfs-hashsums.sh # UML backend doesn't support qcow2 format. supports_qcow2=yes -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 3/7] v2v: tests: isolate SHA1 calculation in an own shared function
sha1sum(1) does not exist everywhere, so wrap it in an own function so the right implementation can be chosen on each OS. Also, wrapping it avoid using awk everytime. --- test-data/guestfs-hashsums.sh | 13 +++++++++++++ v2v/test-v2v-i-ova-formats.sh | 4 +++- v2v/test-v2v-i-ova-gz.sh | 4 +++- v2v/test-v2v-i-ova-two-disks.sh | 6 ++++-- v2v/test-v2v-i-ova.sh | 6 ++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/test-data/guestfs-hashsums.sh b/test-data/guestfs-hashsums.sh index 79dbd67..96e1238 100755 --- a/test-data/guestfs-hashsums.sh +++ b/test-data/guestfs-hashsums.sh @@ -28,3 +28,16 @@ do_md5 () ;; esac } + +do_sha1 () +{ + case "$(uname)" in + Linux) + sha1sum "$1" | awk '{print $1}' + ;; + *) + echo "$0: unknown method to calculate SHA1 of file on $(uname)" + exit 1 + ;; + esac +} diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh index 47e57c6..3e2923d 100755 --- a/v2v/test-v2v-i-ova-formats.sh +++ b/v2v/test-v2v-i-ova-formats.sh @@ -46,6 +46,8 @@ fi export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" +. $srcdir/../test-data/guestfs-hashsums.sh + d=test-v2v-i-ova-formats.d rm -rf $d mkdir $d @@ -55,7 +57,7 @@ pushd $d # Create a phony OVA. This is only a test of source parsing, not # conversion, so the contents of the disks doesn't matter. truncate -s 10k disk1.vmdk -sha=`sha1sum disk1.vmdk | awk '{print $1}'` +sha=`do_sha1 disk1.vmdk` echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf for format in $formats; do diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh index 65071dd..086ff98 100755 --- a/v2v/test-v2v-i-ova-gz.sh +++ b/v2v/test-v2v-i-ova-gz.sh @@ -34,6 +34,8 @@ fi export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" +. $srcdir/../test-data/guestfs-hashsums.sh + d=test-v2v-i-ova-gz.d rm -rf $d mkdir $d @@ -42,7 +44,7 @@ pushd $d truncate -s 10k disk1.vmdk gzip disk1.vmdk -sha=`sha1sum disk1.vmdk.gz | awk '{print $1}'` +sha=`do_sha1 disk1.vmdk.gz` echo -e "SHA1(disk1.vmdk.gz)=$sha\r" > disk1.mf tar -cf test.ova ../test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index 85b23f0..4e7f38b 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -35,6 +35,8 @@ fi export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win" +. $srcdir/../test-data/guestfs-hashsums.sh + d=test-v2v-i-ova-two-disks.d rm -rf $d mkdir $d @@ -44,10 +46,10 @@ pushd $d # Create a phony OVA. This is only a test of source parsing, not # conversion, so the contents of the disks doesn't matter. truncate -s 10k disk1.vmdk -sha=`sha1sum disk1.vmdk | awk '{print $1}'` +sha=`do_sha1 disk1.vmdk` echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf truncate -s 100k disk2.vmdk -sha=`sha1sum disk2.vmdk | awk '{print $1}'` +sha=`do_sha1 disk2.vmdk` echo -e "SHA1(disk2.vmdk)=$sha\r" > disk2.mf tar -cf test.ova ../test-v2v-i-ova-two-disks.ovf disk1.vmdk disk1.mf disk2.vmdk disk2.mf diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 484e098..ea4f3df 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -41,6 +41,8 @@ fi export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win" +. $srcdir/../test-data/guestfs-hashsums.sh + d=test-v2v-i-ova.d rm -rf $d mkdir $d @@ -53,9 +55,9 @@ raw=TestOva-sda qemu-img convert $f -O vmdk $d/$vmdk cp $ovf $d/$ovf -sha1=`sha1sum $d/$ovf | awk '{print $1}'` +sha1=`do_sha1 $d/$ovf` echo "SHA1($ovf)= $sha1" > $d/$mf -sha1=`sha1sum $d/$vmdk | awk '{print $1}'` +sha1=`do_sha1 $d/$vmdk` echo "SHA1($vmdk)= $sha1" >> $d/$mf pushd . -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 4/7] v2v: tests: use guestfs-hashsums.sh for MD5
Use the common helper for MD5 checksum, instead of assuming md5sum(1). --- v2v/test-v2v-in-place.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/v2v/test-v2v-in-place.sh b/v2v/test-v2v-in-place.sh index 251e78c..e55daa0 100755 --- a/v2v/test-v2v-in-place.sh +++ b/v2v/test-v2v-in-place.sh @@ -44,6 +44,8 @@ fi export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win" +. $srcdir/../test-data/guestfs-hashsums.sh + d=$PWD/test-v2v-in-place.d rm -rf $d mkdir $d @@ -51,7 +53,7 @@ mkdir $d img="$d/test.qcow2" rm -f $img qemu-img create -f qcow2 -b $img_base -o compat=1.1,backing_fmt=raw $img -md5="$(md5sum $img_base)" +md5="$(do_md5 $img_base)" libvirt_xml="$d/test.xml" rm -f $libvirt_xml @@ -113,7 +115,7 @@ guestfish --ro -a "$img" -i < "$script" > "$response" diff -u "$expected" "$response" # Test the base image remained untouched -test "$md5" = "$(md5sum $img_base)" +test "$md5" = "$(do_md5 $img_base)" # Clean up. rm -r $d -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 5/7] php: pass $(MAKE) to run-php-tests.sh
Instead of hardcoding "make" in run-php-tests.sh, pass the actual name of make from the Makefile; the default is still "make", mostly to use the script without having to set $MAKE. --- php/Makefile.am | 4 +++- php/run-php-tests.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/php/Makefile.am b/php/Makefile.am index 836f4ba..4db7d84 100644 --- a/php/Makefile.am +++ b/php/Makefile.am @@ -60,7 +60,9 @@ extension/config.h: extension/config.m4 ../config.status test -f "$@" && touch -- $@ # Don't use --test because PHP always returns a success code. -TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS_ENVIRONMENT = \ + MAKE=$(MAKE) \ + $(top_builddir)/run TESTS = run-php-tests.sh diff --git a/php/run-php-tests.sh b/php/run-php-tests.sh index 4132927..e5cfc0d 100755 --- a/php/run-php-tests.sh +++ b/php/run-php-tests.sh @@ -44,4 +44,4 @@ printenv | grep -E '^(LIBGUESTFS|LIBVIRT|LIBVIRTD|VIRTLOCKD|LD|MALLOC)_' >> env TESTS=$(echo tests/guestfs_*.phpt) echo TESTS: $TESTS -make test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" REPORT_EXIT_STATUS=1 TEST_TIMEOUT=300 +${MAKE:-make} test TESTS="$TESTS" PHP_EXECUTABLE="$PWD/php-for-tests.sh" REPORT_EXIT_STATUS=1 TEST_TIMEOUT=300 -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 6/7] build: check the path of true, and use it in tests
Check for the full path of true, and use it instead of hardcoding /bin/true (which is still left as fallback). --- m4/guestfs_progs.m4 | 4 ++++ tests/regressions/rhbz790721.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/m4/guestfs_progs.m4 b/m4/guestfs_progs.m4 index 0546b29..e876942 100644 --- a/m4/guestfs_progs.m4 +++ b/m4/guestfs_progs.m4 @@ -136,3 +136,7 @@ AM_SUBST_NOTMAKE([VG]) dnl Check for fuser (used in FUSE stuff). AC_PATH_PROGS([FUSER],[fuser],[/sbin/fuser]) AC_DEFINE_UNQUOTED([FUSER],["$FUSER"],[Name of fuser program.]) + +dnl Check for true (used in tests). +AC_PATH_PROGS([TOOL_TRUE],[true],[/bin/true]) +AC_DEFINE_UNQUOTED([TOOL_TRUE],["$TOOL_TRUE"],[Name of 'true' program.]) diff --git a/tests/regressions/rhbz790721.c b/tests/regressions/rhbz790721.c index de6646d..37f0754 100644 --- a/tests/regressions/rhbz790721.c +++ b/tests/regressions/rhbz790721.c @@ -138,7 +138,7 @@ start_thread (void *vi) } /* Fake out hypervisor. */ - if (guestfs_set_hv (g, "/bin/true") == -1) { + if (guestfs_set_hv (g, TOOL_TRUE) == -1) { *(int *)vi = -1; pthread_exit (vi); } -- 2.5.0
Pino Toscano
2016-Mar-18 16:18 UTC
[Libguestfs] [PATCH 7/7] build: improve GUESTFS_FIND_DB_TOOL macro
- find the unversioned name just once - add 5.3 and 5.2 as versions - add db_$TOOL-X and db_$TOOL-X.Y as patterns (found on FreeBSD) --- m4/guestfs-find-db-tool.m4 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/m4/guestfs-find-db-tool.m4 b/m4/guestfs-find-db-tool.m4 index 0cbbd13..ee20301 100644 --- a/m4/guestfs-find-db-tool.m4 +++ b/m4/guestfs-find-db-tool.m4 @@ -20,13 +20,14 @@ AC_DEFUN([GUESTFS_FIND_DB_TOOL],[ TOOL=$2 db_tool_name="db_$TOOL" - db_versions="5.1 4.8 4.7 4.6" - db_tool_patterns="db_$TOOL dbX_$TOOL dbX.Y_$TOOL" + db_versions="5.3 5.2 5.1 4.8 4.7 4.6" + db_tool_patterns="dbX_$TOOL dbX.Y_$TOOL" + db_tool_patterns="dbX_$TOOL db_$TOOL-X dbX.Y_$TOOL db_$TOOL-X.Y" AC_ARG_VAR(VARIABLE, [Absolute path to $db_tool_name executable]) AS_IF(test -z "$VARIABLE", [ - exe_list="" + exe_list="db_$TOOL" for ver in $db_versions ; do ver_maj=`echo $ver | cut -d. -f1` ver_min=`echo $ver | cut -d. -f2` -- 2.5.0
Richard W.M. Jones
2016-Mar-19 17:14 UTC
Re: [Libguestfs] [PATCH 2/7] tests: move guestfs-md5.sh to test-data
On Fri, Mar 18, 2016 at 05:18:08PM +0100, Pino Toscano wrote:> +do_md5 () > +{ > + case "$(uname)" in > + Linux) > + md5sum "$1" | awk '{print $1}' > + ;; > + *) > + echo "$0: unknown method to calculate MD5 of file on $(uname)"s/MD5/hash/ (although that error was present in the original file too, so maybe it should be in a new commit). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Richard W.M. Jones
2016-Mar-19 17:16 UTC
Re: [Libguestfs] [PATCH 7/7] build: improve GUESTFS_FIND_DB_TOOL macro
ACK series. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Seemingly Similar Threads
- [PATCH 9/9] tests/qemu: isolate MD5 calculation in an own shared function
- [PATCH 0/7] Small portability changes
- Re: [PATCH 2/7] tests: move guestfs-md5.sh to test-data
- [PATCH] Optionally, allow distros to use openssl for MD5 verification
- [PATCH v4 0/6] Import directly from OVA tar archive if possible