Pino Toscano
2014-Mar-05 10:17 UTC
[Libguestfs] [PATCH 0/2] supermin: fix with no dpkg installed
f093ba80e0918484838dba46a747ffaecf983fb3 caused a regression (startup failure) when dpkg is not installed. Simple fix with simple test for it. Pino Toscano (2): dpkg: do not always run dpkg_primary_arch tests: add a basic run test src/dpkg.ml | 4 ++-- tests/Makefile.am | 3 ++- tests/test-basic.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 tests/test-basic.sh -- 1.8.3.1
Pino Toscano
2014-Mar-05 10:17 UTC
[Libguestfs] [PATCH 1/2] dpkg: do not always run dpkg_primary_arch
Having dpkg_primary_arch as a top-level statement means it will be evaluated at startup, which will fail if dpkg is not installed. Turn it into a function so it can be run just when needed. --- src/dpkg.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dpkg.ml b/src/dpkg.ml index 147d0bc..71aa12c 100644 --- a/src/dpkg.ml +++ b/src/dpkg.ml @@ -29,7 +29,7 @@ let dpkg_detect () Config.apt_get <> "no" && file_exists "/etc/debian_version" -let dpkg_primary_arch +let dpkg_primary_arch () let cmd = sprintf "%s --print-architecture" Config.dpkg in let lines = run_command_get_lines cmd in match lines with @@ -80,7 +80,7 @@ let dpkg_package_of_string str (* On multiarch setups, only consider the primary architecture *) try List.find (fun pkg -> - pkg.arch = dpkg_primary_arch || pkg.arch = "all") pkgs + pkg.arch = dpkg_primary_arch () || pkg.arch = "all") pkgs with Not_found -> assert false -- 1.8.3.1
Add a simple test which just runs the basic options of supermin, so it can be tested even if the other tests (all being network tests) are disabled. --- tests/Makefile.am | 3 ++- tests/test-basic.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 tests/test-basic.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index b6f8416..fd059d5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,7 +19,8 @@ EXTRA_DIST = $(TESTS) -TESTS +TESTS = \ + test-basic.sh if NETWORK_TESTS TESTS += \ diff --git a/tests/test-basic.sh b/tests/test-basic.sh new file mode 100755 index 0000000..d91bbd9 --- /dev/null +++ b/tests/test-basic.sh @@ -0,0 +1,28 @@ +#!/bin/bash - +# supermin +# (C) Copyright 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +set -e + +# Test the basic run of supermin +../src/supermin --help + +# Very simple test for the version string +../src/supermin --version | grep ^supermin + +# Check that listing drivers work +../src/supermin --list-drivers -- 1.8.3.1
Richard W.M. Jones
2014-Mar-05 12:42 UTC
Re: [Libguestfs] [PATCH 2/2] tests: add a basic run test
ACK to both patches. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW