From: Richard Jones Date: Tue, 30 Mar 2010 13:18:44 +0000 (+0100) Subject: tools: Add basic tests for the virt-* tools. X-Git-Tag: 1.0.89~6 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=fc5fbd460aa0aaf6bb65ca5fa1be59345f4f079f tools: Add basic tests for the virt-* tools. --- diff --git a/.gitignore b/.gitignore index 6a47234..dada5ad 100644 --- a/.gitignore +++ b/.gitignore @@ -225,6 +225,7 @@ stamp-h1 test-tool/libguestfs-test-tool.1 test-tool/libguestfs-test-tool test-tool/libguestfs-test-tool-helper +tools/test.img tools/virt-*.1 /GNUmakefile /maint.mk diff --git a/tools/Makefile.am b/tools/Makefile.am index d212d38..08f126d 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -30,9 +30,12 @@ tools = \ win-reg EXTRA_DIST = \ + make-test-img.sh run-locally \ $(tools:%=virt-%) +CLEANFILES = test.img + if HAVE_TOOLS bin_SCRIPTS = $(tools:%=virt-%) @@ -61,4 +64,25 @@ $(top_builddir)/html/virt-%.1.html: virt-% --outfile html/$<.1.html \ tools/$< +# Tests. + +random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null) + +TESTS_ENVIRONMENT = \ + MALLOC_PERTURB_=$(random_val) \ + LD_LIBRARY_PATH=$(top_builddir)/src/.libs \ + LIBGUESTFS_PATH=$(top_builddir)/appliance \ + PERL5LIB=$(top_builddir)/perl/blib/lib:$(top_builddir)/perl/blib/arch + +# Build a standard test image to be used by all these tests. +check_DATA = test.img +test.img: make-test-img.sh + $(TESTS_ENVIRONMENT) $(srcdir)/make-test-img.sh + +TESTS = test-virt-cat.sh \ + test-virt-df.sh \ + test-virt-list-filesystems.sh \ + test-virt-ls.sh \ + test-virt-tar.sh + endif diff --git a/tools/make-test-img.sh b/tools/make-test-img.sh new file mode 100755 index 0000000..c6481cd --- /dev/null +++ b/tools/make-test-img.sh @@ -0,0 +1,88 @@ +#!/bin/bash - +# libguestfs virt-* tools +# Copyright (C) 2010 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. + +# Make a standard test image which is used by all the tools/test-*.sh +# test scripts. This test image is supposed to look like a Fedora +# installation, or at least enough of one to fool virt-inspector's +# heuristics. + +export LANG=C +set -e + +rm -f test.img + +cat > fstab <