Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 00/17] tests: Introduce test harness for running tests.
Since v3: - A large number of fixes, especially for running the tests on installed libguestfs. - Fixed EXTRA_DIST rules throughout. - Extra patch 17/17 which is a tidy-up of the generated XML listing guests. Rich.
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 01/17] tests: Introduce test harness for running tests.
We would like to have a more flexible way to run tests, including running them on an installed copy of libguestfs, running them in parallel, and being able to express dependencies and ordering between tests and data files properly. Therefore introduce a test harness (test-harness) program which can run tests either from the locally built copy, or from an installed copy of the tests (in $libdir/guestfs/tests). The test harness is backwards compatible on the command line, ie. 'make check', 'make -C inspector check-valgrind' etc. will still work. But in addition, you can now run the tests on an installed copy of libguestfs by doing: cd $libdir/guestfs/tests ./test-harness The test-harness script supports various options, see 'test-harness(1)' for full details. Other notable features: - Checking SKIP_* environment variables in tests is no longer necessary. The test harness deals with these. - Every test runs in its own temporary directory. There is no need to clean up output files. On the other hand, tests must use $srcdir, $builddir, $datadir etc. to refer to test data. This is only implemented for a single directory at the moment (ie. inspector/) --- .gitignore | 6 +- Makefile.am | 20 + common-rules.mk | 3 + configure.ac | 2 + generator/Makefile.am | 24 + generator/main.ml | 9 + generator/test_harness.ml | 738 +++++++++++++++++++++++ generator/tests.ml | 71 +++ generator/tests_mk.ml | 130 ++++ generator/types.ml | 15 + inspector/Makefile.am | 17 +- inspector/test-virt-inspector-local-guests.sh.in | 26 + inspector/test-virt-inspector.sh | 12 +- inspector/test-xmllint.sh.in | 5 + inspector/tests.mk | 94 +++ pick-guests.pl.in | 4 +- po-docs/podfiles | 1 + test-harness.pod | 252 ++++++++ tests/data/Makefile.am | 59 +- tests/guests/Makefile.am | 95 +-- tests/guests/guest-aux/make-archlinux-img.sh | 4 +- tests/guests/guest-aux/make-debian-img.sh | 6 +- tests/guests/guest-aux/make-fedora-img.pl | 21 +- tests/guests/guest-aux/make-ubuntu-img.sh | 4 +- tests/guests/guest-aux/make-windows-img.sh | 6 +- 25 files changed, 1482 insertions(+), 142 deletions(-) create mode 100644 generator/test_harness.ml create mode 100644 generator/tests.ml create mode 100644 generator/tests_mk.ml create mode 100755 inspector/test-virt-inspector-local-guests.sh.in create mode 100644 inspector/tests.mk create mode 100644 test-harness.pod diff --git a/.gitignore b/.gitignore index e968399..72f8cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -276,8 +276,8 @@ Makefile.in /html/virt-v2v.1.html /html/virt-v2v-test-harness.1.html /html/virt-win-reg.1.html -/inspector/actual-*.xml /inspector/stamp-virt-inspector.pod +/inspector/test-virt-inspector-local-guests.sh /inspector/test-xmllint.sh /inspector/virt-inspector /inspector/virt-inspector.1 @@ -496,6 +496,8 @@ Makefile.in /sysprep/virt-sysprep.1 /test.err /test.out +/test-harness +/test-harness.1 /tests/c-api/test-add-drive-opts /tests/c-api/test-add-libvirt-dom /tests/c-api/test-backend-settings @@ -549,7 +551,7 @@ Makefile.in /tests/guests/guest-aux/fedora-packages.db /tests/guests/guest-aux/windows-software /tests/guests/guest-aux/windows-system -/tests/guests/stamp-fedora-md.img +/tests/guests/stamp-guests /tests/guests/ubuntu.img /tests/guests/archlinux.img /tests/guests/coreos.img diff --git a/Makefile.am b/Makefile.am index 8f0bb1b..2c6c8b2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -207,6 +207,7 @@ EXTRA_DIST = \ logo/virt-builder.svg \ m4/.gitignore \ ocaml-link.sh \ + test-harness.pod \ tests/run-xml-to-junit.sh \ tests/run-xml-to-junit.xsl \ tmp/.gitignore \ @@ -405,6 +406,16 @@ podwrapper.1: podwrapper.pl $< mv $@-t $@ +# NB. test-harness is an internal tool, so the man page mustn't be installed. +noinst_MANS += test-harness.1 +test-harness.1: test-harness.pod + $(PODWRAPPER) \ + --section 1 \ + --man $@-t \ + --license GPLv2+ \ + $< + mv $@-t $@ + # Make clean. CLEANFILES = \ @@ -414,6 +425,7 @@ CLEANFILES = \ podwrapper.1 \ qemu-wrapper.sh \ stamp-guestfs-release-notes.pod \ + test-harness.1 \ tmp/disk* \ tmp/run-* \ tmp/valgrind-*.log @@ -423,6 +435,11 @@ clean-local: -rm -rf tmp/guestfs.* -rm -rf tmp/.guestfs-* +# Tests. + +localtestsdir = $(alltestsdir) +localtests_DATA = bindtests + # If you don't want to run all of the tests ('make check') then this # will just run libguestfs-test-tool for a quick check. Note this # is NOT a substitute for proper testing! @@ -541,6 +558,9 @@ check-slow: build-test-guests build-test-guests: $(MAKE) -C tests/guests check +# Install valgrind suppressions file in test directory. +alltests_DATA = valgrind-suppressions + # Print subdirs. # # If you want to selectively run tests, or if the test suite fails half diff --git a/common-rules.mk b/common-rules.mk index 312107e..5a239ab 100644 --- a/common-rules.mk +++ b/common-rules.mk @@ -27,3 +27,6 @@ builddir ?= @builddir@ abs_builddir ?= @abs_builddir@ srcdir ?= @srcdir@ abs_srcdir ?= @abs_srcdir@ + +# Tests directory. +alltestsdir = $(libdir)/guestfs/tests diff --git a/configure.ac b/configure.ac index d54ce7d..461d5cc 100644 --- a/configure.ac +++ b/configure.ac @@ -1700,6 +1700,8 @@ mkdir -p \ dnl http://www.mail-archive.com/automake at 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-virt-inspector-local-guests.sh], + [chmod +x,-w inspector/test-virt-inspector-local-guests.sh]) AC_CONFIG_FILES([inspector/test-xmllint.sh], [chmod +x,-w inspector/test-xmllint.sh]) AC_CONFIG_FILES([p2v/virt-p2v-make-disk], diff --git a/generator/Makefile.am b/generator/Makefile.am index a3fe50d..1c16ad0 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -50,6 +50,9 @@ sources = \ ruby.ml \ structs.ml \ structs.mli \ + tests.ml \ + tests_mk.ml \ + test_harness.ml \ tests_c_api.ml \ types.ml \ utils.ml \ @@ -68,6 +71,8 @@ objects = \ pr.cmo \ docstrings.cmo \ checks.cmo \ + tests.cmo \ + tests_mk.cmo \ c.cmo \ xdr.cmo \ daemon.cmo \ @@ -90,17 +95,30 @@ objects = \ customize.cmo \ main.cmo +test_harness_objects = \ + types.cmo \ + utils.cmo \ + tests.cmo \ + test_harness.cmo + EXTRA_DIST = $(sources) files-generated.txt OCAMLCFLAGS = $(OCAML_WARN_ERROR) -I $(srcdir) -I . -package unix,str noinst_PROGRAM = generator +# Install the test harness. +localtestsdir = $(alltestsdir) +localtests_SCRIPTS = ../test-harness + if HAVE_OCAML generator: $(objects) $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -linkpkg $^ -o $@ +../test-harness: $(test_harness_objects) + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -linkpkg $^ -o $@ + # Dependencies. %.cmi: %.mli $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ @@ -133,6 +151,12 @@ generator: chmod +x $@-t mv $@-t $@ +../test-harness: + rm -f $@ $@-t + echo 'echo Warning: Install OCaml compiler in order to rebuild the test-harness.' > $@-t + chmod +x $@-t + mv $@-t $@ + endif noinst_DATA = stamp-generator diff --git a/generator/main.ml b/generator/main.ml index 94f0d09..23e9fbc 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -29,6 +29,8 @@ open Types open C open Xdr open Daemon +open Tests +open Tests_mk open Tests_c_api open Fish open Ocaml @@ -47,6 +49,8 @@ open Bindtests open Errnostring open Customize +let (//) = Filename.concat + let perror msg = function | Unix_error (err, _, _) -> eprintf "%s: %s\n" msg (error_message err) @@ -211,6 +215,11 @@ Run it from the top source directory using the command output_to "customize/customize-synopsis.pod" generate_customize_synopsis_pod; output_to "customize/customize-options.pod" generate_customize_options_pod; + List.iter ( + fun (dir, tests) -> + output_to (dir // "tests.mk") (generate_tests_mk dir tests) + ) tests; + (* Generate the list of files generated -- last. *) printf "generated %d lines of code\n" (get_lines_generated ()); let files = List.sort compare (get_files_generated ()) in diff --git a/generator/test_harness.ml b/generator/test_harness.ml new file mode 100644 index 0000000..af8182c --- /dev/null +++ b/generator/test_harness.ml @@ -0,0 +1,738 @@ +(* 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 + *) + +(* The test-harness standalone program. *) + +open Unix +open Printf + +open Types +open Tests + +(* Prevent this script from being run as root. *) +let () + if geteuid () = 0 then ( + eprintf "%s: don't run the libguestfs tests as root\n" Sys.executable_name; + exit 1 + ) + +let (//) = Filename.concat + +let isatty = isatty stdout + +(* ANSI terminal colours. *) +let ansi_green ?(chan = Pervasives.stdout) () + if isatty then output_string chan "\x1b[0;32m" +let ansi_red ?(chan = Pervasives.stdout) () + if isatty then output_string chan "\x1b[1;31m" +let ansi_blue ?(chan = Pervasives.stdout) () + if isatty then output_string chan "\x1b[1;34m" +let ansi_restore ?(chan = Pervasives.stdout) () + if isatty then output_string chan "\x1b[0m" + +let is_dir path + try (stat path).st_kind = S_DIR + with Unix_error _ -> false + +let is_file path + try (stat path).st_kind = S_REG + with Unix_error _ -> false + +let is_executable path + is_file path && + try access path [X_OK]; true + with Unix_error _ -> false + +let relative_path_to_absolute path + let cmd = sprintf "realpath %s" (Filename.quote path) in + let chan = open_process_in cmd in + let path = input_line chan in + (match close_process_in chan with + | WEXITED 0 -> () + | WEXITED _ + | WSIGNALED _ + | WSTOPPED _ -> + failwith "realpath command failed, see earlier errors" + ); + path + +let get_lines cmd + let chan = open_process_in cmd in + let rec loop acc + try + let line = input_line chan in + loop (line :: acc) + with End_of_file -> List.rev acc + in + let lines = loop [] in + (match close_process_in chan with + | WEXITED 0 -> () + | WEXITED _ + | WSIGNALED _ + | WSTOPPED _ -> + failwith (sprintf "get_lines: external command failed: %s" + cmd) + ); + lines + +let mkdtemp () + let chan = open_process_in "mktemp -d" in + let path = input_line chan in + (match close_process_in chan with + | WEXITED 0 -> () + | WEXITED _ + | WSIGNALED _ + | WSTOPPED _ -> + failwith "mktemp -d command failed" + ); + path + +type ('a, 'b) maybe = Either of 'a | Or of 'b + +let pushdir dir f + let olddir = getcwd () in + chdir dir; + let r = try Either (f ()) with exn -> Or exn in + chdir olddir; + match r with + | Either r -> r + | Or exn -> raise exn + +(* Timeout settings. *) +let timeout_period = "4h" +and timeout_kill = "30s" + +type start_dir +| TopDir (* top dir - run all the tests *) +| PhonyGuestsDir (* phony guests dir *) +| Dir of string * test (* a test directory *) + +let () + let home + try Sys.getenv "HOME" + with Not_found -> + failwith "HOME environment variable is not set" in + + let cachedir + try Sys.getenv "XDG_CACHE_HOME" + with Not_found -> home // ".cache" in + + let debug = ref false in + let direct = ref false in + let fast = ref false in + let libvirt = ref false in + let local_guests = ref false in + let make_phony_guests_only = ref false in + let slow = ref false in + let uml = ref false in + let upstream_libvirt = ref false in + let upstream_qemu = ref false in + let valgrind = ref false in + let verbose = ref false in + let uml_binary = ref (home // "d/linux-um/vmlinux") in + let libvirtdir = ref (home // "d/libvirt") in + let qemu_binary = ref (home // "d/qemu/x86_64-softmmu/qemu-system-x86_64") in + + let argspec = Arg.align [ + "--debug", Arg.Set debug, " Run tests with debugging enabled"; + "--direct", Arg.Set direct, " Run tests using the direct backend"; + "--fast", Arg.Set fast, " Run only tests which do not need the appliance"; + "--libvirt", Arg.Set libvirt, " Run tests using the libvirt backend"; + "--local-guests", Arg.Set local_guests, " Run tests that use locally installed guests r/o"; + "--make-phony-guests-only", Arg.Set make_phony_guests_only, " Generate the phony guests used for testing"; + "--slow", Arg.Set slow, " Run only long-running tests"; + "--uml", Arg.Set uml, " Run tests using UML backend"; + "--upstream-libvirt", Arg.Set upstream_libvirt, " Run tests using upstream libvirt"; + "--upstream-qemu", Arg.Set upstream_qemu, " Run tests using upstream qemu"; + "--valgrind", Arg.Set valgrind, " Run tests under valgrind"; + "-v", Arg.Set verbose, " Enable verbose debugging in test harness"; + "--verbose", Arg.Set verbose, " Enable verbose debugging in test harness"; + "--with-uml", Arg.Set_string uml_binary, "vmlinux Select UML binary"; + "--with-upstream-libvirt", Arg.Set_string libvirtdir, "dir Select libvirt directory"; + "--with-upstream-qemu", Arg.Set_string qemu_binary, "qemu Select qemu binary"; + ] in + let args = ref [] in + let anon_fun s = args := s :: !args in + let usage_msg + "test-harness: Run the libguestfs test suite, or parts of it. + +See test-harness(1) for full details on how to run this program. + +Usage: + test-harness [--options] [test-directory] + +Options:" in + Arg.parse argspec anon_fun usage_msg; + + let args = !args in + let debug = !debug in + let direct = !direct in + let fast = !fast in + let libvirt = !libvirt in + let local_guests = !local_guests in + let make_phony_guests_only = !make_phony_guests_only in + let slow = !slow in + let uml = !uml in + let upstream_libvirt = !upstream_libvirt in + let upstream_qemu = !upstream_qemu in + let valgrind = !valgrind in + let verbose = !verbose in + let uml_binary = !uml_binary in + let libvirtdir = !libvirtdir in + let qemu_binary = !qemu_binary in + + (* Some combinations are not permitted. *) + if (fast && slow) || (fast && local_guests) || (slow && local_guests) then + failwith "cannot use --fast, --slow and --local-guests options together"; + + (* If none of the selection options are used, default to fast + normal. *) + let fast, normal + if not fast && not slow && not local_guests then true, true + else fast, false in + + (* --direct, --libvirt and --uml cannot be combined. *) + if (direct && libvirt) || (direct && uml) || (libvirt && uml) then + failwith "cannot use --direct, --libvirt and --uml options together"; + + if verbose then ( + printf "test-harness modes:%s%s%s%s%s%s%s\n" + (if fast then " --fast" else "") + (if normal then " --normal" else "") + (if slow then " --slow" else "") + (if local_guests then "--local-guests" else "") + (if direct then " --direct" else "") + (if libvirt then " --libvirt" else "") + (if uml then " --uml" else "") + ); + + (* If there is a single parameter on the command line, then we + * chdir to that directory. + *) + (match args with + | [] -> () + | [dir] -> chdir dir + | _ -> + failwith "too many command line arguments" + ); + + (* Which directory are we running in? *) + let start_dir + let pwd = getcwd () in + let basename = Filename.basename pwd in + if is_executable "test-harness" && is_dir "inspector" then + TopDir + else if basename = "guests" && is_dir "guest-aux" then + PhonyGuestsDir + else ( + (* Search through the tests for the current directory. *) + try + let dir, tests + List.find ( + fun (dir, tests) -> + (* Find the name of any test that should be in the directory. *) + let any_file + if tests.check <> [] then List.hd tests.check + else if tests.check_fast <> [] then List.hd tests.check_fast + else if tests.check_slow <> [] then List.hd tests.check_slow + else if tests.check_local_guests <> [] then + List.hd tests.check_local_guests + else ( + assert (tests.check_data <> []); + List.hd tests.check_data + ) in + basename = Filename.basename dir && is_file any_file + ) tests in + Dir (dir, tests) + with + Not_found -> + failwith (sprintf "current directory (%s) is not a libguestfs test directory" basename) + ) in + + (* If we are running from automake, then automake will pass $srcdir + * to us, and if it's not "." then we have to adjust our path to the + * top source directory accordingly. + *) + let srcdir = try Sys.getenv "srcdir" with Not_found -> "." in + + (* Are we running from the build directory or from installed tests? *) + let running_in_builddir = is_file (srcdir // "Makefile.am") in + + (* If installed, then we cannot write to the phony guests directory. *) + let phonydir + if running_in_builddir then ( + match start_dir with + | TopDir -> + relative_path_to_absolute "tests/guests" + | PhonyGuestsDir -> + relative_path_to_absolute "." + | Dir (dir, _) -> + let top_builddir = ref ".." in + for i = 0 to String.length dir-1 do + if dir.[i] = '/' then top_builddir := !top_builddir // ".." + done; + let top_builddir = !top_builddir in + relative_path_to_absolute (top_builddir // "tests/guests") + ) + else ( + (try mkdir cachedir 0o755 + with Unix_error _ -> ()); + (try mkdir (cachedir // "libguestfs-tests") 0o755 + with Unix_error _ -> ()); + (try mkdir (cachedir // "libguestfs-tests/phony-guests") 0o755 + with Unix_error _ -> ()); + cachedir // "libguestfs-tests/phony-guests" + ) in + + (* If the user gave the valgrind option, check it is valid. *) + if valgrind then ( + if Sys.command "valgrind --help >/dev/null 2>&1" <> 0 then + failwith "valgrind is not installed" + ); + + (* Do we have libtool? *) + let have_libtool = Sys.command "libtool --help >/dev/null 2>&1" = 0 in + + (* Do we have Padraig's timeout utility? It must have the + * --foreground option (RHBZ#1025269) and the -k option (not present + * in RHEL 6). + *) + let timeout + Sys.command "timeout --help >/dev/null 2>&1" = 0 && + Sys.command "timeout --foreground 2 sleep 0 >/dev/null 2>&1" = 0 && + Sys.command "timeout -k 10s 10s true >/dev/null 2>&1" = 0 in + + (* Returns a relative path to top build directory from the current + * directory. + *) + let top_builddir () + let rec loop i top_builddir + if i > 10 then + failwith "top_builddir: not in a test directory" + else if is_executable (top_builddir // "test-harness") then + top_builddir + else if top_builddir = "." then + loop (i+1) ".." + else + loop (i+1) (top_builddir // "..") + in + loop 0 "." + in + + (* Set up the environment (variables) for a test. *) + let set_up_environment () + let abs_builddir = relative_path_to_absolute "." in + let abs_srcdir = relative_path_to_absolute srcdir in + + let top_builddir = top_builddir () in + let top_srcdir + if srcdir = "." then top_builddir + else top_builddir // srcdir in + let abs_top_builddir = relative_path_to_absolute top_builddir in + let abs_top_srcdir = relative_path_to_absolute top_srcdir in + + let datadir = abs_top_builddir // "tests/data" in + + if verbose then ( + printf "abs_builddir=%s\n" abs_builddir; + printf "abs_srcdir=%s\n" abs_srcdir; + printf "abs_top_builddir=%s\n" abs_top_builddir; + printf "abs_top_srcdir=%s\n" abs_top_srcdir; + printf "phonydir=%s\n" phonydir; + printf "datadir=%s\n" datadir; + ); + + (* Note that because the tests always run in a temporary + * directory, relative paths are useless, so we always populate the + * environment with absolute paths. + *) + putenv "builddir" abs_builddir; + putenv "srcdir" abs_srcdir; + putenv "top_builddir" abs_top_builddir; + putenv "top_srcdir" abs_top_srcdir; + putenv "abs_builddir" abs_builddir; + putenv "abs_srcdir" abs_srcdir; + putenv "abs_top_builddir" abs_top_builddir; + putenv "abs_top_srcdir" abs_top_srcdir; + putenv "phonydir" phonydir; + putenv "datadir" datadir; + + (* Debugging? *) + if debug then ( + putenv "LIBGUESTFS_DEBUG" "1"; + putenv "LIBGUESTFS_TRACE" "1" + ); + + (* Valgrind? *) + if valgrind then ( + let vg + sprintf "valgrind --vgdb=no --log-file=valgrind.log --leak-check=full --error-exitcode=119 --suppressions=%s/valgrind-suppressions" + abs_top_srcdir in + putenv "VG" vg + ); + + (* Direct backend? *) + if direct then + putenv "LIBGUESTFS_BACKEND" "direct" + + (* Libvirt backend? *) + else if libvirt then + putenv "LIBGUESTFS_BACKEND" "libvirt" + + (* UML? *) + else if uml then ( + putenv "LIBGUESTFS_BACKEND" "uml"; + putenv "LIBGUESTFS_HV" uml_binary + ); + + (* Upstream QEMU? *) + if upstream_qemu then + putenv "LIBGUESTFS_HV" qemu_binary; + in + + (* Function which runs to create the phony guests for testing. + * Unfortunately we're recreating 'make' here. This isn't really + * avoidable as we have to be able to run after installation, and + * it's inconvenient to create a Makefile for that. + *) + let rec make_phony_guests () + (* Set up the environment as for tests ... *) + set_up_environment (); + (* ... but adjust srcdir to point to the tests/guests directory + * since the scripts in guest-aux are expecting this. + *) + let abs_top_srcdir = Sys.getenv "abs_top_srcdir" in + putenv "srcdir" (abs_top_srcdir // "tests/guests"); + if verbose then + printf "srcdir [adjusted for make_phony_guests]=%s\n" + (Sys.getenv "srcdir"); + + pushdir phonydir (fun () -> + (* Because we distribute all the intermediate files, they are + * always(?) in srcdir, not builddir. + *) + let gaux = abs_top_srcdir // "tests/guests/guest-aux" in + if verbose then + printf "gaux=%s\n" gaux; + + (* Make several different blank images. These are not guests, but we + * include them in the libvirt fake XML to make sure that virt-df and + * virt-alignment-scan don't break when they encounter them. + *) + List.iter ( + fun ft -> + let o = sprintf "blank-%s.img" ft in + rule o [] (fun () -> + let cmd + sprintf "guestfish -N %s-t=%s exit && mv %s-t %s" o ft o o in + if Sys.command cmd <> 0 then + failwith "guestfish command failed" + ) + ) [ "disk"; "part"; "fs"; "bootroot"; "bootrootlv" ]; + + (* Make several (phony) Fedora images. *) + List.iter ( + fun (layout, o) -> + rule o [ gaux // "make-fedora-img.pl"; + gaux // "fedora-journal.tar.xz"; + gaux // "fedora-name.db"; + gaux // "fedora-packages.db" ] + (fun () -> + let cmd = sprintf "%s/make-fedora-img.pl --layout=%s" + gaux layout in + if Sys.command cmd <> 0 then + failwith "make-fedora-img.pl failed" + ) + ) [ "partitions", "fedora.img"; + "partitions-md", "fedora-md1.img"; + "btrfs", "fedora-btrfs.img" ]; + + (* Make a (phony) Arch image. *) + let o = "archlinux.img" in + rule o [ gaux // "make-archlinux-img.sh" ] + (fun () -> + let cmd = sprintf "%s/make-archlinux-img.sh" gaux in + if Sys.command cmd <> 0 then + failwith "make-archlinux-img.sh failed" + ); + + (* Make a (phony) CoreOS image. *) + let o = "coreos.img" in + rule o [ gaux // "make-coreos-img.sh" ] + (fun () -> + let cmd = sprintf "%s/make-coreos-img.sh" gaux in + if Sys.command cmd <> 0 then + failwith "make-coreos-img.sh failed" + ); + + (* Make a (phony) Debian image. *) + let o = "debian.img" in + rule o [ gaux // "make-debian-img.sh" ] + (fun () -> + let cmd = sprintf "%s/make-debian-img.sh" gaux in + if Sys.command cmd <> 0 then + failwith "make-debian-img.sh failed" + ); + + (* Make a (phony) Ubuntu image. *) + let o = "ubuntu.img" in + rule o [ gaux // "make-ubuntu-img.sh" ] + (fun () -> + let cmd = sprintf "%s/make-ubuntu-img.sh" gaux in + if Sys.command cmd <> 0 then + failwith "make-ubuntu-img.sh failed" + ); + + (* Make a (phony) Windows image. *) + let o = "windows.img" in + rule o [ gaux // "make-windows-img.sh"; + gaux // "windows-software"; + gaux // "windows-system" ] + (fun () -> + let cmd = sprintf "%s/make-windows-img.sh" gaux in + if Sys.command cmd <> 0 then + failwith "make-windows-img.sh failed" + ); + + (* Make XML describing all guests we managed to create above. *) + let cmd + sprintf "%s/make-guests-all-good.pl > guests-all-good.xml blank-disk.img blank-part.img blank-fs.img blank-bootroot.img blank-bootrootlv.img archlinux.img coreos.img debian.img fedora.img fedora-md1.img fedora-md2.img fedora-btrfs.img ubuntu.img windows.img" + gaux in + if Sys.command cmd <> 0 then + failwith "make-guests-all-good.pl failed"; + + let cmd = "rm -f *.tmp.*" in + ignore (Sys.command cmd); + ) + + (* Like 'make', run a rule if target does not exist, or if target is + * older than any of the sources. + *) + and rule target sources f + let target_stat + try Some (stat target) + with Unix_error (ENOENT, _, _) -> + (* Target file does not exist. *) + printf "test-harness: building %s\n%!" target; + f (); None in + match target_stat with + | None -> () + | Some target_stat -> + let rec loop = function + | [] -> () + | source :: sources -> + let source_stat = stat source in + if target_stat.st_mtime < source_stat.st_mtime then ( + printf "test-harness: building %s\n%!" target; + f () + ) + else + loop sources + in + loop sources + in + + let null_results = (0, 0, 0, 0, 0) in + let add_results (t, s, f, tdo, sk) (t', s', f', tdo', sk') + (t+t', s+s', f+f', tdo+tdo', sk+sk') + in + + let rec run_all_tests () + List.fold_left ( + fun results (dir, tests) -> + printf "test-harness: entering directory %s\n%!" dir; + let results + pushdir dir (fun () -> + add_results results (run_dir_tests dir tests) + ) in + printf "test-harness: leaving directory %s\n%!" dir; + results + ) null_results tests + + (* Run all of the tests in a single directory. 'dir' is the + * directory name, and we are chdir'd into this directory + * already. + *) + and run_dir_tests dir tests + let results = null_results in + let accumulate + List.fold_left + (fun results t -> add_results results (run_one_test dir t [])) + in + let results + if fast then accumulate results tests.check_fast + else results in + let results + if normal then accumulate results tests.check + else results in + let results + if slow then accumulate results tests.check_slow + else results in + let results + if local_guests then + List.fold_left ( + fun results t -> + add_results results (run_local_guests_test dir t) + ) results tests.check_local_guests + else results in + results + + (* Run a single test. *) + and run_one_test dir test args + let skip_env = try Sys.getenv (skip_name test) with Not_found -> "" in + if skip_env = "1" then ( + printf "SKIP: %s\n%!" test; + (1, 0, 0, 0, 1) + ) + else ( + set_up_environment (); + + (* If it's a C program, and we're valgrinding, then we run the + * C program under valgrind directly. + *) + let is_program + not (Filename.check_suffix test ".pl") && + not (Filename.check_suffix test ".sh") in + + (* We run each test in its own temporary directory. *) + let tmpdir = mkdtemp () in + + let results, clean_up_tmpdir + pushdir tmpdir (fun () -> + putenv "tmpdir" tmpdir; + + let cmd + sprintf "%s%s%s%s$abs_srcdir/%s%s > output 2>&1" + (if upstream_libvirt then libvirtdir // "run " else "") + (if timeout then + sprintf "timeout --foreground -k %s %s " + timeout_kill timeout_period + else "") + (if have_libtool then "libtool --mode=execute " else "") + (if is_program && valgrind then "$VG " else "") + test + (String.concat "" + (List.map ((^) " ") (List.map Filename.quote args))) in + + let start_t = gettimeofday () in + let r = Sys.command cmd in + let end_t = gettimeofday () in + + let secs = end_t -. start_t in + + match r with + | 0 -> (* successful *) + ansi_green (); + printf "PASS: %s (%.1f seconds)" test secs; + ansi_restore (); + print_newline (); + (1, 1, 0, 0, 0), true + | 77 -> (* skipped *) + ignore (Sys.command "cat output"); + ansi_blue (); + printf "SKIP: %s" test; + ansi_restore (); + print_newline (); + (1, 0, 0, 0, 1), true + | 119 -> (* valgrind *) + ignore (Sys.command "cat output"); + eprintf "test results left in %s\n" tmpdir; + ansi_blue ~chan:Pervasives.stderr (); + eprintf "VALGRIND FAIL: %s" test; + ansi_restore ~chan:Pervasives.stderr (); + prerr_newline (); + (1, 0, 1, 0, 0), false + | 124 -> (* timed out *) + ignore (Sys.command "cat output"); + eprintf "command timed out after %s\n" timeout_period; + ansi_red ~chan:Pervasives.stderr (); + eprintf "TIMED OUT: %s" test; + ansi_restore ~chan:Pervasives.stderr (); + prerr_newline (); + (1, 0, 0, 1, 0), true + | r -> (* error *) + ignore (Sys.command "cat output"); + eprintf "command failed with exit code %d\n" r; + eprintf "test results left in %s\n" tmpdir; + ansi_red ~chan:Pervasives.stderr (); + eprintf "FAIL: %s" test; + ansi_restore ~chan:Pervasives.stderr (); + prerr_newline (); + (1, 0, 1, 0, 0), false + ) in + + if clean_up_tmpdir then + ignore (Sys.command (sprintf "rm -rf %s" (Filename.quote tmpdir))); + + results + ) + + (* Run a single test using local guests. *) + and run_local_guests_test dir test + let top_builddir = top_builddir () in + let cmd = sprintf "%s/pick-guests.pl 5" top_builddir in + let guests = get_lines cmd in + run_one_test dir test guests + + (* Convert a test name like 'test-network.sh' into 'SKIP_TEST_NETWORK_SH'. *) + and skip_name name + let skip = Utils.replace_char name '-' '_' in + let skip = Utils.replace_char skip '.' '_' in + let skip = "SKIP_" ^ String.uppercase skip in + skip + in + + (* Make the phony guests? *) + if make_phony_guests_only || normal || slow then ( + make_phony_guests (); + if make_phony_guests_only then exit 0 + ); + + (* Run the tests. *) + let total, successful, failed, timedout, skipped + match start_dir with + | TopDir -> run_all_tests () + | Dir (dir, tests) -> run_dir_tests dir tests + | PhonyGuestsDir -> null_results (* do nothing in this directory *) in + + (* Print the test results. *) + printf "--------------------------------------------------\n"; + printf " TEST SUMMARY\n"; + printf "--------------------------------------------------\n"; + printf "Total tests run . . . . . . . %d\n" total; + ansi_green (); + printf "Successful . . . . . . . . . . %d\n" successful; + ansi_restore (); + if failed > 0 then ( + ansi_red (); + printf "Errors . . . . . . . . . . . . %d\n" failed; + ansi_restore () + ); + if timedout > 0 then ( + ansi_red (); + printf "Timed out . . . . . . . . . . %d\n" timedout; + ansi_restore () + ); + if skipped > 0 then ( + ansi_blue (); + printf "Skipped . . . . . . . . . . . %d\n" skipped; + ansi_restore () + ); + printf "--------------------------------------------------\n"; + + (* If there were any errors, then exit with a failure. *) + exit (if failed = 0 && timedout = 0 then 0 else 1) diff --git a/generator/tests.ml b/generator/tests.ml new file mode 100644 index 0000000..4be899b --- /dev/null +++ b/generator/tests.ml @@ -0,0 +1,71 @@ +(* 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 + *) + +(* Please read generator/README first. *) + +open Printf + +open Types +open Utils +open Pr +open Docstrings + +let defaults = { + check = []; check_fast = []; check_slow = []; check_local_guests = []; + check_data = []; check_scripts = []; check_programs = []; +} + +(* The tests in each subdirectory. *) +let tests = [ + "inspector", { + defaults with + check = [ + "test-virt-inspector.sh"; + ]; + check_fast = [ + "test-xmllint.sh"; + ]; + check_local_guests = [ + "test-virt-inspector-local-guests.sh"; + ]; + check_data = [ + "example-debian-netinst-cd.xml"; + "example-debian.xml"; + "example-fedora-dvd.xml"; + "example-fedora-netinst-cd.xml"; + "example-fedora.xml"; + "example-rhel-6-dvd.xml"; + "example-rhel-6-netinst-cd.xml"; + "example-rhel-6.xml"; + "example-ubuntu-live-cd.xml"; + "example-ubuntu.xml"; + "example-windows-2003-x64-cd.xml"; + "example-windows-2003-x86-cd.xml"; + "example-windows.xml"; + "example-windows-xp-cd.xml"; + "expected-archlinux.img.xml"; + "expected-coreos.img.xml"; + "expected-debian.img.xml"; + "expected-fedora.img.xml"; + "expected-ubuntu.img.xml"; + "expected-windows.img.xml"; + "virt-inspector.rng"; + ] + }; + +] diff --git a/generator/tests_mk.ml b/generator/tests_mk.ml new file mode 100644 index 0000000..e2705ce --- /dev/null +++ b/generator/tests_mk.ml @@ -0,0 +1,130 @@ +(* 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 + *) + +(* Please read generator/README first. *) + +open Printf + +open Types +open Tests +open Utils +open Pr +open Docstrings + +(* Generate the tests.mk files in each subdirectory. *) +let generate_tests_mk dir tests () + generate_header HashStyle GPLv2plus; + + pr "localtestsdir = $(alltestsdir)/%s\n" dir; + + if tests.check_data <> [] then ( + pr "\n"; + pr "localtests_DATA ="; + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare tests.check_data); + pr "\n"; + ); + + (* Only add *.sh and *.pl to localtests_SCRIPTS. Others are added to + * localtests_PROGRAMS. + *) + let test_scripts, test_programs + List.partition ( + fun file -> + Filename.check_suffix file ".sh" || Filename.check_suffix file ".pl" + ) (tests.check @ tests.check_fast @ tests.check_slow + @ tests.check_local_guests) in + + (* Also, check_scripts get added to localtests_SCRIPTS. *) + let test_scripts = test_scripts @ tests.check_scripts in + + (* Also, check_programs get added to localtests_PROGRAMS. *) + let test_programs = test_programs @ tests.check_programs in + + if test_scripts <> [] then ( + pr "\n"; + pr "localtests_SCRIPTS ="; + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare test_scripts); + pr "\n" + ); + if test_programs <> [] then ( + pr "\n"; + pr "localtests_PROGRAMS ="; + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare test_programs); + pr "\n" + ); + + (* Create rules so that 'make -C dir check' etc will do something. *) + if tests.check_fast <> [] || tests.check <> [] then ( + pr "\n"; + pr "# Note that we cannot create a simple 'check:' target since\n"; + pr "# automake will (silently) overrule it, so we do this instead:\n"; + pr "\n"; + pr "TESTS_ENVIRONMENT = $(top_builddir)/run\n"; + pr "TESTS = $(top_builddir)/test-harness\n"; + pr "\n"; + pr "check-valgrind:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind\n"; + pr "\n"; + pr "check-direct:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --direct\n"; + pr "\n"; + pr "check-valgrind-direct:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct\n"; + pr "\n"; + pr "check-libvirt:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --libvirt\n"; + pr "\n"; + pr "check-valgrind-libvirt:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt\n"; + pr "\n"; + pr "check-uml:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --uml\n"; + pr "\n"; + pr "check-valgrind-uml:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml\n"; + pr "\n"; + pr "check-with-upstream-qemu:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu\n"; + pr "\n"; + pr "check-with-upstream-libvirt:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt\n"; + ); + + if tests.check_fast <> [] then ( + pr "\n"; + pr "check-fast:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --fast\n" + ); + + if tests.check_slow <> [] then ( + pr "\n"; + pr "check-slow:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --slow\n" + ); + + if tests.check_local_guests <> [] then ( + pr "\n"; + pr "check-local-guests:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --local-guests\n"; + pr "\n"; + pr "check-valgrind-local-guests:\n"; + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests\n" + ); + + pr "\n"; + pr "EXTRA_DIST += tests.mk\n" diff --git a/generator/types.ml b/generator/types.ml index 83a6a98..9083479 100644 --- a/generator/types.ml +++ b/generator/types.ml @@ -207,6 +207,21 @@ type fish_output_t | FishOutputOctal (* for int return, print in octal *) | FishOutputHexadecimal (* for int return, print in hex *) +type test = { + check : string list; + (* "fast" here means the appliance is not needed *) + check_fast : string list; + check_slow : string list; + check_local_guests : string list; + + (* Data files, non-executable. *) + check_data : string list; + (* Data files, scripts. *) + check_scripts : string list; + (* Data files, C programs. *) + check_programs : string list; +} + (* See guestfs(3)/EXTENDING LIBGUESTFS. *) type c_api_tests = (c_api_test_init * c_api_test_prereq * c_api_test * c_api_test_cleanup) list and c_api_test diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 9c79bed..1b4bfc7 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + example_xml = \ example-debian.xml \ example-fedora.xml \ @@ -40,6 +42,7 @@ EXTRA_DIST = \ expected-archlinux.img.xml \ expected-coreos.img.xml \ expected-windows.img.xml \ + test-virt-inspector-local-guests.sh \ test-virt-inspector.sh \ test-xmllint.sh.in \ virt-inspector.pod @@ -103,16 +106,4 @@ stamp-virt-inspector.pod: virt-inspector.pod $< touch $@ -TESTS_ENVIRONMENT = $(top_builddir)/run --test -TESTS = test-virt-inspector.sh -if HAVE_XMLLINT -TESTS += test-xmllint.sh -endif - -check-valgrind: - $(MAKE) TESTS="test-virt-inspector.sh" VG="$(top_builddir)/run @VG@" check - -check-valgrind-local-guests: - for g in $(GUESTS); do \ - $(top_builddir)/run --test @VG@ ./virt-inspector -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \ - done +include $(srcdir)/tests.mk diff --git a/inspector/test-virt-inspector-local-guests.sh.in b/inspector/test-virt-inspector-local-guests.sh.in new file mode 100755 index 0000000..91f1a71 --- /dev/null +++ b/inspector/test-virt-inspector-local-guests.sh.in @@ -0,0 +1,26 @@ +#!/bin/bash - +# libguestfs virt-inspector test script +# @configure_input@ +# Copyright (C) 2012-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. + +export LANG=C +set -e +set -x + +for g in "$@"; do + $VG virt-inspector -c "@libvirt_ro_uri@" -d "$g" +done diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh index 02bbcad..c8ca0e0 100755 --- a/inspector/test-virt-inspector.sh +++ b/inspector/test-virt-inspector.sh @@ -20,23 +20,17 @@ export LANG=C set -e set -x -# Allow this test to be skipped. -if [ -n "$SKIP_TEST_VIRT_INSPECTOR_SH" ]; then - echo "$0: skipping test because SKIP_TEST_VIRT_INSPECTOR_SH is set." - exit 77 -fi - # ntfs-3g can't set UUIDs right now, so ignore just that <uuid>. diff_ignore="-I <uuid>[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]</uuid>" -for f in ../tests/guests/{debian,fedora,ubuntu,archlinux,coreos,windows}.img; do +for f in $phonydir/{debian,fedora,ubuntu,archlinux,coreos,windows}.img; do # Ignore zero-sized windows.img if ntfs-3g is not installed. if [ -s "$f" ]; then b=$(basename "$f" .xml) - $VG virt-inspector -a "$f" > "actual-$b.xml" + $VG virt-inspector -a "$f" > 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 -ur $diff_ignore $srcdir/expected-$b.xml actual-$b.xml fi done diff --git a/inspector/test-xmllint.sh.in b/inspector/test-xmllint.sh.in index 65654bc..2755414 100755 --- a/inspector/test-xmllint.sh.in +++ b/inspector/test-xmllint.sh.in @@ -19,6 +19,11 @@ export LANG=C set -e +if ! "@XMLLINT@" --version >/dev/null 2>&1; then + echo "$0: test skipped before xmllint is not installed" + exit 77 +fi + for f in $srcdir/example-*.xml; do @XMLLINT@ --noout --relaxng $srcdir/virt-inspector.rng $f done diff --git a/inspector/tests.mk b/inspector/tests.mk new file mode 100644 index 0000000..67fc0bc --- /dev/null +++ b/inspector/tests.mk @@ -0,0 +1,94 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-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. + +localtestsdir = $(alltestsdir)/inspector + +localtests_DATA = \ + example-debian-netinst-cd.xml \ + example-debian.xml \ + example-fedora-dvd.xml \ + example-fedora-netinst-cd.xml \ + example-fedora.xml \ + example-rhel-6-dvd.xml \ + example-rhel-6-netinst-cd.xml \ + example-rhel-6.xml \ + example-ubuntu-live-cd.xml \ + example-ubuntu.xml \ + example-windows-2003-x64-cd.xml \ + example-windows-2003-x86-cd.xml \ + example-windows-xp-cd.xml \ + example-windows.xml \ + expected-archlinux.img.xml \ + expected-coreos.img.xml \ + expected-debian.img.xml \ + expected-fedora.img.xml \ + expected-ubuntu.img.xml \ + expected-windows.img.xml \ + virt-inspector.rng + +localtests_SCRIPTS = \ + test-virt-inspector-local-guests.sh \ + test-virt-inspector.sh \ + test-xmllint.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +check-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --local-guests + +check-valgrind-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests + +EXTRA_DIST += tests.mk diff --git a/pick-guests.pl.in b/pick-guests.pl.in index bfc97d8..14feae6 100755 --- a/pick-guests.pl.in +++ b/pick-guests.pl.in @@ -56,7 +56,5 @@ $n = @accessible if @accessible < $n; # Return the first n guests from the list. for (my $i = 0; $i < $n; ++$i) { - print " " if $i > 0; - print $accessible[$i]; + print $accessible[$i], "\n" } -print "\n"; diff --git a/po-docs/podfiles b/po-docs/podfiles index 21f1cf1..50c31f2 100644 --- a/po-docs/podfiles +++ b/po-docs/podfiles @@ -56,6 +56,7 @@ ../sysprep/sysprep-extra-options.pod ../sysprep/sysprep-operations.pod ../sysprep/virt-sysprep.pod +../test-harness.pod ../test-tool/libguestfs-test-tool.pod ../tools/virt-list-filesystems ../tools/virt-list-partitions diff --git a/test-harness.pod b/test-harness.pod new file mode 100644 index 0000000..b08c8b0 --- /dev/null +++ b/test-harness.pod @@ -0,0 +1,252 @@ +=head1 NAME + +test-harness - Run the libguestfs test suite, or parts of it. + +=head1 SYNOPSIS + + test-harness [--options] [test-directory] + +=head1 DESCRIPTION + +This program runs the libguestfs test suite, or parts of it. You can +run it either on a just-built libguestfs source tree, or on the +installed libguestfs and virt-* tools. + +Normally tests in the current directory are run. If the current +directory is the top level of the test suite then the whole test suite +is run. If the current directory is a leaf directory, then only tests +in that directory are run. + +If you specify a directory name on the command line, then we run tests +from that directory instead. + +=head1 OPTIONS + +=head2 Options to select which tests are run + +If neither I<--fast> nor I<--slow>, then I<--fast> + normal tests are run. + +=over 4 + +=item B<--fast> + +Run only tests which do not need the appliance. + +=item B<--slow> + +Run only long-running tests. + +=item B<--local-guests> + +Run tests that use locally installed guests read-only. + +=back + +=head2 Options to run the selected tests under different test conditions + +=over 4 + +=item B<--debug> + +Run tests with debugging enabled [recommended]. + +=item B<--valgrind> + +Run tests under valgrind. + +=item B<--direct> + +Run tests using the direct backend. + +=item B<--libvirt> + +Run tests using the libvirt backend. + +=item B<--uml> + +Run tests using the UML backend. + +=item B<--with-uml VMLINUX> + +Select UML binary [default: F<$HOME/d/linux-um/vmlinux>]. + +=item B<--upstream-libvirt> + +Run tests using upstream libvirt. + +=item B<--with-upstream-libvirt LIBVIRTDIR> + +Select libvirt directory [default: F<$HOME/d/libvirt>]. + +=item B<--upstream-qemu> + +Run tests using upstream qemu. + +=item B<--with-upstream-qemu QEMUBINARY> + +Select qemu binary +[default: F<$HOME/d/qemu/x86_64-softmmu/qemu-system-x86_64>]. + +=back + +=head2 Options used internally + +=over 4 + +=item B<--make-phony-guests-only> + +Generate the phony guests used for testing. + +=back + +=head2 Other options + +=over 4 + +=item B<--help> + +Display short help and exit. + +=item B<-v> + +=item B<--verbose> + +Enables some verbose debugging in the test-harness program itself. + +=back + +=head1 TEST ENVIRONMENT + +=head2 Temporary directory + +The test-harness creates a temporary directory for each test and sets +the test current working directory there. Any temporary files needed +by the test should be created in the current (ie. temporary) +directory. + +The temporary directory and its contents are deleted after the test +has run, except where the test failed. + +=head2 Environment variables + +When running each test, test-harness passes various environment +variables: + +=over 4 + +=item C<builddir> + +=item C<top_builddir> + +=item C<abs_builddir> + +=item C<abs_top_builddir> + +The path to the build directory and the top build directory. + +For example, if running tests in F<libguestfs.git/tests/events> then +C<builddir> would point to F<libguestfs.git/tests/events>, and +C<top_builddir> would point to F<libguestfs.git>. + +The C<abs_*> variants are absolute paths. (In fact because of the +current directory being the temporary directory, all environment +variables contain absolute paths). + +=item C<srcdir> + +=item C<top_srcdir> + +=item C<abs_srcdir> + +=item C<abs_top_srcdir> + +If you are not using separate source and build directories, then these +environment variables are the same as the C<builddir> variants above. + +If you are using separate source and build directories, then these +point to the source directories. + +=item C<phonydir> + +The phony test guests (see F<libguestfs.git/tests/guests>). + +=item C<datadir> + +The data files (see F<libguestfs.git/tests/data>). + +=item C<tmpdir> + +The temporary directory created for the test. This is the same as the +current working directory when the test starts. + +=item C<LIBGUESTFS_DEBUG=1> + +=item C<LIBGUESTFS_TRACE=1> + +If the I<--debug> flag was passed, then these environment variables +are set. + +=item C<LIBGUESTFS_BACKEND=(direct|libvirt|uml)> + +If using the I<--direct>, I<--libvirt> or I<--uml> flags, then the +backend environment variable is set appropriately. + +=item C<LIBGUESTFS_HV=>(qemu|uml) + +Points to the qemu or UML hypervisor. + +=back + +=head2 Skipping tests + +You can skip tests by setting C<SKIP_*> environment variables. The +environment variable name is formed by converting all characters to +uppercase and replacing non-alphanumeric characters with C<_>. For +example, F<test-network.sh> becomes C<SKIP_TEST_NETWORK_SH>. + +Tests can also skip themselves (eg. if they cannot run with the +requested backend, or if a data file is missing). The test should +print a diagnostic message and exit with code C<77>. + +=head2 Exit code of the test + +The test should exit with one of the following exit codes: + +=over 4 + +=item C<0> + +Test successful. + +=item C<1>-C<76> + +The test failed. + +=item C<77> + +The test was skipped. + +=item C<119> + +L<valgrind(1)> returns this code to indicate a valgrind failure. + +=item C<124> + +L<timeout(1)> returns this code if the test timed out. + +=back + +=head1 SEE ALSO + +L<automake(1)>, +L<timeout(1)>, +L<valgrind(1)>, +L<http://libguestfs.org/>. + +=head1 AUTHOR + +Richard W.M. Jones. + +=head1 COPYRIGHT + +Copyright (C) 2014-2015 Red Hat Inc. diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 305136f..d379826 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -19,13 +19,6 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ README-binfiles \ - filesanddirs-10M.tar.xz \ - filesanddirs-100M.tar.xz \ - helloworld.tar \ - helloworld.tar.gz \ - helloworld.tar.xz \ - mbr-ext2-empty.img.gz \ - empty known-1 known-2 known-3 known-4 known-5 \ bin-aarch64-dynamic \ bin-armv7-dynamic \ bin-i586-dynamic \ @@ -37,6 +30,13 @@ EXTRA_DIST = \ bin-win32.exe \ bin-win64.exe \ bin-x86_64-dynamic \ + empty \ + filesanddirs-10M.tar.xz \ + filesanddirs-100M.tar.xz \ + helloworld.tar \ + helloworld.tar.gz \ + helloworld.tar.xz \ + known-1 known-2 known-3 known-4 known-5 \ lib-aarch64.so \ lib-armv7.so \ lib-i586.so \ @@ -48,19 +48,11 @@ EXTRA_DIST = \ lib-win32.dll \ lib-win64.dll \ lib-x86_64.so \ - test-grep.txt \ - minimal + mbr-ext2-empty.img.gz \ + minimal \ + test-grep.txt images_files_src = \ - $(srcdir)/helloworld.tar \ - $(srcdir)/helloworld.tar.gz \ - $(srcdir)/helloworld.tar.xz \ - $(srcdir)/empty \ - $(srcdir)/known-1 \ - $(srcdir)/known-2 \ - $(srcdir)/known-3 \ - $(srcdir)/known-4 \ - $(srcdir)/known-5 \ $(srcdir)/bin-aarch64-dynamic \ $(srcdir)/bin-armv7-dynamic \ $(srcdir)/bin-i586-dynamic \ @@ -72,6 +64,17 @@ images_files_src = \ $(srcdir)/bin-win32.exe \ $(srcdir)/bin-win64.exe \ $(srcdir)/bin-x86_64-dynamic \ + $(srcdir)/empty \ + $(srcdir)/filesanddirs-10M.tar.xz \ + $(srcdir)/filesanddirs-100M.tar.xz \ + $(srcdir)/helloworld.tar \ + $(srcdir)/helloworld.tar.gz \ + $(srcdir)/helloworld.tar.xz \ + $(srcdir)/known-1 \ + $(srcdir)/known-2 \ + $(srcdir)/known-3 \ + $(srcdir)/known-4 \ + $(srcdir)/known-5 \ $(srcdir)/lib-aarch64.so \ $(srcdir)/lib-armv7.so \ $(srcdir)/lib-i586.so \ @@ -83,8 +86,8 @@ images_files_src = \ $(srcdir)/lib-win32.dll \ $(srcdir)/lib-win64.dll \ $(srcdir)/lib-x86_64.so \ - $(srcdir)/test-grep.txt \ - $(srcdir)/minimal + $(srcdir)/minimal \ + $(srcdir)/test-grep.txt images_files_build = \ 100kallzeroes \ @@ -107,12 +110,14 @@ images_files_build = \ lib-i586.so.xz \ test-grep.txt.gz -check_DATA = $(images_files_build) test.iso - -CLEANFILES = $(images_files_build) test.iso - images_files = $(images_files_src) $(images_files_build) +localtestsdir = $(alltestsdir)/tests/data + +localtests_DATA = $(images_files) test.iso + +CLEANFILES = $(images_files_build) test.iso + test.iso: $(images_files) rm -f $@ $@-t mkdir -p directory @@ -156,21 +161,21 @@ test.iso: $(images_files) # Blank disk images in various sizes and formats. blank-disk-1s.raw: rm -f $@ - ../../fish/guestfish sparse $@ 512 + truncate -s 512 $@ blank-disk-1s.qcow2: qemu-img create -f qcow2 -o preallocation=metadata $@ 512 blank-disk-1K.raw: rm -f $@ - ../../fish/guestfish sparse $@ 1K + truncate -s 1K $@ blank-disk-1K.qcow2: qemu-img create -f qcow2 -o preallocation=metadata $@ 1K blank-disk-1M.raw: rm -f $@ - ../../fish/guestfish sparse $@ 1M + truncate -s 1M $@ blank-disk-1M.qcow2: qemu-img create -f qcow2 -o preallocation=metadata $@ 1M diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 6ada4ec..796d428 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -60,70 +60,37 @@ disk_images = \ # time and we need the tools we have built in order to make it. check_DATA = $(disk_images) guests-all-good.xml -CLEANFILES = $(check_DATA) \ - guests-all-good.xml \ - stamp-fedora-md.img \ - *.tmp.* +$(disk_images) guests-all-good.xml: stamp-guests -# Make several different blank images. These are not guests, but we -# include them in the libvirt fake XML to make sure that virt-df and -# virt-alignment-scan don't break when they encounter them. -blank-%.img: - rm -f $@ $@-t - $(top_builddir)/run \ - ../../fish/guestfish \ - -N $@-t="$$(echo $@ | $(SED) -e 's/blank-//' -e 's/.img//')" exit - mv $@-t $@ - -# Make a (dummy) Fedora image. -fedora.img: guest-aux/make-fedora-img.pl \ - guest-aux/fedora-journal.tar.xz \ - guest-aux/fedora-name.db \ - guest-aux/fedora-packages.db - SRCDIR=$(srcdir) LAYOUT=partitions $(top_builddir)/run --test $< - -# Make a (dummy) Fedora image using md devices -fedora-md1.img fedora-md2.img: stamp-fedora-md.img - -stamp-fedora-md.img: guest-aux/make-fedora-img.pl \ - guest-aux/fedora-journal.tar.xz \ - guest-aux/fedora-name.db \ - guest-aux/fedora-packages.db - rm -f $@ - SRCDIR=$(srcdir) LAYOUT=partitions-md $(top_builddir)/run --test $< +stamp-guests: $(top_builddir)/test-harness + $(top_builddir)/run $< --make-phony-guests-only touch $@ -fedora-btrfs.img: guest-aux/make-fedora-img.pl \ - guest-aux/fedora-journal.tar.xz \ - guest-aux/fedora-name.db \ - guest-aux/fedora-packages.db - SRCDIR=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test $< +CLEANFILES = \ + $(check_DATA) \ + stamp-guests \ + *.tmp.* -# Make a (dummy) Debian image. -debian.img: guest-aux/make-debian-img.sh - SRCDIR=$(srcdir) $(top_builddir)/run --test $< - -# Make a (dummy) Ubuntu image. -ubuntu.img: guest-aux/make-ubuntu-img.sh - SRCDIR=$(srcdir) $(top_builddir)/run --test $< - -# Make a (dummy) Arch Linux image. -archlinux.img: guest-aux/make-archlinux-img.sh - SRCDIR=$(srcdir) $(top_builddir)/run --test $< - -# Make a (dummy) CoreOS image. -coreos.img: guest-aux/make-coreos-img.sh - SRCDIR=$(srcdir) $(top_builddir)/run --test $< - -# Make a (dummy) Windows image. -windows.img: guest-aux/make-windows-img.sh \ - guest-aux/windows-software guest-aux/windows-system - SRCDIR=$(srcdir) $(top_builddir)/run --test $< - -guests-all-good.xml: guest-aux/make-guests-all-good.pl $(disk_images) - rm -f $@ $@-t - $^ > $@-t - mv $@-t $@ +# For installed tests. +localtestsdir = $(alltestsdir)/tests/guests/guest-aux +localtests_DATA = \ + guest-aux/archlinux-package \ + guest-aux/debian-packages \ + guest-aux/debian-syslog \ + guest-aux/fedora-journal.tar.xz \ + guest-aux/fedora-name.db \ + guest-aux/fedora-packages.db \ + guest-aux/minimal-hive \ + guest-aux/windows-software \ + guest-aux/windows-system +localtests_SCRIPTS = \ + guest-aux/make-archlinux-img.sh \ + guest-aux/make-coreos-img.sh \ + guest-aux/make-debian-img.sh \ + guest-aux/make-fedora-img.pl \ + guest-aux/make-guests-all-good.pl \ + guest-aux/make-ubuntu-img.sh \ + guest-aux/make-windows-img.sh # Since users might not have the tools needed to create this, we also # distribute these files and they are only cleaned by 'make distclean' @@ -155,11 +122,3 @@ DISTCLEANFILES = \ guest-aux/fedora-packages.db \ guest-aux/windows-software \ guest-aux/windows-system - -# Don't construct the guests in parallel. In automake 1.13, check_DATA -# was changed so it can now run in parallel, but this causes everything -# to fall over on machines with limited memory. -# -# ALSO: the guestfish rules above for making the blank-*.img files are -# NOT safe to run in parallel. -.NOTPARALLEL: diff --git a/tests/guests/guest-aux/make-archlinux-img.sh b/tests/guests/guest-aux/make-archlinux-img.sh index 62babd1..54a27b0 100755 --- a/tests/guests/guest-aux/make-archlinux-img.sh +++ b/tests/guests/guest-aux/make-archlinux-img.sh @@ -47,9 +47,9 @@ write /etc/fstab "/dev/sda1 / ext4 rw,relatime,data=ordered 0 1" touch /etc/arch-release write /etc/hostname "archlinux.test" -upload $SRCDIR/guest-aux/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc +upload $srcdir/guest-aux/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls +upload $datadir/../data/bin-x86_64-dynamic /bin/ls mkdir /boot/grub touch /boot/grub/grub.conf diff --git a/tests/guests/guest-aux/make-debian-img.sh b/tests/guests/guest-aux/make-debian-img.sh index 95228ab..af251b4 100755 --- a/tests/guests/guest-aux/make-debian-img.sh +++ b/tests/guests/guest-aux/make-debian-img.sh @@ -82,11 +82,11 @@ upload fstab.tmp.$$ /etc/fstab write /etc/debian_version "5.0.1" write /etc/hostname "debian.invalid" -upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status +upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls +upload $datadir/../data/bin-x86_64-dynamic /bin/ls -upload $SRCDIR/guest-aux/debian-syslog /var/log/syslog +upload $srcdir/guest-aux/debian-syslog /var/log/syslog mkdir /boot/grub touch /boot/grub/grub.conf diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl index eae11d6..c85271f 100755 --- a/tests/guests/guest-aux/make-fedora-img.pl +++ b/tests/guests/guest-aux/make-fedora-img.pl @@ -44,11 +44,12 @@ my $g = Sys::Guestfs->new (); my $bootdev; -foreach ('LAYOUT', 'SRCDIR') { - defined ($ENV{$_}) or die "Missing environment variable: $_"; +if (@ARGV < 1 || $ARGV[0] !~ /^--layout=(.*)/) { + die "usage: $0 --layout=(partitions|partitions-md|btrfs)\n" } +my $layout = $1; -if ($ENV{LAYOUT} eq 'partitions') { +if ($layout eq 'partitions') { push (@images, "fedora.img.tmp.$$"); open (my $fstab, '>', "fstab.tmp.$$") or die; @@ -73,7 +74,7 @@ EOF init_lvm_root ('/dev/sda2'); } -elsif ($ENV{LAYOUT} eq 'partitions-md') { +elsif ($layout eq 'partitions-md') { push (@images, "fedora-md1.img.tmp.$$", "fedora-md2.img.tmp.$$"); open (my $fstab, '>', "fstab.tmp.$$") or die; @@ -122,7 +123,7 @@ EOF init_lvm_root ('/dev/md/root'); } -elsif ($ENV{LAYOUT} eq 'btrfs') { +elsif ($layout eq 'btrfs') { push (@images, "fedora-btrfs.img.tmp.$$"); open (my $fstab, '>', "fstab.tmp.$$") or die; @@ -154,7 +155,7 @@ EOF } else { - print STDERR "$0: Unknown LAYOUT: ",$ENV{LAYOUT},"\n"; + print STDERR "$0: Unknown layout: ",$layout,"\n"; exit 1; } @@ -217,12 +218,12 @@ if (-f "mdadm.tmp.$$") { unlink ("mdadm.tmp.$$") or die; } -$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name'); -$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages'); +$g->upload ($ENV{srcdir}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name'); +$g->upload ($ENV{srcdir}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages'); -$g->upload ($ENV{SRCDIR}.'/../data/bin-x86_64-dynamic', '/bin/ls'); +$g->upload ($ENV{datadir}.'/../data/bin-x86_64-dynamic', '/bin/ls'); -$g->txz_in ($ENV{SRCDIR}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal'); +$g->txz_in ($ENV{srcdir}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal'); $g->mkdir ('/boot/grub'); $g->touch ('/boot/grub/grub.conf'); diff --git a/tests/guests/guest-aux/make-ubuntu-img.sh b/tests/guests/guest-aux/make-ubuntu-img.sh index 183985b..36abe55 100755 --- a/tests/guests/guest-aux/make-ubuntu-img.sh +++ b/tests/guests/guest-aux/make-ubuntu-img.sh @@ -73,9 +73,9 @@ write /etc/debian_version "5.0.1" upload release.tmp.$$ /etc/lsb-release write /etc/hostname "ubuntu.invalid" -upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status +upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls +upload $datadir/../data/bin-x86_64-dynamic /bin/ls mkdir /boot/grub touch /boot/grub/grub.conf diff --git a/tests/guests/guest-aux/make-windows-img.sh b/tests/guests/guest-aux/make-windows-img.sh index cfe59dc..ad3201a 100755 --- a/tests/guests/guest-aux/make-windows-img.sh +++ b/tests/guests/guest-aux/make-windows-img.sh @@ -59,10 +59,10 @@ mount /dev/sda2 / mkdir-p /Windows/System32/Config mkdir-p /Windows/System32/Drivers -upload $SRCDIR/guest-aux/windows-software /Windows/System32/Config/SOFTWARE -upload $SRCDIR/guest-aux/windows-system /Windows/System32/Config/SYSTEM +upload $srcdir/guest-aux/windows-software /Windows/System32/Config/SOFTWARE +upload $srcdir/guest-aux/windows-system /Windows/System32/Config/SYSTEM -upload $SRCDIR/../data/bin-win32.exe /Windows/System32/cmd.exe +upload $datadir/../data/bin-win32.exe /Windows/System32/cmd.exe mkdir "/Program Files" touch /autoexec.bat -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 02/17] tests/c-api: Convert the C API tests to use the test harness.
This involves some significant changes to this test framework. In particular: - Instead of just specifying $srcdir at the start of a FileIn path, you can now specify arbitrary environment variables. This is necessary to allow the tests to run from a tmpdir. - Use COPYING instead of COPYING.LIB, and copy that file into the test suite directory. - Require the static binaries (test-command, test-pwd) in order to run tests. - Don't conditionalize the C++ tests. Instead if a C++ compiler is not available then we build a "skip" script. --- .gitignore | 3 - Makefile.am | 4 +- generator/actions.ml | 150 ++++++++++++++++++++++++---------------------- generator/tests.ml | 28 +++++++++ generator/tests_c_api.ml | 9 ++- inspector/tests.mk | 2 +- tests/c-api/Makefile.am | 84 +++++++------------------- tests/c-api/test-dlopen.c | 15 ++--- tests/c-api/tests-main.c | 56 +++++++++++------ tests/c-api/tests.h | 2 +- tests/c-api/tests.mk | 79 ++++++++++++++++++++++++ 11 files changed, 257 insertions(+), 175 deletions(-) create mode 100644 tests/c-api/tests.mk diff --git a/.gitignore b/.gitignore index 72f8cc4..045f3de 100644 --- a/.gitignore +++ b/.gitignore @@ -508,16 +508,13 @@ Makefile.in /tests/c-api/test-dlopen /tests/c-api/test-environment /tests/c-api/test-event-string -/tests/c-api/test*.img /tests/c-api/test-just-header /tests/c-api/test-just-header-cxx /tests/c-api/test-last-errno -/tests/c-api/test.log /tests/c-api/test-private-data /tests/c-api/test-pwd /tests/c-api/tests /tests/c-api/tests.c -/tests/c-api/test*.tmp /tests/c-api/test-user-cancel /tests/charsets/test-charset-fidelity /tests/data/100kallnewlines diff --git a/Makefile.am b/Makefile.am index 2c6c8b2..ef66d4c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -558,8 +558,8 @@ check-slow: build-test-guests build-test-guests: $(MAKE) -C tests/guests check -# Install valgrind suppressions file in test directory. -alltests_DATA = valgrind-suppressions +# Install some files in the test directory. +alltests_DATA = COPYING valgrind-suppressions # Print subdirs. # diff --git a/generator/actions.ml b/generator/actions.ml index 35af981..d2b057d 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -2767,19 +2767,19 @@ data." }; style = RString "format", [String "filename"], []; tests = [ InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1s.raw"]], "raw"), []; + [["disk_format"; "$datadir/blank-disk-1s.raw"]], "raw"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1s.qcow2"]], "qcow2"), []; + [["disk_format"; "$datadir/blank-disk-1s.qcow2"]], "qcow2"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1K.raw"]], "raw"), []; + [["disk_format"; "$datadir/blank-disk-1K.raw"]], "raw"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1K.qcow2"]], "qcow2"), []; + [["disk_format"; "$datadir/blank-disk-1K.qcow2"]], "qcow2"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1M.raw"]], "raw"), []; + [["disk_format"; "$datadir/blank-disk-1M.raw"]], "raw"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-1M.qcow2"]], "qcow2"), []; + [["disk_format"; "$datadir/blank-disk-1M.qcow2"]], "qcow2"), []; InitEmpty, Always, TestResultString ( - [["disk_format"; "../data/blank-disk-with-backing.qcow2"]], "qcow2"), []; + [["disk_format"; "$datadir/blank-disk-with-backing.qcow2"]], "qcow2"), []; ]; shortdesc = "detect the disk format of a disk image"; longdesc = "\ @@ -2797,19 +2797,19 @@ See also: L<guestfs(3)/DISK IMAGE FORMATS>" }; style = RInt64 "size", [String "filename"], []; tests = [ InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1s.raw"]], "ret == 512"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1s.raw"]], "ret == 512"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1s.qcow2"]], "ret == 512"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1s.qcow2"]], "ret == 512"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1K.raw"]], "ret == 1024"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1K.raw"]], "ret == 1024"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1K.qcow2"]], "ret == 1024"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1K.qcow2"]], "ret == 1024"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1M.raw"]], "ret == 1024*1024"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1M.raw"]], "ret == 1024*1024"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-1M.qcow2"]], "ret == 1024*1024"), []; + [["disk_virtual_size"; "$datadir/blank-disk-1M.qcow2"]], "ret == 1024*1024"), []; InitEmpty, Always, TestResult ( - [["disk_virtual_size"; "../data/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), []; + [["disk_virtual_size"; "$datadir/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), []; ]; shortdesc = "return virtual size of a disk"; longdesc = "\ @@ -2824,19 +2824,19 @@ circumstances. See L<guestfs(3)/CVE-2010-3851>." }; style = RBool "backingfile", [String "filename"], []; tests = [ InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1s.raw"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1s.raw"]]), []; InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1s.qcow2"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1s.qcow2"]]), []; InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1K.raw"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1K.raw"]]), []; InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1K.qcow2"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1K.qcow2"]]), []; InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1M.raw"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1M.raw"]]), []; InitEmpty, Always, TestResultFalse ( - [["disk_has_backing_file"; "../data/blank-disk-1M.qcow2"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-1M.qcow2"]]), []; InitEmpty, Always, TestResultTrue ( - [["disk_has_backing_file"; "../data/blank-disk-with-backing.qcow2"]]), []; + [["disk_has_backing_file"; "$datadir/blank-disk-with-backing.qcow2"]]), []; ]; shortdesc = "return whether disk has a backing file"; longdesc = "\ @@ -4303,67 +4303,67 @@ C<guestfs_is_file>, C<guestfs_is_blockdev> (etc), C<guestfs_is_zero>." }; tests = [ InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command"]; - ["upload"; "test-command"; "/command/test-command"]; + ["upload"; "$builddir/test-command"; "/command/test-command"]; ["chmod"; "0o755"; "/command/test-command"]; ["command"; "/command/test-command 1"]], "Result1"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command2"]; - ["upload"; "test-command"; "/command2/test-command"]; + ["upload"; "$builddir/test-command"; "/command2/test-command"]; ["chmod"; "0o755"; "/command2/test-command"]; ["command"; "/command2/test-command 2"]], "Result2\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command3"]; - ["upload"; "test-command"; "/command3/test-command"]; + ["upload"; "$builddir/test-command"; "/command3/test-command"]; ["chmod"; "0o755"; "/command3/test-command"]; ["command"; "/command3/test-command 3"]], "\nResult3"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command4"]; - ["upload"; "test-command"; "/command4/test-command"]; + ["upload"; "$builddir/test-command"; "/command4/test-command"]; ["chmod"; "0o755"; "/command4/test-command"]; ["command"; "/command4/test-command 4"]], "\nResult4\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command5"]; - ["upload"; "test-command"; "/command5/test-command"]; + ["upload"; "$builddir/test-command"; "/command5/test-command"]; ["chmod"; "0o755"; "/command5/test-command"]; ["command"; "/command5/test-command 5"]], "\nResult5\n\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command6"]; - ["upload"; "test-command"; "/command6/test-command"]; + ["upload"; "$builddir/test-command"; "/command6/test-command"]; ["chmod"; "0o755"; "/command6/test-command"]; ["command"; "/command6/test-command 6"]], "\n\nResult6\n\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command7"]; - ["upload"; "test-command"; "/command7/test-command"]; + ["upload"; "$builddir/test-command"; "/command7/test-command"]; ["chmod"; "0o755"; "/command7/test-command"]; ["command"; "/command7/test-command 7"]], ""), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command8"]; - ["upload"; "test-command"; "/command8/test-command"]; + ["upload"; "$builddir/test-command"; "/command8/test-command"]; ["chmod"; "0o755"; "/command8/test-command"]; ["command"; "/command8/test-command 8"]], "\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command9"]; - ["upload"; "test-command"; "/command9/test-command"]; + ["upload"; "$builddir/test-command"; "/command9/test-command"]; ["chmod"; "0o755"; "/command9/test-command"]; ["command"; "/command9/test-command 9"]], "\n\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command10"]; - ["upload"; "test-command"; "/command10/test-command"]; + ["upload"; "$builddir/test-command"; "/command10/test-command"]; ["chmod"; "0o755"; "/command10/test-command"]; ["command"; "/command10/test-command 10"]], "Result10-1\nResult10-2\n"), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command11"]; - ["upload"; "test-command"; "/command11/test-command"]; + ["upload"; "$builddir/test-command"; "/command11/test-command"]; ["chmod"; "0o755"; "/command11/test-command"]; ["command"; "/command11/test-command 11"]], "Result11-1\nResult11-2"), []; InitScratchFS, IfNotCrossAppliance, TestLastFail ( [["mkdir"; "/command12"]; - ["upload"; "test-command"; "/command12/test-command"]; + ["upload"; "$builddir/test-command"; "/command12/test-command"]; ["chmod"; "0o755"; "/command12/test-command"]; ["command"; "/command12/test-command"]]), []; InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/pwd"]; - ["upload"; "test-pwd"; "/pwd/test-pwd"]; + ["upload"; "$builddir/test-pwd"; "/pwd/test-pwd"]; ["chmod"; "0o755"; "/pwd/test-pwd"]; ["command"; "/pwd/test-pwd"]], "/"), []; ]; @@ -4407,67 +4407,67 @@ locations." }; tests = [ InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines"]; - ["upload"; "test-command"; "/command_lines/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines/test-command"]; ["chmod"; "0o755"; "/command_lines/test-command"]; ["command_lines"; "/command_lines/test-command 1"]], "is_string_list (ret, 1, \"Result1\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines2"]; - ["upload"; "test-command"; "/command_lines2/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines2/test-command"]; ["chmod"; "0o755"; "/command_lines2/test-command"]; ["command_lines"; "/command_lines2/test-command 2"]], "is_string_list (ret, 1, \"Result2\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines3"]; - ["upload"; "test-command"; "/command_lines3/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines3/test-command"]; ["chmod"; "0o755"; "/command_lines3/test-command"]; ["command_lines"; "/command_lines3/test-command 3"]], "is_string_list (ret, 2, \"\", \"Result3\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines4"]; - ["upload"; "test-command"; "/command_lines4/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines4/test-command"]; ["chmod"; "0o755"; "/command_lines4/test-command"]; ["command_lines"; "/command_lines4/test-command 4"]], "is_string_list (ret, 2, \"\", \"Result4\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines5"]; - ["upload"; "test-command"; "/command_lines5/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines5/test-command"]; ["chmod"; "0o755"; "/command_lines5/test-command"]; ["command_lines"; "/command_lines5/test-command 5"]], "is_string_list (ret, 3, \"\", \"Result5\", \"\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines6"]; - ["upload"; "test-command"; "/command_lines6/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines6/test-command"]; ["chmod"; "0o755"; "/command_lines6/test-command"]; ["command_lines"; "/command_lines6/test-command 6"]], "is_string_list (ret, 4, \"\", \"\", \"Result6\", \"\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines7"]; - ["upload"; "test-command"; "/command_lines7/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines7/test-command"]; ["chmod"; "0o755"; "/command_lines7/test-command"]; ["command_lines"; "/command_lines7/test-command 7"]], "is_string_list (ret, 0)"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines8"]; - ["upload"; "test-command"; "/command_lines8/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines8/test-command"]; ["chmod"; "0o755"; "/command_lines8/test-command"]; ["command_lines"; "/command_lines8/test-command 8"]], "is_string_list (ret, 1, \"\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines9"]; - ["upload"; "test-command"; "/command_lines9/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines9/test-command"]; ["chmod"; "0o755"; "/command_lines9/test-command"]; ["command_lines"; "/command_lines9/test-command 9"]], "is_string_list (ret, 2, \"\", \"\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines10"]; - ["upload"; "test-command"; "/command_lines10/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines10/test-command"]; ["chmod"; "0o755"; "/command_lines10/test-command"]; ["command_lines"; "/command_lines10/test-command 10"]], "is_string_list (ret, 2, \"Result10-1\", \"Result10-2\")"), []; InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines11"]; - ["upload"; "test-command"; "/command_lines11/test-command"]; + ["upload"; "$builddir/test-command"; "/command_lines11/test-command"]; ["chmod"; "0o755"; "/command_lines11/test-command"]; ["command_lines"; "/command_lines11/test-command 11"]], "is_string_list (ret, 2, \"Result11-1\", \"Result11-2\")"), [] @@ -4680,11 +4680,13 @@ This uses the L<blockdev(8)> command." }; progress = true; cancellable = true; tests = [ InitScratchFS, Always, TestResultString ( - (* Pick a file from cwd which isn't likely to change. *) [["mkdir"; "/upload"]; - ["upload"; "$srcdir/../../COPYING.LIB"; "/upload/COPYING.LIB"]; - ["checksum"; "md5"; "/upload/COPYING.LIB"]], - Digest.to_hex (Digest.file "COPYING.LIB")), [] + (* Pick a file from the top-level directory which is included + * in the external test suite. + *) + ["upload"; "$top_srcdir/COPYING"; "/upload/COPYING"]; + ["checksum"; "md5"; "/upload/COPYING"]], + Digest.to_hex (Digest.file "COPYING")), [] ]; shortdesc = "upload a file from the local machine"; longdesc = "\ @@ -4702,13 +4704,15 @@ See also C<guestfs_download>." }; progress = true; cancellable = true; tests = [ InitScratchFS, Always, TestResultString ( - (* Pick a file from cwd which isn't likely to change. *) [["mkdir"; "/download"]; - ["upload"; "$srcdir/../../COPYING.LIB"; "/download/COPYING.LIB"]; - ["download"; "/download/COPYING.LIB"; "testdownload.tmp"]; + (* Pick a file from the top-level directory which is included + * in the external test suite. + *) + ["upload"; "$top_srcdir/COPYING"; "/download/COPYING"]; + ["download"; "/download/COPYING"; "testdownload.tmp"]; ["upload"; "testdownload.tmp"; "/download/upload"]; ["checksum"; "md5"; "/download/upload"]], - Digest.to_hex (Digest.file "COPYING.LIB")), [] + Digest.to_hex (Digest.file "COPYING")), [] ]; shortdesc = "download a file to the local machine"; longdesc = "\ @@ -4800,15 +4804,15 @@ To get the checksums for many files, use C<guestfs_checksums_out>." }; tests = [ InitScratchFS, Always, TestResultString ( [["mkdir"; "/tar_in"]; - ["tar_in"; "$srcdir/../data/helloworld.tar"; "/tar_in"; "NOARG"; ""; ""; ""]; + ["tar_in"; "$datadir/helloworld.tar"; "/tar_in"; "NOARG"; ""; ""; ""]; ["cat"; "/tar_in/hello"]], "hello\n"), []; InitScratchFS, Always, TestResultString ( [["mkdir"; "/tar_in_gz"]; - ["tar_in"; "$srcdir/../data/helloworld.tar.gz"; "/tar_in_gz"; "gzip"; ""; ""; ""]; + ["tar_in"; "$datadir/helloworld.tar.gz"; "/tar_in_gz"; "gzip"; ""; ""; ""]; ["cat"; "/tar_in_gz/hello"]], "hello\n"), []; InitScratchFS, IfAvailable "xz", TestResultString ( [["mkdir"; "/tar_in_xz"]; - ["tar_in"; "$srcdir/../data/helloworld.tar.xz"; "/tar_in_xz"; "xz"; ""; ""; ""]; + ["tar_in"; "$datadir/helloworld.tar.xz"; "/tar_in_xz"; "xz"; ""; ""; ""]; ["cat"; "/tar_in_xz/hello"]], "hello\n"), [] ]; shortdesc = "unpack tarfile to directory"; @@ -4895,7 +4899,7 @@ If set to true, POSIX ACLs are saved in the output tar. tests = [ InitScratchFS, Always, TestResultString ( [["mkdir"; "/tgz_in"]; - ["tgz_in"; "$srcdir/../data/helloworld.tar.gz"; "/tgz_in"]; + ["tgz_in"; "$datadir/helloworld.tar.gz"; "/tgz_in"]; ["cat"; "/tgz_in/hello"]], "hello\n"), [] ]; shortdesc = "unpack compressed tarball to directory"; @@ -8247,7 +8251,7 @@ or growing unnecessarily." }; tests = [ InitScratchFS, Always, TestResultString ( [["mkdir"; "/txz_in"]; - ["txz_in"; "$srcdir/../data/helloworld.tar.xz"; "/txz_in"]; + ["txz_in"; "$datadir/helloworld.tar.xz"; "/txz_in"]; ["cat"; "/txz_in/hello"]], "hello\n"), [] ]; shortdesc = "unpack compressed tarball to directory"; @@ -8359,7 +8363,7 @@ types (see C<guestfs_part_get_parttype>)." }; tests = [ InitISOFS, Always, TestResult ( [["checksum_device"; "md5"; "/dev/sdd"]], - "check_file_md5 (ret, \"../data/test.iso\") == 0"), [] + "check_file_md5 (ret, \"$datadir/test.iso\") == 0"), [] ]; shortdesc = "compute MD5, SHAx or CRC checksum of the contents of a device"; longdesc = "\ @@ -8433,7 +8437,7 @@ to find out what it is for." }; cancellable = true; tests = [ InitScratchFS, Always, TestResultString ( - [["base64_in"; "../data/hello.b64"; "/base64_in"]; + [["base64_in"; "$datadir/hello.b64"; "/base64_in"]; ["cat"; "/base64_in"]], "hello\n"), [] ]; shortdesc = "upload base64-encoded data to file"; @@ -8993,9 +8997,9 @@ See also C<guestfs_part_to_partnum>, C<guestfs_device_index>." }; proc_nr = Some 273; progress = true; cancellable = true; tests - (let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in [ + (let md5 = Digest.to_hex (Digest.file "COPYING") in [ InitScratchFS, Always, TestResultString ( - [["upload_offset"; "$srcdir/../../COPYING.LIB"; "/upload_offset"; "0"]; + [["upload_offset"; "$top_srcdir/COPYING"; "/upload_offset"; "0"]; ["checksum"; "md5"; "/upload_offset"]], md5), [] ]); shortdesc = "upload a file from the local machine with offset"; @@ -9023,17 +9027,19 @@ See also C<guestfs_upload>, C<guestfs_pwrite>." }; proc_nr = Some 274; progress = true; cancellable = true; tests - (let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in + (let md5 = Digest.to_hex (Digest.file "COPYING") in let offset = string_of_int 100 in - let size = string_of_int ((Unix.stat "COPYING.LIB").Unix.st_size - 100) in + let size = string_of_int ((Unix.stat "COPYING").Unix.st_size - 100) in [ InitScratchFS, Always, TestResultString ( - (* Pick a file from cwd which isn't likely to change. *) [["mkdir"; "/download_offset"]; - ["upload"; "$srcdir/../../COPYING.LIB"; "/download_offset/COPYING.LIB"]; - ["download_offset"; "/download_offset/COPYING.LIB"; "testdownload.tmp"; offset; size]; - ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING.LIB"; offset]; - ["checksum"; "md5"; "/download_offset/COPYING.LIB"]], md5), [] + (* Pick a file from the top-level directory which is included + * in the external test suite. + *) + ["upload"; "$top_srcdir/COPYING"; "/download_offset/COPYING"]; + ["download_offset"; "/download_offset/COPYING"; "testdownload.tmp"; offset; size]; + ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING"; offset]; + ["checksum"; "md5"; "/download_offset/COPYING"]], md5), [] ]); shortdesc = "download a file to the local machine with offset and size"; longdesc = "\ @@ -10881,7 +10887,7 @@ C<guestfs_xfs_growfs> calls." }; optional = Some "hivex"; tests = [ InitScratchFS, Always, TestRun ( - [["upload"; "$srcdir/../data/minimal"; "/hivex_open"]; + [["upload"; "$datadir/minimal"; "/hivex_open"]; ["hivex_open"; "/hivex_open"; ""; ""; "false"]; ["hivex_root"]; (* in this hive, it returns 0x1020 *) ["hivex_node_name"; "0x1020"]; @@ -11029,11 +11035,11 @@ See also: C<guestfs_hivex_value_utf8>." }; optional = Some "hivex"; tests = [ InitScratchFS, Always, TestRun ( - [["upload"; "$srcdir/../data/minimal"; "/hivex_commit1"]; + [["upload"; "$datadir/minimal"; "/hivex_commit1"]; ["hivex_open"; "/hivex_commit1"; ""; ""; "true"]; ["hivex_commit"; "NULL"]]), [["hivex_close"]]; InitScratchFS, Always, TestResultTrue ( - [["upload"; "$srcdir/../data/minimal"; "/hivex_commit2"]; + [["upload"; "$datadir/minimal"; "/hivex_commit2"]; ["hivex_open"; "/hivex_commit2"; ""; ""; "true"]; ["hivex_commit"; "/hivex_commit2_copy"]; ["is_file"; "/hivex_commit2_copy"; "false"]]), [["hivex_close"]] diff --git a/generator/tests.ml b/generator/tests.ml index 4be899b..d361ef8 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -32,6 +32,34 @@ let defaults = { (* The tests in each subdirectory. *) let tests = [ + + "tests/c-api", { + defaults with + check_fast = [ + "test-just-header"; + "test-just-header-cxx"; + "test-add-drive-opts"; + "test-backend-settings"; + "test-create-handle"; + "test-config"; + "test-event-string"; + "test-environment"; + "test-private-data"; + "test-dlopen"; + ]; + check = [ + "tests"; + "test-last-errno"; + "test-user-cancel"; + "test-debug-to-file"; + "test-add-libvirt-dom"; + ]; + check_programs = [ + "test-command"; + "test-pwd"; + ]; + }; + "inspector", { defaults with check = [ diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml index 1522eff..5062ce1 100644 --- a/generator/tests_c_api.ml +++ b/generator/tests_c_api.ml @@ -403,17 +403,16 @@ and generate_test_command_call ?(expect_error = false) ?test ?ret test_name cmd | String _, arg, sym | OptString _, arg, sym | Key _, arg, sym - | GUID _, arg, sym -> - pr " const char *%s = \"%s\";\n" sym (c_quote arg); + | GUID _, arg, sym + | FileIn _, arg, sym -> + pr " CLEANUP_FREE char *%s = substitute_environment (\"%s\");\n" + sym (c_quote arg) | BufferIn _, arg, sym -> pr " const char *%s = \"%s\";\n" sym (c_quote arg); pr " size_t %s_size = %d;\n" sym (String.length arg) | Int _, _, _ | Int64 _, _, _ | Bool _, _, _ -> () - | FileIn _, arg, sym -> - pr " CLEANUP_FREE char *%s = substitute_srcdir (\"%s\");\n" - sym (c_quote arg) | FileOut _, _, _ -> () | StringList _, "", sym | DeviceList _, "", sym -> diff --git a/inspector/tests.mk b/inspector/tests.mk index 67fc0bc..714486c 100644 --- a/inspector/tests.mk +++ b/inspector/tests.mk @@ -3,7 +3,7 @@ # generator/ *.ml # ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. # -# Copyright (C) 2009-2014 Red Hat Inc. +# Copyright (C) 2009-2015 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 diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am index 7bfffe5..5322c5e 100644 --- a/tests/c-api/Makefile.am +++ b/tests/c-api/Makefile.am @@ -17,68 +17,16 @@ include $(top_srcdir)/subdir-rules.mk -generator_built = tests.c +generator_built = tests.c tests.mk -BUILT_SOURCES = $(generator_built) +BUILT_SOURCES = tests.c -EXTRA_DIST = $(BUILT_SOURCES) +EXTRA_DIST = \ + tests.c \ + test-command.c \ + test-pwd.c -check_PROGRAMS = \ - tests \ - test-command \ - test-just-header \ - test-create-handle \ - test-config \ - test-add-drive-opts \ - test-last-errno \ - test-backend-settings \ - test-private-data \ - test-user-cancel \ - test-debug-to-file \ - test-environment \ - test-pwd \ - test-event-string -if HAVE_LIBDL -check_PROGRAMS += \ - test-dlopen -endif - -TESTS = \ - tests \ - test-just-header \ - test-create-handle \ - test-config \ - test-add-drive-opts \ - test-last-errno \ - test-backend-settings \ - test-private-data \ - test-user-cancel \ - test-debug-to-file \ - test-environment \ - test-event-string -if HAVE_LIBDL -TESTS += \ - test-dlopen -endif - -if HAVE_CXX -check_PROGRAMS += test-just-header-cxx -TESTS += test-just-header-cxx -endif - -if HAVE_LIBVIRT -check_PROGRAMS += test-add-libvirt-dom -TESTS += test-add-libvirt-dom -endif -EXTRA_DIST += test-add-libvirt-dom.c - -TESTS_ENVIRONMENT = \ - SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ - SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ - SKIP_TEST_COMMAND=$(shell ldd test-pwd | grep -sq 'not a dynamic executable' || echo 1) \ - $(top_builddir)/run --test $(VG) - -#SKIP_TEST_CHECKSUM_8=$(shell if test `find ../initramfs -name squashfs.ko | wc -l` -eq 0; then echo 1; fi) +include $(srcdir)/tests.mk tests_SOURCES = \ tests.c \ @@ -127,6 +75,10 @@ test_just_header_cxx_CXXFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) test_just_header_cxx_LDADD = \ $(top_builddir)/src/libguestfs.la +else +test-just-header-cxx: + echo 'exit 77' > $@ + chmod 0755 $@ endif test_create_handle_SOURCES = test-create-handle.c @@ -142,10 +94,13 @@ test_dlopen_SOURCES = test-dlopen.c test_dlopen_CPPFLAGS = \ -I$(top_srcdir)/src -I$(top_builddir)/src test_dlopen_CFLAGS = \ - $(WARN_CFLAGS) $(WERROR_CFLAGS) \ - -DLIBRARY=\"$(top_builddir)/src/.libs/libguestfs.so.0\" + $(WARN_CFLAGS) $(WERROR_CFLAGS) test_dlopen_LDADD = \ -ldl +else +test-dlopen: + echo 'exit 77' > $@ + chmod 0755 $@ endif test_config_SOURCES = test-config.c @@ -251,7 +206,8 @@ test_add_libvirt_dom_LDADD = \ $(top_builddir)/src/libguestfs.la $(LIBVIRT_LIBS) \ $(LTLIBINTL) \ $(LTLIBTHREAD) $(top_builddir)/gnulib/lib/libgnu.la +else +test-add-libvirt-dom: + echo 'exit 77' > $@ + chmod 0755 $@ endif - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check diff --git a/tests/c-api/test-dlopen.c b/tests/c-api/test-dlopen.c index 3efd847..c9190b0 100644 --- a/tests/c-api/test-dlopen.c +++ b/tests/c-api/test-dlopen.c @@ -25,6 +25,11 @@ #include <unistd.h> #include <dlfcn.h> +/* This is found on LD_LIBRARY_PATH set by the ./run script, or + * from the usual libdir. + */ +#define LIBRARY "libguestfs.so.0" + /* We don't need the <guestfs.h> header file here. */ typedef struct guestfs_h guestfs_h; @@ -32,10 +37,6 @@ typedef guestfs_h *(*guestfs_create_t) (void); typedef const char * (*guestfs_get_program_t) (guestfs_h *); typedef void (*guestfs_close_t) (guestfs_h *); -#ifndef LIBRARY -#error "-DLIBRARY was not defined" -#endif - static void * read_symbol (void *lib, const char *symbol) { @@ -60,12 +61,6 @@ main (int argc, char *argv[]) guestfs_close_t guestfs_close; guestfs_h *g; - if (access (LIBRARY, X_OK) == -1) { - fprintf (stderr, "test skipped because %s cannot be accessed: %m\n", - LIBRARY); - exit (77); - } - lib = dlopen (LIBRARY, RTLD_LAZY); if (lib == NULL) { fprintf (stderr, "could not open %s: %s\n", LIBRARY, dlerror ()); diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c index 71a361a..5852125 100644 --- a/tests/c-api/tests-main.c +++ b/tests/c-api/tests-main.c @@ -360,35 +360,45 @@ match_re (const char *str, const char *pattern) return r != PCRE_ERROR_NOMATCH; } -/* Used for FileIn parameters in tests. If the path starts with - * "$srcdir" then replace that with the contents of the $srcdir - * environment variable (this is set by automake and run time). The - * caller must free the returned string. +/* Used for some parameters in tests. If the string starts with + * "$variable" then replace that with the contents of the named + * environment variable. The caller must free the returned string. */ char * -substitute_srcdir (const char *path) +substitute_environment (const char *str) { char *ret; + size_t len; + CLEANUP_FREE char *name = NULL; + const char *value; - if (STRPREFIX (path, "$srcdir")) { - const char *srcdir; + if (STRPREFIX (str, "$")) { + len = strspn (str+1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"); + if (len == 0) { + fprintf (stderr, "tests: invalid environment variable in string (%s)\n", + str); + exit (EXIT_FAILURE); + } + name = strndup (str+1, len); + if (name == NULL) { + perror ("strndup"); + exit (EXIT_FAILURE); + } - srcdir = getenv ("srcdir"); - if (!srcdir) { - fprintf (stderr, "tests: environment variable $srcdir is not defined.\n" - "Normally it is defined by automake. If you are running the\n" - "tests directly, set $srcdir to point to the source tests/c-api\n" - "directory.\n"); + value = getenv (name); + if (!value) { + fprintf (stderr, "tests: environment variable $%s is not defined.\n", + name); exit (EXIT_FAILURE); } - if (asprintf (&ret, "%s%s", srcdir, path + 7) == -1) { + if (asprintf (&ret, "%s%s", value, str + 1 + len) == -1) { perror ("asprintf"); exit (EXIT_FAILURE); } } else { - ret = strdup (path); + ret = strdup (str); if (!ret) { perror ("strdup"); exit (EXIT_FAILURE); @@ -433,6 +443,8 @@ static guestfs_h * create_handle (void) { guestfs_h *g; + const char *datadir; + CLEANUP_FREE char *test_iso = NULL; g = guestfs_create (); if (g == NULL) { @@ -455,8 +467,18 @@ create_handle (void) exit (EXIT_FAILURE); } - if (guestfs_add_drive_ro (g, "../data/test.iso") == -1) { - printf ("FAIL: guestfs_add_drive_ro ../data/test.iso\n"); + datadir = getenv ("datadir"); + if (datadir == NULL) { + fprintf (stderr, "environment variable $datadir is not defined\n"); + exit (EXIT_FAILURE); + } + if (asprintf (&test_iso, "%s/test.iso", datadir) == -1) { + perror ("asprintf"); + exit (EXIT_FAILURE); + } + + if (guestfs_add_drive_ro (g, test_iso) == -1) { + printf ("FAIL: guestfs_add_drive_ro $datadir/test.iso\n"); exit (EXIT_FAILURE); } diff --git a/tests/c-api/tests.h b/tests/c-api/tests.h index 2631a5d..3e14b07 100644 --- a/tests/c-api/tests.h +++ b/tests/c-api/tests.h @@ -44,7 +44,7 @@ extern const char *get_key (char **hash, const char *key); extern int check_hash (char **ret, const char *key, const char *expected); extern int match_re (const char *str, const char *pattern); extern int using_cross_appliance (void); -extern char *substitute_srcdir (const char *path); +extern char *substitute_environment (const char *str); extern void skipped (const char *test_name, const char *fs, ...) __attribute__((format (printf,2,3))); #endif /* TESTS_H_ */ diff --git a/tests/c-api/tests.mk b/tests/c-api/tests.mk new file mode 100644 index 0000000..999221a --- /dev/null +++ b/tests/c-api/tests.mk @@ -0,0 +1,79 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/c-api + +localtests_PROGRAMS = \ + test-add-drive-opts \ + test-add-libvirt-dom \ + test-backend-settings \ + test-command \ + test-config \ + test-create-handle \ + test-debug-to-file \ + test-dlopen \ + test-environment \ + test-event-string \ + test-just-header \ + test-just-header-cxx \ + test-last-errno \ + test-private-data \ + test-pwd \ + test-user-cancel \ + tests + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 03/17] tests: Convert all subdirectories of tests/ to use the test harness.
The general plan for converting each subdirectory is: (1) Create a new subdirectory entry in generator/tests.ml. (2) Add the tests, data files, etc to generator/tests.ml entry. (3) Remove all TESTS/TEST_ENVIRONMENT variables. (4) Add 'generator_built = tests.mk' and 'include $(srcdir)/tests.mk'. (5) May need to add an empty 'EXTRA_DIST =' line, if there isn't one already. (6) Remove any SKIP_* checks from the tests (since the test harness now does this for you). (7) May need to update the test so it references any data files it needs relative to environment variables like $srcdir, $builddir, $top_builddir, etc. (8) Remove any relative paths to binaries (eg. '../../fish/guestfish' would become just 'guestfish') since we want to be able to test the installed copy of libguestfs, and the ./run script will set the $PATH correctly for local builds. (9) Build it, and run the new tests to check it works. (10) Check it works for an installed copy of the tests too. --- .gitignore | 4 - configure.ac | 1 - generator/tests.ml | 281 ++++++++++++++++++++++++++ tests/9p/Makefile.am | 7 +- tests/9p/test-9p.sh | 5 - tests/9p/tests.mk | 60 ++++++ tests/bigdirs/Makefile.am | 12 +- tests/bigdirs/tests.mk | 30 +++ tests/btrfs/Makefile.am | 15 +- tests/btrfs/test-btrfs-devices.sh | 8 +- tests/btrfs/test-btrfs-misc.pl | 3 - tests/btrfs/test-btrfs-subvolume-default.pl | 3 - tests/btrfs/tests.mk | 63 ++++++ tests/charsets/Makefile.am | 7 +- tests/charsets/test-charset-fidelity.c | 12 +- tests/charsets/tests.mk | 60 ++++++ tests/create/Makefile.am | 9 +- tests/create/tests.mk | 63 ++++++ tests/daemon/Makefile.am | 14 +- tests/daemon/captive-daemon.pm | 111 ++++++++++ tests/daemon/captive-daemon.pm.in | 123 ----------- tests/daemon/test-btrfs.pl | 2 +- tests/daemon/test-daemon-start.pl | 2 +- tests/daemon/tests.mk | 65 ++++++ tests/discard/Makefile.am | 9 +- tests/discard/test-blkdiscard.pl | 5 - tests/discard/test-discard.pl | 5 - tests/discard/test-fstrim.pl | 5 - tests/discard/tests.mk | 62 ++++++ tests/disk-labels/Makefile.am | 10 +- tests/disk-labels/test-disk-labels.pl | 4 +- tests/disk-labels/tests.mk | 60 ++++++ tests/disks/Makefile.am | 14 +- tests/disks/test-max-disks.pl | 2 +- tests/disks/test-qemu-drive-libvirt.sh | 4 +- tests/disks/tests.mk | 63 ++++++ tests/events/Makefile.am | 19 +- tests/events/test-console-debug.pl | 4 +- tests/events/test-libvirt-auth-callbacks.c | 14 +- tests/events/tests.mk | 69 +++++++ tests/fuzz/Makefile.am | 15 +- tests/fuzz/fuzz-inspection.pl | 11 +- tests/fuzz/tests.mk | 60 ++++++ tests/hotplug/Makefile.am | 13 +- tests/hotplug/test-hot-add.pl | 4 +- tests/hotplug/test-hot-remove.pl | 4 +- tests/hotplug/tests.mk | 61 ++++++ tests/journal/Makefile.am | 10 +- tests/journal/test-journal.pl | 6 +- tests/journal/tests.mk | 60 ++++++ tests/luks/Makefile.am | 11 +- tests/luks/test-luks-list.sh | 7 +- tests/luks/test-luks.sh | 7 +- tests/luks/tests.mk | 61 ++++++ tests/lvm/Makefile.am | 9 +- tests/lvm/test-lvm-filtering.sh | 7 +- tests/lvm/tests.mk | 61 ++++++ tests/md/Makefile.am | 11 +- tests/md/test-inspect-fstab-md.sh | 11 +- tests/md/test-inspect-fstab.sh | 4 +- tests/md/test-list-filesystems.sh | 7 +- tests/md/test-list-md-devices.sh | 7 +- tests/md/test-mdadm.sh | 7 +- tests/md/tests.mk | 64 ++++++ tests/mount-local/Makefile.am | 19 +- tests/mount-local/test-parallel-mount-local.c | 36 ++-- tests/mount-local/tests.mk | 60 ++++++ tests/mountable/Makefile.am | 10 +- tests/mountable/test-mountable-inspect.sh | 9 +- tests/mountable/tests.mk | 63 ++++++ tests/nbd/Makefile.am | 10 +- tests/nbd/test-nbd.pl | 6 +- tests/nbd/tests.mk | 60 ++++++ tests/network/Makefile.am | 10 +- tests/network/test-network.sh | 5 - tests/network/tests.mk | 60 ++++++ tests/ntfsclone/Makefile.am | 10 +- tests/ntfsclone/test-ntfsclone.sh | 11 +- tests/ntfsclone/tests.mk | 60 ++++++ tests/parallel/Makefile.am | 18 +- tests/parallel/test-parallel.c | 11 +- tests/parallel/tests.mk | 30 +++ tests/protocol/Makefile.am | 16 +- tests/protocol/tests.mk | 69 +++++++ tests/qemu/Makefile.am | 18 +- tests/qemu/qemu-force-tcg.sh | 5 - tests/qemu/tests.mk | 67 ++++++ tests/relative-paths/Makefile.am | 11 +- tests/relative-paths/test-relative-paths.sh | 8 +- tests/relative-paths/tests.mk | 60 ++++++ tests/rsync/Makefile.am | 8 +- tests/rsync/test-rsync.sh | 8 +- tests/rsync/tests.mk | 60 ++++++ tests/selinux/Makefile.am | 18 +- tests/selinux/run-test.pl | 10 +- tests/selinux/tests.mk | 64 ++++++ tests/syslinux/Makefile.am | 13 +- tests/syslinux/test-syslinux.pl | 4 +- tests/syslinux/tests.mk | 62 ++++++ tests/tmpdirs/Makefile.am | 10 +- tests/tmpdirs/tests.mk | 63 ++++++ tests/xfs/Makefile.am | 10 +- tests/xfs/test-xfs-misc.pl | 4 +- tests/xfs/tests.mk | 60 ++++++ tests/xml/Makefile.am | 29 +-- tests/xml/rhbz701814.pl | 4 +- tests/xml/rhbz701814.sh | 22 ++ tests/xml/tests.mk | 68 +++++++ 108 files changed, 2504 insertions(+), 582 deletions(-) create mode 100644 tests/9p/tests.mk create mode 100644 tests/bigdirs/tests.mk create mode 100644 tests/btrfs/tests.mk create mode 100644 tests/charsets/tests.mk create mode 100644 tests/create/tests.mk create mode 100755 tests/daemon/captive-daemon.pm delete mode 100644 tests/daemon/captive-daemon.pm.in create mode 100644 tests/daemon/tests.mk create mode 100644 tests/discard/tests.mk create mode 100644 tests/disk-labels/tests.mk create mode 100644 tests/disks/tests.mk create mode 100644 tests/events/tests.mk create mode 100644 tests/fuzz/tests.mk create mode 100644 tests/hotplug/tests.mk create mode 100644 tests/journal/tests.mk create mode 100644 tests/luks/tests.mk create mode 100644 tests/lvm/tests.mk create mode 100644 tests/md/tests.mk create mode 100644 tests/mount-local/tests.mk create mode 100644 tests/mountable/tests.mk create mode 100644 tests/nbd/tests.mk create mode 100644 tests/network/tests.mk create mode 100644 tests/ntfsclone/tests.mk create mode 100644 tests/parallel/tests.mk create mode 100644 tests/protocol/tests.mk create mode 100644 tests/qemu/tests.mk create mode 100644 tests/relative-paths/tests.mk create mode 100644 tests/rsync/tests.mk create mode 100644 tests/selinux/tests.mk create mode 100644 tests/syslinux/tests.mk create mode 100644 tests/tmpdirs/tests.mk create mode 100644 tests/xfs/tests.mk create mode 100755 tests/xml/rhbz701814.sh create mode 100644 tests/xml/tests.mk diff --git a/.gitignore b/.gitignore index 045f3de..09c6056 100644 --- a/.gitignore +++ b/.gitignore @@ -533,7 +533,6 @@ Makefile.in /tests/data/lib-i586.so.xz /tests/data/test-grep.txt.gz /tests/data/test.iso -/tests/daemon/captive-daemon.pm /tests/disks/test-qemu-drive-libvirt.xml /tests/events/test-libvirt-auth-callbacks /tests/guests/blank-*.img @@ -564,9 +563,6 @@ Makefile.in /tests/regressions/rhbz914931 /tests/regressions/rhbz1044014.out /tests/regressions/rhbz1055452 -/tests/rsync/rsyncd.pid -/tests/syslinux/extlinux-guest.img -/tests/syslinux/syslinux-guest.img /test-tool/libguestfs-test-tool /test-tool/libguestfs-test-tool.1 /test-tool/libguestfs-test-tool-helper diff --git a/configure.ac b/configure.ac index 461d5cc..c3abcaf 100644 --- a/configure.ac +++ b/configure.ac @@ -1793,7 +1793,6 @@ AC_CONFIG_FILES([Makefile tests/create/Makefile tests/data/Makefile tests/daemon/Makefile - tests/daemon/captive-daemon.pm tests/discard/Makefile tests/disks/Makefile tests/disks/test-qemu-drive-libvirt.xml diff --git a/generator/tests.ml b/generator/tests.ml index d361ef8..a8d2fb0 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -33,6 +33,39 @@ let defaults = { (* The tests in each subdirectory. *) let tests = [ + "tests/qemu", { + defaults with + check = [ + "qemu-liveness.sh"; + "qemu-snapshot-isolation.sh"; + "qemu-force-tcg.sh"; + ]; + (* qemu-boot & qemu-speed-test are built but not run by default + * as they are mainly qemu & kernel diagnostic tools. + *) + check_programs = [ + "qemu-boot"; + "qemu-speed-test"; + ]; + check_scripts = [ + "guestfs-md5.sh" + ]; + }; + + "tests/protocol", { + defaults with + check = [ + "test-both-ends-cancel.sh"; + "test-cancellation-download-librarycancels.sh"; + "test-cancellation-upload-daemoncancels.sh"; + "test-error-messages"; + "test-launch-race.pl"; + "test-qemudie-killsub.sh"; + "test-qemudie-midcommand.sh"; + "test-qemudie-synch.sh"; + ]; + }; + "tests/c-api", { defaults with check_fast = [ @@ -60,6 +93,254 @@ let tests = [ ]; }; + "tests/9p", { + defaults with + check = [ + "test-9p.sh"; + ]; + }; + + "tests/bigdirs", { + defaults with + check_slow = [ + "test-big-dirs.pl"; + ]; + }; + + "tests/btrfs", { + defaults with + check = [ + "test-btrfs-misc.pl"; + "test-btrfs-devices.sh"; + "test-btrfs-subvolume-default.pl"; + "test-btrfs-replace.sh"; + ]; + }; + + "tests/charsets", { + defaults with + check = [ + "test-charset-fidelity"; + ]; + }; + + "tests/create", { + defaults with + check_fast = [ + "test-disk-create.sh"; + ]; + }; + + "tests/daemon", { + defaults with + check_fast = [ + "test-daemon-start.pl"; + "test-btrfs.pl"; + ]; + check_scripts = [ + "captive-daemon.pm"; + ]; + }; + + "tests/discard", { + defaults with + check = [ + "test-blkdiscard.pl"; + "test-discard.pl"; + "test-fstrim.pl"; + ]; + }; + + "tests/disk-labels", { + defaults with + check = [ + "test-disk-labels.pl"; + ]; + }; + + "tests/disks", { + defaults with + check = [ + "test-max-disks.pl"; + "test-qemu-drive-libvirt.sh"; + "test-qemu-drive.sh"; + ]; + check_scripts = [ + "debug-qemu.sh"; + ]; + }; + + "tests/events", { + defaults with + check_fast = [ + "test-libvirt-auth-callbacks"; + ]; + check = [ + "test-console-debug.pl"; + ]; + check_data = [ + "libvirt-auth.xml"; + ]; + }; + + "tests/fuzz", { + defaults with + check = [ + "fuzz-inspection.pl"; + ]; + }; + + "tests/hotplug", { + defaults with + check = [ + "test-hot-add.pl"; + "test-hot-remove.pl"; + ]; + }; + + "tests/journal", { + defaults with + check = [ + "test-journal.pl"; + ]; + }; + + "tests/luks", { + defaults with + check = [ + "test-luks.sh"; + "test-luks-list.sh"; + ]; + }; + + "tests/lvm", { + defaults with + check = [ + "test-lvm-filtering.sh"; + "test-lvm-mapping.pl"; + ]; + }; + + "tests/md", { + defaults with + check = [ + "test-inspect-fstab.sh"; + "test-inspect-fstab-md.sh"; + "test-list-filesystems.sh"; + "test-list-md-devices.sh"; + "test-mdadm.sh"; + ]; + }; + + "tests/mountable", { + defaults with + check = [ + "test-internal-parse-mountable"; + "test-mountable-inspect.sh"; + ]; + }; + + "tests/mount-local", { + defaults with + check = [ + "test-parallel-mount-local"; + ]; + }; + + "tests/nbd", { + defaults with + check = [ + "test-nbd.pl"; + ]; + }; + + "tests/network", { + defaults with + check = [ + "test-network.sh"; + ]; + }; + + "tests/ntfsclone", { + defaults with + check = [ + "test-ntfsclone.sh"; + ]; + }; + + "tests/parallel", { + defaults with + check_slow = [ + "test-parallel"; + ]; + }; + + "tests/relative-paths", { + defaults with + check = [ + "test-relative-paths.sh"; + ]; + }; + + "tests/rsync", { + defaults with + check = [ + "test-rsync.sh"; + ]; + }; + + "tests/selinux", { + defaults with + check = [ + "test-xattrs-direct.sh"; + "test-selinux-direct.sh"; + "test-xattrs-fuse.sh"; + "test-selinux-fuse.sh"; + ]; + check_scripts = [ + "run-test.pl" + ]; + }; + + "tests/syslinux", { + defaults with + check = [ + "test-syslinux.sh"; + "test-extlinux.sh"; + ]; + check_scripts = [ + "test-syslinux.pl" + ]; + }; + + "tests/tmpdirs", { + defaults with + check_fast = [ + "test-tmpdirs.pl"; + ]; + }; + + "tests/xfs", { + defaults with + check = [ + "test-xfs-misc.pl"; + ]; + }; + + "tests/xml", { + defaults with + check_fast = [ + "rhbz701814.sh"; + ]; + check_scripts = [ + "rhbz701814.pl"; + ]; + check_data = [ + "rhbz701814-faked.xml"; + "rhbz701814-node.xml" + ]; + }; + "inspector", { defaults with check = [ diff --git a/tests/9p/Makefile.am b/tests/9p/Makefile.am index 5c4629a..cbf7907 100644 --- a/tests/9p/Makefile.am +++ b/tests/9p/Makefile.am @@ -17,9 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -EXTRA_DIST = $(TESTS) +generator_built = tests.mk -TESTS = test-9p.sh +EXTRA_DIST = test-9p.sh -TESTS_ENVIRONMENT = abs_srcdir=$(abs_srcdir) \ - $(top_builddir)/run --test +include $(srcdir)/tests.mk diff --git a/tests/9p/test-9p.sh b/tests/9p/test-9p.sh index 9e396a4..5ab47ab 100755 --- a/tests/9p/test-9p.sh +++ b/tests/9p/test-9p.sh @@ -21,11 +21,6 @@ set -e -if [ -n "$SKIP_TEST_9P_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - backend="$(guestfish get-backend)" if [[ "$backend" != "direct" ]]; then echo "$0: test skipped because backend ($backend) is not 'direct'." diff --git a/tests/9p/tests.mk b/tests/9p/tests.mk new file mode 100644 index 0000000..d706b07 --- /dev/null +++ b/tests/9p/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/9p + +localtests_SCRIPTS = \ + test-9p.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/bigdirs/Makefile.am b/tests/bigdirs/Makefile.am index 770d97d..34fbf74 100644 --- a/tests/bigdirs/Makefile.am +++ b/tests/bigdirs/Makefile.am @@ -17,14 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = test-big-dirs.pl -# Don't run this test by default. It takes a very long time to run -# and is not especially informative. However we have to have an empty -# TESTS rule otherwise you can't run the test from the command line -# using 'make TESTS=test-big-dirs.pl check' -TESTS -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -check-slow: - $(MAKE) TESTS="test-big-dirs.pl" check +include $(srcdir)/tests.mk diff --git a/tests/bigdirs/tests.mk b/tests/bigdirs/tests.mk new file mode 100644 index 0000000..daa233c --- /dev/null +++ b/tests/bigdirs/tests.mk @@ -0,0 +1,30 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/bigdirs + +localtests_SCRIPTS = \ + test-big-dirs.pl + +check-slow: + $(top_builddir)/run $(top_builddir)/test-harness --slow + +EXTRA_DIST += tests.mk diff --git a/tests/btrfs/Makefile.am b/tests/btrfs/Makefile.am index b6ef794..97de00b 100644 --- a/tests/btrfs/Makefile.am +++ b/tests/btrfs/Makefile.am @@ -17,13 +17,12 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-btrfs-misc.pl \ - test-btrfs-devices.sh \ - test-btrfs-subvolume-default.pl \ - test-btrfs-replace.sh - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ - $(TESTS) + test-btrfs-devices.sh \ + test-btrfs-misc.pl \ + test-btrfs-replace.sh \ + test-btrfs-subvolume-default.pl + +include $(srcdir)/tests.mk diff --git a/tests/btrfs/test-btrfs-devices.sh b/tests/btrfs/test-btrfs-devices.sh index 3935c60..785f767 100755 --- a/tests/btrfs/test-btrfs-devices.sh +++ b/tests/btrfs/test-btrfs-devices.sh @@ -24,12 +24,6 @@ set -e -# Allow the test to be skipped since btrfs is often broken. -if [ -n "$SKIP_TEST_BTRFS_DEVICES_SH" ]; then - echo "$0: skipping test because environment variable is set." - exit 77 -fi - # If btrfs is not available, bail. if ! guestfish -a /dev/null run : available btrfs; then echo "$0: skipping test because btrfs is not available" @@ -55,7 +49,7 @@ mkfs-btrfs "/dev/sda1 /dev/sdb1" mount /dev/sda1 / mkdir /data1 -tar-in $srcdir/../data/filesanddirs-10M.tar.xz /data1 compress:xz +tar-in $datadir/filesanddirs-10M.tar.xz /data1 compress:xz # In btrfs-progs 0.19, a test was added which prevents us from # deleting the mount device (/dev/sda1) although that restriction diff --git a/tests/btrfs/test-btrfs-misc.pl b/tests/btrfs/test-btrfs-misc.pl index 0a8e942..2c6c9dd 100755 --- a/tests/btrfs/test-btrfs-misc.pl +++ b/tests/btrfs/test-btrfs-misc.pl @@ -24,9 +24,6 @@ use Errno; use Sys::Guestfs; -# Allow the test to be skipped since btrfs is often broken. -exit 77 if $ENV{SKIP_TEST_BTRFS_MISC_PL}; - my $g = Sys::Guestfs->new (); $g->add_drive_scratch (1024*1024*1024); diff --git a/tests/btrfs/test-btrfs-subvolume-default.pl b/tests/btrfs/test-btrfs-subvolume-default.pl index fd20fa2..b7045ac 100755 --- a/tests/btrfs/test-btrfs-subvolume-default.pl +++ b/tests/btrfs/test-btrfs-subvolume-default.pl @@ -23,9 +23,6 @@ use warnings; use Sys::Guestfs; -# Allow the test to be skipped since btrfs is often broken. -exit 77 if $ENV{SKIP_TEST_BTRFS_SUBVOLUME_DEFAULT_PL}; - my $g = Sys::Guestfs->new (); $g->add_drive_scratch (1024*1024*1024); diff --git a/tests/btrfs/tests.mk b/tests/btrfs/tests.mk new file mode 100644 index 0000000..f8b49a4 --- /dev/null +++ b/tests/btrfs/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/btrfs + +localtests_SCRIPTS = \ + test-btrfs-devices.sh \ + test-btrfs-misc.pl \ + test-btrfs-replace.sh \ + test-btrfs-subvolume-default.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/charsets/Makefile.am b/tests/charsets/Makefile.am index b6e503e..274e84f 100644 --- a/tests/charsets/Makefile.am +++ b/tests/charsets/Makefile.am @@ -17,12 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-charset-fidelity +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) +EXTRA_DIST -check_PROGRAMS = $(TESTS) +include $(srcdir)/tests.mk test_charset_fidelity_SOURCES = test-charset-fidelity.c test_charset_fidelity_CPPFLAGS = \ diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c index 9a477ce..869b123 100644 --- a/tests/charsets/test-charset-fidelity.c +++ b/tests/charsets/test-charset-fidelity.c @@ -33,8 +33,6 @@ #include "guestfs.h" #include "guestfs-internal-frontend.h" -static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY"; - struct filesystem { const char *fs_name; /* Name of filesystem. */ int fs_case_insensitive; /* True if filesystem is case insensitive. */ @@ -74,19 +72,10 @@ static void ignore_lost_and_found (char **); int main (int argc, char *argv[]) { - char *str; guestfs_h *g; size_t i; struct filesystem *fs; - /* Allow this test to be skipped. */ - str = getenv (ourenvvar); - if (str && guestfs_int_is_true (str) > 0) { - printf ("%s: test skipped because environment variable is set.\n", - guestfs_int_program_name); - exit (77); - } - g = guestfs_create (); if (g == NULL) error (EXIT_FAILURE, 0, "failed to create handle"); @@ -114,6 +103,7 @@ main (int argc, char *argv[]) static void test_filesystem (guestfs_h *g, const struct filesystem *fs) { + static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY"; const char *feature[] = { fs->fs_feature, NULL }; char envvar[sizeof (ourenvvar) + 20]; char *str; diff --git a/tests/charsets/tests.mk b/tests/charsets/tests.mk new file mode 100644 index 0000000..d18e30e --- /dev/null +++ b/tests/charsets/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/charsets + +localtests_PROGRAMS = \ + test-charset-fidelity + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/create/Makefile.am b/tests/create/Makefile.am index cdcecd2..4f4fd42 100644 --- a/tests/create/Makefile.am +++ b/tests/create/Makefile.am @@ -17,11 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-disk-create.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = \ - $(top_builddir)/run --test +EXTRA_DIST = test-disk-create.sh -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/create/tests.mk b/tests/create/tests.mk new file mode 100644 index 0000000..d0e98d2 --- /dev/null +++ b/tests/create/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/create + +localtests_SCRIPTS = \ + test-disk-create.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/tests/daemon/Makefile.am b/tests/daemon/Makefile.am index bb380c5..b88dba2 100644 --- a/tests/daemon/Makefile.am +++ b/tests/daemon/Makefile.am @@ -21,17 +21,11 @@ include $(top_srcdir)/subdir-rules.mk -check_DATA = captive-daemon.pm - -TESTS = \ - test-daemon-start.pl \ - test-btrfs.pl - -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) +generator_built = tests.mk EXTRA_DIST = \ captive-daemon.pm \ - $(TESTS) + test-daemon-start.pl \ + test-btrfs.pl -check-valgrind: - $(MAKE) check TEST_WITH_VALGRIND=1 +include $(srcdir)/tests.mk diff --git a/tests/daemon/captive-daemon.pm b/tests/daemon/captive-daemon.pm new file mode 100755 index 0000000..15e6e62 --- /dev/null +++ b/tests/daemon/captive-daemon.pm @@ -0,0 +1,111 @@ +# libguestfs +# Copyright (C) 2015 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. + +# Small library to help testing the daemon directly. + +package CaptiveDaemon; + +use strict; +use warnings; + +use Sys::Guestfs; + +$| = 1; + +# Refuse to run if the user is trying to run tests as root. There's +# too much risk that things will go badly wrong. +if ($> == 0) { + print "$0: don't run the libguestfs tests as root!\n"; + exit 77 +} + +sub run_tests { + my $g = Sys::Guestfs->new(); + my $tmpdir = $g->get_tmpdir; + my $verbose = $g->get_verbose; + $g->close; + + # Choose a random name for the socket. The daemon will create the + # socket so we don't need to do that. + my @chars = ("A".."Z", "a".."z", "0".."9"); + my $sockname = $tmpdir; + $sockname .= "/"; + $sockname .= $chars[rand @chars] for 1..8; + + # Assemble the command we will run in the subprocess. + my $cmd + "$ENV{top_builddir}/daemon/guestfsd --channel $sockname -r -t -l"; + if ($verbose) { + $cmd = $cmd . " -v" + } + if ($ENV{VG}) { + $cmd = $ENV{VG} . " " . $cmd + } + + if ($verbose) { + print "$0: running: $cmd\n"; + } + + # Fork to run the daemon in the background. + my $pid = fork (); + die "fork: $!" unless defined $pid; + if ($pid == 0) { + # Child process: the daemon. + exec $cmd or die "guestfsd: $!"; + } + + # Wait for the daemon to create the socket, but if it doesn't + # appear after a short timeout, assume there has been a failure. + for (my $i = 0; $i < 10; ++$i) { + last if -S $sockname; + sleep 1; + } + die "subprocess did not create the socket, check earlier messages\n" + unless -S $sockname; + + # Create the libguestfs handle and connect to the daemon using + # libguestfs live. + $g = Sys::Guestfs->new (); + $g->set_backend ("unix:" . $sockname); + $g->set_autosync (0); + $g->launch; + + # Run the user tests. + my $r = ::tests ($g); + + # Tell the daemon to exit cleanly, and remove the socket. + $g->internal_exit; + $g->close; + unlink $sockname; + + waitpid ($pid, 0) or die "waitpid: $!"; + if ($? != 0) { + my $signal = $? & 127; + die "ERROR: guestfsd died on signal $signal\n" if $signal; + my $crash = $? & 128; + die "ERROR: guestfsd core dumped\n" if $crash; + + # Exit with status code - the test harness will print an error. + my $status = $? >> 8; + exit $status; + } + + # Exit with failure if the user test failed. + exit 1 unless $r +} + +1; diff --git a/tests/daemon/captive-daemon.pm.in b/tests/daemon/captive-daemon.pm.in deleted file mode 100644 index 19833b8..0000000 --- a/tests/daemon/captive-daemon.pm.in +++ /dev/null @@ -1,123 +0,0 @@ -# libguestfs -# Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Small library to help testing the daemon directly. - -package CaptiveDaemon; - -use strict; -use warnings; - -use Sys::Guestfs; - -$| = 1; - -# Filled in by autoconf. -my %var; -$var{top_builddir} = "@top_builddir@"; -$var{abs_top_srcdir} = "@abs_top_srcdir@"; -$var{abs_top_builddir} = "@abs_top_builddir@"; -$var{VALGRIND} = "@VALGRIND@"; - -# Now we have to substitute the above variables into this one: -my $VG = '@VG@'; -$VG =~ s/\$\(([A-Za-z_]+)\)/ $var{"$1"} /ge; - -# Refuse to run if the user is trying to run tests as root. There's -# too much risk that things will go badly wrong. -if ($> == 0) { - print "$0: don't run the libguestfs tests as root!\n"; - exit 77 -} - -sub run_tests { - my $g = Sys::Guestfs->new(); - my $tmpdir = $g->get_tmpdir; - my $verbose = $g->get_verbose; - $g->close; - - # Choose a random name for the socket. The daemon will create the - # socket so we don't need to do that. - my @chars = ("A".."Z", "a".."z", "0".."9"); - my $sockname = $tmpdir; - $sockname .= "/"; - $sockname .= $chars[rand @chars] for 1..8; - - # Assemble the command we will run in the subprocess. - my $cmd - "$var{top_builddir}/daemon/guestfsd --channel $sockname -r -t -l"; - if ($verbose) { - $cmd = $cmd . " -v" - } - if ($ENV{TEST_WITH_VALGRIND}) { - $cmd = $VG . " " . $cmd - } - - if ($verbose) { - print "$0: running: $cmd\n"; - } - - # Fork to run the daemon in the background. - my $pid = fork (); - die "fork: $!" unless defined $pid; - if ($pid == 0) { - # Child process: the daemon. - exec $cmd or die "guestfsd: $!"; - } - - # Wait for the daemon to create the socket, but if it doesn't - # appear after a short timeout, assume there has been a failure. - for (my $i = 0; $i < 10; ++$i) { - last if -S $sockname; - sleep 1; - } - die "subprocess did not create the socket, check earlier messages\n" - unless -S $sockname; - - # Create the libguestfs handle and connect to the daemon using - # libguestfs live. - $g = Sys::Guestfs->new (); - $g->set_backend ("unix:" . $sockname); - $g->set_autosync (0); - $g->launch; - - # Run the user tests. - my $r = ::tests ($g); - - # Tell the daemon to exit cleanly, and remove the socket. - $g->internal_exit; - $g->close; - unlink $sockname; - - waitpid ($pid, 0) or die "waitpid: $!"; - if ($? != 0) { - my $signal = $? & 127; - die "ERROR: guestfsd died on signal $signal\n" if $signal; - my $crash = $? & 128; - die "ERROR: guestfsd core dumped\n" if $crash; - my $status = $? >> 8; - die "ERROR: guestfsd died with exit code 119 (valgrind failure)\n" - if $status == 119; - die "ERROR: guestfsd died with exit code $status\n"; - } - - # Exit with failure if the user test failed. - exit 1 unless $r -} - -1; diff --git a/tests/daemon/test-btrfs.pl b/tests/daemon/test-btrfs.pl index 7a0c345..ee6d832 100755 --- a/tests/daemon/test-btrfs.pl +++ b/tests/daemon/test-btrfs.pl @@ -23,7 +23,7 @@ use warnings; use File::Temp qw/tempdir/; -require 'captive-daemon.pm'; +require "$ENV{srcdir}/captive-daemon.pm"; # Set $PATH to include directory that will have phony 'btrfs' binary. my $bindir = tempdir (CLEANUP => 1); diff --git a/tests/daemon/test-daemon-start.pl b/tests/daemon/test-daemon-start.pl index 91e008a..3d391a8 100755 --- a/tests/daemon/test-daemon-start.pl +++ b/tests/daemon/test-daemon-start.pl @@ -21,7 +21,7 @@ use strict; use warnings; -require 'captive-daemon.pm'; +require "$ENV{srcdir}/captive-daemon.pm"; sub tests { my $g = shift; diff --git a/tests/daemon/tests.mk b/tests/daemon/tests.mk new file mode 100644 index 0000000..0cef426 --- /dev/null +++ b/tests/daemon/tests.mk @@ -0,0 +1,65 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/daemon + +localtests_SCRIPTS = \ + captive-daemon.pm \ + test-btrfs.pl \ + test-daemon-start.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/tests/discard/Makefile.am b/tests/discard/Makefile.am index e109628..09aa77c 100644 --- a/tests/discard/Makefile.am +++ b/tests/discard/Makefile.am @@ -17,12 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ +generator_built = tests.mk + +EXTRA_DIST = \ test-blkdiscard.pl \ test-discard.pl \ test-fstrim.pl -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/discard/test-blkdiscard.pl b/tests/discard/test-blkdiscard.pl index e080350..2142a27 100755 --- a/tests/discard/test-blkdiscard.pl +++ b/tests/discard/test-blkdiscard.pl @@ -28,11 +28,6 @@ $ENV{"LANG"} = "C"; $| = 1; -if ($ENV{SKIP_TEST_BLKDISCARD_PL}) { - print "$0: skipped test because environment variable is set\n"; - exit 77; -} - my $g = Sys::Guestfs->new (); # Discard is only supported when using qemu. diff --git a/tests/discard/test-discard.pl b/tests/discard/test-discard.pl index dbcf6a5..bd92d5e 100755 --- a/tests/discard/test-discard.pl +++ b/tests/discard/test-discard.pl @@ -28,11 +28,6 @@ $ENV{"LANG"} = "C"; $| = 1; -if ($ENV{SKIP_TEST_DISCARD_PL}) { - print "$0: skipped test because environment variable is set\n"; - exit 77; -} - my $g = Sys::Guestfs->new (); # Discard is only supported when using qemu. diff --git a/tests/discard/test-fstrim.pl b/tests/discard/test-fstrim.pl index cbd28bf..b847fd4 100755 --- a/tests/discard/test-fstrim.pl +++ b/tests/discard/test-fstrim.pl @@ -28,11 +28,6 @@ $ENV{"LANG"} = "C"; $| = 1; -if ($ENV{SKIP_TEST_FSTRIM_PL}) { - print "$0: skipped test because environment variable is set\n"; - exit 77; -} - my $g = Sys::Guestfs->new (); # Discard is only supported when using qemu. diff --git a/tests/discard/tests.mk b/tests/discard/tests.mk new file mode 100644 index 0000000..061b34e --- /dev/null +++ b/tests/discard/tests.mk @@ -0,0 +1,62 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/discard + +localtests_SCRIPTS = \ + test-blkdiscard.pl \ + test-discard.pl \ + test-fstrim.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/disk-labels/Makefile.am b/tests/disk-labels/Makefile.am index cd8f0e7..38fe06a 100644 --- a/tests/disk-labels/Makefile.am +++ b/tests/disk-labels/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-disk-labels.pl +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-disk-labels.pl -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/disk-labels/test-disk-labels.pl b/tests/disk-labels/test-disk-labels.pl index a74e300..66f58c8 100755 --- a/tests/disk-labels/test-disk-labels.pl +++ b/tests/disk-labels/test-disk-labels.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -23,8 +23,6 @@ use warnings; use Sys::Guestfs; -exit 77 if $ENV{SKIP_TEST_DISK_LABELS_PL}; - if (Sys::Guestfs->new()->get_backend() eq "uml") { print "$0: test skipped because UML backend does not support disk labels\n"; exit 77 diff --git a/tests/disk-labels/tests.mk b/tests/disk-labels/tests.mk new file mode 100644 index 0000000..129007d --- /dev/null +++ b/tests/disk-labels/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/disk-labels + +localtests_SCRIPTS = \ + test-disk-labels.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/disks/Makefile.am b/tests/disks/Makefile.am index ec95e82..fb858ec 100644 --- a/tests/disks/Makefile.am +++ b/tests/disks/Makefile.am @@ -17,16 +17,12 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ +generator_built = tests.mk + +EXTRA_DIST = \ + debug-qemu.sh \ test-max-disks.pl \ test-qemu-drive-libvirt.sh \ test-qemu-drive.sh -TESTS_ENVIRONMENT = \ - abs_srcdir=$(abs_srcdir) \ - abs_builddir=$(abs_builddir) \ - $(top_builddir)/run --test - -EXTRA_DIST = \ - debug-qemu.sh \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/disks/test-max-disks.pl b/tests/disks/test-max-disks.pl index 9561b6b..6fd86fa 100755 --- a/tests/disks/test-max-disks.pl +++ b/tests/disks/test-max-disks.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 diff --git a/tests/disks/test-qemu-drive-libvirt.sh b/tests/disks/test-qemu-drive-libvirt.sh index 59d6101..e3610a6 100755 --- a/tests/disks/test-qemu-drive-libvirt.sh +++ b/tests/disks/test-qemu-drive-libvirt.sh @@ -31,12 +31,12 @@ if [ -z "$abs_builddir" ]; then exit 1 fi -if [ ! -x ../../src/libvirt-is-version ]; then +if [ ! -x $top_builddir/src/libvirt-is-version ]; then echo "$0: test skipped because libvirt-is-version is not built yet" exit 77 fi -if ! ../../src/libvirt-is-version 1 1 3; then +if ! $top_builddir/src/libvirt-is-version 1 1 3; then echo "$0: test skipped because libvirt is too old (< 1.1.3)" exit 77 fi diff --git a/tests/disks/tests.mk b/tests/disks/tests.mk new file mode 100644 index 0000000..5382453 --- /dev/null +++ b/tests/disks/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/disks + +localtests_SCRIPTS = \ + debug-qemu.sh \ + test-max-disks.pl \ + test-qemu-drive-libvirt.sh \ + test-qemu-drive.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/events/Makefile.am b/tests/events/Makefile.am index 6569854..ef74bbf 100644 --- a/tests/events/Makefile.am +++ b/tests/events/Makefile.am @@ -17,20 +17,15 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ - test-console-debug.pl \ - libvirt-auth.xml + libvirt-auth.xml \ + test-console-debug.pl -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -check_PROGRAMS - -TESTS = test-console-debug.pl +include $(srcdir)/tests.mk if HAVE_LIBVIRT -TESTS += test-libvirt-auth-callbacks -check_PROGRAMS += test-libvirt-auth-callbacks - test_libvirt_auth_callbacks_SOURCES = test-libvirt-auth-callbacks.c test_libvirt_auth_callbacks_CPPFLAGS = \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ @@ -45,4 +40,8 @@ test_libvirt_auth_callbacks_LDADD = \ $(LIBXML2_LIBS) \ $(LTLIBINTL) \ $(top_builddir)/gnulib/lib/libgnu.la +else +test-libvirt-auth-callbacks: + echo 'exit 77' > $@ + chmod 0755 $@ endif diff --git a/tests/events/test-console-debug.pl b/tests/events/test-console-debug.pl index eb6a774..f2057a6 100755 --- a/tests/events/test-console-debug.pl +++ b/tests/events/test-console-debug.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -22,8 +22,6 @@ use warnings; use Sys::Guestfs; -exit 77 if $ENV{SKIP_TEST_CONSOLE_DEBUG_PL}; - my $g = Sys::Guestfs->new (); my $log_messages = ""; diff --git a/tests/events/test-libvirt-auth-callbacks.c b/tests/events/test-libvirt-auth-callbacks.c index 383f20f..1447ce5 100644 --- a/tests/events/test-libvirt-auth-callbacks.c +++ b/tests/events/test-libvirt-auth-callbacks.c @@ -43,7 +43,7 @@ int main (int argc, char *argv[]) { unsigned long ver; - const char *srcdir; + const char *abs_srcdir; char *cwd; char *test_uri; @@ -59,13 +59,13 @@ main (int argc, char *argv[]) exit (77); } - /* $srcdir must have been passed (by automake). */ - srcdir = getenv ("srcdir"); - if (!srcdir) { + /* $abs_srcdir is passed by the test harness program. */ + abs_srcdir = getenv ("abs_srcdir"); + if (!abs_srcdir) { fprintf (stderr, - "%s: environment variable $srcdir is not defined.\n" + "%s: environment variable $abs_srcdir is not defined.\n" "Normally it is defined by automake. If you are running the\n" - "tests directly, set $srcdir to point to the source tests/events\n" + "tests directly, set $abs_srcdir to point to the source tests/events\n" "directory.\n", argv[0]); exit (EXIT_FAILURE); } @@ -76,7 +76,7 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - if (asprintf (&test_uri, "test://%s/%s/libvirt-auth.xml", cwd, srcdir) == -1) { + if (asprintf (&test_uri, "test://%s/libvirt-auth.xml", abs_srcdir) == -1) { perror ("asprintf"); exit (EXIT_FAILURE); } diff --git a/tests/events/tests.mk b/tests/events/tests.mk new file mode 100644 index 0000000..df36a2d --- /dev/null +++ b/tests/events/tests.mk @@ -0,0 +1,69 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/events + +localtests_DATA = \ + libvirt-auth.xml + +localtests_SCRIPTS = \ + test-console-debug.pl + +localtests_PROGRAMS = \ + test-libvirt-auth-callbacks + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/tests/fuzz/Makefile.am b/tests/fuzz/Makefile.am index 67793d5..facd40b 100644 --- a/tests/fuzz/Makefile.am +++ b/tests/fuzz/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,15 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -EXTRA_DIST = \ - $(TESTS) +generator_built = tests.mk -export ITERATIONS ?= 10 +EXTRA_DIST = fuzz-inspection.pl -TESTS = \ - fuzz-inspection.pl - -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) - -check-valgrind: - $(MAKE) VG="@VG@" check +include $(srcdir)/tests.mk diff --git a/tests/fuzz/fuzz-inspection.pl b/tests/fuzz/fuzz-inspection.pl index 9fcd98e..c651ca9 100755 --- a/tests/fuzz/fuzz-inspection.pl +++ b/tests/fuzz/fuzz-inspection.pl @@ -33,19 +33,14 @@ $progname =~ s{.*/}{}; my $trace_depth = 0; -my $srcdir = $ENV{srcdir} || "."; +my $srcdir = $ENV{srcdir}; # Location of tests/data. -my $datasrcdir = $srcdir . "/../data"; -my $databindir = "../data"; +my $datasrcdir = $ENV{datadir}; +my $databindir = $ENV{datadir}; # Location of tests/guests/guest-aux. my $guestauxsrcdir = $srcdir . "/../guests/guest-aux"; my $guestauxbindir = "../guests/guest-aux"; -if ($ENV{SKIP_FUZZ_INSPECTION_PL}) { - print "$progname: test skipped because environment variable set\n"; - exit 77 -} - # So srand returns the seed. if ($] < 5.014) { print "$progname: test skipped because perl < 5.14\n"; diff --git a/tests/fuzz/tests.mk b/tests/fuzz/tests.mk new file mode 100644 index 0000000..c85f1e8 --- /dev/null +++ b/tests/fuzz/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/fuzz + +localtests_SCRIPTS = \ + fuzz-inspection.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/hotplug/Makefile.am b/tests/hotplug/Makefile.am index 9187c76..7f687a5 100644 --- a/tests/hotplug/Makefile.am +++ b/tests/hotplug/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,12 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-hot-add.pl \ - test-hot-remove.pl - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ - $(TESTS) \ + test-hot-add.pl \ + test-hot-remove.pl \ test-hotplug-repeated.pl + +include $(srcdir)/tests.mk diff --git a/tests/hotplug/test-hot-add.pl b/tests/hotplug/test-hot-add.pl index 034cff4..07701e3 100755 --- a/tests/hotplug/test-hot-add.pl +++ b/tests/hotplug/test-hot-add.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -24,8 +24,6 @@ use Sys::Guestfs; my $g = Sys::Guestfs->new (); -exit 77 if $ENV{SKIP_TEST_HOT_ADD_PL}; - # Skip the test if the default backend isn't libvirt, since only # the libvirt backend supports hotplugging. my $backend = $g->get_backend (); diff --git a/tests/hotplug/test-hot-remove.pl b/tests/hotplug/test-hot-remove.pl index 087399d..c2fc404 100755 --- a/tests/hotplug/test-hot-remove.pl +++ b/tests/hotplug/test-hot-remove.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -24,8 +24,6 @@ use Sys::Guestfs; my $g = Sys::Guestfs->new (); -exit 77 if $ENV{SKIP_TEST_HOT_REMOVE_PL}; - # Skip the test if the default backend isn't libvirt, since only # the libvirt backend supports hotplugging. my $backend = $g->get_backend (); diff --git a/tests/hotplug/tests.mk b/tests/hotplug/tests.mk new file mode 100644 index 0000000..8ccb901 --- /dev/null +++ b/tests/hotplug/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/hotplug + +localtests_SCRIPTS = \ + test-hot-add.pl \ + test-hot-remove.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/journal/Makefile.am b/tests/journal/Makefile.am index ffdf5fe..c71e300 100644 --- a/tests/journal/Makefile.am +++ b/tests/journal/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-journal.pl +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-journal.pl -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/journal/test-journal.pl b/tests/journal/test-journal.pl index 38950f9..018523d 100755 --- a/tests/journal/test-journal.pl +++ b/tests/journal/test-journal.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -25,10 +25,8 @@ use warnings; use Sys::Guestfs; -exit 77 if $ENV{SKIP_TEST_JOURNAL_PL}; - my $g = Sys::Guestfs->new (); -$g->add_drive ("../guests/fedora.img", readonly => 1, format => "raw"); +$g->add_drive ("$ENV{phonydir}/fedora.img", readonly => 1, format => "raw"); $g->launch (); # If journal feature is not available, bail. diff --git a/tests/journal/tests.mk b/tests/journal/tests.mk new file mode 100644 index 0000000..7b8a7f3 --- /dev/null +++ b/tests/journal/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/journal + +localtests_SCRIPTS = \ + test-journal.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/luks/Makefile.am b/tests/luks/Makefile.am index 3d1fb67..08cf007 100644 --- a/tests/luks/Makefile.am +++ b/tests/luks/Makefile.am @@ -17,11 +17,10 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-luks.sh \ - test-luks-list.sh - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ - $(TESTS) + test-luks-list.sh \ + test-luks.sh + +include $(srcdir)/tests.mk diff --git a/tests/luks/test-luks-list.sh b/tests/luks/test-luks-list.sh index be22e8b..a420535 100755 --- a/tests/luks/test-luks-list.sh +++ b/tests/luks/test-luks-list.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -20,11 +20,6 @@ set -e -[ -n "$SKIP_TEST_LUKS_SH" ] && { - echo "test-luks-list.sh skipped (environment variable set)" - exit 77 -} - # If luks is not available, bail. if ! guestfish -a /dev/null run : available luks; then echo "$0: skipping test because luks is not available" diff --git a/tests/luks/test-luks.sh b/tests/luks/test-luks.sh index 2f65750..3b9dda4 100755 --- a/tests/luks/test-luks.sh +++ b/tests/luks/test-luks.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2010 Red Hat Inc. +# Copyright (C) 2010-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 @@ -20,11 +20,6 @@ set -e -[ -n "$SKIP_TEST_LUKS_SH" ] && { - echo "test-luks.sh skipped (environment variable set)" - exit 77 -} - # If luks is not available, bail. if ! guestfish -a /dev/null run : available luks; then echo "$0: skipping test because luks is not available" diff --git a/tests/luks/tests.mk b/tests/luks/tests.mk new file mode 100644 index 0000000..d370b99 --- /dev/null +++ b/tests/luks/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/luks + +localtests_SCRIPTS = \ + test-luks-list.sh \ + test-luks.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/lvm/Makefile.am b/tests/lvm/Makefile.am index 4c509f2..cc8c63e 100644 --- a/tests/lvm/Makefile.am +++ b/tests/lvm/Makefile.am @@ -17,11 +17,10 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ +generator_built = tests.mk + +EXTRA_DIST = \ test-lvm-filtering.sh \ test-lvm-mapping.pl -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/lvm/test-lvm-filtering.sh b/tests/lvm/test-lvm-filtering.sh index f00d712..b8acd34 100755 --- a/tests/lvm/test-lvm-filtering.sh +++ b/tests/lvm/test-lvm-filtering.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2010 Red Hat Inc. +# Copyright (C) 2010-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 @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_LVM_FILTERING_SH" ]; then - echo "$0: skipping test because environment variable is set." - exit 77 -fi - rm -f test-lvm-filtering-1.img test-lvm-filtering-2.img actual=$(guestfish <<'EOF' diff --git a/tests/lvm/tests.mk b/tests/lvm/tests.mk new file mode 100644 index 0000000..de3f4f0 --- /dev/null +++ b/tests/lvm/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/lvm + +localtests_SCRIPTS = \ + test-lvm-filtering.sh \ + test-lvm-mapping.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/md/Makefile.am b/tests/md/Makefile.am index e1f5e54..c03eec9 100644 --- a/tests/md/Makefile.am +++ b/tests/md/Makefile.am @@ -17,14 +17,13 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-inspect-fstab.sh \ +generator_built = tests.mk + +EXTRA_DIST = \ test-inspect-fstab-md.sh \ + test-inspect-fstab.sh \ test-list-filesystems.sh \ test-list-md-devices.sh \ test-mdadm.sh -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/md/test-inspect-fstab-md.sh b/tests/md/test-inspect-fstab-md.sh index 43e1d3a..72323f5 100755 --- a/tests/md/test-inspect-fstab-md.sh +++ b/tests/md/test-inspect-fstab-md.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -21,16 +21,11 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_INSPECT_FSTAB_MD_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f inspect-fstab-md-{1,2}.img inspect-fstab-md.fstab inspect-fstab-md.output # First, test the regular fedora image, which specifies /boot as /dev/md0 -cp ../guests/fedora-md1.img inspect-fstab-md-1.img -cp ../guests/fedora-md2.img inspect-fstab-md-2.img +cp $phonydir/fedora-md1.img inspect-fstab-md-1.img +cp $phonydir/fedora-md2.img inspect-fstab-md-2.img guestfish -i inspect-fstab-md-[12].img <<'EOF' | sort > inspect-fstab-md.output exists /boot/grub/grub.conf diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh index f31ec2e..ab65c12 100755 --- a/tests/md/test-inspect-fstab.sh +++ b/tests/md/test-inspect-fstab.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -35,7 +35,7 @@ rm -f inspect-fstab-1.qcow2 inspect-fstab.fstab inspect-fstab.output # and then inspect it. guestfish -- \ disk-create inspect-fstab-1.qcow2 qcow2 -1 \ - backingfile:../guests/fedora.img backingformat:raw + backingfile:$phonydir/fedora.img backingformat:raw cat <<'EOF' > inspect-fstab.fstab /dev/VG/Root / ext2 default 0 0 diff --git a/tests/md/test-list-filesystems.sh b/tests/md/test-list-filesystems.sh index 2bfa6f3..9e8544b 100755 --- a/tests/md/test-list-filesystems.sh +++ b/tests/md/test-list-filesystems.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_LIST_FILESYSTEMS_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f list-fs.output # Create 2 disks partitioned as: diff --git a/tests/md/test-list-md-devices.sh b/tests/md/test-list-md-devices.sh index 5a9cbe8..7cb2158 100755 --- a/tests/md/test-list-md-devices.sh +++ b/tests/md/test-list-md-devices.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_LIST_MD_DEVICES_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 0 -fi - output=$( guestfish <<EOF # Add 2 empty disks diff --git a/tests/md/test-mdadm.sh b/tests/md/test-mdadm.sh index 05b2432..071ee20 100755 --- a/tests/md/test-mdadm.sh +++ b/tests/md/test-mdadm.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_MDADM_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f mdadm-{1,2,3,4}.img guestfish <<EOF diff --git a/tests/md/tests.mk b/tests/md/tests.mk new file mode 100644 index 0000000..e6c395d --- /dev/null +++ b/tests/md/tests.mk @@ -0,0 +1,64 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/md + +localtests_SCRIPTS = \ + test-inspect-fstab-md.sh \ + test-inspect-fstab.sh \ + test-list-filesystems.sh \ + test-list-md-devices.sh \ + test-mdadm.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/mount-local/Makefile.am b/tests/mount-local/Makefile.am index 6ae4161..809019e 100644 --- a/tests/mount-local/Makefile.am +++ b/tests/mount-local/Makefile.am @@ -17,14 +17,14 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + +EXTRA_DIST + +include $(srcdir)/tests.mk + if HAVE_FUSE -TESTS = test-parallel-mount-local - -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) - -check_PROGRAMS = $(TESTS) - test_parallel_mount_local_SOURCES = \ test-parallel-mount-local.c \ ../../df/estimate-max-threads.c \ @@ -46,7 +46,8 @@ test_parallel_mount_local_LDADD = \ $(LIBVIRT_LIBS) \ $(top_builddir)/gnulib/lib/libgnu.la -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - +else +test-parallel-mount-local: + echo 'exit 77' > $@ + chmod +x $@ endif diff --git a/tests/mount-local/test-parallel-mount-local.c b/tests/mount-local/test-parallel-mount-local.c index 2032cbd..2f89dfe 100644 --- a/tests/mount-local/test-parallel-mount-local.c +++ b/tests/mount-local/test-parallel-mount-local.c @@ -63,6 +63,7 @@ static int guestunmount (const char *mp, unsigned flags); #define GUESTUNMOUNT_RMDIR 2 static volatile sig_atomic_t quit = 0; +static char *argv0 = NULL; static void catch_sigint (int signal) @@ -79,9 +80,9 @@ int main (int argc, char *argv[]) { size_t i; - char *skip; struct sigaction sa; int r, errors = 0; + const char *abs_builddir; void *status; srandom (time (NULL)); @@ -92,20 +93,28 @@ main (int argc, char *argv[]) exit (EXIT_SUCCESS); } - /* Allow the test to be skipped by setting an environment variable. */ - skip = getenv ("SKIP_TEST_PARALLEL_MOUNT_LOCAL"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - guestfs_int_program_name); - exit (77); - } - if (access ("/dev/fuse", W_OK) == -1) { fprintf (stderr, "%s: test skipped because /dev/fuse is not writable.\n", guestfs_int_program_name); exit (77); } + /* We need an absolute path to the current binary. The test harness + * passes $abs_builddir to us. + */ + abs_builddir = getenv ("abs_builddir"); + if (abs_builddir == NULL) { + fprintf (stderr, + "%s: $abs_builddir is not set.\n" + "Only run this program from the test harness.\n", + argv[0]); + exit (EXIT_FAILURE); + } + if (asprintf (&argv0, "%s/test-parallel-mount-local", abs_builddir) == -1) { + perror ("asprintf"); + exit (EXIT_FAILURE); + } + /* Choose the number of threads based on the amount of free memory. */ nr_threads = MIN (MAX_THREADS, estimate_max_threads ()); @@ -157,6 +166,8 @@ main (int argc, char *argv[]) cleanup_thread_state (); + free (argv0); + exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -217,9 +228,8 @@ start_thread (void *statevp) if (pid == 0) { /* child */ setpgid (0, 0); /* so we don't get ^C from parent */ - execlp ("./test-parallel-mount-local", - "test-parallel-mount-local", "--test", state->mp, NULL); - perror ("execlp"); + execlp (argv0, "test-parallel-mount-local", "--test", state->mp, NULL); + perror (argv0); goto error; } @@ -363,7 +373,7 @@ guestunmount (const char *mp, unsigned flags) } snprintf (cmd, sizeof cmd, - "../../fuse/guestunmount%s %s", + "guestunmount%s %s", (flags & GUESTUNMOUNT_SILENT) ? " --quiet" : "", mp); status = system (cmd); diff --git a/tests/mount-local/tests.mk b/tests/mount-local/tests.mk new file mode 100644 index 0000000..31f33ba --- /dev/null +++ b/tests/mount-local/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/mount-local + +localtests_PROGRAMS = \ + test-parallel-mount-local + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/mountable/Makefile.am b/tests/mountable/Makefile.am index 0e2cedd..c724b93 100644 --- a/tests/mountable/Makefile.am +++ b/tests/mountable/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,13 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -EXTRA_DIST = \ - test-mountable-inspect.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-mountable-inspect.sh -TESTS=test-internal-parse-mountable test-mountable-inspect.sh -check_PROGRAMS = test-internal-parse-mountable +include $(srcdir)/tests.mk test_internal_parse_mountable_SOURCES = test-internal-parse-mountable.c test_internal_parse_mountable_CPPFLAGS = \ diff --git a/tests/mountable/test-mountable-inspect.sh b/tests/mountable/test-mountable-inspect.sh index 3b81fd0..7ba42a5 100755 --- a/tests/mountable/test-mountable-inspect.sh +++ b/tests/mountable/test-mountable-inspect.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -22,11 +22,6 @@ export LANG=C canonical="sed s,/dev/vd,/dev/sd,g" # Allow the test to be skipped since btrfs is often broken. -if [ -n "$SKIP_TEST_MOUNTABLE_INSPECT_SH" ]; then - echo "$0: skipping test because environment variable is set." - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: skipping test because uml backend does not support qcow2" exit 77 @@ -44,7 +39,7 @@ rm -f root.tmp test.qcow2 test.output # and then inspect it. guestfish -- \ disk-create test.qcow2 qcow2 -1 \ - backingfile:../guests/fedora-btrfs.img backingformat:raw + backingfile:$phonydir/fedora-btrfs.img backingformat:raw # Test that basic inspection works and the expected filesystems are # found diff --git a/tests/mountable/tests.mk b/tests/mountable/tests.mk new file mode 100644 index 0000000..e9940ef --- /dev/null +++ b/tests/mountable/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/mountable + +localtests_SCRIPTS = \ + test-mountable-inspect.sh + +localtests_PROGRAMS = \ + test-internal-parse-mountable + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/nbd/Makefile.am b/tests/nbd/Makefile.am index 09d79c8..923f819 100644 --- a/tests/nbd/Makefile.am +++ b/tests/nbd/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-nbd.pl +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-nbd.pl -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/nbd/test-nbd.pl b/tests/nbd/test-nbd.pl index 6353b25..03bd18f 100755 --- a/tests/nbd/test-nbd.pl +++ b/tests/nbd/test-nbd.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -22,13 +22,11 @@ use POSIX qw(getcwd); use Sys::Guestfs; -my $disk = "../guests/fedora.img"; +my $disk = "$ENV{phonydir}/fedora.img"; my $pid = 0; END { kill 15, $pid if $pid > 0 }; -exit 77 if $ENV{SKIP_TEST_NBD_PL}; - if (Sys::Guestfs->new()->get_backend() eq "uml") { print "$0: test skipped because UML backend does not support NBD\n"; exit 77 diff --git a/tests/nbd/tests.mk b/tests/nbd/tests.mk new file mode 100644 index 0000000..33f87a9 --- /dev/null +++ b/tests/nbd/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/nbd + +localtests_SCRIPTS = \ + test-nbd.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/network/Makefile.am b/tests/network/Makefile.am index 2d47ca1..5fa75e2 100644 --- a/tests/network/Makefile.am +++ b/tests/network/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-network.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-network.sh -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/network/test-network.sh b/tests/network/test-network.sh index 51f3667..435840e 100755 --- a/tests/network/test-network.sh +++ b/tests/network/test-network.sh @@ -23,11 +23,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_NETWORK_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - backend="$(guestfish get-backend)" if [[ "$backend" =~ ^uml ]]; then echo "$0: test skipped because backend ($backend) is 'uml'." diff --git a/tests/network/tests.mk b/tests/network/tests.mk new file mode 100644 index 0000000..847a5b3 --- /dev/null +++ b/tests/network/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/network + +localtests_SCRIPTS = \ + test-network.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/ntfsclone/Makefile.am b/tests/ntfsclone/Makefile.am index 80795c5..e66af4c 100644 --- a/tests/ntfsclone/Makefile.am +++ b/tests/ntfsclone/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-ntfsclone.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-ntfsclone.sh -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/ntfsclone/test-ntfsclone.sh b/tests/ntfsclone/test-ntfsclone.sh index 30c21bf..f9271d4 100755 --- a/tests/ntfsclone/test-ntfsclone.sh +++ b/tests/ntfsclone/test-ntfsclone.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_NTFSCLONE_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2 # Skip if ntfs-3g is not supported by the appliance. @@ -33,13 +28,13 @@ if ! guestfish add /dev/null : run : available "ntfs3g"; then exit 77 fi -if [ ! -s ../guests/windows.img ]; then +if [ ! -s $phonydir/windows.img ]; then echo "$0: skipped because windows.img is zero-sized" exit 77 fi # Export the filesystems to the backup file. -guestfish --ro -a ../guests/windows.img <<EOF +guestfish --ro -a $phonydir/windows.img <<EOF run ntfsclone-out /dev/sda1 ntfsclone-backup1 preservetimestamps:true force:true ntfsclone-out /dev/sda2 ntfsclone-backup2 metadataonly:true ignorefscheck:true diff --git a/tests/ntfsclone/tests.mk b/tests/ntfsclone/tests.mk new file mode 100644 index 0000000..ac3fd37 --- /dev/null +++ b/tests/ntfsclone/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/ntfsclone + +localtests_SCRIPTS = \ + test-ntfsclone.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/parallel/Makefile.am b/tests/parallel/Makefile.am index 9421bfc..fc26bc3 100644 --- a/tests/parallel/Makefile.am +++ b/tests/parallel/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,13 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -# Don't run this test by default. However we have to have an empty -# TESTS rule otherwise you can't run the test from the command line -# using 'make TESTS=test-parallel check' -TESTS -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk -check_PROGRAMS = test-parallel +EXTRA_DIST + +include $(srcdir)/tests.mk test_parallel_SOURCES = test-parallel.c test_parallel_CPPFLAGS = \ @@ -37,9 +35,3 @@ test_parallel_LDADD = \ $(top_builddir)/src/libutils.la \ $(top_builddir)/src/libguestfs.la \ $(top_builddir)/gnulib/lib/libgnu.la - -#check-valgrind: -# $(MAKE) VG="$(top_builddir)/run @VG@" TESTS="test-parallel" check - -check-slow: - $(MAKE) TESTS="test-parallel" check diff --git a/tests/parallel/test-parallel.c b/tests/parallel/test-parallel.c index d018ec7..4cd9d73 100644 --- a/tests/parallel/test-parallel.c +++ b/tests/parallel/test-parallel.c @@ -1,5 +1,5 @@ /* libguestfs - * Copyright (C) 2012 Red Hat Inc. + * Copyright (C) 2012-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 @@ -66,7 +66,6 @@ catch_sigint (int signal) int main (int argc, char *argv[]) { - char *skip; struct sigaction sa; int r; size_t i, errors = 0; @@ -74,14 +73,6 @@ main (int argc, char *argv[]) srandom (time (NULL)); - /* Allow the test to be skipped by setting an environment variable. */ - skip = getenv ("SKIP_TEST_PARALLEL"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - guestfs_int_program_name); - exit (77); - } - memset (&sa, 0, sizeof sa); sa.sa_handler = catch_sigint; sa.sa_flags = SA_RESTART; diff --git a/tests/parallel/tests.mk b/tests/parallel/tests.mk new file mode 100644 index 0000000..803a2c4 --- /dev/null +++ b/tests/parallel/tests.mk @@ -0,0 +1,30 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/parallel + +localtests_PROGRAMS = \ + test-parallel + +check-slow: + $(top_builddir)/run $(top_builddir)/test-harness --slow + +EXTRA_DIST += tests.mk diff --git a/tests/protocol/Makefile.am b/tests/protocol/Makefile.am index 27e64c1..f6b847c 100644 --- a/tests/protocol/Makefile.am +++ b/tests/protocol/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-both-ends-cancel.sh \ test-cancellation-download-librarycancels.sh \ @@ -26,19 +28,7 @@ EXTRA_DIST = \ test-qemudie-midcommand.sh \ test-qemudie-synch.sh -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS = \ - test-both-ends-cancel.sh \ - test-cancellation-download-librarycancels.sh \ - test-cancellation-upload-daemoncancels.sh \ - test-error-messages \ - test-launch-race.pl \ - test-qemudie-killsub.sh \ - test-qemudie-midcommand.sh \ - test-qemudie-synch.sh - -check_PROGRAMS = test-error-messages +include $(srcdir)/tests.mk test_error_messages_SOURCES = \ test-error-messages.c diff --git a/tests/protocol/tests.mk b/tests/protocol/tests.mk new file mode 100644 index 0000000..c15a3d0 --- /dev/null +++ b/tests/protocol/tests.mk @@ -0,0 +1,69 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/protocol + +localtests_SCRIPTS = \ + test-both-ends-cancel.sh \ + test-cancellation-download-librarycancels.sh \ + test-cancellation-upload-daemoncancels.sh \ + test-launch-race.pl \ + test-qemudie-killsub.sh \ + test-qemudie-midcommand.sh \ + test-qemudie-synch.sh + +localtests_PROGRAMS = \ + test-error-messages + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/qemu/Makefile.am b/tests/qemu/Makefile.am index 478b3f1..707e303 100644 --- a/tests/qemu/Makefile.am +++ b/tests/qemu/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -21,23 +21,17 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - qemu-liveness.sh \ - qemu-snapshot-isolation.sh \ - qemu-force-tcg.sh - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ - $(TESTS) \ guestfs-md5.sh \ + qemu-liveness.sh \ + qemu-snapshot-isolation.sh \ + qemu-force-tcg.sh \ qemu-boot.c \ qemu-speed-test.c -# qemu-boot & qemu-speed-test are built but not run by default as they -# are mainly qemu & kernel diagnostic tools. - -check_PROGRAMS = qemu-boot qemu-speed-test +include $(srcdir)/tests.mk qemu_boot_SOURCES = \ ../../df/estimate-max-threads.c \ diff --git a/tests/qemu/qemu-force-tcg.sh b/tests/qemu/qemu-force-tcg.sh index 79b32b7..28ce470 100755 --- a/tests/qemu/qemu-force-tcg.sh +++ b/tests/qemu/qemu-force-tcg.sh @@ -18,11 +18,6 @@ # Check force_tcg really forces TCG mode. -if [ -n "$SKIP_QEMU_FORCE_TCG_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - # Only applicable to the direct and libvirt backends: if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: skipping test because it is only applicable when qemu is being used." diff --git a/tests/qemu/tests.mk b/tests/qemu/tests.mk new file mode 100644 index 0000000..abd2ed3 --- /dev/null +++ b/tests/qemu/tests.mk @@ -0,0 +1,67 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/qemu + +localtests_SCRIPTS = \ + guestfs-md5.sh \ + qemu-force-tcg.sh \ + qemu-liveness.sh \ + qemu-snapshot-isolation.sh + +localtests_PROGRAMS = \ + qemu-boot \ + qemu-speed-test + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/relative-paths/Makefile.am b/tests/relative-paths/Makefile.am index beb60d9..90bf40f 100644 --- a/tests/relative-paths/Makefile.am +++ b/tests/relative-paths/Makefile.am @@ -25,13 +25,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-relative-paths.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-relative-paths.sh -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/relative-paths/test-relative-paths.sh b/tests/relative-paths/test-relative-paths.sh index 4924cc3..37082c1 100755 --- a/tests/relative-paths/test-relative-paths.sh +++ b/tests/relative-paths/test-relative-paths.sh @@ -18,11 +18,6 @@ set -e -if [ -n "$SKIP_TEST_RELATIVE_PATHS_SH" ]; then - echo "$0: skipped (environment variable set)" - exit 77 -fi - # UML doesn't support qcow2. Conceivably there might be a similar # problem with UML COW images which would require a separate test. if [ "$(guestfish get-backend)" = "uml" ]; then @@ -50,7 +45,8 @@ qemu-img create -f qcow2 backing3 10M qemu-img create -f qcow2 -b ./backing3 overlay3 qemu-img create -f qcow2 backing4 10M -qemu-img create -f qcow2 -b ../../tests/relative-paths/backing4 overlay4 +b="$(basename $(pwd))" +qemu-img create -f qcow2 -b ../$b/backing4 overlay4 qemu-img create -f qcow2 backing5 10M pushd dir1 diff --git a/tests/relative-paths/tests.mk b/tests/relative-paths/tests.mk new file mode 100644 index 0000000..483d39e --- /dev/null +++ b/tests/relative-paths/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/relative-paths + +localtests_SCRIPTS = \ + test-relative-paths.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/rsync/Makefile.am b/tests/rsync/Makefile.am index b548d91..31b5941 100644 --- a/tests/rsync/Makefile.am +++ b/tests/rsync/Makefile.am @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-rsync.sh +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-rsync.sh -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/rsync/test-rsync.sh b/tests/rsync/test-rsync.sh index 53fcab8..894987d 100755 --- a/tests/rsync/test-rsync.sh +++ b/tests/rsync/test-rsync.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -22,11 +22,6 @@ unset CDPATH set -e -if [ -n "$SKIP_TEST_RSYNC_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - # Check we have the rsync command. if ! rsync --help >/dev/null 2>&1; then echo "$0: skipping test because local rsync command is not available" @@ -68,7 +63,6 @@ if ! guestfish -a /dev/null run : available rsync; then fi pwd="$(pwd)" -datadir="$(cd ../../tests/data && pwd)" rm -rf tmp mkdir tmp diff --git a/tests/rsync/tests.mk b/tests/rsync/tests.mk new file mode 100644 index 0000000..90b806b --- /dev/null +++ b/tests/rsync/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/rsync + +localtests_SCRIPTS = \ + test-rsync.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/selinux/Makefile.am b/tests/selinux/Makefile.am index 71943b2..9525d81 100644 --- a/tests/selinux/Makefile.am +++ b/tests/selinux/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -20,21 +20,13 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-xattrs-direct.sh \ - test-selinux-direct.sh - -if HAVE_FUSE -TESTS += \ - test-xattrs-fuse.sh \ - test-selinux-fuse.sh -endif - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ run-test.pl \ test-xattrs-direct.sh \ - test-xattrs-fuse.sh \ test-selinux-direct.sh \ + test-xattrs-fuse.sh \ test-selinux-fuse.sh + +include $(srcdir)/tests.mk diff --git a/tests/selinux/run-test.pl b/tests/selinux/run-test.pl index 89846ae..38cca6a 100755 --- a/tests/selinux/run-test.pl +++ b/tests/selinux/run-test.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -49,12 +49,6 @@ die unless $test_type eq "xattrs" || $test_type eq "selinux"; my $test_via = $ARGV[1]; die unless $test_via eq "direct" || $test_via eq "fuse"; -my $env_name = "SKIP_TEST_SELINUX_" . uc ($test_type) . "_" . uc ($test_via); -if ($ENV{$env_name}) { - print "$prog $test_type $test_via: test skipped because $env_name is set.\n"; - exit 77 -} - # SELinux labelling won't work (and can be skipped) if SELinux isn't # installed or isn't enabled on the host. if ($test_type eq "selinux") { @@ -170,7 +164,7 @@ sub run_fuse_tests } # Unmount the test directory. - if (system ("../../fuse/guestunmount", $mpdir) != 0) { + if (system ("guestunmount", $mpdir) != 0) { die "failed to unmount FUSE directory\n"; } diff --git a/tests/selinux/tests.mk b/tests/selinux/tests.mk new file mode 100644 index 0000000..7d6b9f5 --- /dev/null +++ b/tests/selinux/tests.mk @@ -0,0 +1,64 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/selinux + +localtests_SCRIPTS = \ + run-test.pl \ + test-selinux-direct.sh \ + test-selinux-fuse.sh \ + test-xattrs-direct.sh \ + test-xattrs-fuse.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/syslinux/Makefile.am b/tests/syslinux/Makefile.am index bb9a024..86567e3 100644 --- a/tests/syslinux/Makefile.am +++ b/tests/syslinux/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,14 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-syslinux.sh \ - test-extlinux.sh - -TESTS_ENVIRONMENT = $(top_builddir)/run --test +generator_built = tests.mk EXTRA_DIST = \ - $(TESTS) \ + test-syslinux.sh \ + test-extlinux.sh \ test-syslinux.pl -CLEANFILES = syslinux-guest.img extlinux-guest.img +include $(srcdir)/tests.mk diff --git a/tests/syslinux/test-syslinux.pl b/tests/syslinux/test-syslinux.pl index cea0e54..67830c0 100755 --- a/tests/syslinux/test-syslinux.pl +++ b/tests/syslinux/test-syslinux.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -22,8 +22,6 @@ use warnings; use Sys::Guestfs; -exit 77 if $ENV{SKIP_TEST_SYSLINUX_PL}; - my $bootloader = $ENV{BOOTLOADER} || "syslinux"; my $disk = "$bootloader-guest.img"; diff --git a/tests/syslinux/tests.mk b/tests/syslinux/tests.mk new file mode 100644 index 0000000..bb69c97 --- /dev/null +++ b/tests/syslinux/tests.mk @@ -0,0 +1,62 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/syslinux + +localtests_SCRIPTS = \ + test-extlinux.sh \ + test-syslinux.pl \ + test-syslinux.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/tmpdirs/Makefile.am b/tests/tmpdirs/Makefile.am index 32fd632..c433d00 100644 --- a/tests/tmpdirs/Makefile.am +++ b/tests/tmpdirs/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-tmpdirs.pl +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-tmpdirs.pl -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/tmpdirs/tests.mk b/tests/tmpdirs/tests.mk new file mode 100644 index 0000000..4ede29b --- /dev/null +++ b/tests/tmpdirs/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/tmpdirs + +localtests_SCRIPTS = \ + test-tmpdirs.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/tests/xfs/Makefile.am b/tests/xfs/Makefile.am index fbe0e15..446837c 100644 --- a/tests/xfs/Makefile.am +++ b/tests/xfs/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -17,10 +17,8 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-xfs-misc.pl +generator_built = tests.mk -TESTS_ENVIRONMENT = $(top_builddir)/run --test +EXTRA_DIST = test-xfs-misc.pl -EXTRA_DIST = \ - $(TESTS) +include $(srcdir)/tests.mk diff --git a/tests/xfs/test-xfs-misc.pl b/tests/xfs/test-xfs-misc.pl index 1d09474..07da0df 100755 --- a/tests/xfs/test-xfs-misc.pl +++ b/tests/xfs/test-xfs-misc.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -23,8 +23,6 @@ use warnings; use Sys::Guestfs; -exit 77 if $ENV{SKIP_TEST_XFS_MISC_PL}; - my $g = Sys::Guestfs->new (); $g->add_drive_scratch (1024*1024*1024); diff --git a/tests/xfs/tests.mk b/tests/xfs/tests.mk new file mode 100644 index 0000000..9b05c7b --- /dev/null +++ b/tests/xfs/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/xfs + +localtests_SCRIPTS = \ + test-xfs-misc.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/tests/xml/Makefile.am b/tests/xml/Makefile.am index aa57619..86fe077 100644 --- a/tests/xml/Makefile.am +++ b/tests/xml/Makefile.am @@ -1,5 +1,5 @@ # libguestfs -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -17,30 +17,23 @@ include $(top_srcdir)/subdir-rules.mk -if HAVE_LIBVIRT +generator_built = tests.mk + +EXTRA_DIST = \ + rhbz701814.pl \ + rhbz701814.sh \ + rhbz701814-faked.xml \ + rhbz701814-node.xml + +include $(srcdir)/tests.mk # This LD_PRELOAD library can be used to precisely control the XML # returned by libvirt. -check_LTLIBRARIES = libfakevirtxml.la +localtests_LTLIBRARIES = libfakevirtxml.la libfakevirtxml_la_SOURCES = fake-libvirt-xml.c libfakevirtxml_la_CFLAGS = $(LIBVIRT_CFLAGS) # -version-info and -rpath force libtool to build a shared library. libfakevirtxml_la_LDFLAGS = -version-info 0:0:0 -rpath /nowhere -TESTS_ENVIRONMENT = \ - abs_srcdir=$(abs_srcdir) \ - LD_PRELOAD=.libs/libfakevirtxml.so \ - $(top_builddir)/run --test - -TESTS = \ - rhbz701814.pl - -endif - -EXTRA_DIST = \ - rhbz701814.pl \ - rhbz701814-faked.xml \ - rhbz701814-node.xml - CLEANFILES = *~ diff --git a/tests/xml/rhbz701814.pl b/tests/xml/rhbz701814.pl index 01fa128..9e03029 100755 --- a/tests/xml/rhbz701814.pl +++ b/tests/xml/rhbz701814.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright (C) 2012 Red Hat Inc. +# Copyright (C) 2012-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 @@ -25,8 +25,8 @@ use Sys::Guestfs; my $srcdir = $ENV{srcdir}; die "\$srcdir environment variable is not set" unless defined $srcdir; $ENV{FAKE_LIBVIRT_XML} = "$srcdir/rhbz701814-faked.xml"; + my $abs_srcdir = $ENV{abs_srcdir}; - my $uri = "test://$abs_srcdir/rhbz701814-node.xml"; my $g = Sys::Guestfs->new (); diff --git a/tests/xml/rhbz701814.sh b/tests/xml/rhbz701814.sh new file mode 100755 index 0000000..cbedafa --- /dev/null +++ b/tests/xml/rhbz701814.sh @@ -0,0 +1,22 @@ +#!/bin/sh - +# 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. + +# Regression test for: +# https://bugzilla.redhat.com/show_bug.cgi?id=701814 + +LD_PRELOAD=.libs/libfakevirtxml.so \ +exec $srcdir/rhbz701814.pl diff --git a/tests/xml/tests.mk b/tests/xml/tests.mk new file mode 100644 index 0000000..3b01551 --- /dev/null +++ b/tests/xml/tests.mk @@ -0,0 +1,68 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/xml + +localtests_DATA = \ + rhbz701814-faked.xml \ + rhbz701814-node.xml + +localtests_SCRIPTS = \ + rhbz701814.pl \ + rhbz701814.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 04/17] tests/regressions: Convert the regression tests to use the test harness.
--- generator/tests.ml | 40 ++++++++++++++ tests/regressions/Makefile.am | 48 ++--------------- tests/regressions/rhbz1001875.sh | 7 +-- tests/regressions/rhbz1044014.sh | 11 ++-- tests/regressions/rhbz1054761.sh | 5 -- tests/regressions/rhbz1091803.sh | 5 -- tests/regressions/rhbz563450.sh | 8 +-- tests/regressions/rhbz563450b.sh | 6 +-- tests/regressions/rhbz690819.sh | 7 +-- tests/regressions/rhbz789960.sh | 2 +- tests/regressions/rhbz914931.c | 11 +--- tests/regressions/test-noexec-stack.pl | 48 ++++++++--------- tests/regressions/tests.mk | 97 ++++++++++++++++++++++++++++++++++ 13 files changed, 177 insertions(+), 118 deletions(-) create mode 100644 tests/regressions/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index a8d2fb0..54343ea 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -341,6 +341,46 @@ let tests = [ ]; }; + "tests/regressions", { + defaults with + check_fast = [ + "rhbz501893"; + "rhbz1055452"; + "rhbz1175196.sh"; + ]; + check = [ + "rhbz503169c13.sh"; + "rhbz557655.sh"; + "rhbz563450.sh"; + "rhbz563450b.sh"; + "rhbz576879.sh"; + "rhbz578407.sh"; + "rhbz580246.sh"; + "rhbz602997.sh"; + "rhbz690819.sh"; + "rhbz789960.sh"; + "rhbz790721"; + "rhbz811649.sh"; + "rhbz895904.sh"; + "rhbz914931"; + "rhbz957772.sh"; + "rhbz975797.sh"; + "rhbz1001875.sh"; + "rhbz1044014.sh"; + "rhbz1054761.sh"; + "rhbz1091803.sh"; + "rhbz1232192.sh"; + "test-noexec-stack.pl"; + ]; + check_slow = [ + "rhbz909624.sh" + ]; + check_data = [ + "rhbz557655-expected.stderr"; + "rhbz557655-expected.stdout"; + ]; + }; + "inspector", { defaults with check = [ diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index 74f23dd..c33cd2c 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ rhbz503169c13.sh \ rhbz557655.sh \ @@ -47,49 +49,12 @@ EXTRA_DIST = \ rhbz1232192.xml \ test-noexec-stack.pl -TESTS = \ - rhbz501893 \ - rhbz503169c13.sh \ - rhbz557655.sh \ - rhbz563450.sh \ - rhbz563450b.sh \ - rhbz576879.sh \ - rhbz578407.sh \ - rhbz580246.sh \ - rhbz602997.sh \ - rhbz690819.sh \ - rhbz789960.sh \ - rhbz790721 \ - rhbz811649.sh \ - rhbz895904.sh \ - rhbz914931 \ - rhbz957772.sh \ - rhbz975797.sh \ - rhbz1001875.sh \ - rhbz1054761.sh \ - rhbz1055452 \ - rhbz1091803.sh \ - rhbz1175196.sh \ - rhbz1232192.sh \ - test-noexec-stack.pl - -if HAVE_LIBVIRT -TESTS += rhbz1044014.sh -endif - -tests_not_run = \ +# There are a couple of tests that we don't run: +EXTRA_DIST += \ rhbz727178.sh \ rhbz909624.sh -TESTS_ENVIRONMENT = \ - NOEXEC_CHECK="$(top_builddir)/src/.libs/libguestfs.so $(top_builddir)/daemon/guestfsd" \ - $(top_builddir)/run --test - -check_PROGRAMS = \ - rhbz501893 \ - rhbz790721 \ - rhbz914931 \ - rhbz1055452 +include $(srcdir)/tests.mk rhbz501893_SOURCES = rhbz501893.c rhbz501893_CPPFLAGS = \ @@ -129,6 +94,3 @@ rhbz1055452_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) rhbz1055452_LDADD = \ $(top_builddir)/src/libguestfs.la - -check-slow: - $(MAKE) TESTS="rhbz909624.sh" check diff --git a/tests/regressions/rhbz1001875.sh b/tests/regressions/rhbz1001875.sh index 885fd8c..6812333 100755 --- a/tests/regressions/rhbz1001875.sh +++ b/tests/regressions/rhbz1001875.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -23,11 +23,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_RHBZ1001875_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f rhbz1001875.img rhbz1001875-[123].tar guestfish -N rhbz1001875.img=fs -m /dev/sda1 <<EOF diff --git a/tests/regressions/rhbz1044014.sh b/tests/regressions/rhbz1044014.sh index 8e0df2a..6a718bb 100755 --- a/tests/regressions/rhbz1044014.sh +++ b/tests/regressions/rhbz1044014.sh @@ -22,11 +22,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_RHBZ1044014_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - # Check we are running against the libvirt backend. backend="$(guestfish get-backend)" if [[ ! ( "$backend" =~ ^libvirt ) ]]; then @@ -34,18 +29,18 @@ if [[ ! ( "$backend" =~ ^libvirt ) ]]; then exit 77 fi -if [ ! -x ../../src/libvirt-is-version ]; then +if [ ! -x $top_builddir/src/libvirt-is-version ]; then echo "$0: test skipped because libvirt-is-version is not built yet" exit 77 fi -if ! ../../src/libvirt-is-version 1 2 1; then +if ! $top_builddir/src/libvirt-is-version 1 2 1; then echo "$0: test skipped because libvirt is too old (< 1.2.1)" exit 77 fi # Set the backend to the test driver. -export LIBGUESTFS_BACKEND="libvirt:test://$(pwd)/$srcdir/rhbz1044014.xml" +export LIBGUESTFS_BACKEND="libvirt:test://$abs_srcdir/rhbz1044014.xml" rm -f rhbz1044014.out diff --git a/tests/regressions/rhbz1054761.sh b/tests/regressions/rhbz1054761.sh index 344479d..c37e237 100755 --- a/tests/regressions/rhbz1054761.sh +++ b/tests/regressions/rhbz1054761.sh @@ -23,11 +23,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_RHBZ1054761_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f rhbz1054761-[ab].img guestfish -N rhbz1054761-a.img=disk -N rhbz1054761-b.img=disk <<EOF diff --git a/tests/regressions/rhbz1091803.sh b/tests/regressions/rhbz1091803.sh index 6851a1c..2e4d373 100755 --- a/tests/regressions/rhbz1091803.sh +++ b/tests/regressions/rhbz1091803.sh @@ -23,11 +23,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_RHBZ1091803_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - guestfish <<EOF scratch 100M run diff --git a/tests/regressions/rhbz563450.sh b/tests/regressions/rhbz563450.sh index d7cf751..adf1df4 100755 --- a/tests/regressions/rhbz563450.sh +++ b/tests/regressions/rhbz563450.sh @@ -22,7 +22,7 @@ set -e export LANG=C -if [ ! -s ../guests/fedora.img -o ! -s ../data/test.iso -o ! -s ../guests/debian.img ]; then +if [ ! -s $phonydir/fedora.img -o ! -s $datadir/test.iso -o ! -s $phonydir/debian.img ]; then echo "$0: test skipped because there is no fedora.img nor test.iso nor debian.img" exit 77 fi @@ -30,9 +30,9 @@ fi rm -f test.out guestfish --ro > test.out <<EOF -add-drive-ro ../guests/fedora.img -add-cdrom ../data/test.iso -add-drive-ro ../guests/debian.img +add-drive-ro $phonydir/fedora.img +add-cdrom $datadir/test.iso +add-drive-ro $phonydir/debian.img run diff --git a/tests/regressions/rhbz563450b.sh b/tests/regressions/rhbz563450b.sh index 26aaf6f..eb91a38 100755 --- a/tests/regressions/rhbz563450b.sh +++ b/tests/regressions/rhbz563450b.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2013 Red Hat Inc. +# Copyright (C) 2013-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 @@ -22,7 +22,7 @@ set -e export LANG=C -if [ ! -s ../data/test.iso ]; then +if [ ! -s $datadir/test.iso ]; then echo "$0: test skipped because there is no test.iso" exit 77 fi @@ -30,7 +30,7 @@ fi rm -f test.out guestfish --ro > test.out <<EOF -add-cdrom ../data/test.iso +add-cdrom $datadir/test.iso run diff --git a/tests/regressions/rhbz690819.sh b/tests/regressions/rhbz690819.sh index 0af0b64..5b785d7 100755 --- a/tests/regressions/rhbz690819.sh +++ b/tests/regressions/rhbz690819.sh @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2011 Red Hat Inc. +# Copyright (C) 2011-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 @@ -23,11 +23,6 @@ set -e export LANG=C -if [ -n "$SKIP_TEST_RHBZ690819_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - arch="$(uname -m)" if [[ "$arch" =~ ^arm || "$arch" = "aarch64" ]]; then echo "$0: test skipped because ARM does not support 'ide' interface." diff --git a/tests/regressions/rhbz789960.sh b/tests/regressions/rhbz789960.sh index 056b7ed..9888a17 100755 --- a/tests/regressions/rhbz789960.sh +++ b/tests/regressions/rhbz789960.sh @@ -24,7 +24,7 @@ export LANG=C rm -f test.out -guestfish -a ../guests/fedora.img --ro > test.out <<EOF +guestfish -a $phonydir/fedora.img --ro > test.out <<EOF run # Not a device at all, should fail. diff --git a/tests/regressions/rhbz914931.c b/tests/regressions/rhbz914931.c index bce2924..bd1812b 100644 --- a/tests/regressions/rhbz914931.c +++ b/tests/regressions/rhbz914931.c @@ -1,5 +1,5 @@ /* libguestfs - * Copyright (C) 2013 Red Hat Inc. + * Copyright (C) 2013-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 @@ -37,15 +37,6 @@ main (int argc, char *argv[]) { guestfs_h *g; int r; - char *str; - - /* Allow this test to be skipped. */ - str = getenv ("SKIP_TEST_RHBZ914931"); - if (str && guestfs_int_is_true (str) > 0) { - printf ("%s: test skipped because environment variable is set.\n", - guestfs_int_program_name); - exit (77); - } g = guestfs_create (); if (!g) { diff --git a/tests/regressions/test-noexec-stack.pl b/tests/regressions/test-noexec-stack.pl index 68bbb0b..e54b1df 100755 --- a/tests/regressions/test-noexec-stack.pl +++ b/tests/regressions/test-noexec-stack.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. +# Copyright (C) 2009-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 @@ -18,67 +18,61 @@ use strict; use warnings; -if ($ENV{SKIP_TEST_NOEXEC_STACK_PL}) { - print "$0: skipped test because environment variable is set\n"; - exit 77; -} - -die("NOEXEC_CHECK not set") unless(exists($ENV{NOEXEC_CHECK})); - -my @files = split(/ /, $ENV{NOEXEC_CHECK}); +my @files = ( "$ENV{top_builddir}/src/.libs/libguestfs.so", + "$ENV{top_builddir}/daemon/guestfsd" ); FILES: foreach my $file (@files) { my $output; my @cmd = ('readelf', '-l', $file); - open($output, '-|', @cmd) - or die("$0: failed to run: '".join(' ', @cmd)."': $!\n"); + open ($output, '-|', @cmd) + or die ("$0: failed to run: '".join(' ', @cmd)."': $!\n"); my $offset; my $line = 1; # Find the offset of the Flags field - while(<$output>) { - next unless(/^\s*Type\b/); + while (<$output>) { + next unless /^\s*Type\b/; my @lines; - push(@lines, $_); + push (@lines, $_); # Look for a Flg field on this line (32 bit) - $offset = index($_, 'Flg '); + $offset = index ($_, 'Flg '); - if(-1 == $offset) { + if (-1 == $offset) { # 64 bit is split over 2 lines. Look for a Flags field on the next # line $_ = <$output>; - $offset = index($_, 'Flags '); + $offset = index ($_, 'Flags '); $line = 2; - push(@lines, $_); + push (@lines, $_); } - die("Unrecognised header: ".join("\n", @lines)) if(-1 == $offset); + die "Unrecognised header: ".join("\n", @lines) if -1 == $offset; last; } # Find the GNU_STACK entry - while(<$output>) { - next unless(/^\s*GNU_STACK\b/); + while (<$output>) { + next unless /^\s*GNU_STACK\b/; # Skip over input lines according to the header - for(my $i = 1; $i < $line; $i++) { + for (my $i = 1; $i < $line; $i++) { $_ = <$output>; } - my $flags = substr($_, $offset, 3); + my $flags = substr ($_, $offset, 3); - $flags =~ /^[ R][ W]([ E])$/ or die("Unrecognised flags: $flags"); + $flags =~ /^[ R][ W]([ E])$/ or die "Unrecognised flags: $flags"; - if('E' eq $1) { + if ('E' eq $1) { print "***** $file has an executable stack *****\n"; - exit(1); + exit 1; } next FILES; } - die("Didn't find GNU_STACK entry"); + die "Didn't find GNU_STACK entry"; } diff --git a/tests/regressions/tests.mk b/tests/regressions/tests.mk new file mode 100644 index 0000000..d582b91 --- /dev/null +++ b/tests/regressions/tests.mk @@ -0,0 +1,97 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tests/regressions + +localtests_DATA = \ + rhbz557655-expected.stderr \ + rhbz557655-expected.stdout + +localtests_SCRIPTS = \ + rhbz1001875.sh \ + rhbz1044014.sh \ + rhbz1054761.sh \ + rhbz1091803.sh \ + rhbz1175196.sh \ + rhbz1232192.sh \ + rhbz503169c13.sh \ + rhbz557655.sh \ + rhbz563450.sh \ + rhbz563450b.sh \ + rhbz576879.sh \ + rhbz578407.sh \ + rhbz580246.sh \ + rhbz602997.sh \ + rhbz690819.sh \ + rhbz789960.sh \ + rhbz811649.sh \ + rhbz895904.sh \ + rhbz909624.sh \ + rhbz957772.sh \ + rhbz975797.sh \ + test-noexec-stack.pl + +localtests_PROGRAMS = \ + rhbz1055452 \ + rhbz501893 \ + rhbz790721 \ + rhbz914931 + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +check-slow: + $(top_builddir)/run $(top_builddir)/test-harness --slow + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 05/17] tests/regressions: Remove executable stack test.
It's not our job to worry about downstream packaging issues ... --- generator/tests.ml | 1 - tests/regressions/Makefile.am | 3 +- tests/regressions/test-noexec-stack.pl | 78 ---------------------------------- tests/regressions/tests.mk | 3 +- 4 files changed, 2 insertions(+), 83 deletions(-) delete mode 100755 tests/regressions/test-noexec-stack.pl diff --git a/generator/tests.ml b/generator/tests.ml index 54343ea..6963ab4 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -370,7 +370,6 @@ let tests = [ "rhbz1054761.sh"; "rhbz1091803.sh"; "rhbz1232192.sh"; - "test-noexec-stack.pl"; ]; check_slow = [ "rhbz909624.sh" diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index c33cd2c..f3f55f0 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -46,8 +46,7 @@ EXTRA_DIST = \ rhbz1091803.sh \ rhbz1175196.sh \ rhbz1232192.sh \ - rhbz1232192.xml \ - test-noexec-stack.pl + rhbz1232192.xml # There are a couple of tests that we don't run: EXTRA_DIST += \ diff --git a/tests/regressions/test-noexec-stack.pl b/tests/regressions/test-noexec-stack.pl deleted file mode 100755 index e54b1df..0000000 --- a/tests/regressions/test-noexec-stack.pl +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009-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. - -use strict; -use warnings; - -my @files = ( "$ENV{top_builddir}/src/.libs/libguestfs.so", - "$ENV{top_builddir}/daemon/guestfsd" ); - -FILES: foreach my $file (@files) { - my $output; - my @cmd = ('readelf', '-l', $file); - open ($output, '-|', @cmd) - or die ("$0: failed to run: '".join(' ', @cmd)."': $!\n"); - - my $offset; - my $line = 1; - - # Find the offset of the Flags field - while (<$output>) { - next unless /^\s*Type\b/; - - my @lines; - push (@lines, $_); - - # Look for a Flg field on this line (32 bit) - $offset = index ($_, 'Flg '); - - if (-1 == $offset) { - # 64 bit is split over 2 lines. Look for a Flags field on the next - # line - $_ = <$output>; - $offset = index ($_, 'Flags '); - $line = 2; - push (@lines, $_); - } - - die "Unrecognised header: ".join("\n", @lines) if -1 == $offset; - last; - } - - # Find the GNU_STACK entry - while (<$output>) { - next unless /^\s*GNU_STACK\b/; - - # Skip over input lines according to the header - for (my $i = 1; $i < $line; $i++) { - $_ = <$output>; - } - - my $flags = substr ($_, $offset, 3); - - $flags =~ /^[ R][ W]([ E])$/ or die "Unrecognised flags: $flags"; - - if ('E' eq $1) { - print "***** $file has an executable stack *****\n"; - exit 1; - } - - next FILES; - } - - die "Didn't find GNU_STACK entry"; -} diff --git a/tests/regressions/tests.mk b/tests/regressions/tests.mk index d582b91..4d9217b 100644 --- a/tests/regressions/tests.mk +++ b/tests/regressions/tests.mk @@ -46,8 +46,7 @@ localtests_SCRIPTS = \ rhbz895904.sh \ rhbz909624.sh \ rhbz957772.sh \ - rhbz975797.sh \ - test-noexec-stack.pl + rhbz975797.sh localtests_PROGRAMS = \ rhbz1055452 \ -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 06/17] fish: Convert guestfish tests to use the test harness.
--- fish/Makefile.am | 37 ++------------------ fish/test-find0.sh | 4 +-- fish/test-inspect.sh | 2 +- fish/test-mount-local.sh | 9 ++--- fish/test-read-file.sh | 6 ++-- fish/test-run.sh | 2 +- fish/test-upload-to-dir.sh | 2 +- fish/tests.mk | 85 ++++++++++++++++++++++++++++++++++++++++++++++ generator/tests.ml | 31 +++++++++++++++++ 9 files changed, 129 insertions(+), 49 deletions(-) create mode 100644 fish/tests.mk diff --git a/fish/Makefile.am b/fish/Makefile.am index c4b82ae..5b79931 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -37,7 +37,8 @@ generator_built = \ guestfish-commands.pod \ guestfish-prepopts.pod \ prepopts.h \ - prepopts.c + prepopts.c \ + tests.mk BUILT_SOURCES = \ $(generator_built) \ @@ -266,39 +267,7 @@ toolsconf_DATA = libguestfs-tools.conf # Tests. -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS = \ - test-a.sh \ - test-add-domain.sh \ - test-add-uri.sh \ - test-d.sh \ - test-escapes.sh \ - test-events.sh \ - test-invalid-params.sh \ - test-tilde.sh - -if ENABLE_APPLIANCE -TESTS += \ - test-copy.sh \ - test-edit.sh \ - test-file-attrs.sh \ - test-find0.sh \ - test-inspect.sh \ - test-glob.sh \ - test-mount-local.sh \ - test-prep.sh \ - test-read-file.sh \ - test-remote.sh \ - test-remote-events.sh \ - test-reopen.sh \ - test-run.sh \ - test-stringlist.sh \ - test-upload-to-dir.sh -endif - -check-valgrind: - $(MAKE) TESTS="test-a.sh test-add-domain.sh test-add-uri.sh test-copy.sh test-d.sh test-edit.sh test-escapes.sh test-events.sh test-find0.sh test-glob.sh test-inspect.sh test-prep.sh test-read-file.sh test-remote.sh test-remote-events.sh test-reopen.sh test-run.sh test-stringlist.sh test-tilde.sh test-upload-to-dir.sh" VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk EXTRA_DIST += \ test-a.sh \ diff --git a/fish/test-find0.sh b/fish/test-find0.sh index 07daab3..77ceda7 100755 --- a/fish/test-find0.sh +++ b/fish/test-find0.sh @@ -22,8 +22,8 @@ set -e rm -f test.out -$VG guestfish <<'EOF' -add-ro ../tests/data/test.iso +$VG guestfish <<EOF +add-ro $datadir/test.iso run mount-ro /dev/sda / find0 / test.out diff --git a/fish/test-inspect.sh b/fish/test-inspect.sh index 126740d..363ea50 100755 --- a/fish/test-inspect.sh +++ b/fish/test-inspect.sh @@ -18,4 +18,4 @@ set -e -$VG guestfish -a ../tests/guests/fedora.img -i exit +$VG guestfish -a $phonydir/fedora.img -i exit diff --git a/fish/test-mount-local.sh b/fish/test-mount-local.sh index 0b5804e..952c7d4 100755 --- a/fish/test-mount-local.sh +++ b/fish/test-mount-local.sh @@ -18,11 +18,6 @@ # Test guestfish mount-local / mount-local-run commands. -if [ -n "$SKIP_TEST_MOUNT_LOCAL_SH" ]; then - echo "$0: skipping test because SKIP_TEST_MOUNT_LOCAL_SH is set." - exit 77 -fi - # Skip if no FUSE. test -w /dev/fuse || { @@ -51,7 +46,7 @@ if [ $# -gt 0 -a "$1" = "--run-test" ]; then echo 'mount-local test successful' > test-mount-local-mp/ok # Unmount the mountpoint. - ../fuse/guestunmount test-mount-local-mp + guestunmount test-mount-local-mp exit 0 fi @@ -63,7 +58,7 @@ mkdir test-mount-local-mp if ! guestfish -N test-mount-local.img=fs -m /dev/sda1 2>test-mount-local.errors <<EOF; then mount-local test-mount-local-mp -! $0 --run-test & +! $abs_srcdir/test-mount-local.sh --run-test & mount-local-run # /ok should have been created and left over by the test. diff --git a/fish/test-read-file.sh b/fish/test-read-file.sh index 8f35efb..838853a 100755 --- a/fish/test-read-file.sh +++ b/fish/test-read-file.sh @@ -22,13 +22,13 @@ set -e rm -f test.out -$VG guestfish <<'EOF' > test.out -add-ro ../tests/data/test.iso +$VG guestfish <<EOF > test.out +add-ro $datadir/test.iso run mount-ro /dev/sda / read-file /helloworld.tar EOF -cmp $srcdir/../tests/data/helloworld.tar test.out +cmp $datadir/helloworld.tar test.out rm -f test.out diff --git a/fish/test-run.sh b/fish/test-run.sh index a66ad9c..ed99b7d 100755 --- a/fish/test-run.sh +++ b/fish/test-run.sh @@ -18,4 +18,4 @@ set -e -$VG guestfish -a ../tests/guests/fedora.img run +$VG guestfish -a $phonydir/fedora.img run diff --git a/fish/test-upload-to-dir.sh b/fish/test-upload-to-dir.sh index 0bacd75..996547d 100755 --- a/fish/test-upload-to-dir.sh +++ b/fish/test-upload-to-dir.sh @@ -24,7 +24,7 @@ set -e rm -f test-upload-to-dir.img test-upload-to-dir.out -if $VG guestfish -N test-upload-to-dir.img=fs -m /dev/sda1 upload ../tests/data/test.iso / 2>test-upload-to-dir.out +if $VG guestfish -N test-upload-to-dir.img=fs -m /dev/sda1 upload $datadir/test.iso / 2>test-upload-to-dir.out then echo "$0: expecting guestfish to return an error" exit 1 diff --git a/fish/tests.mk b/fish/tests.mk new file mode 100644 index 0000000..c68fa0b --- /dev/null +++ b/fish/tests.mk @@ -0,0 +1,85 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/fish + +localtests_SCRIPTS = \ + test-a.sh \ + test-add-domain.sh \ + test-add-uri.sh \ + test-copy.sh \ + test-d.sh \ + test-edit.sh \ + test-escapes.sh \ + test-events.sh \ + test-file-attrs.sh \ + test-find0.sh \ + test-glob.sh \ + test-inspect.sh \ + test-invalid-params.sh \ + test-mount-local.sh \ + test-prep.sh \ + test-read-file.sh \ + test-remote-events.sh \ + test-remote.sh \ + test-reopen.sh \ + test-run.sh \ + test-stringlist.sh \ + test-tilde.sh \ + test-upload-to-dir.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 6963ab4..5f4e2ed 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -380,6 +380,37 @@ let tests = [ ]; }; + "fish", { + defaults with + check_fast = [ + "test-a.sh"; + "test-add-domain.sh"; + "test-add-uri.sh"; + "test-d.sh"; + "test-escapes.sh"; + "test-events.sh"; + "test-invalid-params.sh"; + "test-tilde.sh"; + ]; + check = [ + "test-copy.sh"; + "test-edit.sh"; + "test-file-attrs.sh"; + "test-find0.sh"; + "test-inspect.sh"; + "test-glob.sh"; + "test-mount-local.sh"; + "test-prep.sh"; + "test-read-file.sh"; + "test-remote.sh"; + "test-remote-events.sh"; + "test-reopen.sh"; + "test-run.sh"; + "test-stringlist.sh"; + "test-upload-to-dir.sh"; + ]; + }; + "inspector", { defaults with check = [ -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 07/17] cat: Convert virt-cat and friends to use the test harness.
--- .gitignore | 1 + cat/Makefile.am | 23 ++------- cat/test-virt-cat.sh | 4 +- cat/test-virt-filesystems-local-guests.sh.in | 24 ++++++++++ cat/test-virt-filesystems.sh | 4 +- cat/test-virt-log.sh | 2 +- cat/test-virt-ls.sh | 8 ++-- cat/tests.mk | 70 ++++++++++++++++++++++++++++ configure.ac | 2 + generator/tests.ml | 13 ++++++ 10 files changed, 123 insertions(+), 28 deletions(-) create mode 100755 cat/test-virt-filesystems-local-guests.sh.in create mode 100644 cat/tests.mk diff --git a/.gitignore b/.gitignore index 09c6056..244d025 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ Makefile.in /builder/virt-index-validate.1 /builder/*.xz /cat/stamp-virt-*.pod +/cat/test-virt-filesystems-local-guests.sh /cat/virt-cat /cat/virt-cat.1 /cat/virt-filesystems diff --git a/cat/Makefile.am b/cat/Makefile.am index d0db6fa..f644cd1 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -17,10 +17,13 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-cat.sh \ virt-cat.pod \ test-virt-filesystems.sh \ + test-virt-filesystems-local-guests.sh \ virt-filesystems.pod \ test-virt-log.sh \ virt-log.pod \ @@ -189,22 +192,4 @@ stamp-virt-ls.pod: virt-ls.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = \ - test-virt-cat.sh \ - test-virt-filesystems.sh \ - test-virt-log.sh \ - test-virt-ls.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -check-valgrind-local-guests: - for g in $(GUESTS); do \ - $(top_builddir)/run --test @VG@ ./virt-filesystems -c "$(libvirt_ro_uri)" -d "$$g" --all --long -h --uuid || exit $$?; \ - done +include $(srcdir)/tests.mk diff --git a/cat/test-virt-cat.sh b/cat/test-virt-cat.sh index 0fcd98d..ce70123 100755 --- a/cat/test-virt-cat.sh +++ b/cat/test-virt-cat.sh @@ -20,11 +20,11 @@ export LANG=C set -e # Read out the test files from the image using virt-cat. -if [ "$($VG virt-cat ../tests/guests/fedora.img /etc/test1)" != "abcdefg" ]; then +if [ "$($VG virt-cat $phonydir/fedora.img /etc/test1)" != "abcdefg" ]; then echo "$0: error: mismatch in file test1" exit 1 fi -if [ "$($VG virt-cat ../tests/guests/fedora.img /etc/test2)" != "" ]; then +if [ "$($VG virt-cat $phonydir/fedora.img /etc/test2)" != "" ]; then echo "$0: error: mismatch in file test2" exit 1 fi diff --git a/cat/test-virt-filesystems-local-guests.sh.in b/cat/test-virt-filesystems-local-guests.sh.in new file mode 100755 index 0000000..236f498 --- /dev/null +++ b/cat/test-virt-filesystems-local-guests.sh.in @@ -0,0 +1,24 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2009-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. + +export LANG=C +set -e + +for g in "$@"; do + $VG virt-filesystems -c "@libvirt_ro_uri@" -d "$g" --all --long -h --uuid +done diff --git a/cat/test-virt-filesystems.sh b/cat/test-virt-filesystems.sh index b2f3b48..a517d76 100755 --- a/cat/test-virt-filesystems.sh +++ b/cat/test-virt-filesystems.sh @@ -19,7 +19,7 @@ export LANG=C set -e -output="$($VG virt-filesystems -a ../tests/guests/fedora.img | sort)" +output="$($VG virt-filesystems -a $phonydir/fedora.img | sort)" expected="/dev/VG/LV1 /dev/VG/LV2 /dev/VG/LV3 @@ -32,7 +32,7 @@ if [ "$output" != "$expected" ]; then exit 1 fi -output="$($VG virt-filesystems -a ../tests/guests/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)" +output="$($VG virt-filesystems -a $phonydir/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)" expected="/dev/VG /dev/VG/LV1 /dev/VG/LV2 diff --git a/cat/test-virt-log.sh b/cat/test-virt-log.sh index aff994a..feacefb 100755 --- a/cat/test-virt-log.sh +++ b/cat/test-virt-log.sh @@ -35,7 +35,7 @@ can_handle () tmpfile=`mktemp` # Read out the log files from the image using virt-log. -for f in ../tests/guests/{fedora,debian,ubuntu}.img; do +for f in $phonydir/{fedora,debian,ubuntu}.img; do echo "Trying $f ..." if [ ! -s "$f" ]; then echo "SKIP: empty file" diff --git a/cat/test-virt-ls.sh b/cat/test-virt-ls.sh index 5bb4b8a..23465f4 100755 --- a/cat/test-virt-ls.sh +++ b/cat/test-virt-ls.sh @@ -20,7 +20,7 @@ export LANG=C set -e # Read out the test directory using virt-ls. -if [ "$($VG virt-ls ../tests/guests/fedora.img /bin)" != "ls +if [ "$($VG virt-ls $phonydir/fedora.img /bin)" != "ls test1 test2 test3 @@ -33,7 +33,7 @@ test7" ]; then fi # Try the -lR option. -output="$($VG virt-ls -lR ../tests/guests/fedora.img /boot | awk '{print $1 $2 $4}')" +output="$($VG virt-ls -lR $phonydir/fedora.img /boot | awk '{print $1 $2 $4}')" expected="d0755/boot d0755/boot/grub -0644/boot/grub/grub.conf @@ -49,5 +49,5 @@ if [ "$output" != "$expected" ]; then fi # Try the -l and -R options. XXX Should check the output. -$VG virt-ls -l ../tests/guests/fedora.img / -$VG virt-ls -R ../tests/guests/fedora.img / +$VG virt-ls -l $phonydir/fedora.img / +$VG virt-ls -R $phonydir/fedora.img / diff --git a/cat/tests.mk b/cat/tests.mk new file mode 100644 index 0000000..b076f86 --- /dev/null +++ b/cat/tests.mk @@ -0,0 +1,70 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/cat + +localtests_SCRIPTS = \ + test-virt-cat.sh \ + test-virt-filesystems-local-guests.sh \ + test-virt-filesystems.sh \ + test-virt-log.sh \ + test-virt-ls.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --local-guests + +check-valgrind-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests + +EXTRA_DIST += tests.mk diff --git a/configure.ac b/configure.ac index c3abcaf..a8e2586 100644 --- a/configure.ac +++ b/configure.ac @@ -1700,6 +1700,8 @@ mkdir -p \ dnl http://www.mail-archive.com/automake at gnu.org/msg10204.html AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance], [chmod +x,-w appliance/libguestfs-make-fixed-appliance]) +AC_CONFIG_FILES([cat/test-virt-filesystems-local-guests.sh], + [chmod +x,-w cat/test-virt-filesystems-local-guests.sh]) AC_CONFIG_FILES([inspector/test-virt-inspector-local-guests.sh], [chmod +x,-w inspector/test-virt-inspector-local-guests.sh]) AC_CONFIG_FILES([inspector/test-xmllint.sh], diff --git a/generator/tests.ml b/generator/tests.ml index 5f4e2ed..be8b765 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -380,6 +380,19 @@ let tests = [ ]; }; + "cat", { + defaults with + check = [ + "test-virt-cat.sh"; + "test-virt-filesystems.sh"; + "test-virt-log.sh"; + "test-virt-ls.sh"; + ]; + check_local_guests = [ + "test-virt-filesystems-local-guests.sh"; + ]; + }; + "fish", { defaults with check_fast = [ -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 08/17] generator: tests: Add comments to each section.
Whitespace change. --- generator/tests.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/generator/tests.ml b/generator/tests.ml index be8b765..7467c39 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -30,9 +30,11 @@ let defaults = { check_data = []; check_scripts = []; check_programs = []; } -(* The tests in each subdirectory. *) +(* The tests in each subdirectory. Note that order is important. *) let tests = [ + (* Basic safety tests -- MUST BE FIRST! *) + "tests/qemu", { defaults with check = [ @@ -52,6 +54,8 @@ let tests = [ ]; }; + (* Test low-level protocol. *) + "tests/protocol", { defaults with check = [ @@ -66,6 +70,8 @@ let tests = [ ]; }; + (* Test C API. *) + "tests/c-api", { defaults with check_fast = [ @@ -93,6 +99,8 @@ let tests = [ ]; }; + (* Tests of various features. *) + "tests/9p", { defaults with check = [ @@ -341,6 +349,8 @@ let tests = [ ]; }; + (* Regression tests. *) + "tests/regressions", { defaults with check_fast = [ @@ -380,6 +390,8 @@ let tests = [ ]; }; + (* Test tools written in C. *) + "cat", { defaults with check = [ -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 09/17] src: Convert test-utils to use the test harness.
--- generator/tests.ml | 7 ++++++ src/Makefile.am | 17 +++++---------- src/tests.mk | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 src/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 7467c39..c211344 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -472,4 +472,11 @@ let tests = [ ] }; + "src", { + defaults with + check_fast = [ + "test-utils"; + ] + }; + ] diff --git a/src/Makefile.am b/src/Makefile.am index 38a4f50..85b7091 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,8 @@ generator_built = \ structs-cleanup.c \ structs-compare.c \ structs-copy.c \ - structs-free.c + structs-free.c \ + tests.mk BUILT_SOURCES = \ $(generator_built) \ @@ -247,14 +248,7 @@ libvirt_is_version_CFLAGS = \ $(LIBVIRT_CFLAGS) endif -# Tests: main tests are in tests/c-api. Here we just have some -# internal tests of utility functions. Note we don't just test what's -# in utils.c, we can test other functions as well here. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) - -TESTS = test-utils -check_PROGRAMS = test-utils +# Test program. test_utils_SOURCES = test-utils.c test_utils_CPPFLAGS = \ @@ -268,9 +262,6 @@ test_utils_LDADD = \ $(LTLIBINTL) \ $(top_builddir)/gnulib/lib/libgnu.la -check-valgrind: - $(MAKE) VG="@VG@" check - # Pkgconfig. pkgconfigdir = $(libdir)/pkgconfig @@ -297,3 +288,5 @@ stamp-guestfs.pod: guestfs.pod \ --license LGPLv2+ \ $< touch $@ + +include $(srcdir)/tests.mk diff --git a/src/tests.mk b/src/tests.mk new file mode 100644 index 0000000..10e6964 --- /dev/null +++ b/src/tests.mk @@ -0,0 +1,63 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/src + +localtests_PROGRAMS = \ + test-utils + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 10/17] ocaml: Convert OCaml bindings tests to use the test harness.
--- generator/tests.ml | 37 +++++++++++++++++++++ generator/tests_mk.ml | 14 ++++++-- ocaml/Makefile.am | 57 ++++++--------------------------- ocaml/run-bindtests | 27 ---------------- ocaml/run-bindtests.sh | 26 +++++++++++++++ ocaml/tests.mk | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 170 insertions(+), 78 deletions(-) delete mode 100755 ocaml/run-bindtests create mode 100755 ocaml/run-bindtests.sh create mode 100644 ocaml/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index c211344..4ed53e8 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -479,4 +479,41 @@ let tests = [ ] }; + (* Test language bindings. *) + + "ocaml", { + defaults with + check_fast = [ + "run-bindtests.sh"; + "t/guestfs_010_load.bc"; + "t/guestfs_020_create.bc"; + "t/guestfs_030_create_flags.bc"; + "t/guestfs_040_create_multiple.bc"; + "t/guestfs_050_handle_properties.bc"; + "t/guestfs_060_explicit_close.bc"; + "t/guestfs_070_optargs.bc"; + "t/guestfs_410_close_event.bc"; + "t/guestfs_420_log_messages.bc"; + "t/guestfs_010_load.opt"; + "t/guestfs_020_create.opt"; + "t/guestfs_030_create_flags.opt"; + "t/guestfs_040_create_multiple.opt"; + "t/guestfs_050_handle_properties.opt"; + "t/guestfs_060_explicit_close.opt"; + "t/guestfs_070_optargs.opt"; + "t/guestfs_410_close_event.opt"; + "t/guestfs_420_log_messages.opt" + ]; + check = [ + "t/guestfs_100_launch.bc"; + "t/guestfs_430_progress_messages.bc"; + "t/guestfs_100_launch.opt"; + "t/guestfs_430_progress_messages.opt"; + ]; + check_scripts = [ + "bindtests.bc"; + "bindtests.opt"; + ]; + }; + ] diff --git a/generator/tests_mk.ml b/generator/tests_mk.ml index e2705ce..7e98297 100644 --- a/generator/tests_mk.ml +++ b/generator/tests_mk.ml @@ -39,13 +39,21 @@ let generate_tests_mk dir tests () pr "\n"; ); - (* Only add *.sh and *.pl to localtests_SCRIPTS. Others are added to - * localtests_PROGRAMS. + (* Certain extensions are treated as scripts and added to + * localtests_SCRIPTS. Others are added to localtests_PROGRAMS. *) + let scripts_extensions = [ + ".bc"; ".opt"; (* for OCaml *) + ".pl"; + ".sh" + ] in + let test_scripts, test_programs List.partition ( fun file -> - Filename.check_suffix file ".sh" || Filename.check_suffix file ".pl" + List.exists + (fun extn -> Filename.check_suffix file extn) + scripts_extensions ) (tests.check @ tests.check_fast @ tests.check_slow @ tests.check_local_guests) in diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index db13a8f..74320c6 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -21,7 +21,8 @@ generator_built = \ guestfs.mli \ guestfs.ml \ guestfs-c-actions.c \ - $(srcdir)/bindtests.ml + $(srcdir)/bindtests.ml \ + tests.mk EXTRA_DIST = \ $(generator_built) \ @@ -29,7 +30,7 @@ EXTRA_DIST = \ guestfs-c.c guestfs-c.h \ html/.gitignore \ META.in \ - run-bindtests \ + run-bindtests.sh \ t/*.ml CLEANFILES = *.annot *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so @@ -100,50 +101,9 @@ html/index.html: $(srcdir)/guestfs.mli $(srcdir)/guestfs.ml endif -TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) +# Tests. -test_progs_bc = \ - t/guestfs_010_load.bc \ - t/guestfs_020_create.bc \ - t/guestfs_030_create_flags.bc \ - t/guestfs_040_create_multiple.bc \ - t/guestfs_050_handle_properties.bc \ - t/guestfs_060_explicit_close.bc \ - t/guestfs_070_optargs.bc \ - t/guestfs_410_close_event.bc \ - t/guestfs_420_log_messages.bc - -test_progs_opt = \ - t/guestfs_010_load.opt \ - t/guestfs_020_create.opt \ - t/guestfs_030_create_flags.opt \ - t/guestfs_040_create_multiple.opt \ - t/guestfs_050_handle_properties.opt \ - t/guestfs_060_explicit_close.opt \ - t/guestfs_070_optargs.opt \ - t/guestfs_410_close_event.opt \ - t/guestfs_420_log_messages.opt - -if ENABLE_APPLIANCE -test_progs_bc += \ - t/guestfs_100_launch.bc \ - t/guestfs_430_progress_messages.bc -test_progs_opt += \ - t/guestfs_100_launch.opt \ - t/guestfs_430_progress_messages.opt -endif - -test_progs_all = $(test_progs_bc) -if HAVE_OCAMLOPT -test_progs_all += $(test_progs_opt) -endif - -TESTS = run-bindtests $(test_progs_all) - -noinst_DATA += bindtests.bc $(test_progs_all) -if HAVE_OCAMLOPT -noinst_DATA += bindtests.opt -endif +include $(srcdir)/tests.mk %.bc: %.cmo mlguestfs.cma $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ @@ -152,11 +112,12 @@ endif if HAVE_OCAMLOPT %.opt: %.cmx mlguestfs.cmxa $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@ +else +%.opt: + echo 'exit 77' > $@ + chmod 0755 $@ endif -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" TESTS="$(test_progs_all)" check - # Dependencies. %.cmi: %.mli $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ diff --git a/ocaml/run-bindtests b/ocaml/run-bindtests deleted file mode 100755 index 1fa54ec..0000000 --- a/ocaml/run-bindtests +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# libguestfs OCaml bindings -# Copyright (C) 2009 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. - -set -e - -./bindtests.bc > bindtests.tmp -diff -u $srcdir/../bindtests bindtests.tmp - -test -x ./bindtests.opt || exit 0 - -./bindtests.opt > bindtests.tmp -diff -u $srcdir/../bindtests bindtests.tmp diff --git a/ocaml/run-bindtests.sh b/ocaml/run-bindtests.sh new file mode 100755 index 0000000..dfeb61a --- /dev/null +++ b/ocaml/run-bindtests.sh @@ -0,0 +1,26 @@ +#!/bin/sh - +# libguestfs OCaml bindings +# Copyright (C) 2009-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. + +set -e + +$builddir/bindtests.bc > bindtests.tmp +diff -u $srcdir/../bindtests bindtests.tmp + +# Note next command will exit 77 if !HAVE_OCAMLOPT. +$builddir/bindtests.opt > bindtests.tmp +diff -u $srcdir/../bindtests bindtests.tmp diff --git a/ocaml/tests.mk b/ocaml/tests.mk new file mode 100644 index 0000000..817430b --- /dev/null +++ b/ocaml/tests.mk @@ -0,0 +1,87 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/ocaml + +localtests_SCRIPTS = \ + bindtests.bc \ + bindtests.opt \ + run-bindtests.sh \ + t/guestfs_010_load.bc \ + t/guestfs_010_load.opt \ + t/guestfs_020_create.bc \ + t/guestfs_020_create.opt \ + t/guestfs_030_create_flags.bc \ + t/guestfs_030_create_flags.opt \ + t/guestfs_040_create_multiple.bc \ + t/guestfs_040_create_multiple.opt \ + t/guestfs_050_handle_properties.bc \ + t/guestfs_050_handle_properties.opt \ + t/guestfs_060_explicit_close.bc \ + t/guestfs_060_explicit_close.opt \ + t/guestfs_070_optargs.bc \ + t/guestfs_070_optargs.opt \ + t/guestfs_100_launch.bc \ + t/guestfs_100_launch.opt \ + t/guestfs_410_close_event.bc \ + t/guestfs_410_close_event.opt \ + t/guestfs_420_log_messages.bc \ + t/guestfs_420_log_messages.opt \ + t/guestfs_430_progress_messages.bc \ + t/guestfs_430_progress_messages.opt + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 11/17] Convert all OCaml virt-* tools to use the test harness.
--- .gitignore | 4 +- builder/Makefile.am | 32 ++---- builder/test-virt-builder-list.sh | 2 - builder/test-virt-builder.sh | 22 ++-- builder/test-virt-index-validate.sh | 8 +- builder/tests.mk | 82 +++++++++++++++ builder/website/Makefile.am | 9 +- builder/website/tests.mk | 67 ++++++++++++ configure.ac | 2 + customize/Makefile.am | 16 +-- customize/test-virt-customize.sh | 2 +- customize/tests.mk | 60 +++++++++++ generator/tests.ml | 146 +++++++++++++++++++++++++++ mllib/Makefile.am | 17 +--- mllib/tests.mk | 64 ++++++++++++ resize/Makefile.am | 16 +-- resize/tests.mk | 60 +++++++++++ sparsify/Makefile.am | 17 +--- sparsify/test-virt-sparsify-in-place.sh | 5 - sparsify/tests.mk | 61 +++++++++++ sysprep/Makefile.am | 28 +---- sysprep/script1.sh | 2 +- sysprep/script2.sh | 2 +- sysprep/script4.sh | 2 +- sysprep/test-virt-sysprep-local-guests.sh.in | 24 +++++ sysprep/test-virt-sysprep-passwords.sh | 4 +- sysprep/test-virt-sysprep-script.sh | 13 +-- sysprep/test-virt-sysprep.sh | 5 - sysprep/tests.mk | 73 ++++++++++++++ v2v/Makefile.am | 120 +++++----------------- v2v/test-v2v-cdrom.sh | 58 +++++++---- v2v/test-v2v-cdrom.xml | 43 -------- v2v/test-v2v-i-disk.sh | 7 +- v2v/test-v2v-i-ova-formats.sh | 15 +-- v2v/test-v2v-i-ova-gz.sh | 9 +- v2v/test-v2v-i-ova-two-disks.sh | 9 +- v2v/test-v2v-i-ova.sh | 11 +- v2v/test-v2v-machine-readable.sh | 5 - v2v/test-v2v-networks-and-bridges.sh | 96 ++++++++++++++---- v2v/test-v2v-networks-and-bridges.xml | 85 ---------------- v2v/test-v2v-no-copy.sh | 36 +++---- v2v/test-v2v-o-glance.sh | 11 +- v2v/test-v2v-o-libvirt.sh | 19 +--- v2v/test-v2v-o-null.sh | 10 +- v2v/test-v2v-o-qemu.sh | 8 +- v2v/test-v2v-o-rhev.sh | 30 ++---- v2v/test-v2v-o-vdsm-options.sh | 38 +++---- v2v/test-v2v-of-option.sh | 20 +--- v2v/test-v2v-on-option.sh | 22 +--- v2v/test-v2v-print-source.sh | 30 ++---- v2v/test-v2v-real-conversions.sh | 43 ++++---- v2v/test-v2v-sound.sh | 43 ++++---- v2v/test-v2v-sound.xml | 36 ------- v2v/test-v2v-windows-conversion.sh | 24 ++--- v2v/tests.mk | 101 ++++++++++++++++++ 55 files changed, 1060 insertions(+), 714 deletions(-) create mode 100644 builder/tests.mk create mode 100644 builder/website/tests.mk create mode 100644 customize/tests.mk create mode 100644 mllib/tests.mk create mode 100644 resize/tests.mk create mode 100644 sparsify/tests.mk create mode 100755 sysprep/test-virt-sysprep-local-guests.sh.in create mode 100644 sysprep/tests.mk delete mode 100644 v2v/test-v2v-cdrom.xml delete mode 100644 v2v/test-v2v-networks-and-bridges.xml delete mode 100644 v2v/test-v2v-sound.xml create mode 100644 v2v/tests.mk diff --git a/.gitignore b/.gitignore index 244d025..8f48e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -487,12 +487,10 @@ Makefile.in /stamp-guestfs-release-notes.pod /stamp-h1 /sysprep/.depend -/sysprep/stamp-script1.sh -/sysprep/stamp-script2.sh -/sysprep/stamp-script4.sh /sysprep/stamp-virt-sysprep.pod /sysprep/sysprep-extra-options.pod /sysprep/sysprep-operations.pod +/sysprep/test-virt-sysprep-local-guests.sh /sysprep/virt-sysprep /sysprep/virt-sysprep.1 /test.err diff --git a/builder/Makefile.am b/builder/Makefile.am index f48efb0..aa74c3d 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -15,10 +15,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -include $(top_srcdir)/subdir-rules.mk - AM_YFLAGS = -d +include $(top_srcdir)/subdir-rules.mk + +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ libguestfs.gpg \ @@ -205,18 +207,10 @@ stamp-virt-builder.pod: virt-builder.pod $(top_srcdir)/customize/customize-synop CLEANFILES += stamp-virt-builder.pod -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -disk_images := \ - $(shell for f in debian fedora ubuntu windows; do if [ -s "../tests/guests/$$f.img" ]; then echo $$f.xz; fi; done) \ - $(shell if [ -s "../tests/guests/fedora.img" ]; then echo fedora.qcow2 fedora.qcow2.xz; fi) +# Disk images for tests. CLEANFILES += *.qcow2 *.xz -check_DATA = $(disk_images) - fedora.qcow2: ../tests/guests/fedora.img rm -f $@ $@-t qemu-img convert -f raw -O qcow2 $< $@-t @@ -232,20 +226,6 @@ fedora.qcow2.xz: fedora.qcow2 xz --best -c $< > $@-t mv $@-t $@ -TESTS = \ - test-virt-builder-list.sh \ - test-virt-index-validate.sh - -if ENABLE_APPLIANCE -TESTS += test-virt-builder.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -check-slow: - $(MAKE) TESTS="test-virt-builder-planner.sh" check - # Dependencies. depend: .depend @@ -330,3 +310,5 @@ endif # in the distribution, so just remove them from the distdir. dist-hook: rm -f $(distdir)/index-parse.c $(distdir)/index-parse.h $(distdir)/index-scan.c + +include $(srcdir)/tests.mk diff --git a/builder/test-virt-builder-list.sh b/builder/test-virt-builder-list.sh index 2b6dfad..e42e3ec 100755 --- a/builder/test-virt-builder-list.sh +++ b/builder/test-virt-builder-list.sh @@ -21,8 +21,6 @@ export LANG=C set -e -abs_builddir=$(pwd) - export XDG_CONFIG_HOME export XDG_CONFIG_DIRS="$abs_builddir/test-config" diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh index f357d12..c6e99c4 100755 --- a/builder/test-virt-builder.sh +++ b/builder/test-virt-builder.sh @@ -19,17 +19,10 @@ export LANG=C set -e -abs_builddir=$(pwd) - export XDG_CONFIG_HOME export XDG_CONFIG_DIRS="$abs_builddir/test-config" -if [ -n "$SKIP_TEST_VIRT_BUILDER_SH" ]; then - echo "$0: skipping test because environment variable is set." - exit 77 -fi - -if [ ! -f fedora.xz ]; then +if [ ! -f $builddir/fedora.xz ]; then echo "$0: test skipped because there is no fedora.xz in the build directory" exit 77 fi @@ -64,19 +57,20 @@ $VG virt-builder phony-fedora \ --root-password password:123456 \ --mkdir /etc/foo/bar/baz \ --write '/etc/foo/bar/baz/foo:Hello World' \ - --upload Makefile:/Makefile \ - --edit '/Makefile: s{^#.*}{}' \ - --upload Makefile:/etc/foo/bar/baz \ - --delete /Makefile \ + --upload $srcdir/test-virt-builder.sh:/test \ + --edit '/test: s{^#.*}{}' \ + --upload $srcdir/test-virt-builder.sh:/etc/foo/bar/baz \ + --delete /test \ --link /etc/foo/bar/baz/foo:/foo \ --link /etc/foo/bar/baz/foo:/foo1:/foo2:/foo3 \ - --firstboot Makefile --firstboot-command 'echo "hello"' \ + --firstboot $srcdir/test-virt-builder.sh \ + --firstboot-command 'echo "hello"' \ --firstboot-install "minicom,inkscape" # Check that some modifications were made. $VG guestfish --ro -i -a $output > test.out <<EOF # Uploaded files -is-file /etc/foo/bar/baz/Makefile +is-file /etc/foo/bar/baz/test-virt-builder.sh cat /etc/foo/bar/baz/foo is-symlink /foo is-symlink /foo1 diff --git a/builder/test-virt-index-validate.sh b/builder/test-virt-index-validate.sh index b00a086..0e65591 100755 --- a/builder/test-virt-index-validate.sh +++ b/builder/test-virt-index-validate.sh @@ -19,7 +19,7 @@ export LANG=C set -e -! $VG virt-index-validate test-virt-index-validate-bad-1 -$VG virt-index-validate test-virt-index-validate-good-1 -$VG virt-index-validate test-virt-index-validate-good-2 -$VG virt-index-validate test-virt-index-validate-good-3 +! $VG virt-index-validate $srcdir/test-virt-index-validate-bad-1 +$VG virt-index-validate $srcdir/test-virt-index-validate-good-1 +$VG virt-index-validate $srcdir/test-virt-index-validate-good-2 +$VG virt-index-validate $srcdir/test-virt-index-validate-good-3 diff --git a/builder/tests.mk b/builder/tests.mk new file mode 100644 index 0000000..d4efad0 --- /dev/null +++ b/builder/tests.mk @@ -0,0 +1,82 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/builder + +localtests_DATA = \ + debian.xz \ + fedora.qcow2 \ + fedora.qcow2.xz \ + fedora.xz \ + ubuntu.xz \ + windows.xz \ + test-index \ + test-virt-index-validate-bad-1 \ + test-virt-index-validate-good-1 \ + test-virt-index-validate-good-2 \ + test-virt-index-validate-good-3 + +localtests_SCRIPTS = \ + test-virt-builder-list.sh \ + test-virt-builder-planner.sh \ + test-virt-builder.sh \ + test-virt-index-validate.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +check-slow: + $(top_builddir)/run $(top_builddir)/test-harness --slow + +EXTRA_DIST += tests.mk diff --git a/builder/website/Makefile.am b/builder/website/Makefile.am index 4a65156..1c2c0da 100644 --- a/builder/website/Makefile.am +++ b/builder/website/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ .gitignore \ compress.sh \ @@ -42,9 +44,4 @@ EXTRA_DIST = \ CLEANFILES = *~ -# Validates the index file. -TESTS_ENVIRONMENT = $(top_builddir)/run --test -TESTS = validate.sh - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk diff --git a/builder/website/tests.mk b/builder/website/tests.mk new file mode 100644 index 0000000..0f716a7 --- /dev/null +++ b/builder/website/tests.mk @@ -0,0 +1,67 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/builder/website + +localtests_DATA = \ + index \ + index.asc + +localtests_SCRIPTS = \ + validate.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/configure.ac b/configure.ac index a8e2586..cd075dd 100644 --- a/configure.ac +++ b/configure.ac @@ -1718,6 +1718,8 @@ AC_CONFIG_FILES([podwrapper.pl], [chmod +x,-w podwrapper.pl]) AC_CONFIG_FILES([run], [chmod +x,-w run]) +AC_CONFIG_FILES([sysprep/test-virt-sysprep-local-guests.sh], + [chmod +x,-w cat/test-virt-sysprep-local-guests.sh]) AC_CONFIG_FILES([Makefile align/Makefile diff --git a/customize/Makefile.am b/customize/Makefile.am index 6e876a4..f213604 100644 --- a/customize/Makefile.am +++ b/customize/Makefile.am @@ -31,7 +31,8 @@ generator_built = \ customize_cmdline.mli \ customize_cmdline.ml \ customize-options.pod \ - customize-synopsis.pod + customize-synopsis.pod \ + tests.mk SOURCES_MLI = \ crypt.mli \ @@ -163,17 +164,6 @@ stamp-virt-customize.pod: virt-customize.pod $(top_srcdir)/customize/customize-s $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = test-virt-customize.sh -endif - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - # Dependencies. depend: .depend @@ -193,3 +183,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/customize/test-virt-customize.sh b/customize/test-virt-customize.sh index 979e6f0..2d17a67 100755 --- a/customize/test-virt-customize.sh +++ b/customize/test-virt-customize.sh @@ -22,7 +22,7 @@ set -e # virt-customize with the -n option doesn't modify the guest. It ought # to be able to customize any of our Linux-like test guests. -for f in ../tests/guests/{debian,fedora,ubuntu}.img; do +for f in $phonydir/{debian,fedora,ubuntu}.img; do # Ignore zero-sized windows.img if ntfs-3g is not installed. if [ -s "$f" ]; then # Add --no-network so UML works. diff --git a/customize/tests.mk b/customize/tests.mk new file mode 100644 index 0000000..f79c51b --- /dev/null +++ b/customize/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/customize + +localtests_SCRIPTS = \ + test-virt-customize.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 4ed53e8..3b72fd8 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -516,4 +516,150 @@ let tests = [ ]; }; + (* Test tools written in OCaml. *) + + "mllib", { + defaults with + check_fast = [ + "common_utils_tests"; + "JSON_tests"; + ]; + }; + + "customize", { + defaults with + check = [ + "test-virt-customize.sh" + ]; + }; + + "builder", { + defaults with + check_fast = [ + "test-virt-builder-list.sh"; + "test-virt-index-validate.sh" + ]; + check = [ + "test-virt-builder.sh" + ]; + check_slow = [ + "test-virt-builder-planner.sh" + ]; + check_data = [ + "debian.xz"; + "fedora.xz"; + "ubuntu.xz"; + "windows.xz"; + "fedora.qcow2"; + "fedora.qcow2.xz"; + "test-index"; + "test-virt-index-validate-bad-1"; + "test-virt-index-validate-good-1"; + "test-virt-index-validate-good-2"; + "test-virt-index-validate-good-3"; + ]; + }; + + "builder/website", { + defaults with + check_fast = [ + "validate.sh" + ]; + check_data = [ + "index"; + "index.asc" + ]; + }; + + "resize", { + defaults with + check = [ + "test-virt-resize.pl" + ]; + }; + + "sparsify", { + defaults with + check = [ + "test-virt-sparsify.sh"; + "test-virt-sparsify-in-place.sh"; + ]; + }; + + "sysprep", { + defaults with + check = [ + "test-virt-sysprep.sh"; + "test-virt-sysprep-passwords.sh"; + "test-virt-sysprep-script.sh"; + ]; + check_local_guests = [ + "test-virt-sysprep-local-guests.sh"; + ]; + check_scripts = [ + "script1.sh"; + "script2.sh"; + "script3.sh"; + "script4.sh" + ]; + }; + + (* The virt-v2v tests here are not meant to be thorough tests of guest + * conversion. There is a test suite used to test conversion which is + * kept outside libguestfs because it contains lots of proprietary + * unredistributable guests like Windows. + * + * The tests here instead are testing: + * + * - virt-v2v command line arguments + * - virt-v2v reads and writes files to the correct places + * - valgrind & memory leaks + * - any conversion properties that can be tested using just the + * phony guests (but we don't go out of our way here) + * - that up to date guests don't crash virt-v2v + *) + "v2v", { + defaults with + check_fast = [ + "test-v2v-i-ova-formats.sh"; + "test-v2v-i-ova-gz.sh"; + "test-v2v-i-ova-two-disks.sh"; + "v2v_unit_tests"; + ]; + check = [ + "test-v2v-cdrom.sh"; + "test-v2v-i-ova.sh"; + "test-v2v-i-disk.sh"; + "test-v2v-machine-readable.sh"; + "test-v2v-networks-and-bridges.sh"; + "test-v2v-no-copy.sh"; + "test-v2v-o-glance.sh"; + "test-v2v-o-libvirt.sh"; + "test-v2v-o-null.sh"; + "test-v2v-o-qemu.sh"; + "test-v2v-o-rhev.sh"; + "test-v2v-o-vdsm-options.sh"; + "test-v2v-of-option.sh"; + "test-v2v-on-option.sh"; + "test-v2v-print-source.sh"; + "test-v2v-sound.sh"; + "test-v2v-windows-conversion.sh"; + ]; + check_slow = [ + "test-v2v-real-conversions.sh"; + ]; + check_data = [ + "test-v2v-cdrom.expected"; + "test-v2v-i-ova.ovf"; + "test-v2v-i-ova.xml"; + "test-v2v-i-ova-formats.expected"; + "test-v2v-i-ova-formats.ovf"; + "test-v2v-i-ova-gz.expected"; + "test-v2v-i-ova-gz.ovf"; + "test-v2v-i-ova-two-disks.expected"; + "test-v2v-i-ova-two-disks.ovf"; + "test-v2v-networks-and-bridges-expected.xml"; + ]; + }; + ] diff --git a/mllib/Makefile.am b/mllib/Makefile.am index 39f1b33..3dfa2fb 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_MLI) \ $(filter-out config.ml libdir.ml,$(SOURCES_ML)) \ @@ -182,21 +184,8 @@ JSON_tests_LINK = \ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \ $(JSON_tests_THEOBJECTS) -o $@ -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS -check_PROGRAMS - -if HAVE_OCAML_PKG_OUNIT -check_PROGRAMS += common_utils_tests JSON_tests -TESTS += common_utils_tests JSON_tests -endif - CLEANFILES += oUnit-* -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - # Dependencies. depend: .depend @@ -216,3 +205,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/mllib/tests.mk b/mllib/tests.mk new file mode 100644 index 0000000..0ae0029 --- /dev/null +++ b/mllib/tests.mk @@ -0,0 +1,64 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/mllib + +localtests_PROGRAMS = \ + JSON_tests \ + common_utils_tests + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/resize/Makefile.am b/resize/Makefile.am index d142288..3a23d9a 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ virt-resize.pod \ @@ -127,18 +129,6 @@ stamp-virt-resize.pod: virt-resize.pod CLEANFILES += stamp-virt-resize.pod -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS -if ENABLE_APPLIANCE -TESTS += test-virt-resize.pl -endif - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - # Dependencies. depend: .depend @@ -158,3 +148,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/resize/tests.mk b/resize/tests.mk new file mode 100644 index 0000000..88dd8e0 --- /dev/null +++ b/resize/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/resize + +localtests_SCRIPTS = \ + test-virt-resize.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index ab9af7a..1112c17 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_ML) $(SOURCES_C) \ virt-sparsify.pod \ @@ -120,19 +122,6 @@ stamp-virt-sparsify.pod: virt-sparsify.pod CLEANFILES += stamp-virt-sparsify.pod -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = \ - test-virt-sparsify.sh \ - test-virt-sparsify-in-place.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - # Dependencies. depend: .depend @@ -152,3 +141,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/sparsify/test-virt-sparsify-in-place.sh b/sparsify/test-virt-sparsify-in-place.sh index 64ead1a..0b86562 100755 --- a/sparsify/test-virt-sparsify-in-place.sh +++ b/sparsify/test-virt-sparsify-in-place.sh @@ -19,11 +19,6 @@ export LANG=C set -e -if [ -n "$SKIP_TEST_VIRT_SPARSIFY_IN_PLACE_SH" ]; then - echo "$0: skipping test (environment variable set)" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: skipping test because uml backend does not support discard" exit 77 diff --git a/sparsify/tests.mk b/sparsify/tests.mk new file mode 100644 index 0000000..f375c03 --- /dev/null +++ b/sparsify/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/sparsify + +localtests_SCRIPTS = \ + test-virt-sparsify-in-place.sh \ + test-virt-sparsify.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 1e30455..245cbdd 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -17,10 +17,13 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ script1.sh script2.sh script3.sh script4.sh \ test-virt-sysprep.sh \ + test-virt-sysprep-local-guests.sh \ test-virt-sysprep-passwords.sh \ test-virt-sysprep-script.sh \ virt-sysprep.pod @@ -200,29 +203,6 @@ sysprep-operations.pod: virt-sysprep $(top_builddir)/run ./$< --dump-pod > $@-t mv $@-t $@ -# Tests. - -TESTS_ENVIRONMENT = \ - abs_builddir=$(abs_builddir) \ - abs_srcdir=$(abs_srcdir) \ - PATH=$(abs_top_builddir)/fuse:$(PATH) \ - $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = \ - test-virt-sysprep.sh \ - test-virt-sysprep-passwords.sh \ - test-virt-sysprep-script.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) TESTS="test-virt-sysprep.sh" VG="$(top_builddir)/run @VG@" check - -check-valgrind-local-guests: - for g in $(GUESTS); do \ - $(top_builddir)/run --test @VG@ ./virt-sysprep -n -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \ - done - # Dependencies. depend: .depend @@ -242,3 +222,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/sysprep/script1.sh b/sysprep/script1.sh index 6ba274c..8726a6f 100755 --- a/sysprep/script1.sh +++ b/sysprep/script1.sh @@ -18,4 +18,4 @@ # This is used by test-virt-sysprep-script.sh. -pwd > $abs_builddir/stamp-script1.sh +pwd > $tmpdir/stamp-script1.sh diff --git a/sysprep/script2.sh b/sysprep/script2.sh index a8ca21f..163f36e 100755 --- a/sysprep/script2.sh +++ b/sysprep/script2.sh @@ -20,4 +20,4 @@ rm -f etc/resolv.conf -pwd > $abs_builddir/stamp-script2.sh +pwd > $tmpdir/stamp-script2.sh diff --git a/sysprep/script4.sh b/sysprep/script4.sh index fe377e0..313ab85 100755 --- a/sysprep/script4.sh +++ b/sysprep/script4.sh @@ -18,4 +18,4 @@ # This is used by test-virt-sysprep-script.sh. -pwd >> $abs_builddir/stamp-script4.sh +pwd >> $tmpdir/stamp-script4.sh diff --git a/sysprep/test-virt-sysprep-local-guests.sh.in b/sysprep/test-virt-sysprep-local-guests.sh.in new file mode 100755 index 0000000..36ef713 --- /dev/null +++ b/sysprep/test-virt-sysprep-local-guests.sh.in @@ -0,0 +1,24 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2015 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. + +export LANG=C +set -e + +for g in "$@"; do + $VG virt-sysprep -n -c "@libvirt_ro_uri@" -d "$g" +done diff --git a/sysprep/test-virt-sysprep-passwords.sh b/sysprep/test-virt-sysprep-passwords.sh index b5189c8..74ae5e7 100755 --- a/sysprep/test-virt-sysprep-passwords.sh +++ b/sysprep/test-virt-sysprep-passwords.sh @@ -26,7 +26,7 @@ if [ "$(guestfish get-backend)" = "uml" ]; then exit 77 fi -if [ ! -s ../tests/guests/fedora.img ]; then +if [ ! -s $phonydir/fedora.img ]; then echo "$0: skipping test because there is no phony Fedora test image" exit 77 fi @@ -37,7 +37,7 @@ fi rm -f passwords.qcow2 password guestfish -- \ disk-create passwords.qcow2 qcow2 -1 \ - backingfile:../tests/guests/fedora.img backingformat:raw + backingfile:$phonydir/fedora.img backingformat:raw guestfish -a passwords.qcow2 -i <<'EOF' write-append /etc/shadow "test01::15677:0:99999:7:::\n" diff --git a/sysprep/test-virt-sysprep-script.sh b/sysprep/test-virt-sysprep-script.sh index 10ba1d1..0dbf964 100755 --- a/sysprep/test-virt-sysprep-script.sh +++ b/sysprep/test-virt-sysprep-script.sh @@ -20,11 +20,6 @@ export LANG=C set -e #set -x -if [ -n "$SKIP_TEST_VIRT_SYSPREP_SCRIPT_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - if [ ! -w /dev/fuse ]; then echo "$0: SKIPPING test, because there is no /dev/fuse." exit 77 @@ -32,7 +27,7 @@ fi # Check that multiple scripts can run. rm -f stamp-script1.sh stamp-script2.sh stamp-script4.sh -if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \ +if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \ --script $abs_srcdir/script1.sh --script $abs_srcdir/script2.sh; then echo "$0: virt-sysprep wasn't expected to exit with error." exit 1 @@ -43,19 +38,19 @@ if [ ! -f stamp-script1.sh -o ! -f stamp-script2.sh ]; then fi # Check that if a script fails, virt-sysprep exits with an error. -if virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \ +if virt-sysprep -q -n -a $phonydir/fedora.img --enable script \ --script $abs_srcdir/script3.sh; then echo "$0: virt-sysprep didn't exit with an error." exit 1 fi # Check that virt-sysprep uses a new temporary directory every time. -if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \ +if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \ --script $abs_srcdir/script4.sh; then echo "$0: virt-sysprep (script4.sh, try #1) wasn't expected to exit with error." exit 1 fi -if ! virt-sysprep -q -n -a ../tests/guests/fedora.img --enable script \ +if ! virt-sysprep -q -n -a $phonydir/fedora.img --enable script \ --script $abs_srcdir/script4.sh; then echo "$0: virt-sysprep (script4.sh, try #2) wasn't expected to exit with error." exit 1 diff --git a/sysprep/test-virt-sysprep.sh b/sysprep/test-virt-sysprep.sh index 14cd492..7ec96d0 100755 --- a/sysprep/test-virt-sysprep.sh +++ b/sysprep/test-virt-sysprep.sh @@ -19,11 +19,6 @@ export LANG=C set -e -if [ -n "$SKIP_TEST_VIRT_SYSPREP_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - # Get a comma-separated list of the enabled-by-default operations. operations=$( virt-sysprep --list-operations | diff --git a/sysprep/tests.mk b/sysprep/tests.mk new file mode 100644 index 0000000..fb6cd49 --- /dev/null +++ b/sysprep/tests.mk @@ -0,0 +1,73 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/sysprep + +localtests_SCRIPTS = \ + script1.sh \ + script2.sh \ + script3.sh \ + script4.sh \ + test-virt-sysprep-local-guests.sh \ + test-virt-sysprep-passwords.sh \ + test-virt-sysprep-script.sh \ + test-virt-sysprep.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --local-guests + +check-valgrind-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests + +EXTRA_DIST += tests.mk diff --git a/v2v/Makefile.am b/v2v/Makefile.am index e957a15..a72c518 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -17,24 +17,43 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ $(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \ - v2v_unit_tests.ml \ - $(TESTS) $(SLOW_TESTS) \ HACKING \ + v2v_unit_tests.ml \ test-v2v-cdrom.expected \ - test-v2v-cdrom.xml \ - test-v2v-i-ova.ovf \ - test-v2v-i-ova.xml \ + test-v2v-cdrom.sh \ + test-v2v-i-disk.sh \ test-v2v-i-ova-formats.expected \ test-v2v-i-ova-formats.ovf \ + test-v2v-i-ova-formats.sh \ test-v2v-i-ova-gz.expected \ test-v2v-i-ova-gz.ovf \ + test-v2v-i-ova-gz.sh \ test-v2v-i-ova-two-disks.expected \ test-v2v-i-ova-two-disks.ovf \ + test-v2v-i-ova-two-disks.sh \ + test-v2v-i-ova.ovf \ + test-v2v-i-ova.sh \ + test-v2v-i-ova.xml \ + test-v2v-machine-readable.sh \ test-v2v-networks-and-bridges-expected.xml \ - test-v2v-networks-and-bridges.xml \ - test-v2v-sound.xml \ + test-v2v-networks-and-bridges.sh \ + test-v2v-no-copy.sh \ + test-v2v-o-glance.sh \ + test-v2v-o-libvirt.sh \ + test-v2v-o-null.sh \ + test-v2v-o-qemu.sh \ + test-v2v-o-rhev.sh \ + test-v2v-o-vdsm-options.sh \ + test-v2v-of-option.sh \ + test-v2v-on-option.sh \ + test-v2v-print-source.sh \ + test-v2v-real-conversions.sh \ + test-v2v-sound.sh \ + test-v2v-windows-conversion.sh \ virt-v2v.pod CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o virt-v2v @@ -200,92 +219,7 @@ stamp-virt-v2v.pod: virt-v2v.pod CLEANFILES += stamp-virt-v2v.pod -# Tests. - -# The virt-v2v tests here are not meant to be thorough tests of guest -# conversion. There is a test suite used to test conversion which is -# kept outside libguestfs because it contains lots of proprietary -# unredistributable guests like Windows. -# -# The tests here instead are testing: -# -# - virt-v2v command line arguments -# - virt-v2v reads and writes files to the correct places -# - valgrind & memory leaks -# - any conversion properties that can be tested using just the -# phony guests (but we don't go out of our way here) -# - that up to date guests don't crash virt-v2v - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS = \ - test-v2v-i-ova-formats.sh \ - test-v2v-i-ova-gz.sh \ - test-v2v-i-ova-two-disks.sh - -if HAVE_OCAML_PKG_OUNIT -TESTS += v2v_unit_tests -endif - -if ENABLE_APPLIANCE -TESTS += \ - test-v2v-cdrom.sh \ - test-v2v-i-ova.sh \ - test-v2v-i-disk.sh \ - test-v2v-machine-readable.sh \ - test-v2v-networks-and-bridges.sh \ - test-v2v-no-copy.sh \ - test-v2v-o-glance.sh \ - test-v2v-o-libvirt.sh \ - test-v2v-o-null.sh \ - test-v2v-o-qemu.sh \ - test-v2v-o-rhev.sh \ - test-v2v-o-vdsm-options.sh \ - test-v2v-of-option.sh \ - test-v2v-on-option.sh \ - test-v2v-print-source.sh \ - test-v2v-sound.sh \ - test-v2v-windows-conversion.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -SLOW_TESTS = \ - test-v2v-real-conversions.sh - -check-slow: $(real_guests:%=%.img) - $(MAKE) check TESTS="$(SLOW_TESTS)" - -# A selection of real guests that test-v2v-real-conversions.sh will -# try to convert. This is only used by 'make check-slow'. - -real_guests = \ - centos-6 \ - centos-7.0 \ - fedora-20 \ - rhel-5.10 \ - rhel-6.5 \ - rhel-7.0 - -$(real_guests:%=%.img): - rm -f $@ - n=`basename $@ .img`; \ - vb="$(top_builddir)/run $(top_builddir)/builder/virt-builder"; \ - if $$vb --help >/dev/null && $$vb --notes $$n >/dev/null; then \ - $$vb $$n; \ - else \ - touch $$n.img; \ - fi - -CLEANFILES += $(real_guests:%=%.img) - # Unit tests. -check_PROGRAMS -if HAVE_OCAML_PKG_OUNIT -check_PROGRAMS += v2v_unit_tests -endif - v2v_unit_tests_BOBJECTS = \ $(top_builddir)/mllib/config.cmo \ $(top_builddir)/mllib/common_gettext.cmo \ @@ -340,3 +274,5 @@ endif DISTCLEANFILES = .depend .PHONY: depend docs + +include $(srcdir)/tests.mk diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh index 93975c2..1130e46 100755 --- a/v2v/test-v2v-cdrom.sh +++ b/v2v/test-v2v-cdrom.sh @@ -23,26 +23,18 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_CDROM_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_builddir="$(pwd)" -libvirt_uri="test://$abs_builddir/test-v2v-cdrom.xml" - -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 fi -f=../tests/guests/blank-disk.img +f=$phonydir/blank-disk.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because blank-disk.img was not created" exit 77 @@ -54,27 +46,51 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-cdrom.d -rm -rf $d -mkdir $d +# Libvirt XML. +echo > guest.xml <<EOF +<node> + <domain type='test'> + <name>windows</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/windows.img'/> + <!-- virt-v2v should install virtio drivers and turn this + into dev='vda' bus='virtio' --> + <target dev='hda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-disk.img'/> + <!-- virt-v2v should preserve the device name and bus --> + <target dev='hdc' bus='ide'/> + </disk> + </devices> + </domain> +</node> +EOF +libvirt_uri="test://$tmpdir/guest.xml" $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d --no-copy + -o local -os . --no-copy # Test the libvirt XML metadata was created. -test -f $d/windows.xml +test -f windows.xml # Grab just the <disk>..</disk> output and compare it to what we # expect. https://stackoverflow.com/questions/16587218 awk '/<disk /{p=1;print;next} p&&/<\/disk>/{p=0;print;next} ;p' \ - $d/windows.xml | - grep -v '<source file' > $d/disks + windows.xml | + grep -v '<source file' > disks -if ! diff -u test-v2v-cdrom.expected $d/disks; then +if ! diff -u $srcdir/test-v2v-cdrom.expected disks; then echo "$0: unexpected disk assignments" - cat $d/disks + cat disks exit 1 fi - -rm -r $d diff --git a/v2v/test-v2v-cdrom.xml b/v2v/test-v2v-cdrom.xml deleted file mode 100644 index b48d88f..0000000 --- a/v2v/test-v2v-cdrom.xml +++ /dev/null @@ -1,43 +0,0 @@ -<!-- -libguestfs virt-v2v tool -Copyright (C) 2009-2015 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. ---> -<node> - <domain type='test'> - <name>windows</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='../tests/guests/windows.img'/> - <!-- virt-v2v should install virtio drivers and turn this - into dev='vda' bus='virtio' --> - <target dev='hda' bus='ide'/> - </disk> - <disk type='file' device='cdrom'> - <driver name='qemu' type='raw'/> - <source file='../tests/guests/blank-disk.img'/> - <!-- virt-v2v should preserve the device name and bus --> - <target dev='hdc' bus='ide'/> - </disk> - </devices> - </domain> -</node> diff --git a/v2v/test-v2v-i-disk.sh b/v2v/test-v2v-i-disk.sh index b15e0d0..e385bf3 100755 --- a/v2v/test-v2v-i-disk.sh +++ b/v2v/test-v2v-i-disk.sh @@ -22,17 +22,12 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_I_DISK_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh index bd3e048..67dbbde 100755 --- a/v2v/test-v2v-i-ova-formats.sh +++ b/v2v/test-v2v-i-ova-formats.sh @@ -24,11 +24,6 @@ set -e formats="tar zip tar-gz tar-xz" -if [ -n "$SKIP_TEST_V2V_I_OVA_FORMATS_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if ! zip --version >/dev/null 2>&1; then echo "$0: test skipped because 'zip' utility is not available" exit 77 @@ -65,17 +60,17 @@ echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf for format in $formats; do case "$format" in tar) - tar -cf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + tar -cf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf ;; zip) - zip -r test ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + zip -r test $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf mv test.zip test-$format.ova ;; tar-gz) - tar -czf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + tar -czf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf ;; tar-xz) - tar -cJf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + tar -cJf test-$format.ova $srcdir/test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf ;; *) echo "Unhandled format '$format'" @@ -94,7 +89,7 @@ for format in $formats; do sed 's,[^ \t]*\(disk.*.vmdk\),\1,' > $d/source # Check the parsed source is what we expect. - diff -u test-v2v-i-ova-formats.expected $d/source + diff -u $srcdir/test-v2v-i-ova-formats.expected $d/source done rm -rf $d diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh index 6c630fb..18cce91 100755 --- a/v2v/test-v2v-i-ova-gz.sh +++ b/v2v/test-v2v-i-ova-gz.sh @@ -22,11 +22,6 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_I_OVA_GZ_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 @@ -49,7 +44,7 @@ gzip disk1.vmdk sha=`sha1sum disk1.vmdk | awk '{print $1}'` echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf -tar -cf test.ova ../test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf +tar -cf test.ova $srcdir/test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf popd # Run virt-v2v but only as far as the --print-source stage, and @@ -60,6 +55,6 @@ $VG virt-v2v --debug-gc --quiet \ sed 's,[^ \t]*\(\.vmdk\),\1,' > $d/source # Check the parsed source is what we expect. -diff -u test-v2v-i-ova-gz.expected $d/source +diff -u $srcdir/test-v2v-i-ova-gz.expected $d/source rm -rf $d diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh index dfda956..db27573 100755 --- a/v2v/test-v2v-i-ova-two-disks.sh +++ b/v2v/test-v2v-i-ova-two-disks.sh @@ -22,11 +22,6 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_I_OVA_TWO_DISKS_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 @@ -53,7 +48,7 @@ truncate -s 100k disk2.vmdk sha=`sha1sum disk2.vmdk | awk '{print $1}'` 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 +tar -cf test.ova $srcdir/test-v2v-i-ova-two-disks.ovf disk1.vmdk disk1.mf disk2.vmdk disk2.mf popd # Run virt-v2v but only as far as the --print-source stage, and @@ -64,6 +59,6 @@ $VG virt-v2v --debug-gc --quiet \ sed 's,[^ \t]*\(disk.*.vmdk\),\1,' > $d/source # Check the parsed source is what we expect. -diff -u test-v2v-i-ova-two-disks.expected $d/source +diff -u $srcdir/test-v2v-i-ova-two-disks.expected $d/source rm -rf $d diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh index 5047eca..1eef6aa 100755 --- a/v2v/test-v2v-i-ova.sh +++ b/v2v/test-v2v-i-ova.sh @@ -22,17 +22,12 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_I_OVA_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -55,7 +50,7 @@ ova=test-ova.ova raw=TestOva-sda qemu-img convert $f -O vmdk $d/$vmdk -cp $ovf $d/$ovf +cp $srcdir/test-v2v-i-ova.ovf $d/$ovf sha1=`sha1sum $d/$ovf | awk '{print $1}'` echo "SHA1($ovf)= $sha1" > $d/$mf sha1=`sha1sum $d/$vmdk | awk '{print $1}'` @@ -83,6 +78,6 @@ sed \ < $d/TestOva.xml.old > $d/TestOva.xml # Check the libvirt XML output. -diff -u test-v2v-i-ova.xml $d/TestOva.xml +diff -u $srcdir/test-v2v-i-ova.xml $d/TestOva.xml rm -rf $d diff --git a/v2v/test-v2v-machine-readable.sh b/v2v/test-v2v-machine-readable.sh index 3e94ae5..7b0ae9c 100755 --- a/v2v/test-v2v-machine-readable.sh +++ b/v2v/test-v2v-machine-readable.sh @@ -22,11 +22,6 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_MACHINE_READABLE_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - $VG virt-v2v --debug-gc --machine-readable > test-v2v-machine-readable.out grep virt-v2v test-v2v-machine-readable.out grep libguestfs-rewrite test-v2v-machine-readable.out diff --git a/v2v/test-v2v-networks-and-bridges.sh b/v2v/test-v2v-networks-and-bridges.sh index 68743d6..680ef44 100755 --- a/v2v/test-v2v-networks-and-bridges.sh +++ b/v2v/test-v2v-networks-and-bridges.sh @@ -22,20 +22,12 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_NETWORKS_AND_BRIDGES_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_builddir="$(pwd)" -libvirt_uri="test://$abs_builddir/test-v2v-networks-and-bridges.xml" - -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,14 +39,82 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-networks-and-bridges.d -rm -rf $d -mkdir $d +# Libvirt XML. +echo > guest.xml <<EOF +<node> + <domain type='test'> + <name>windows</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/windows.img'/> + <target dev='vda' bus='virtio'/> + </disk> + + <!-- various different networks and bridges which should + be renamed by the test --> + + <!-- standard ESX bridge --> + <interface type='bridge'> + <mac address='00:00:00:00:00:00'/> + <source bridge='VM Network'/> + <model type='e1000'/> + </interface> + + <!-- another bridge to be remapped --> + <interface type='bridge'> + <mac address='52:54:00:01:02:03'/> + <source bridge='bob'/> + <model type='e1000'/> + </interface> + + <!-- typical libvirt network --> + <interface type='network'> + <mac address='52:54:00:01:02:04'/> + <source network='default'/> + <model type='virtio'/> + </interface> + + <!-- some more random networks to map --> + <interface type='network'> + <mac address='52:54:00:01:02:05'/> + <source network='john'/> + <model type='virtio'/> + </interface> + + <interface type='network'> + <source network='paul'/> + <model type='virtio'/> + <mac address='52:54:00:01:02:06'/> + </interface> + + <interface type='network'> + <model type='rtl8139'/> + <source network='george'/> + <mac address='52:54:00:01:02:07'/> + </interface> + + <interface type='network'> + <mac address='52:54:00:01:02:08'/> + <model type='virtio'/> + <source network='ringo'/> + </interface> + + </devices> + </domain> +</node> +EOF +libvirt_uri="test://$tmpdir/guest.xml" # Use --no-copy because we only care about metadata for this test. $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d --no-copy \ + -o local -os . --no-copy \ --bridge "VM Network:bridge1" \ -b bridge2 \ --network default:network1 \ @@ -63,15 +123,13 @@ $VG virt-v2v --debug-gc \ --network network4 # Test the libvirt XML metadata was created. -test -f $d/windows.xml +test -f windows.xml # Extract just the network interfaces from the XML. # Delete the network model XML because that can change depending # on whether virtio-win is installed or not. -sed -n '/interface/,/\/interface/p' $d/windows.xml | - grep -v 'model type=' > $d/networks +sed -n '/interface/,/\/interface/p' windows.xml | + grep -v 'model type=' > networks # Test that the output has mapped the networks and bridges correctly. -diff -ur test-v2v-networks-and-bridges-expected.xml $d/networks - -rm -r $d +diff -ur $srcdir/test-v2v-networks-and-bridges-expected.xml networks diff --git a/v2v/test-v2v-networks-and-bridges.xml b/v2v/test-v2v-networks-and-bridges.xml deleted file mode 100644 index a6409f8..0000000 --- a/v2v/test-v2v-networks-and-bridges.xml +++ /dev/null @@ -1,85 +0,0 @@ -<!-- -libguestfs virt-v2v tool -Copyright (C) 2009-2015 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. ---> -<node> - <domain type='test'> - <name>windows</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='../tests/guests/windows.img'/> - <target dev='vda' bus='virtio'/> - </disk> - - <!-- various different networks and bridges which should - be renamed by the test --> - - <!-- standard ESX bridge --> - <interface type='bridge'> - <mac address='00:00:00:00:00:00'/> - <source bridge='VM Network'/> - <model type='e1000'/> - </interface> - - <!-- another bridge to be remapped --> - <interface type='bridge'> - <mac address='52:54:00:01:02:03'/> - <source bridge='bob'/> - <model type='e1000'/> - </interface> - - <!-- typical libvirt network --> - <interface type='network'> - <mac address='52:54:00:01:02:04'/> - <source network='default'/> - <model type='virtio'/> - </interface> - - <!-- some more random networks to map --> - <interface type='network'> - <mac address='52:54:00:01:02:05'/> - <source network='john'/> - <model type='virtio'/> - </interface> - - <interface type='network'> - <source network='paul'/> - <model type='virtio'/> - <mac address='52:54:00:01:02:06'/> - </interface> - - <interface type='network'> - <model type='rtl8139'/> - <source network='george'/> - <mac address='52:54:00:01:02:07'/> - </interface> - - <interface type='network'> - <mac address='52:54:00:01:02:08'/> - <model type='virtio'/> - <source network='ringo'/> - </interface> - - </devices> - </domain> -</node> diff --git a/v2v/test-v2v-no-copy.sh b/v2v/test-v2v-no-copy.sh index f0408dc..882ce28 100755 --- a/v2v/test-v2v-no-copy.sh +++ b/v2v/test-v2v-no-copy.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_NO_COPY_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,37 +41,31 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-no-copy.d -rm -rf $d -mkdir $d - # No copy with -o local. $VG virt-v2v --debug-gc --no-copy \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d + -o local -os . # Test the libvirt XML metadata was created. -test -f $d/windows.xml +test -f windows.xml # Test the disk was NOT created. -! test -f $d/windows-sda +! test -f windows-sda # --no-copy with -o rhev. -mkdir $d/12345678-1234-1234-1234-123456789abc -mkdir $d/12345678-1234-1234-1234-123456789abc/images -mkdir $d/12345678-1234-1234-1234-123456789abc/master -mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms +mkdir 12345678-1234-1234-1234-123456789abc +mkdir 12345678-1234-1234-1234-123456789abc/images +mkdir 12345678-1234-1234-1234-123456789abc/master +mkdir 12345678-1234-1234-1234-123456789abc/master/vms # $VG - XXX Disabled because the forking used to write files in -o rhev # mode confuses valgrind. virt-v2v --debug-gc --no-copy \ -i libvirt -ic "$libvirt_uri" windows \ - -o rhev -os $d + -o rhev -os . # Test the OVF metadata was created. -test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf +test -f 12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf # Test the disk was NOT created. -! test -f $d/12345678-1234-1234-1234-123456789abc/images/*/*.meta - -rm -r $d +! test -f 12345678-1234-1234-1234-123456789abc/images/*/*.meta diff --git a/v2v/test-v2v-o-glance.sh b/v2v/test-v2v-o-glance.sh index 121177f..7a7366d 100755 --- a/v2v/test-v2v-o-glance.sh +++ b/v2v/test-v2v-o-glance.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_GLANCE_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -50,6 +44,7 @@ fi # We don't want to upload to the real glance, so introduce a fake # glance binary. ln -sf "$(which echo)" glance +export PATH=.:$PATH $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ diff --git a/v2v/test-v2v-o-libvirt.sh b/v2v/test-v2v-o-libvirt.sh index 77b38e0..891ca00 100755 --- a/v2v/test-v2v-o-libvirt.sh +++ b/v2v/test-v2v-o-libvirt.sh @@ -22,11 +22,6 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_LIBVIRT_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 @@ -40,10 +35,9 @@ if [ "$(id -u)" -eq 0 ]; then exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -58,20 +52,16 @@ fi # Generate a random guest name. guestname=tmp-$(tr -cd 'a-f0-9' < /dev/urandom | head -c 8) -d=test-v2v-o-libvirt.d -rm -rf $d -mkdir $d - # Set up the output directory as a libvirt storage pool. virsh pool-destroy test-v2v-libvirt ||: -virsh pool-create-as test-v2v-libvirt dir - - - - $(pwd)/$d +virsh pool-create-as test-v2v-libvirt dir - - - - $(pwd) $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ -o libvirt -os test-v2v-libvirt -on $guestname # Test the disk was created. -test -f $d/$guestname-sda +test -f $guestname-sda # Test the guest exists. virsh dumpxml $guestname @@ -79,4 +69,3 @@ virsh dumpxml $guestname # Clean up. virsh pool-destroy test-v2v-libvirt ||: virsh undefine $guestname ||: -rm -r $d diff --git a/v2v/test-v2v-o-null.sh b/v2v/test-v2v-o-null.sh index 9ed581b..bced065 100755 --- a/v2v/test-v2v-o-null.sh +++ b/v2v/test-v2v-o-null.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_NULL_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 diff --git a/v2v/test-v2v-o-qemu.sh b/v2v/test-v2v-o-qemu.sh index 9de2b56..a1a92f5 100755 --- a/v2v/test-v2v-o-qemu.sh +++ b/v2v/test-v2v-o-qemu.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_QEMU_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 diff --git a/v2v/test-v2v-o-rhev.sh b/v2v/test-v2v-o-rhev.sh index 1162e31..e5baf99 100755 --- a/v2v/test-v2v-o-rhev.sh +++ b/v2v/test-v2v-o-rhev.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_RHEV_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,26 +41,22 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-o-rhev.d -rm -rf $d -mkdir $d - # Create a dummy Export Storage Domain. -mkdir $d/12345678-1234-1234-1234-123456789abc -mkdir $d/12345678-1234-1234-1234-123456789abc/images -mkdir $d/12345678-1234-1234-1234-123456789abc/master -mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms +mkdir 12345678-1234-1234-1234-123456789abc +mkdir 12345678-1234-1234-1234-123456789abc/images +mkdir 12345678-1234-1234-1234-123456789abc/master +mkdir 12345678-1234-1234-1234-123456789abc/master/vms # $VG - XXX Disabled because the forking used to write files in -o rhev # mode confuses valgrind. virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o rhev -os $d + -o rhev -os . # Test the OVF metadata was created. -test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf +test -f 12345678-1234-1234-1234-123456789abc/master/vms/*/*.ovf -pushd $d/12345678-1234-1234-1234-123456789abc/images/* +pushd 12345678-1234-1234-1234-123456789abc/images/* # Test the disk .meta was created. test -f *.meta @@ -76,5 +66,3 @@ vol=`basename *.meta .meta` test -f $vol popd - -rm -r $d diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh index c170467..b9140c5 100755 --- a/v2v/test-v2v-o-vdsm-options.sh +++ b/v2v/test-v2v-o-vdsm-options.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_O_VDSM_OPTIONS_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,38 +41,34 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-o-vdsm-options.d -rm -rf $d -mkdir $d - # Create a dummy Export Storage Domain. -mkdir $d/12345678-1234-1234-1234-123456789abc -mkdir $d/12345678-1234-1234-1234-123456789abc/images -mkdir $d/12345678-1234-1234-1234-123456789abc/images/IMAGE -mkdir $d/12345678-1234-1234-1234-123456789abc/master -mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms -mkdir $d/12345678-1234-1234-1234-123456789abc/master/vms/VM +mkdir 12345678-1234-1234-1234-123456789abc +mkdir 12345678-1234-1234-1234-123456789abc/images +mkdir 12345678-1234-1234-1234-123456789abc/images/IMAGE +mkdir 12345678-1234-1234-1234-123456789abc/master +mkdir 12345678-1234-1234-1234-123456789abc/master/vms +mkdir 12345678-1234-1234-1234-123456789abc/master/vms/VM # The --vdsm-*-uuid options don't actually check that the # parameter is a UUID, which is useful here. $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o vdsm -os $d/12345678-1234-1234-1234-123456789abc \ + -o vdsm -os 12345678-1234-1234-1234-123456789abc \ --vmtype desktop \ --vdsm-image-uuid IMAGE \ --vdsm-vol-uuid VOL \ --vdsm-vm-uuid VM \ - --vdsm-ovf-output $d/12345678-1234-1234-1234-123456789abc/master/vms/VM \ + --vdsm-ovf-output 12345678-1234-1234-1234-123456789abc/master/vms/VM \ # Test the OVF metadata was created. -test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf +test -f 12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf # Test the OVF metadata contains <VmType>0</VmType> (desktop). grep '<VmType>0</VmType>' \ - $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf + 12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf -pushd $d/12345678-1234-1234-1234-123456789abc/images/IMAGE +pushd 12345678-1234-1234-1234-123456789abc/images/IMAGE # Test the disk .meta was created. test -f VOL.meta @@ -87,5 +77,3 @@ test -f VOL.meta test -f VOL popd - -rm -r $d diff --git a/v2v/test-v2v-of-option.sh b/v2v/test-v2v-of-option.sh index 27441cf..1d17283 100755 --- a/v2v/test-v2v-of-option.sh +++ b/v2v/test-v2v-of-option.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_OF_OPTION_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network or qcow2" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,18 +41,12 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-windows-conversion.d -rm -rf $d -mkdir $d - $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d -of qcow2 + -o local -os . -of qcow2 # Test the disk is qcow2 format. -if [ "$(guestfish disk-format $d/windows-sda)" != qcow2 ]; then +if [ "$(guestfish disk-format windows-sda)" != qcow2 ]; then echo "$0: test failed: output is not qcow2" exit 1 fi - -rm -r $d diff --git a/v2v/test-v2v-on-option.sh b/v2v/test-v2v-on-option.sh index e3edb67..8536a91 100755 --- a/v2v/test-v2v-on-option.sh +++ b/v2v/test-v2v-on-option.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_ON_OPTION_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,16 +41,10 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-windows-conversion.d -rm -rf $d -mkdir $d - $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d -on this-is-not-windows + -o local -os . -on this-is-not-windows # Test the libvirt XML metadata and a disk was created. -test -f $d/this-is-not-windows.xml -test -f $d/this-is-not-windows-sda - -rm -r $d +test -f this-is-not-windows.xml +test -f this-is-not-windows-sda diff --git a/v2v/test-v2v-print-source.sh b/v2v/test-v2v-print-source.sh index e7a8382..fd57989 100755 --- a/v2v/test-v2v-print-source.sh +++ b/v2v/test-v2v-print-source.sh @@ -22,38 +22,28 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_PRINT_SOURCE_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi +libvirt_uri="test://$phonydir/guests.xml" -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" - -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 fi -d=test-v2v-print-source.d -rm -rf $d -mkdir $d - $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d \ - --print-source > $d/output + -o local -os . \ + --print-source > output -mv $d/output $d/output.orig -< $d/output.orig \ +mv output output.orig +< output.orig \ grep -v 'Opening the source' | grep -v 'Source guest information' | sed -e 's,/.*/,/,' | grep -v '^$' \ -> $d/output +> output -if [ "$(cat $d/output)" != " source name: windows +if [ "$(cat output)" != " source name: windows hypervisor type: test memory: 1073741824 (bytes) nr vCPUs: 1 @@ -66,8 +56,6 @@ disks: removable media: NICs:" ]; then echo "$0: unexpected output from test:" - cat $d/output.orig + cat output.orig exit 1 fi - -rm -r $d diff --git a/v2v/test-v2v-real-conversions.sh b/v2v/test-v2v-real-conversions.sh index bb98488..adb7b4e 100755 --- a/v2v/test-v2v-real-conversions.sh +++ b/v2v/test-v2v-real-conversions.sh @@ -18,31 +18,24 @@ # Test virt-v2v on some real guests. # -# The phony Fedora guest isn't sufficient for testing. The -# Makefile.am builds some real guests using virt-builder and we just -# run virt-v2v on those (to make sure it doesn't crash / assert). +# The phony Fedora guest isn't sufficient for testing. Build some +# real guests and run virt-v2v on those (to make sure it doesn't +# crash / assert). unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_REAL_CONVERSIONS_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi +real_guests="centos-6 centos-7.0 fedora-22 rhel-5.10 rhel-6.5 rhel-7.0" -d=test-v2v-real-conversions.d -rm -rf $d -mkdir $d - -for file in *.img; do - if test -f $file && test -s $file ; then - n=`basename $file .img` +for g in $real_guests; do + if virt-builder --help >/dev/null && virt-builder --notes $g >/dev/null; then + virt-builder $g # Create some minimal test metadata. - cat > $d/$n-input.xml <<EOF + cat > $g-input.xml <<EOF <domain type='test'> - <name>$n</name> + <name>$g</name> <memory>1048576</memory> <os> <type>hvm</type> @@ -51,7 +44,7 @@ for file in *.img; do <devices> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> - <source file='$(pwd)/$file'/> + <source file='$(pwd)/$g.img'/> <target dev='vda' bus='virtio'/> </disk> </devices> @@ -59,24 +52,22 @@ for file in *.img; do EOF virt-v2v --debug-gc \ - -i libvirtxml $d/$n-input.xml \ - -o local -os $d + -i libvirtxml $g-input.xml \ + -o local -os $(pwd) # Test the libvirt XML metadata and a disk was created. - test -f $d/$n.xml - test -f $d/$n-sda + test -f $g.xml + test -f $g-sda # Test the disk has a similar size to the original. - size_before="$(du $file | awk '{print $1}')" - size_after="$(du $d/$n-sda | awk '{print $1}')" + size_before="$(du $g.img | awk '{print $1}')" + size_after="$(du $g-sda | awk '{print $1}')" diff="$(( 100 * size_after / size_before ))" if test $diff -lt 50; then echo "$0: disk image may have been corrupted or truncated" echo "size_before=$size_before size_after=$size_after diff=$diff" - ls -l $file $d/$n-sda + ls -l $file $g-sda exit 1 fi fi done - -rm -r $d diff --git a/v2v/test-v2v-sound.sh b/v2v/test-v2v-sound.sh index 7cb6f24..cf29fb3 100755 --- a/v2v/test-v2v-sound.sh +++ b/v2v/test-v2v-sound.sh @@ -22,20 +22,12 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_SOUND_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_builddir="$(pwd)" -libvirt_uri="test://$abs_builddir/test-v2v-sound.xml" - -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -47,18 +39,35 @@ if ! test -r $virt_tools_data_dir/rhsrvany.exe; then exit 77 fi -d=test-v2v-sound.d -rm -rf $d -mkdir $d +# Libvirt XML. +echo > guest.xml <<EOF +<node> + <domain type='test'> + <name>windows</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/windows.img'/> + <target dev='vda' bus='virtio'/> + </disk> + <sound model="ich9"/> + </devices> + </domain> +</node> +EOF +libvirt_uri="test://$tmpdir/guest.xml" $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d --no-copy + -o local -os . --no-copy # Test the libvirt XML metadata was created. -test -f $d/windows.xml +test -f windows.xml # Check the <sound> element exists in the output. -grep 'sound model=.ich9' $d/windows.xml - -rm -r $d +grep 'sound model=.ich9' windows.xml diff --git a/v2v/test-v2v-sound.xml b/v2v/test-v2v-sound.xml deleted file mode 100644 index f2babef..0000000 --- a/v2v/test-v2v-sound.xml +++ /dev/null @@ -1,36 +0,0 @@ -<!-- -libguestfs virt-v2v tool -Copyright (C) 2009-2015 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. ---> -<node> - <domain type='test'> - <name>windows</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='../tests/guests/windows.img'/> - <target dev='vda' bus='virtio'/> - </disk> - <sound model="ich9"/> - </devices> - </domain> -</node> diff --git a/v2v/test-v2v-windows-conversion.sh b/v2v/test-v2v-windows-conversion.sh index 7e8e628..4ce93f8 100755 --- a/v2v/test-v2v-windows-conversion.sh +++ b/v2v/test-v2v-windows-conversion.sh @@ -22,20 +22,14 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_V2V_WINDOWS_CONVERSION_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -abs_top_builddir="$(cd ..; pwd)" -libvirt_uri="test://$abs_top_builddir/tests/guests/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" -f=../tests/guests/windows.img +f=$phonydir/windows.img if ! test -f $f || ! test -s $f; then echo "$0: test skipped because phony Windows image was not created" exit 77 @@ -57,21 +51,17 @@ function random_choice choices=("/dev/sda2" "single" "first") root=`random_choice` -d=test-v2v-windows-conversion.d -rm -rf $d -mkdir $d - $VG virt-v2v --debug-gc \ -i libvirt -ic "$libvirt_uri" windows \ - -o local -os $d \ + -o local -os . \ --root $root # Test the libvirt XML metadata and a disk was created. -test -f $d/windows.xml -test -f $d/windows-sda +test -f windows.xml +test -f windows-sda # Test some aspects of the target disk image. -guestfish --ro -a $d/windows-sda -i <<EOF +guestfish --ro -a windows-sda -i <<EOF is-dir "/Program Files/Red Hat/Firstboot" is-file "/Program Files/Red Hat/Firstboot/firstboot.bat" is-dir "/Program Files/Red Hat/Firstboot/scripts" @@ -81,5 +71,3 @@ EOF # We also update the Registry several times, for firstboot, and (ONLY # if the virtio-win drivers are installed locally) the critical device # database. - -rm -r $d diff --git a/v2v/tests.mk b/v2v/tests.mk new file mode 100644 index 0000000..a10844f --- /dev/null +++ b/v2v/tests.mk @@ -0,0 +1,101 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/v2v + +localtests_DATA = \ + test-v2v-cdrom.expected \ + test-v2v-i-ova-formats.expected \ + test-v2v-i-ova-formats.ovf \ + test-v2v-i-ova-gz.expected \ + test-v2v-i-ova-gz.ovf \ + test-v2v-i-ova-two-disks.expected \ + test-v2v-i-ova-two-disks.ovf \ + test-v2v-i-ova.ovf \ + test-v2v-i-ova.xml \ + test-v2v-networks-and-bridges-expected.xml + +localtests_SCRIPTS = \ + test-v2v-cdrom.sh \ + test-v2v-i-disk.sh \ + test-v2v-i-ova-formats.sh \ + test-v2v-i-ova-gz.sh \ + test-v2v-i-ova-two-disks.sh \ + test-v2v-i-ova.sh \ + test-v2v-machine-readable.sh \ + test-v2v-networks-and-bridges.sh \ + test-v2v-no-copy.sh \ + test-v2v-o-glance.sh \ + test-v2v-o-libvirt.sh \ + test-v2v-o-null.sh \ + test-v2v-o-qemu.sh \ + test-v2v-o-rhev.sh \ + test-v2v-o-vdsm-options.sh \ + test-v2v-of-option.sh \ + test-v2v-on-option.sh \ + test-v2v-print-source.sh \ + test-v2v-real-conversions.sh \ + test-v2v-sound.sh \ + test-v2v-windows-conversion.sh + +localtests_PROGRAMS = \ + v2v_unit_tests + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +check-slow: + $(top_builddir)/run $(top_builddir)/test-harness --slow + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 12/17] tools: Convert tools to use the test harness.
--- generator/tests.ml | 10 ++++++ tools/Makefile.am | 16 ++++------ tools/test-virt-list-filesystems.sh | 2 +- tools/test-virt-tar.sh | 2 +- tools/tests.mk | 61 +++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 tools/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 3b72fd8..fa720bc 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -662,4 +662,14 @@ let tests = [ ]; }; + (* Tools written in Perl. *) + + "tools", { + defaults with + check = [ + "test-virt-list-filesystems.sh"; + "test-virt-tar.sh"; + ]; + }; + ] diff --git a/tools/Makefile.am b/tools/Makefile.am index 40ee410..6a25f50 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + tools = \ list-filesystems \ list-partitions \ @@ -28,7 +30,8 @@ CLEANFILES = *.pl EXTRA_DIST = \ $(tools:%=virt-%) \ - test-virt-*.sh + test-virt-list-filesystems.sh \ + test-virt-tar.sh if HAVE_TOOLS @@ -55,16 +58,9 @@ $(top_builddir)/html/virt-%.1.html: virt-% --license GPLv2+ \ $< -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = test-virt-list-filesystems.sh \ - test-virt-tar.sh -endif ENABLE_APPLIANCE - endif all-local: for f in $(tools:%=tools/virt-%); do echo $$f; done > $(top_srcdir)/po/POTFILES-pl + +include $(srcdir)/tests.mk diff --git a/tools/test-virt-list-filesystems.sh b/tools/test-virt-list-filesystems.sh index a78f359..125d6d3 100755 --- a/tools/test-virt-list-filesystems.sh +++ b/tools/test-virt-list-filesystems.sh @@ -21,7 +21,7 @@ set -e # Run virt-list-filesystems. # Only columns 1 & 2 are guaranteed, we may add more in future. -if [ "$($srcdir/virt-list-filesystems -l ../tests/guests/fedora.img | +if [ "$(virt-list-filesystems -l $phonydir/fedora.img | sort | awk '{print $1 $2}')" \ != \ "/dev/VG/LV1ext2 diff --git a/tools/test-virt-tar.sh b/tools/test-virt-tar.sh index f363e04..8694d84 100755 --- a/tools/test-virt-tar.sh +++ b/tools/test-virt-tar.sh @@ -20,7 +20,7 @@ export LANG=C set -e # Read out the test directory using virt-tar. -$srcdir/virt-tar -x ../tests/guests/fedora.img /bin test.tar +virt-tar -x $phonydir/fedora.img /bin test.tar if [ "$(tar tf test.tar | sort)" != "./ ./ls diff --git a/tools/tests.mk b/tools/tests.mk new file mode 100644 index 0000000..cd4f12f --- /dev/null +++ b/tools/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/tools + +localtests_SCRIPTS = \ + test-virt-list-filesystems.sh \ + test-virt-tar.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 13/17] p2v: Convert virt-p2v to use the test harness.
--- generator/tests.ml | 13 +++++++++ p2v/Makefile.am | 21 ++++---------- p2v/test-virt-p2v-cmdline.sh | 5 ---- p2v/test-virt-p2v.sh | 12 ++------ p2v/tests.mk | 67 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 p2v/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index fa720bc..2f0d9f0 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -479,6 +479,19 @@ let tests = [ ] }; + "p2v", { + defaults with + check_fast = [ + "test-virt-p2v-cmdline.sh"; + ]; + check = [ + "test-virt-p2v.sh"; + ]; + check_data = [ + "test-virt-p2v-ssh.sh"; + ]; + }; + (* Test language bindings. *) "ocaml", { diff --git a/p2v/Makefile.am b/p2v/Makefile.am index 57efd8d..4c774c4 100644 --- a/p2v/Makefile.am +++ b/p2v/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ HACKING \ dependencies.m4 \ @@ -24,6 +26,9 @@ EXTRA_DIST = \ launch-virt-p2v.in \ p2v.ks.in \ p2v.service \ + test-virt-p2v-cmdline.sh \ + test-virt-p2v.sh \ + test-virt-p2v-ssh.sh \ virt-p2v.pod \ virt-p2v-make-disk.in \ virt-p2v-make-disk.pod \ @@ -151,18 +156,4 @@ stamp-virt-p2v-make-kickstart.pod: virt-p2v-make-kickstart.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS = \ - test-virt-p2v-cmdline.sh - -if ENABLE_APPLIANCE -TESTS += \ - test-virt-p2v.sh -endif ENABLE_APPLIANCE - -EXTRA_DIST += \ - $(TESTS) \ - test-virt-p2v-ssh.sh +include $(srcdir)/tests.mk diff --git a/p2v/test-virt-p2v-cmdline.sh b/p2v/test-virt-p2v-cmdline.sh index bdd51d3..7f6db93 100755 --- a/p2v/test-virt-p2v-cmdline.sh +++ b/p2v/test-virt-p2v-cmdline.sh @@ -22,11 +22,6 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_VIRT_P2V_CMDLINE_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - out=test-virt-p2v-cmdline.out rm -f $out diff --git a/p2v/test-virt-p2v.sh b/p2v/test-virt-p2v.sh index 8c3731c..fe5b389 100755 --- a/p2v/test-virt-p2v.sh +++ b/p2v/test-virt-p2v.sh @@ -22,23 +22,17 @@ unset CDPATH export LANG=C set -e -if [ -n "$SKIP_TEST_VIRT_P2V_SH" ]; then - echo "$0: test skipped because environment variable is set" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because UML backend does not support network" exit 77 fi -guestsdir="$(cd ../tests/guests && pwd)" -f1="$guestsdir/windows.img" +f1="$phonydir/windows.img" if ! test -f $f1 || ! test -s $f1; then echo "$0: test skipped because phony Windows image was not created" exit 77 fi -f2="$guestsdir/blank-part.img" +f2="$phonydir/blank-part.img" if ! test -f $f2 || ! test -s $f2; then echo "$0: test skipped because blank-part.img was not created" exit 77 @@ -57,7 +51,7 @@ mkdir $d # We don't want the program under test to run real 'ssh'. It's # unlikely to work. Therefore create a dummy 'ssh' binary. pushd $d -ln -sf ../test-virt-p2v-ssh.sh ssh +ln -sf $srcdir/test-virt-p2v-ssh.sh ssh popd export PATH=$d:$PATH diff --git a/p2v/tests.mk b/p2v/tests.mk new file mode 100644 index 0000000..2093fd9 --- /dev/null +++ b/p2v/tests.mk @@ -0,0 +1,67 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/p2v + +localtests_DATA = \ + test-virt-p2v-ssh.sh + +localtests_SCRIPTS = \ + test-virt-p2v-cmdline.sh \ + test-virt-p2v.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 14/17] align, etc.: Convert more virt-* tools to use the test harness.
Use test-harness framework for the following directories: align diff df edit format fuse make-fs rescue --- .gitignore | 1 + align/Makefile.am | 17 ++----- align/test-virt-alignment-scan-guests.sh | 8 +--- align/test-virt-alignment-scan.sh | 2 +- align/tests.mk | 61 +++++++++++++++++++++++++ configure.ac | 2 + df/Makefile.am | 21 ++------- df/test-virt-df-guests.sh | 8 +--- df/test-virt-df-local-guests.sh.in | 24 ++++++++++ df/test-virt-df.sh | 2 +- df/tests.mk | 68 ++++++++++++++++++++++++++++ diff/Makefile.am | 14 ++---- diff/test-virt-diff.sh | 6 +-- diff/tests.mk | 60 +++++++++++++++++++++++++ edit/Makefile.am | 10 ++--- edit/test-virt-edit.sh | 2 +- edit/tests.mk | 60 +++++++++++++++++++++++++ format/Makefile.am | 16 ++----- format/test-virt-format.sh | 5 --- format/tests.mk | 60 +++++++++++++++++++++++++ fuse/Makefile.am | 38 ++++++++-------- fuse/test-fuse-umount-race.sh | 18 ++------ fuse/test-fuse.c | 11 ----- fuse/test-guestmount-fd.c | 39 ++++++++-------- fuse/test-guestunmount-fd.c | 18 +------- fuse/test-guestunmount-not-mounted.sh | 12 +---- fuse/tests.mk | 69 +++++++++++++++++++++++++++++ generator/tests.ml | 76 ++++++++++++++++++++++++++++++-- make-fs/Makefile.am | 14 ++---- make-fs/test-virt-make-fs.sh | 5 --- make-fs/tests.mk | 60 +++++++++++++++++++++++++ rescue/Makefile.am | 17 ++----- rescue/test-virt-rescue-suggest.sh | 2 +- rescue/test-virt-rescue.pl | 2 +- rescue/tests.mk | 61 +++++++++++++++++++++++++ 35 files changed, 676 insertions(+), 213 deletions(-) create mode 100644 align/tests.mk create mode 100755 df/test-virt-df-local-guests.sh.in create mode 100644 df/tests.mk create mode 100644 diff/tests.mk create mode 100644 edit/tests.mk create mode 100644 format/tests.mk create mode 100644 fuse/tests.mk create mode 100644 make-fs/tests.mk create mode 100644 rescue/tests.mk diff --git a/.gitignore b/.gitignore index 8f48e9e..e35a7b3 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,7 @@ Makefile.in /daemon/stubs.c /depcomp /df/stamp-virt-df.pod +/df/test-virt-df-local-guests.sh /df/virt-df /df/virt-df.1 /dib/.depend diff --git a/align/Makefile.am b/align/Makefile.am index 92b86b7..b6ee730 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-alignment-scan.sh \ test-virt-alignment-scan-guests.sh \ @@ -86,17 +88,4 @@ stamp-virt-alignment-scan.pod: virt-alignment-scan.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS - -if ENABLE_APPLIANCE -TESTS += \ - test-virt-alignment-scan.sh \ - test-virt-alignment-scan-guests.sh -endif - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk diff --git a/align/test-virt-alignment-scan-guests.sh b/align/test-virt-alignment-scan-guests.sh index 99e2585..a013705 100755 --- a/align/test-virt-alignment-scan-guests.sh +++ b/align/test-virt-alignment-scan-guests.sh @@ -18,13 +18,7 @@ export LANG=C -if [ -n "$SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH" ]; then - echo "$0: skipping test because SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH is set." - exit 77 -fi - -guestsdir="$(cd ../tests/guests && pwd)" -libvirt_uri="test://$guestsdir/guests-all-good.xml" +libvirt_uri="test://$phonydir/guests-all-good.xml" $VG virt-alignment-scan -c "$libvirt_uri" r=$? diff --git a/align/test-virt-alignment-scan.sh b/align/test-virt-alignment-scan.sh index 293a9ef..35d7a2e 100755 --- a/align/test-virt-alignment-scan.sh +++ b/align/test-virt-alignment-scan.sh @@ -18,7 +18,7 @@ export LANG=C -$VG virt-alignment-scan -a ../tests/guests/fedora.img +$VG virt-alignment-scan -a $phonydir/fedora.img r=$? # 0, 2 and 3 are reasonable non-error exit codes. Others are errors. diff --git a/align/tests.mk b/align/tests.mk new file mode 100644 index 0000000..6b2afef --- /dev/null +++ b/align/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/align + +localtests_SCRIPTS = \ + test-virt-alignment-scan-guests.sh \ + test-virt-alignment-scan.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/configure.ac b/configure.ac index cd075dd..de480e7 100644 --- a/configure.ac +++ b/configure.ac @@ -1702,6 +1702,8 @@ AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance], [chmod +x,-w appliance/libguestfs-make-fixed-appliance]) AC_CONFIG_FILES([cat/test-virt-filesystems-local-guests.sh], [chmod +x,-w cat/test-virt-filesystems-local-guests.sh]) +AC_CONFIG_FILES([df/test-virt-df-local-guests.sh], + [chmod +x,-w cat/test-virt-df-local-guests.sh]) AC_CONFIG_FILES([inspector/test-virt-inspector-local-guests.sh], [chmod +x,-w inspector/test-virt-inspector-local-guests.sh]) AC_CONFIG_FILES([inspector/test-xmllint.sh], diff --git a/df/Makefile.am b/df/Makefile.am index e56ac79..c5ba19e 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -17,10 +17,13 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ README \ test-virt-df.sh \ test-virt-df-guests.sh \ + test-virt-df-guests-missing.sh \ virt-df.pod CLEANFILES = stamp-virt-df.pod @@ -89,20 +92,4 @@ stamp-virt-df.pod: virt-df.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS - -if ENABLE_APPLIANCE -TESTS += \ - test-virt-df.sh \ - test-virt-df-guests.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -check-valgrind-local-guests: - $(top_builddir)/run --test @VG@ ./virt-df -c "$(libvirt_ro_uri)" +include $(srcdir)/tests.mk diff --git a/df/test-virt-df-guests.sh b/df/test-virt-df-guests.sh index b485cd7..78e6f2c 100755 --- a/df/test-virt-df-guests.sh +++ b/df/test-virt-df-guests.sh @@ -21,12 +21,6 @@ export LANG=C set -e -if [ -n "$SKIP_TEST_VIRT_DF_GUESTS_SH" ]; then - echo "$0: skipping test because SKIP_TEST_DF_GUESTS_SH is set." - exit 77 -fi - -guestsdir="$(cd ../tests/guests && pwd)" -libvirt_uri="test://$guestsdir/guests.xml" +libvirt_uri="test://$phonydir/guests.xml" $VG virt-df -c "$libvirt_uri" diff --git a/df/test-virt-df-local-guests.sh.in b/df/test-virt-df-local-guests.sh.in new file mode 100755 index 0000000..188e52b --- /dev/null +++ b/df/test-virt-df-local-guests.sh.in @@ -0,0 +1,24 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2015 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. + +export LANG=C +set -e + +for g in "$@"; do + $VG virt-df -c "@libvirt_ro_uri@" +done diff --git a/df/test-virt-df.sh b/df/test-virt-df.sh index a776c4c..02e5bba 100755 --- a/df/test-virt-df.sh +++ b/df/test-virt-df.sh @@ -20,7 +20,7 @@ export LANG=C set -e # Run virt-df. -output=$($VG virt-df ../tests/guests/fedora.img) +output=$($VG virt-df $phonydir/fedora.img) # Check title is the first line. if [[ ! $output =~ ^Filesystem.* ]]; then diff --git a/df/tests.mk b/df/tests.mk new file mode 100644 index 0000000..da5f0e7 --- /dev/null +++ b/df/tests.mk @@ -0,0 +1,68 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/df + +localtests_SCRIPTS = \ + test-virt-df-guests.sh \ + test-virt-df-local-guests.sh \ + test-virt-df.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --local-guests + +check-valgrind-local-guests: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests + +EXTRA_DIST += tests.mk diff --git a/diff/Makefile.am b/diff/Makefile.am index 65a8a30..a84e569 100644 --- a/diff/Makefile.am +++ b/diff/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-diff.sh \ virt-diff.pod @@ -75,14 +77,4 @@ stamp-virt-diff.pod: virt-diff.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = \ - test-virt-diff.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk diff --git a/diff/test-virt-diff.sh b/diff/test-virt-diff.sh index fa13411..9bafa5a 100755 --- a/diff/test-virt-diff.sh +++ b/diff/test-virt-diff.sh @@ -19,7 +19,7 @@ export LANG=C set -e -if [ ! -f ../tests/guests/fedora.img ]; then +if [ ! -f $phonydir/fedora.img ]; then echo "$0: test skipped because there is no phony fedora test image" exit 77 fi @@ -34,14 +34,14 @@ rm -f fedora.qcow2 # Modify a copy of the image. guestfish -- \ disk-create fedora.qcow2 qcow2 -1 \ - backingfile:../tests/guests/fedora.img backingformat:raw + backingfile:$phonydir/fedora.img backingformat:raw guestfish -a fedora.qcow2 -i <<EOF touch /diff write-append /etc/motd "Testing virt-diff\n" EOF -output="$($VG virt-diff -a ../tests/guests/fedora.img -A fedora.qcow2)" +output="$($VG virt-diff -a $phonydir/fedora.img -A fedora.qcow2)" expected="\ + - 0644 0 /diff diff --git a/diff/tests.mk b/diff/tests.mk new file mode 100644 index 0000000..ec78692 --- /dev/null +++ b/diff/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/diff + +localtests_SCRIPTS = \ + test-virt-diff.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/edit/Makefile.am b/edit/Makefile.am index bbb7254..dbf5f03 100644 --- a/edit/Makefile.am +++ b/edit/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-edit.sh \ virt-edit.pod @@ -78,10 +80,4 @@ stamp-virt-edit.pod: virt-edit.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = test-virt-edit.sh -endif ENABLE_APPLIANCE +include $(srcdir)/tests.mk diff --git a/edit/test-virt-edit.sh b/edit/test-virt-edit.sh index 810e1c1..f752039 100755 --- a/edit/test-virt-edit.sh +++ b/edit/test-virt-edit.sh @@ -30,7 +30,7 @@ rm -f test.qcow2 # discard it. guestfish -- \ disk-create test.qcow2 qcow2 -1 \ - backingfile:../tests/guests/fedora.img backingformat:raw + backingfile:$phonydir/fedora.img backingformat:raw # Edit interactively. We have to simulate this by setting $EDITOR. # The command will be: echo newline >> /tmp/file diff --git a/edit/tests.mk b/edit/tests.mk new file mode 100644 index 0000000..b021e40 --- /dev/null +++ b/edit/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/edit + +localtests_SCRIPTS = \ + test-virt-edit.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/format/Makefile.am b/format/Makefile.am index 276cfc3..e9f28ab 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -17,7 +17,10 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ + test-virt-format.sh \ virt-format.pod CLEANFILES = stamp-virt-format.pod @@ -74,15 +77,4 @@ stamp-virt-format.pod: virt-format.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = test-virt-format.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check - -EXTRA_DIST += test-virt-format.sh +include $(srcdir)/tests.mk diff --git a/format/test-virt-format.sh b/format/test-virt-format.sh index 2383c71..ecb6d2a 100755 --- a/format/test-virt-format.sh +++ b/format/test-virt-format.sh @@ -20,11 +20,6 @@ set -e -if [ -n "$SKIP_TEST_VIRT_FORMAT_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - rm -f test-virt-format.img $VG guestfish -N test-virt-format.img=bootrootlv exit diff --git a/format/tests.mk b/format/tests.mk new file mode 100644 index 0000000..f9815ad --- /dev/null +++ b/format/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/format + +localtests_SCRIPTS = \ + test-virt-format.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/fuse/Makefile.am b/fuse/Makefile.am index 318061b..1ed73ae 100644 --- a/fuse/Makefile.am +++ b/fuse/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ guestmount.pod \ guestunmount.pod \ @@ -124,25 +126,6 @@ stamp-guestunmount.pod: guestunmount.pod $< touch $@ -# Tests. - -TESTS = \ - test-guestunmount-fd \ - test-guestunmount-not-mounted.sh - -if ENABLE_APPLIANCE -TESTS += \ - test-fuse \ - test-fuse-umount-race.sh \ - test-guestmount-fd -endif ENABLE_APPLIANCE - -TESTS_ENVIRONMENT = \ - top_builddir=.. \ - $(top_builddir)/run --test - -check_PROGRAMS = test-fuse test-guestmount-fd test-guestunmount-fd - test_fuse_SOURCES = \ test-fuse.c @@ -197,4 +180,19 @@ test_guestunmount_fd_LDADD = \ $(LTLIBINTL) \ ../gnulib/lib/libgnu.la -endif HAVE_FUSE +else + +# Without fuse, generate some dummy test programs. +test-guestmount-fd: + echo 'exit 77' > $@ + chmod 0755 $@ +test-guestunmount-fd: + echo 'exit 77' > $@ + chmod 0755 $@ +test-fuse: + echo 'exit 77' > $@ + chmod 0755 $@ + +endif + +include $(srcdir)/tests.mk diff --git a/fuse/test-fuse-umount-race.sh b/fuse/test-fuse-umount-race.sh index a1f21ae..aeaacf9 100755 --- a/fuse/test-fuse-umount-race.sh +++ b/fuse/test-fuse-umount-race.sh @@ -23,22 +23,12 @@ unset CDPATH set -e #set -v -if [ -n "$SKIP_TEST_FUSE_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - -if [ -n "$SKIP_TEST_FUSE_UMOUNT_RACE_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - if [ ! -w /dev/fuse ]; then echo "$0: test skipped because there is no /dev/fuse." exit 77 fi -if [ ! -f ../tests/guests/fedora.img ]; then +if [ ! -f $phonydir/fedora.img ]; then echo "$0: test skipped because fedora.img test guest does not exist." exit 77 fi @@ -54,10 +44,10 @@ rm -rf mp # Make a copy of the Fedora image so we can write to it then discard it. guestfish -- \ disk-create test.qcow2 qcow2 -1 \ - backingfile:../tests/guests/fedora.img backingformat:raw + backingfile:$phonydir/fedora.img backingformat:raw mkdir mp -./guestmount -a test.qcow2 -m /dev/VG/Root --pid-file test.pid mp +guestmount -a test.qcow2 -m /dev/VG/Root --pid-file test.pid mp cp $0 mp/test-umount # Save the PID of guestmount. @@ -66,7 +56,7 @@ pid="$(cat test.pid)" timeout=10 # Unmount the mountpoint. -./guestunmount -v mp +guestunmount -v mp # Wait for guestmount to exit. count=$timeout diff --git a/fuse/test-fuse.c b/fuse/test-fuse.c index 6e91d71..c1d093b 100644 --- a/fuse/test-fuse.c +++ b/fuse/test-fuse.c @@ -68,7 +68,6 @@ static int test_fuse (void); int main (int argc, char *argv[]) { - const char *s; const char *acl_group[] = { "acl", NULL }; const char *linuxxattrs_group[] = { "linuxxattrs", NULL }; int debug_calls, r, res; @@ -76,16 +75,6 @@ main (int argc, char *argv[]) struct sigaction sa; char cmd[128]; - /* Allow the test to be skipped. Note I'm using the old shell - * script name here. - */ - s = getenv ("SKIP_TEST_FUSE_SH"); - if (s && STRNEQ (s, "")) { - printf ("%s: test skipped because environment variable is set\n", - argv[0]); - exit (77); - } - if (access ("/dev/fuse", W_OK) == -1) { perror ("/dev/fuse"); exit (77); diff --git a/fuse/test-guestmount-fd.c b/fuse/test-guestmount-fd.c index d6fe12b..8ee44a8 100644 --- a/fuse/test-guestmount-fd.c +++ b/fuse/test-guestmount-fd.c @@ -33,39 +33,40 @@ #include "guestfs.h" #include "guestfs-internal-frontend.h" -#define GUESTMOUNT_BINARY "./guestmount" -#define GUESTUNMOUNT_BINARY "./guestunmount" -#define TEST_IMAGE "../tests/guests/fedora.img" +#define GUESTMOUNT_BINARY "guestmount" +#define GUESTUNMOUNT_BINARY "guestunmount" +#define TEST_IMAGE "fedora.img" #define MOUNTPOINT "test-guestmount-fd.d" #define TEST_FILE MOUNTPOINT "/etc/fstab" int main (int argc, char *argv[]) { - char *skip; + const char *phonydir; + char *test_image; + size_t len; int pipefd[2]; pid_t pid; char c; int r, status; - /* Allow the test to be skipped. */ - skip = getenv ("SKIP_TEST_FUSE_SH"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", + phonydir = getenv ("phonydir"); + if (phonydir == NULL) { + fprintf (stderr, "%s: $phonydir was not set by test harness\n", guestfs_int_program_name); - exit (77); + exit (EXIT_FAILURE); } - - skip = getenv ("SKIP_TEST_GUESTMOUNT_FD"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - guestfs_int_program_name); - exit (77); + len = strlen (phonydir) + strlen (TEST_IMAGE) + 1; + test_image = malloc (len+1); + if (test_image == NULL) { + perror ("malloc"); + exit (EXIT_FAILURE); } + snprintf (test_image, len, "%s/%s", phonydir, TEST_IMAGE); /* Skip the test if the test image can't be found. */ - if (access (TEST_IMAGE, R_OK) == -1) { - perror (TEST_IMAGE); + if (access (test_image, R_OK) == -1) { + perror (test_image); exit (77); } @@ -107,7 +108,7 @@ main (int argc, char *argv[]) execlp (GUESTMOUNT_BINARY, "guestmount", "--fd", fd_str, "--no-fork", - "--ro", "-a", TEST_IMAGE, "-i", MOUNTPOINT, NULL); + "--ro", "-a", test_image, "-i", MOUNTPOINT, NULL); perror ("execlp"); _exit (EXIT_FAILURE); } @@ -173,5 +174,7 @@ main (int argc, char *argv[]) ignore_value (rmdir (MOUNTPOINT)); + free (test_image); + exit (EXIT_SUCCESS); } diff --git a/fuse/test-guestunmount-fd.c b/fuse/test-guestunmount-fd.c index c4b833f..c73fced 100644 --- a/fuse/test-guestunmount-fd.c +++ b/fuse/test-guestunmount-fd.c @@ -39,26 +39,10 @@ int main (int argc, char *argv[]) { - char *skip; int pipefd[2]; pid_t pid; int r, status; - /* Allow the test to be skipped. */ - skip = getenv ("SKIP_TEST_FUSE_SH"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - guestfs_int_program_name); - exit (77); - } - - skip = getenv ("SKIP_TEST_GUESTUNMOUNT_FD"); - if (skip && guestfs_int_is_true (skip) > 0) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - guestfs_int_program_name); - exit (77); - } - /* Create the pipe. */ if (pipe (pipefd) == -1) { perror ("pipe"); @@ -79,7 +63,7 @@ main (int argc, char *argv[]) snprintf (fd_str, sizeof fd_str, "%d", pipefd[0]); - execlp ("./guestunmount", "guestunmount", "--fd", fd_str, "/", NULL); + execlp ("guestunmount", "guestunmount", "--fd", fd_str, "/", NULL); perror ("execlp"); _exit (EXIT_FAILURE); } diff --git a/fuse/test-guestunmount-not-mounted.sh b/fuse/test-guestunmount-not-mounted.sh index 5e1febe..1d76a13 100755 --- a/fuse/test-guestunmount-not-mounted.sh +++ b/fuse/test-guestunmount-not-mounted.sh @@ -24,23 +24,13 @@ unset CDPATH #set -e #set -v -if [ -n "$SKIP_TEST_FUSE_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - -if [ -n "$SKIP_TEST_GUESTUNMOUNT_NOT_MOUNTED_SH" ]; then - echo "$0: test skipped because environment variable is set." - exit 77 -fi - if [ ! -w /dev/fuse ]; then echo "SKIPPING guestunmount test, because there is no /dev/fuse." exit 77 fi # Not expecting cwd to be a FUSE mountpoint. -./guestunmount --quiet $(pwd) +guestunmount --quiet $(pwd) r=$? case $r in 0) diff --git a/fuse/tests.mk b/fuse/tests.mk new file mode 100644 index 0000000..98f08c9 --- /dev/null +++ b/fuse/tests.mk @@ -0,0 +1,69 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/fuse + +localtests_SCRIPTS = \ + test-fuse-umount-race.sh \ + test-guestunmount-not-mounted.sh + +localtests_PROGRAMS = \ + test-fuse \ + test-guestmount-fd \ + test-guestunmount-fd + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 2f0d9f0..a88276d 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -392,6 +392,14 @@ let tests = [ (* Test tools written in C. *) + "align", { + defaults with + check = [ + "test-virt-alignment-scan.sh"; + "test-virt-alignment-scan-guests.sh"; + ]; + }; + "cat", { defaults with check = [ @@ -405,6 +413,31 @@ let tests = [ ]; }; + "diff", { + defaults with + check = [ + "test-virt-diff.sh"; + ]; + }; + + "df", { + defaults with + check = [ + "test-virt-df.sh"; + "test-virt-df-guests.sh"; + ]; + check_local_guests = [ + "test-virt-df-local-guests.sh"; + ]; + }; + + "edit", { + defaults with + check = [ + "test-virt-edit.sh" + ]; + }; + "fish", { defaults with check_fast = [ @@ -436,6 +469,26 @@ let tests = [ ]; }; + "format", { + defaults with + check = [ + "test-virt-format.sh" + ]; + }; + + "fuse", { + defaults with + check_fast = [ + "test-guestunmount-fd"; + "test-guestunmount-not-mounted.sh"; + ]; + check = [ + "test-fuse"; + "test-fuse-umount-race.sh"; + "test-guestmount-fd"; + ]; + }; + "inspector", { defaults with check = [ @@ -472,11 +525,11 @@ let tests = [ ] }; - "src", { + "make-fs", { defaults with - check_fast = [ - "test-utils"; - ] + check = [ + "test-virt-make-fs.sh" + ]; }; "p2v", { @@ -492,6 +545,21 @@ let tests = [ ]; }; + "rescue", { + defaults with + check = [ + "test-virt-rescue.pl"; + "test-virt-rescue-suggest.sh"; + ]; + }; + + "src", { + defaults with + check_fast = [ + "test-utils"; + ] + }; + (* Test language bindings. *) "ocaml", { diff --git a/make-fs/Makefile.am b/make-fs/Makefile.am index b88ece0..45a99ec 100644 --- a/make-fs/Makefile.am +++ b/make-fs/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-make-fs.sh \ virt-make-fs.pod @@ -69,14 +71,4 @@ stamp-virt-make-fs.pod: virt-make-fs.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -if ENABLE_APPLIANCE -TESTS = \ - test-virt-make-fs.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk diff --git a/make-fs/test-virt-make-fs.sh b/make-fs/test-virt-make-fs.sh index 9897473..38adb5c 100755 --- a/make-fs/test-virt-make-fs.sh +++ b/make-fs/test-virt-make-fs.sh @@ -34,11 +34,6 @@ perl -MSys::Guestfs -e ' $g->feature_available (["btrfs"]) and print "btrfs_available=yes\n"; ') -# Allow btrfs to be disabled when btrfs is broken (eg. RHBZ#863978). -if [ -n "$SKIP_TEST_VIRT_MAKE_FS_BTRFS" ]; then - btrfs_available-fi - # UML backend doesn't support qcow2. if [ "$(guestfish get-backend)" != "uml" ]; then qcow2_supported=yes diff --git a/make-fs/tests.mk b/make-fs/tests.mk new file mode 100644 index 0000000..166549e --- /dev/null +++ b/make-fs/tests.mk @@ -0,0 +1,60 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/make-fs + +localtests_SCRIPTS = \ + test-virt-make-fs.sh + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk diff --git a/rescue/Makefile.am b/rescue/Makefile.am index eab06e9..947cb06 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -17,6 +17,8 @@ include $(top_srcdir)/subdir-rules.mk +generator_built = tests.mk + EXTRA_DIST = \ test-virt-rescue.pl \ test-virt-rescue-suggest.sh \ @@ -76,17 +78,4 @@ stamp-virt-rescue.pod: virt-rescue.pod $< touch $@ -# Tests. - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -TESTS - -if ENABLE_APPLIANCE -TESTS += \ - test-virt-rescue.pl \ - test-virt-rescue-suggest.sh -endif ENABLE_APPLIANCE - -check-valgrind: - $(MAKE) TESTS="test-virt-rescue-suggest.sh" VG="$(top_builddir)/run @VG@" check +include $(srcdir)/tests.mk diff --git a/rescue/test-virt-rescue-suggest.sh b/rescue/test-virt-rescue-suggest.sh index f79e4f8..2e1cf7a 100755 --- a/rescue/test-virt-rescue-suggest.sh +++ b/rescue/test-virt-rescue-suggest.sh @@ -19,7 +19,7 @@ export LANG=C set -e -guest=../tests/guests/fedora.img +guest=$phonydir/fedora.img if [ ! -s "$guest" ]; then echo "$0: test skipped because $guest does not exist or is an empty file" diff --git a/rescue/test-virt-rescue.pl b/rescue/test-virt-rescue.pl index 9547fd6..8dea87e 100755 --- a/rescue/test-virt-rescue.pl +++ b/rescue/test-virt-rescue.pl @@ -31,7 +31,7 @@ unless (exists $INC{"Expect.pm"}) { } # Run virt-rescue and make sure we get to the rescue prompt. -my $exp = Expect->spawn ("./virt-rescue", "--scratch") +my $exp = Expect->spawn ("virt-rescue", "--scratch") or die "$progname: Expect could not spawn virt-rescue: $!\n"; my $timeout = 5 * 60; diff --git a/rescue/tests.mk b/rescue/tests.mk new file mode 100644 index 0000000..5401a78 --- /dev/null +++ b/rescue/tests.mk @@ -0,0 +1,61 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/rescue + +localtests_SCRIPTS = \ + test-virt-rescue-suggest.sh \ + test-virt-rescue.pl + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 15/17] builder: Rationalize the tests.
Instead of using a pre-built test-config/ subdirectory, just create the required config on the fly when we need it in the tests. Don't add *.xz files to check_data since that requires that we have a working appliance in order to do a simple 'make', which doesn't work on --disable-appliance builds. Instead, create the disk images on demand in the test scripts. At the same time, remove the website override in ./run since that always breaks 'make check-slow' during the release tests. --- builder/Makefile.am | 19 -------------- .../virt-builder/repos.d/test-index.conf.in | 2 -- builder/test-virt-builder-list.sh | 15 ++++++++--- builder/test-virt-builder-planner.sh | 30 ++++++++++++++-------- builder/test-virt-builder.sh | 17 ++++++++---- .../virt-builder/repos.d/libguestfs.conf.in | 3 --- builder/tests.mk | 6 ----- configure.ac | 2 -- generator/tests.ml | 6 ----- run.in | 7 ----- 10 files changed, 44 insertions(+), 63 deletions(-) delete mode 100644 builder/test-config/virt-builder/repos.d/test-index.conf.in delete mode 100644 builder/test-website/virt-builder/repos.d/libguestfs.conf.in diff --git a/builder/Makefile.am b/builder/Makefile.am index aa74c3d..2e10d41 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -207,25 +207,6 @@ stamp-virt-builder.pod: virt-builder.pod $(top_srcdir)/customize/customize-synop CLEANFILES += stamp-virt-builder.pod -# Disk images for tests. - -CLEANFILES += *.qcow2 *.xz - -fedora.qcow2: ../tests/guests/fedora.img - rm -f $@ $@-t - qemu-img convert -f raw -O qcow2 $< $@-t - mv $@-t $@ - -fedora.qcow2.xz: fedora.qcow2 - rm -f $@ $@-t - xz --best -c $< > $@-t - mv $@-t $@ - -%.xz: ../tests/guests/%.img - rm -f $@ $@-t - xz --best -c $< > $@-t - mv $@-t $@ - # Dependencies. depend: .depend diff --git a/builder/test-config/virt-builder/repos.d/test-index.conf.in b/builder/test-config/virt-builder/repos.d/test-index.conf.in deleted file mode 100644 index 22e03c4..0000000 --- a/builder/test-config/virt-builder/repos.d/test-index.conf.in +++ /dev/null @@ -1,2 +0,0 @@ -[test-index] -uri=file://@abs_top_builddir@/builder/test-index diff --git a/builder/test-virt-builder-list.sh b/builder/test-virt-builder-list.sh index e42e3ec..5a5d61c 100755 --- a/builder/test-virt-builder-list.sh +++ b/builder/test-virt-builder-list.sh @@ -21,8 +21,17 @@ export LANG=C set -e +# Create phony configuration. +cp $srcdir/test-index . + +mkdir -p virt-builder/repos.d +cat > virt-builder/repos.d/test-index.conf <<EOF +[test-index] +uri=file://$tmpdir/test-index +EOF + export XDG_CONFIG_HOME-export XDG_CONFIG_DIRS="$abs_builddir/test-config" +export XDG_CONFIG_DIRS="$tmpdir" short_list=$($VG virt-builder --no-check-signature --no-cache --list) @@ -40,7 +49,7 @@ fi long_list=$(virt-builder --no-check-signature --no-cache --list --long) -if [ "$long_list" != "Source URI: file://$abs_builddir/test-index +if [ "$long_list" != "Source URI: file://$tmpdir/test-index os-version: phony-debian Full name: Phony Debian @@ -115,7 +124,7 @@ if [ "$json_list" != "{ \"version\": 1, \"sources\": [ { - \"uri\": \"file://$abs_builddir/test-index\" + \"uri\": \"file://$tmpdir/test-index\" } ], \"templates\": [ diff --git a/builder/test-virt-builder-planner.sh b/builder/test-virt-builder-planner.sh index f974c27..40a3d7e 100755 --- a/builder/test-virt-builder-planner.sh +++ b/builder/test-virt-builder-planner.sh @@ -19,21 +19,31 @@ export LANG=C set -e -abs_builddir=$(pwd) - -export XDG_CONFIG_HOME-export XDG_CONFIG_DIRS="$abs_builddir/test-config" - -if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then - echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory" - exit 77 -fi - if [ "$(guestfish get-backend)" = "uml" ]; then echo "$0: test skipped because backend is UML" exit 77 fi +# Create phony configuration. +cp $srcdir/test-index . + +mkdir -p virt-builder/repos.d +cat > virt-builder/repos.d/test-index.conf <<EOF +[test-index] +uri=file://$tmpdir/test-index +EOF + +export XDG_CONFIG_HOME+export XDG_CONFIG_DIRS="$tmpdir" + +# Create test images. +for f in debian fedora ubuntu windows; do + xz -c $phonydir/$f.img > $f.xz +done + +qemu-img convert -f raw -O qcow2 $phonydir/fedora.img fedora.qcow2 +xz -c fedora.qcow2 > fedora.qcow2.xz + rm -f planner-output for input in phony-fedora phony-fedora-qcow2 phony-fedora-qcow2-uncompressed phony-fedora-no-format; do diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh index c6e99c4..0fe7bcc 100755 --- a/builder/test-virt-builder.sh +++ b/builder/test-virt-builder.sh @@ -19,13 +19,20 @@ export LANG=C set -e +# Create phony configuration. +cp $srcdir/test-index . + +mkdir -p virt-builder/repos.d +cat > virt-builder/repos.d/test-index.conf <<EOF +[test-index] +uri=file://$tmpdir/test-index +EOF + export XDG_CONFIG_HOME-export XDG_CONFIG_DIRS="$abs_builddir/test-config" +export XDG_CONFIG_DIRS="$tmpdir" -if [ ! -f $builddir/fedora.xz ]; then - echo "$0: test skipped because there is no fedora.xz in the build directory" - exit 77 -fi +# Create one test image. +xz -c $phonydir/fedora.img > fedora.xz output=phony-fedora.img diff --git a/builder/test-website/virt-builder/repos.d/libguestfs.conf.in b/builder/test-website/virt-builder/repos.d/libguestfs.conf.in deleted file mode 100644 index 7bbc28d..0000000 --- a/builder/test-website/virt-builder/repos.d/libguestfs.conf.in +++ /dev/null @@ -1,3 +0,0 @@ -[libguestfs.org] -uri=file://@abs_top_srcdir@/builder/website/index.asc -gpgkey=file://@abs_top_srcdir@/builder/libguestfs.gpg diff --git a/builder/tests.mk b/builder/tests.mk index d4efad0..c04a62a 100644 --- a/builder/tests.mk +++ b/builder/tests.mk @@ -22,12 +22,6 @@ localtestsdir = $(alltestsdir)/builder localtests_DATA = \ - debian.xz \ - fedora.qcow2 \ - fedora.qcow2.xz \ - fedora.xz \ - ubuntu.xz \ - windows.xz \ test-index \ test-virt-index-validate-bad-1 \ test-virt-index-validate-good-1 \ diff --git a/configure.ac b/configure.ac index de480e7..8ed6db8 100644 --- a/configure.ac +++ b/configure.ac @@ -1729,8 +1729,6 @@ AC_CONFIG_FILES([Makefile bash/Makefile builder/Makefile builder/libguestfs.conf - builder/test-config/virt-builder/repos.d/test-index.conf - builder/test-website/virt-builder/repos.d/libguestfs.conf builder/website/Makefile cat/Makefile csharp/Makefile diff --git a/generator/tests.ml b/generator/tests.ml index a88276d..ce04687 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -627,12 +627,6 @@ let tests = [ "test-virt-builder-planner.sh" ]; check_data = [ - "debian.xz"; - "fedora.xz"; - "ubuntu.xz"; - "windows.xz"; - "fedora.qcow2"; - "fedora.qcow2.xz"; "test-index"; "test-virt-index-validate-bad-1"; "test-virt-index-validate-good-1"; diff --git a/run.in b/run.in index 42f8cc8..8949631 100755 --- a/run.in +++ b/run.in @@ -116,13 +116,6 @@ prepend DYLD_LIBRARY_PATH "$b/src/.libs" export LD_LIBRARY_PATH export DYLD_LIBRARY_PATH -# Make virt-builder use the local website copy to avoid hitting -# the network all the time. -if [ -z "$XDG_CONFIG_DIRS" ]; then - prepend XDG_CONFIG_DIRS "$b/builder/test-website" - export XDG_CONFIG_DIRS -fi - # virt-p2v-make-* data directory. if [ -z "$VIRT_P2V_DATA_DIR" ]; then VIRT_P2V_DATA_DIR="$b/p2v" -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 16/17] perl: Convert Perl tests to use the test harness.
--- generator/test_harness.ml | 6 +++- generator/tests.ml | 26 +++++++++++++++ generator/tests_mk.ml | 3 +- perl/Makefile.am | 26 +++------------ perl/run-bindtests | 22 ------------- perl/run-bindtests.sh | 22 +++++++++++++ perl/run-perl-tests | 21 ------------- perl/t/910-pod.t | 2 ++ perl/tests.mk | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 142 insertions(+), 66 deletions(-) delete mode 100755 perl/run-bindtests create mode 100755 perl/run-bindtests.sh delete mode 100755 perl/run-perl-tests create mode 100644 perl/tests.mk diff --git a/generator/test_harness.ml b/generator/test_harness.ml index af8182c..1f6bf90 100644 --- a/generator/test_harness.ml +++ b/generator/test_harness.ml @@ -608,6 +608,9 @@ Options:" in not (Filename.check_suffix test ".pl") && not (Filename.check_suffix test ".sh") in + (* Perl tests need to use the 'prove' program. *) + let is_perl_test = Filename.check_suffix test ".t" in + (* We run each test in its own temporary directory. *) let tmpdir = mkdtemp () in @@ -616,7 +619,7 @@ Options:" in putenv "tmpdir" tmpdir; let cmd - sprintf "%s%s%s%s$abs_srcdir/%s%s > output 2>&1" + sprintf "%s%s%s%s%s$abs_srcdir/%s%s > output 2>&1" (if upstream_libvirt then libvirtdir // "run " else "") (if timeout then sprintf "timeout --foreground -k %s %s " @@ -624,6 +627,7 @@ Options:" in else "") (if have_libtool then "libtool --mode=execute " else "") (if is_program && valgrind then "$VG " else "") + (if is_perl_test then "prove " else "") test (String.concat "" (List.map ((^) " ") (List.map Filename.quote args))) in diff --git a/generator/tests.ml b/generator/tests.ml index ce04687..a214fa7 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -597,6 +597,32 @@ let tests = [ ]; }; + "perl", { + defaults with + check_fast = [ + "run-bindtests.sh"; + "t/010-load.t"; + "t/020-create.t"; + "t/030-create-flags.t"; + "t/040-create-multiple.t"; + "t/060-handle-properties.t"; + "t/070-optargs.t"; + "t/410-close-event.t"; + "t/420-log-messages.t"; + "t/800-explicit-close.t"; + "t/900-introspection.t"; + "t/910-pod.t"; + "t/920-pod-coverage.t"; + ]; + check = [ + "t/100-launch.t"; + "t/810-mkdir-eexist.t"; + ]; + check_data = [ + "bindtests.pl"; + ]; + }; + (* Test tools written in OCaml. *) "mllib", { diff --git a/generator/tests_mk.ml b/generator/tests_mk.ml index 7e98297..38d8630 100644 --- a/generator/tests_mk.ml +++ b/generator/tests_mk.ml @@ -43,8 +43,9 @@ let generate_tests_mk dir tests () * localtests_SCRIPTS. Others are added to localtests_PROGRAMS. *) let scripts_extensions = [ - ".bc"; ".opt"; (* for OCaml *) + ".bc"; ".opt"; (* for OCaml *) ".pl"; + ".t"; (* Perl tests *) ".sh" ] in diff --git a/perl/Makefile.am b/perl/Makefile.am index 1eb0469..a408812 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -19,8 +19,7 @@ include $(top_srcdir)/subdir-rules.mk generator_built = \ Guestfs.xs \ - lib/Sys/Guestfs.pm \ - bindtests.pl + lib/Sys/Guestfs.pm EXTRA_DIST = \ $(generator_built) \ @@ -28,8 +27,7 @@ EXTRA_DIST = \ examples/README \ examples/LICENSE \ examples/*.pl \ - run-bindtests \ - run-perl-tests \ + run-bindtests.sh \ t/*.t \ typemap @@ -41,26 +39,10 @@ if HAVE_PERL # src/ dependencies src_deps: $(top_builddir)/src/libguestfs.la $(generator_built) -# Images used by tests. -test_images: - $(MAKE) -C $(top_builddir)/tests/data - # Build the appliance. appliance: $(MAKE) -C $(top_builddir)/appliance -TESTS = run-bindtests -test_prereq = src_deps all test_images - -if ENABLE_APPLIANCE -test_prereq += appliance -TESTS += run-perl-tests -endif - -$(TESTS): $(test_prereq) - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - INSTALLDIRS = site all: Makefile-pl src_deps @@ -83,4 +65,6 @@ install-data-hook: endif -.PHONY: appliance src_deps test_images +.PHONY: appliance src_deps + +include $(srcdir)/tests.mk diff --git a/perl/run-bindtests b/perl/run-bindtests deleted file mode 100755 index 3fefd05..0000000 --- a/perl/run-bindtests +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# libguestfs Perl bindings -# Copyright (C) 2009 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. - -set -e - -perl $srcdir/bindtests.pl > bindtests.tmp -diff -u $srcdir/../bindtests bindtests.tmp diff --git a/perl/run-bindtests.sh b/perl/run-bindtests.sh new file mode 100755 index 0000000..3fefd05 --- /dev/null +++ b/perl/run-bindtests.sh @@ -0,0 +1,22 @@ +#!/bin/sh - +# libguestfs Perl bindings +# Copyright (C) 2009 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. + +set -e + +perl $srcdir/bindtests.pl > bindtests.tmp +diff -u $srcdir/../bindtests bindtests.tmp diff --git a/perl/run-perl-tests b/perl/run-perl-tests deleted file mode 100755 index 0e7e9ab..0000000 --- a/perl/run-perl-tests +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# libguestfs Perl bindings -# Copyright (C) 2009 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. - -set -e - -make -f Makefile-pl test "$@" diff --git a/perl/t/910-pod.t b/perl/t/910-pod.t index e53caaf..b46062f 100644 --- a/perl/t/910-pod.t +++ b/perl/t/910-pod.t @@ -19,6 +19,8 @@ use Test::More; use strict; use warnings; +chdir "$ENV{builddir}"; + eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok (); diff --git a/perl/tests.mk b/perl/tests.mk new file mode 100644 index 0000000..4782291 --- /dev/null +++ b/perl/tests.mk @@ -0,0 +1,80 @@ +# libguestfs generated file +# WARNING: THIS FILE IS GENERATED FROM: +# generator/ *.ml +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. +# +# Copyright (C) 2009-2015 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. + +localtestsdir = $(alltestsdir)/perl + +localtests_DATA = \ + bindtests.pl + +localtests_SCRIPTS = \ + run-bindtests.sh \ + t/010-load.t \ + t/020-create.t \ + t/030-create-flags.t \ + t/040-create-multiple.t \ + t/060-handle-properties.t \ + t/070-optargs.t \ + t/100-launch.t \ + t/410-close-event.t \ + t/420-log-messages.t \ + t/800-explicit-close.t \ + t/810-mkdir-eexist.t \ + t/900-introspection.t \ + t/910-pod.t \ + t/920-pod-coverage.t + +# Note that we cannot create a simple 'check:' target since +# automake will (silently) overrule it, so we do this instead: + +TESTS_ENVIRONMENT = $(top_builddir)/run +TESTS = $(top_builddir)/test-harness + +check-valgrind: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind + +check-direct: + $(top_builddir)/run $(top_builddir)/test-harness --direct + +check-valgrind-direct: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct + +check-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --libvirt + +check-valgrind-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt + +check-uml: + $(top_builddir)/run $(top_builddir)/test-harness --uml + +check-valgrind-uml: + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml + +check-with-upstream-qemu: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu + +check-with-upstream-libvirt: + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt + +check-fast: + $(top_builddir)/run $(top_builddir)/test-harness --fast + +EXTRA_DIST += tests.mk -- 2.5.0
Richard W.M. Jones
2015-Aug-06 15:05 UTC
[Libguestfs] [PATCH v4 17/17] tests: Rename guests-all-good.xml to guests.xml.
Only df/test-virt-df-guests.sh was using the facility of testing guests with missing/no disks, so let's change just that test instead. --- .gitignore | 1 - align/test-virt-alignment-scan-guests.sh | 2 +- configure.ac | 1 - df/test-virt-df-guests-missing.sh | 140 ++++++++++++ df/tests.mk | 1 + generator/test_harness.ml | 4 +- generator/tests.ml | 1 + tests/guests/Makefile.am | 9 +- tests/guests/guest-aux/make-guests-all-good.pl | 70 ------ tests/guests/guest-aux/make-guests-xml.pl | 65 ++++++ tests/guests/guests.xml.in | 282 ------------------------- 11 files changed, 214 insertions(+), 362 deletions(-) create mode 100755 df/test-virt-df-guests-missing.sh delete mode 100755 tests/guests/guest-aux/make-guests-all-good.pl create mode 100755 tests/guests/guest-aux/make-guests-xml.pl delete mode 100644 tests/guests/guests.xml.in diff --git a/.gitignore b/.gitignore index e35a7b3..49e6391 100644 --- a/.gitignore +++ b/.gitignore @@ -542,7 +542,6 @@ Makefile.in /tests/guests/fedora-md1.img /tests/guests/fedora-md2.img /tests/guests/guests.xml -/tests/guests/guests-all-good.xml /tests/guests/guest-aux/fedora-name.db /tests/guests/guest-aux/fedora-packages.db /tests/guests/guest-aux/windows-software diff --git a/align/test-virt-alignment-scan-guests.sh b/align/test-virt-alignment-scan-guests.sh index a013705..12acb67 100755 --- a/align/test-virt-alignment-scan-guests.sh +++ b/align/test-virt-alignment-scan-guests.sh @@ -18,7 +18,7 @@ export LANG=C -libvirt_uri="test://$phonydir/guests-all-good.xml" +libvirt_uri="test://$phonydir/guests.xml" $VG virt-alignment-scan -c "$libvirt_uri" r=$? diff --git a/configure.ac b/configure.ac index 8ed6db8..4a85584 100644 --- a/configure.ac +++ b/configure.ac @@ -1804,7 +1804,6 @@ AC_CONFIG_FILES([Makefile tests/events/Makefile tests/fuzz/Makefile tests/guests/Makefile - tests/guests/guests.xml tests/hotplug/Makefile tests/http/Makefile tests/journal/Makefile diff --git a/df/test-virt-df-guests-missing.sh b/df/test-virt-df-guests-missing.sh new file mode 100755 index 0000000..b4ac07b --- /dev/null +++ b/df/test-virt-df-guests-missing.sh @@ -0,0 +1,140 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2013 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. + +# Run virt-df on the test guests. + +export LANG=C +set -e + +cat > missing.xml <<EOF +<node> + <!-- no disks --> + <domain type='test'> + <name>nodisks</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + </devices> + </domain> + + <!-- deliberately missing disks --> + <domain type='test'> + <name>missing-disks</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='/no-such-disk.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + + <!-- various blank / non-OS disks --> + <domain type='test'> + <name>blank-bootroot</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-bootroot.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + + <domain type='test'> + <name>blank-bootrootlv</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-bootrootlv.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + + <domain type='test'> + <name>blank-disk</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-disk.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + + <domain type='test'> + <name>blank-fs</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-fs.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + + <domain type='test'> + <name>blank-part</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$phonydir/blank-part.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> +</node> +EOF + +libvirt_uri="test://$tmpdir/missing.xml" + +$VG virt-df -c "$libvirt_uri" diff --git a/df/tests.mk b/df/tests.mk index da5f0e7..ad65e35 100644 --- a/df/tests.mk +++ b/df/tests.mk @@ -22,6 +22,7 @@ localtestsdir = $(alltestsdir)/df localtests_SCRIPTS = \ + test-virt-df-guests-missing.sh \ test-virt-df-guests.sh \ test-virt-df-local-guests.sh \ test-virt-df.sh diff --git a/generator/test_harness.ml b/generator/test_harness.ml index 1f6bf90..fa9b080 100644 --- a/generator/test_harness.ml +++ b/generator/test_harness.ml @@ -510,10 +510,10 @@ Options:" in (* Make XML describing all guests we managed to create above. *) let cmd - sprintf "%s/make-guests-all-good.pl > guests-all-good.xml blank-disk.img blank-part.img blank-fs.img blank-bootroot.img blank-bootrootlv.img archlinux.img coreos.img debian.img fedora.img fedora-md1.img fedora-md2.img fedora-btrfs.img ubuntu.img windows.img" + sprintf "%s/make-guests-xml.pl > guests.xml blank-disk.img blank-part.img blank-fs.img blank-bootroot.img blank-bootrootlv.img archlinux.img coreos.img debian.img fedora.img fedora-md1.img fedora-md2.img fedora-btrfs.img ubuntu.img windows.img" gaux in if Sys.command cmd <> 0 then - failwith "make-guests-all-good.pl failed"; + failwith "make-guests-xml.pl failed"; let cmd = "rm -f *.tmp.*" in ignore (Sys.command cmd); diff --git a/generator/tests.ml b/generator/tests.ml index a214fa7..8ca33e3 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -425,6 +425,7 @@ let tests = [ check = [ "test-virt-df.sh"; "test-virt-df-guests.sh"; + "test-virt-df-guests-missing.sh"; ]; check_local_guests = [ "test-virt-df-local-guests.sh"; diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 796d428..8f5ebdc 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -37,8 +37,7 @@ EXTRA_DIST = \ guest-aux/windows-system \ guest-aux/windows-system.reg \ guest-aux/minimal-hive \ - guest-aux/make-guests-all-good.pl \ - guests.xml.in + guest-aux/make-guests-xml.pl disk_images = \ blank-disk.img \ @@ -58,9 +57,9 @@ disk_images = \ # This is 'check_DATA' because we don't need it until 'make check' # time and we need the tools we have built in order to make it. -check_DATA = $(disk_images) guests-all-good.xml +check_DATA = $(disk_images) guests.xml -$(disk_images) guests-all-good.xml: stamp-guests +$(disk_images) guests.xml: stamp-guests stamp-guests: $(top_builddir)/test-harness $(top_builddir)/run $< --make-phony-guests-only @@ -88,7 +87,7 @@ localtests_SCRIPTS = \ guest-aux/make-coreos-img.sh \ guest-aux/make-debian-img.sh \ guest-aux/make-fedora-img.pl \ - guest-aux/make-guests-all-good.pl \ + guest-aux/make-guests-xml.pl \ guest-aux/make-ubuntu-img.sh \ guest-aux/make-windows-img.sh diff --git a/tests/guests/guest-aux/make-guests-all-good.pl b/tests/guests/guest-aux/make-guests-all-good.pl deleted file mode 100755 index aafcc8e..0000000 --- a/tests/guests/guest-aux/make-guests-all-good.pl +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/perl -# libguestfs -# Copyright (C) 2013 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. - -# Make the ../guests-all-good.xml file. - -use strict; -use warnings; - -my $outdir = `pwd`; chomp $outdir; - -print <<__EOT__; -<!-- -This file is generated from $0. - -ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. - -To use the test guests by name, specify the following libvirt URI: -test://\$(abs_builddir)/guests-all-good.xml - -eg: - ./run ./df/virt-df -c test://$outdir/guests-all-good.xml - ./run ./align/virt-alignment-scan -c test://$outdir/guests-all-good.xml - -Note this differs from 'guests.xml' just in that none of these guests -have missing disks, etc. ---> -<node> -__EOT__ - -foreach (@ARGV) { - my $name = $_; - $name =~ s/.img//; - - if (-f $_ && -s $_) { - print <<__EOT__; - <domain type='test'> - <name>$name</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='$outdir/$_'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> -__EOT__ - } -} - -print "</node>"; diff --git a/tests/guests/guest-aux/make-guests-xml.pl b/tests/guests/guest-aux/make-guests-xml.pl new file mode 100755 index 0000000..5237921 --- /dev/null +++ b/tests/guests/guest-aux/make-guests-xml.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# libguestfs +# Copyright (C) 2013-2015 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. + +# Make the guests.xml file. + +use strict; +use warnings; + +my $outdir = `pwd`; chomp $outdir; + +print <<__EOT__; +<!-- +This file is generated from +$0. + +ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + +To use the test guests by name, specify the following libvirt URI: +test://\$phonydir/guests.xml + +--> +<node> +__EOT__ + +foreach (@ARGV) { + my $name = $_; + $name =~ s/.img//; + + if (-f $_ && -s $_) { + print <<__EOT__; + <domain type='test'> + <name>$name</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='$outdir/$_'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> +__EOT__ + } +} + +print "</node>"; diff --git a/tests/guests/guests.xml.in b/tests/guests/guests.xml.in deleted file mode 100644 index 8f7ac81..0000000 --- a/tests/guests/guests.xml.in +++ /dev/null @@ -1,282 +0,0 @@ -<!-- - libguestfs test images - @configure_input@ - Copyright (C) 2013 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. - - To use the test guests by name, specify the following libvirt URI: - test://$(abs_builddir)/guests.xml - - eg: - ./run ./df/virt-df -c test://@abs_builddir@/guests.xml - ./run ./align/virt-alignment-scan -c test://@abs_builddir@/guests.xml ---> -<node> - - <!-- no disks --> - <domain type='test'> - <name>nodisks</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - </devices> - </domain> - - <!-- deliberately missing disks --> - <domain type='test'> - <name>missing-disks</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/no-such-disk.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>blank-bootroot</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/blank-bootroot.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>blank-bootrootlv</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/blank-bootrootlv.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>blank-disk</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/blank-disk.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>blank-fs</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/blank-fs.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>blank-part</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/blank-part.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>debian</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/debian.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>fedora-btrfs</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/fedora-btrfs.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>fedora</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/fedora.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>fedora-md1</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/fedora-md1.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>fedora-md2</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/fedora-md2.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>ubuntu</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/ubuntu.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>archlinux</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/archlinux.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>coreos</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/coreos.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - - <domain type='test'> - <name>windows</name> - <memory>1048576</memory> - <os> - <type>hvm</type> - <boot dev='hd'/> - </os> - <devices> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/windows.img'/> - <target dev='vda' bus='virtio'/> - </disk> - </devices> - </domain> - -</node> -- 2.5.0
Pino Toscano
2015-Aug-07 15:31 UTC
Re: [Libguestfs] [PATCH v4 01/17] tests: Introduce test harness for running tests.
On Thursday 06 August 2015 16:05:43 Richard W.M. Jones wrote:> We would like to have a more flexible way to run tests, including > running them on an installed copy of libguestfs, running them in > parallel, and being able to express dependencies and ordering between > tests and data files properly. > > Therefore introduce a test harness (test-harness) program which can > run tests either from the locally built copy, or from an installed > copy of the tests (in $libdir/guestfs/tests). > > The test harness is backwards compatible on the command line, ie. > 'make check', 'make -C inspector check-valgrind' etc. will still work. > But in addition, you can now run the tests on an installed copy of > libguestfs by doing: > > cd $libdir/guestfs/tests > ./test-harness > > The test-harness script supports various options, see 'test-harness(1)' > for full details. > > Other notable features: > > - Checking SKIP_* environment variables in tests is no longer > necessary. The test harness deals with these. > > - Every test runs in its own temporary directory. There is no need > to clean up output files. On the other hand, tests must use > $srcdir, $builddir, $datadir etc. to refer to test data. > > This is only implemented for a single directory at the moment > (ie. inspector/)Below there is a start of review of it, as the patch is quite long and complex. Some of the small preparatory changes could be extracted and committed already, which would help in making this slightly small and easier to review. As a general note to the changes: while I'm generally positive in having such better testing framework, I'm not much convinced about hardcoding all the tests in the generator. Will think more about it.> --- > .gitignore | 6 +- > Makefile.am | 20 + > common-rules.mk | 3 + > configure.ac | 2 + > generator/Makefile.am | 24 + > generator/main.ml | 9 + > generator/test_harness.ml | 738 +++++++++++++++++++++++ > generator/tests.ml | 71 +++ > generator/tests_mk.ml | 130 ++++ > generator/types.ml | 15 + > inspector/Makefile.am | 17 +- > inspector/test-virt-inspector-local-guests.sh.in | 26 + > inspector/test-virt-inspector.sh | 12 +- > inspector/test-xmllint.sh.in | 5 + > inspector/tests.mk | 94 +++ > pick-guests.pl.in | 4 +- > po-docs/podfiles | 1 + > test-harness.pod | 252 ++++++++ > tests/data/Makefile.am | 59 +- > tests/guests/Makefile.am | 95 +-- > tests/guests/guest-aux/make-archlinux-img.sh | 4 +- > tests/guests/guest-aux/make-debian-img.sh | 6 +- > tests/guests/guest-aux/make-fedora-img.pl | 21 +- > tests/guests/guest-aux/make-ubuntu-img.sh | 4 +- > tests/guests/guest-aux/make-windows-img.sh | 6 +- > 25 files changed, 1482 insertions(+), 142 deletions(-) > create mode 100644 generator/test_harness.ml > create mode 100644 generator/tests.ml > create mode 100644 generator/tests_mk.ml > create mode 100755 inspector/test-virt-inspector-local-guests.sh.in > create mode 100644 inspector/tests.mk > create mode 100644 test-harness.pod > > diff --git a/.gitignore b/.gitignore > index e968399..72f8cc4 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -276,8 +276,8 @@ Makefile.in > /html/virt-v2v.1.html > /html/virt-v2v-test-harness.1.html > /html/virt-win-reg.1.html > -/inspector/actual-*.xml > /inspector/stamp-virt-inspector.pod > +/inspector/test-virt-inspector-local-guests.sh > /inspector/test-xmllint.sh > /inspector/virt-inspector > /inspector/virt-inspector.1 > @@ -496,6 +496,8 @@ Makefile.in > /sysprep/virt-sysprep.1 > /test.err > /test.out > +/test-harness > +/test-harness.1 > /tests/c-api/test-add-drive-opts > /tests/c-api/test-add-libvirt-dom > /tests/c-api/test-backend-settings > @@ -549,7 +551,7 @@ Makefile.in > /tests/guests/guest-aux/fedora-packages.db > /tests/guests/guest-aux/windows-software > /tests/guests/guest-aux/windows-system > -/tests/guests/stamp-fedora-md.img > +/tests/guests/stamp-guests > /tests/guests/ubuntu.img > /tests/guests/archlinux.img > /tests/guests/coreos.img > diff --git a/Makefile.am b/Makefile.am > index 8f0bb1b..2c6c8b2 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -207,6 +207,7 @@ EXTRA_DIST = \ > logo/virt-builder.svg \ > m4/.gitignore \ > ocaml-link.sh \ > + test-harness.pod \ > tests/run-xml-to-junit.sh \ > tests/run-xml-to-junit.xsl \ > tmp/.gitignore \ > @@ -405,6 +406,16 @@ podwrapper.1: podwrapper.pl > $< > mv $@-t $@ > > +# NB. test-harness is an internal tool, so the man page mustn't be installed.Then I guess it makes no sense to be translated either, so please add an exclusion for in the podfiles target of po-docs/Makefile.am.> +noinst_MANS += test-harness.1 > +test-harness.1: test-harness.pod > + $(PODWRAPPER) \ > + --section 1 \ > + --man $@-t \ > + --license GPLv2+ \ > + $< > + mv $@-t $@ > + > # Make clean. > > CLEANFILES = \ > @@ -414,6 +425,7 @@ CLEANFILES = \ > podwrapper.1 \ > qemu-wrapper.sh \ > stamp-guestfs-release-notes.pod \ > + test-harness.1 \ > tmp/disk* \ > tmp/run-* \ > tmp/valgrind-*.log > @@ -423,6 +435,11 @@ clean-local: > -rm -rf tmp/guestfs.* > -rm -rf tmp/.guestfs-* > > +# Tests. > + > +localtestsdir = $(alltestsdir) > +localtests_DATA = bindtests > + > # If you don't want to run all of the tests ('make check') then this > # will just run libguestfs-test-tool for a quick check. Note this > # is NOT a substitute for proper testing! > @@ -541,6 +558,9 @@ check-slow: build-test-guests > build-test-guests: > $(MAKE) -C tests/guests check > > +# Install valgrind suppressions file in test directory. > +alltests_DATA = valgrind-suppressions > + > # Print subdirs. > # > # If you want to selectively run tests, or if the test suite fails half > diff --git a/common-rules.mk b/common-rules.mk > index 312107e..5a239ab 100644 > --- a/common-rules.mk > +++ b/common-rules.mk > @@ -27,3 +27,6 @@ builddir ?= @builddir@ > abs_builddir ?= @abs_builddir@ > srcdir ?= @srcdir@ > abs_srcdir ?= @abs_srcdir@ > + > +# Tests directory. > +alltestsdir = $(libdir)/guestfs/tests > diff --git a/configure.ac b/configure.ac > index d54ce7d..461d5cc 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1700,6 +1700,8 @@ 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-virt-inspector-local-guests.sh], > + [chmod +x,-w inspector/test-virt-inspector-local-guests.sh]) > AC_CONFIG_FILES([inspector/test-xmllint.sh], > [chmod +x,-w inspector/test-xmllint.sh]) > AC_CONFIG_FILES([p2v/virt-p2v-make-disk], > diff --git a/generator/Makefile.am b/generator/Makefile.am > index a3fe50d..1c16ad0 100644 > --- a/generator/Makefile.am > +++ b/generator/Makefile.am > @@ -50,6 +50,9 @@ sources = \ > ruby.ml \ > structs.ml \ > structs.mli \ > + tests.ml \ > + tests_mk.ml \ > + test_harness.ml \ > tests_c_api.ml \ > types.ml \ > utils.ml \ > @@ -68,6 +71,8 @@ objects = \ > pr.cmo \ > docstrings.cmo \ > checks.cmo \ > + tests.cmo \ > + tests_mk.cmo \ > c.cmo \ > xdr.cmo \ > daemon.cmo \ > @@ -90,17 +95,30 @@ objects = \ > customize.cmo \ > main.cmo > > +test_harness_objects = \ > + types.cmo \ > + utils.cmo \ > + tests.cmo \ > + test_harness.cmo > + > EXTRA_DIST = $(sources) files-generated.txt > > OCAMLCFLAGS = $(OCAML_WARN_ERROR) -I $(srcdir) -I . -package unix,str > > noinst_PROGRAM = generator > > +# Install the test harness. > +localtestsdir = $(alltestsdir) > +localtests_SCRIPTS = ../test-harness > + > if HAVE_OCAML > > generator: $(objects) > $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -linkpkg $^ -o $@ > > +../test-harness: $(test_harness_objects) > + $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -linkpkg $^ -o $@ > + > # Dependencies. > %.cmi: %.mli > $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@ > @@ -133,6 +151,12 @@ generator: > chmod +x $@-t > mv $@-t $@ > > +../test-harness: > + rm -f $@ $@-t > + echo 'echo Warning: Install OCaml compiler in order to rebuild the test-harness.' > $@-t > + chmod +x $@-t > + mv $@-t $@ > + > endif > > noinst_DATA = stamp-generator > diff --git a/generator/main.ml b/generator/main.ml > index 94f0d09..23e9fbc 100644 > --- a/generator/main.ml > +++ b/generator/main.ml > @@ -29,6 +29,8 @@ open Types > open C > open Xdr > open Daemon > +open Tests > +open Tests_mk > open Tests_c_api > open Fish > open Ocaml > @@ -47,6 +49,8 @@ open Bindtests > open Errnostring > open Customize > > +let (//) = Filename.concat > + > let perror msg = function > | Unix_error (err, _, _) -> > eprintf "%s: %s\n" msg (error_message err) > @@ -211,6 +215,11 @@ Run it from the top source directory using the command > output_to "customize/customize-synopsis.pod" generate_customize_synopsis_pod; > output_to "customize/customize-options.pod" generate_customize_options_pod; > > + List.iter ( > + fun (dir, tests) -> > + output_to (dir // "tests.mk") (generate_tests_mk dir tests) > + ) tests; > + > (* Generate the list of files generated -- last. *) > printf "generated %d lines of code\n" (get_lines_generated ()); > let files = List.sort compare (get_files_generated ()) in > diff --git a/generator/test_harness.ml b/generator/test_harness.ml > new file mode 100644 > index 0000000..af8182c > --- /dev/null > +++ b/generator/test_harness.ml > @@ -0,0 +1,738 @@ > +(* 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 > + *) > + > +(* The test-harness standalone program. *) > + > +open Unix > +open Printf > + > +open Types > +open Tests > + > +(* Prevent this script from being run as root. *) > +let () > + if geteuid () = 0 then ( > + eprintf "%s: don't run the libguestfs tests as root\n" Sys.executable_name; > + exit 1 > + ) > + > +let (//) = Filename.concat > + > +let isatty = isatty stdout > + > +(* ANSI terminal colours. *) > +let ansi_green ?(chan = Pervasives.stdout) () > + if isatty then output_string chan "\x1b[0;32m" > +let ansi_red ?(chan = Pervasives.stdout) () > + if isatty then output_string chan "\x1b[1;31m" > +let ansi_blue ?(chan = Pervasives.stdout) () > + if isatty then output_string chan "\x1b[1;34m" > +let ansi_restore ?(chan = Pervasives.stdout) () > + if isatty then output_string chan "\x1b[0m" > + > +let is_dir path > + try (stat path).st_kind = S_DIR > + with Unix_error _ -> false > + > +let is_file path > + try (stat path).st_kind = S_REG > + with Unix_error _ -> false > + > +let is_executable path > + is_file path && > + try access path [X_OK]; true > + with Unix_error _ -> false > + > +let relative_path_to_absolute path > + let cmd = sprintf "realpath %s" (Filename.quote path) in > + let chan = open_process_in cmd in > + let path = input_line chan in > + (match close_process_in chan with > + | WEXITED 0 -> () > + | WEXITED _ > + | WSIGNALED _ > + | WSTOPPED _ -> > + failwith "realpath command failed, see earlier errors" > + ); > + pathSlight code duplication for those command invocation; worth borrow external_command from Common_utils?> + > +let get_lines cmd > + let chan = open_process_in cmd in > + let rec loop acc > + try > + let line = input_line chan in > + loop (line :: acc) > + with End_of_file -> List.rev acc > + in > + let lines = loop [] in > + (match close_process_in chan with > + | WEXITED 0 -> () > + | WEXITED _ > + | WSIGNALED _ > + | WSTOPPED _ -> > + failwith (sprintf "get_lines: external command failed: %s" > + cmd) > + ); > + lines > + > +let mkdtemp () > + let chan = open_process_in "mktemp -d" in > + let path = input_line chan in > + (match close_process_in chan with > + | WEXITED 0 -> () > + | WEXITED _ > + | WSIGNALED _ > + | WSTOPPED _ -> > + failwith "mktemp -d command failed" > + ); > + path > + > +type ('a, 'b) maybe = Either of 'a | Or of 'b > + > +let pushdir dir f > + let olddir = getcwd () in > + chdir dir; > + let r = try Either (f ()) with exn -> Or exn in > + chdir olddir; > + match r with > + | Either r -> r > + | Or exn -> raise exn > + > +(* Timeout settings. *) > +let timeout_period = "4h" > +and timeout_kill = "30s" > + > +type start_dir > +| TopDir (* top dir - run all the tests *) > +| PhonyGuestsDir (* phony guests dir *) > +| Dir of string * test (* a test directory *) > + > +let () > + let home > + try Sys.getenv "HOME" > + with Not_found -> > + failwith "HOME environment variable is not set" in > + > + let cachedir > + try Sys.getenv "XDG_CACHE_HOME" > + with Not_found -> home // ".cache" in > + > + let debug = ref false in > + let direct = ref false in > + let fast = ref false in > + let libvirt = ref false in > + let local_guests = ref false in > + let make_phony_guests_only = ref false in > + let slow = ref false in > + let uml = ref false in > + let upstream_libvirt = ref false in > + let upstream_qemu = ref false in > + let valgrind = ref false in > + let verbose = ref false in > + let uml_binary = ref (home // "d/linux-um/vmlinux") in > + let libvirtdir = ref (home // "d/libvirt") in > + let qemu_binary = ref (home // "d/qemu/x86_64-softmmu/qemu-system-x86_64") in > + > + let argspec = Arg.align [ > + "--debug", Arg.Set debug, " Run tests with debugging enabled"; > + "--direct", Arg.Set direct, " Run tests using the direct backend"; > + "--fast", Arg.Set fast, " Run only tests which do not need the appliance"; > + "--libvirt", Arg.Set libvirt, " Run tests using the libvirt backend"; > + "--local-guests", Arg.Set local_guests, " Run tests that use locally installed guests r/o"; > + "--make-phony-guests-only", Arg.Set make_phony_guests_only, " Generate the phony guests used for testing"; > + "--slow", Arg.Set slow, " Run only long-running tests"; > + "--uml", Arg.Set uml, " Run tests using UML backend"; > + "--upstream-libvirt", Arg.Set upstream_libvirt, " Run tests using upstream libvirt"; > + "--upstream-qemu", Arg.Set upstream_qemu, " Run tests using upstream qemu"; > + "--valgrind", Arg.Set valgrind, " Run tests under valgrind"; > + "-v", Arg.Set verbose, " Enable verbose debugging in test harness"; > + "--verbose", Arg.Set verbose, " Enable verbose debugging in test harness"; > + "--with-uml", Arg.Set_string uml_binary, "vmlinux Select UML binary"; > + "--with-upstream-libvirt", Arg.Set_string libvirtdir, "dir Select libvirt directory"; > + "--with-upstream-qemu", Arg.Set_string qemu_binary, "qemu Select qemu binary";What about --with-upstream-libvirt/qemu automatically imply their usage? (i.e. removing --upstream-libvirt/qemu). This would mean no more default, but the current ones seems a bit... specific :)> + ] in > + let args = ref [] in > + let anon_fun s = args := s :: !args in > + let usage_msg > + "test-harness: Run the libguestfs test suite, or parts of it. > + > +See test-harness(1) for full details on how to run this program. > + > +Usage: > + test-harness [--options] [test-directory] > + > +Options:" in > + Arg.parse argspec anon_fun usage_msg; > + > + let args = !args in > + let debug = !debug in > + let direct = !direct in > + let fast = !fast in > + let libvirt = !libvirt in > + let local_guests = !local_guests in > + let make_phony_guests_only = !make_phony_guests_only in > + let slow = !slow in > + let uml = !uml in > + let upstream_libvirt = !upstream_libvirt in > + let upstream_qemu = !upstream_qemu in > + let valgrind = !valgrind in > + let verbose = !verbose in > + let uml_binary = !uml_binary in > + let libvirtdir = !libvirtdir in > + let qemu_binary = !qemu_binary in > + > + (* Some combinations are not permitted. *) > + if (fast && slow) || (fast && local_guests) || (slow && local_guests) then > + failwith "cannot use --fast, --slow and --local-guests options together";For this, wouldn't be better to use a type + option? Something like: type mode = | Fast | Slow | Local_guests let m = ref None let set_mode new () match m with | None -> m := Some new | Some old when old = new -> () (* same, nothing to do *) | Some old -> failwith "cannot use --fast, --slow and --local-guests options together" ... "--fast", Arg.Unit (set_mode Fast), " Run only tests which do not need the appliance"; etc. Maybe could be overengineered, but at least we don't need to check all the possible combinations of modes :)> + (* If none of the selection options are used, default to fast + normal. *) > + let fast, normal > + if not fast && not slow && not local_guests then true, true > + else fast, false in > + > + (* --direct, --libvirt and --uml cannot be combined. *) > + if (direct && libvirt) || (direct && uml) || (libvirt && uml) then > + failwith "cannot use --direct, --libvirt and --uml options together";What about something like the mode selection above? Or instead compact them into a single --backend=string?> + if verbose then ( > + printf "test-harness modes:%s%s%s%s%s%s%s\n" > + (if fast then " --fast" else "") > + (if normal then " --normal" else "") > + (if slow then " --slow" else "") > + (if local_guests then "--local-guests" else "") > + (if direct then " --direct" else "") > + (if libvirt then " --libvirt" else "") > + (if uml then " --uml" else "") > + ); > + > + (* If there is a single parameter on the command line, then we > + * chdir to that directory. > + *) > + (match args with > + | [] -> () > + | [dir] -> chdir dir > + | _ -> > + failwith "too many command line arguments" > + ); > + > + (* Which directory are we running in? *) > + let start_dir > + let pwd = getcwd () in > + let basename = Filename.basename pwd in > + if is_executable "test-harness" && is_dir "inspector" then > + TopDir > + else if basename = "guests" && is_dir "guest-aux" then > + PhonyGuestsDir > + else ( > + (* Search through the tests for the current directory. *) > + try > + let dir, tests > + List.find ( > + fun (dir, tests) -> > + (* Find the name of any test that should be in the directory. *) > + let any_file > + if tests.check <> [] then List.hd tests.check > + else if tests.check_fast <> [] then List.hd tests.check_fast > + else if tests.check_slow <> [] then List.hd tests.check_slow > + else if tests.check_local_guests <> [] then > + List.hd tests.check_local_guests > + else ( > + assert (tests.check_data <> []); > + List.hd tests.check_data > + ) in > + basename = Filename.basename dir && is_file any_file > + ) tests in > + Dir (dir, tests) > + with > + Not_found -> > + failwith (sprintf "current directory (%s) is not a libguestfs test directory" basename) > + ) in > + > + (* If we are running from automake, then automake will pass $srcdir > + * to us, and if it's not "." then we have to adjust our path to the > + * top source directory accordingly. > + *) > + let srcdir = try Sys.getenv "srcdir" with Not_found -> "." in > + > + (* Are we running from the build directory or from installed tests? *) > + let running_in_builddir = is_file (srcdir // "Makefile.am") inHmm only Makefile.am? Maybe worth checking for more files, to avoid that just one file is enough to switch it to in-builddir mode. Could guestfs-release-notes.pod be an unambiguous-enough file?> + (* If installed, then we cannot write to the phony guests directory. *) > + let phonydir > + if running_in_builddir then ( > + match start_dir with > + | TopDir -> > + relative_path_to_absolute "tests/guests" > + | PhonyGuestsDir -> > + relative_path_to_absolute "." > + | Dir (dir, _) -> > + let top_builddir = ref ".." in > + for i = 0 to String.length dir-1 do > + if dir.[i] = '/' then top_builddir := !top_builddir // ".." > + done; > + let top_builddir = !top_builddir in > + relative_path_to_absolute (top_builddir // "tests/guests") > + ) > + else ( > + (try mkdir cachedir 0o755 > + with Unix_error _ -> ()); > + (try mkdir (cachedir // "libguestfs-tests") 0o755 > + with Unix_error _ -> ()); > + (try mkdir (cachedir // "libguestfs-tests/phony-guests") 0o755 > + with Unix_error _ -> ()); > + cachedir // "libguestfs-tests/phony-guests"Worth copying mkdir_p from Common_utils?> + (* If the user gave the valgrind option, check it is valid. *) > + if valgrind then ( > + if Sys.command "valgrind --help >/dev/null 2>&1" <> 0 then > + failwith "valgrind is not installed" > + );For this and the other tool checks below: worth copying Tool_not_found + which from dib/utils.ml?> + (* Do we have libtool? *) > + let have_libtool = Sys.command "libtool --help >/dev/null 2>&1" = 0 in > + > + (* Do we have Padraig's timeout utility? It must have the > + * --foreground option (RHBZ#1025269) and the -k option (not present > + * in RHEL 6). > + *) > + let timeout > + Sys.command "timeout --help >/dev/null 2>&1" = 0 && > + Sys.command "timeout --foreground 2 sleep 0 >/dev/null 2>&1" = 0 && > + Sys.command "timeout -k 10s 10s true >/dev/null 2>&1" = 0 in > + > + (* Returns a relative path to top build directory from the current > + * directory. > + *) > + let top_builddir () > + let rec loop i top_builddir > + if i > 10 then > + failwith "top_builddir: not in a test directory" > + else if is_executable (top_builddir // "test-harness") then > + top_builddir > + else if top_builddir = "." then > + loop (i+1) ".." > + else > + loop (i+1) (top_builddir // "..") > + in > + loop 0 "." > + in > + > + (* Set up the environment (variables) for a test. *) > + let set_up_environment () > + let abs_builddir = relative_path_to_absolute "." in > + let abs_srcdir = relative_path_to_absolute srcdir in > + > + let top_builddir = top_builddir () in > + let top_srcdir > + if srcdir = "." then top_builddir > + else top_builddir // srcdir in > + let abs_top_builddir = relative_path_to_absolute top_builddir in > + let abs_top_srcdir = relative_path_to_absolute top_srcdir in > + > + let datadir = abs_top_builddir // "tests/data" in > + > + if verbose then ( > + printf "abs_builddir=%s\n" abs_builddir; > + printf "abs_srcdir=%s\n" abs_srcdir; > + printf "abs_top_builddir=%s\n" abs_top_builddir; > + printf "abs_top_srcdir=%s\n" abs_top_srcdir; > + printf "phonydir=%s\n" phonydir; > + printf "datadir=%s\n" datadir; > + ); > + > + (* Note that because the tests always run in a temporary > + * directory, relative paths are useless, so we always populate the > + * environment with absolute paths. > + *) > + putenv "builddir" abs_builddir; > + putenv "srcdir" abs_srcdir; > + putenv "top_builddir" abs_top_builddir; > + putenv "top_srcdir" abs_top_srcdir; > + putenv "abs_builddir" abs_builddir; > + putenv "abs_srcdir" abs_srcdir; > + putenv "abs_top_builddir" abs_top_builddir; > + putenv "abs_top_srcdir" abs_top_srcdir; > + putenv "phonydir" phonydir; > + putenv "datadir" datadir; > + > + (* Debugging? *) > + if debug then ( > + putenv "LIBGUESTFS_DEBUG" "1"; > + putenv "LIBGUESTFS_TRACE" "1" > + ); > + > + (* Valgrind? *) > + if valgrind then ( > + let vg > + sprintf "valgrind --vgdb=no --log-file=valgrind.log --leak-check=full --error-exitcode=119 --suppressions=%s/valgrind-suppressions" > + abs_top_srcdir in > + putenv "VG" vg > + ); > + > + (* Direct backend? *) > + if direct then > + putenv "LIBGUESTFS_BACKEND" "direct" > + > + (* Libvirt backend? *) > + else if libvirt then > + putenv "LIBGUESTFS_BACKEND" "libvirt" > + > + (* UML? *) > + else if uml then ( > + putenv "LIBGUESTFS_BACKEND" "uml"; > + putenv "LIBGUESTFS_HV" uml_binary > + ); > + > + (* Upstream QEMU? *) > + if upstream_qemu then > + putenv "LIBGUESTFS_HV" qemu_binary; > + in > + > + (* Function which runs to create the phony guests for testing. > + * Unfortunately we're recreating 'make' here. This isn't really > + * avoidable as we have to be able to run after installation, and > + * it's inconvenient to create a Makefile for that. > + *) > + let rec make_phony_guests () > + (* Set up the environment as for tests ... *) > + set_up_environment (); > + (* ... but adjust srcdir to point to the tests/guests directory > + * since the scripts in guest-aux are expecting this. > + *) > + let abs_top_srcdir = Sys.getenv "abs_top_srcdir" in > + putenv "srcdir" (abs_top_srcdir // "tests/guests"); > + if verbose then > + printf "srcdir [adjusted for make_phony_guests]=%s\n" > + (Sys.getenv "srcdir"); > + > + pushdir phonydir (fun () -> > + (* Because we distribute all the intermediate files, they are > + * always(?) in srcdir, not builddir. > + *) > + let gaux = abs_top_srcdir // "tests/guests/guest-aux" in > + if verbose then > + printf "gaux=%s\n" gaux; > + > + (* Make several different blank images. These are not guests, but we > + * include them in the libvirt fake XML to make sure that virt-df and > + * virt-alignment-scan don't break when they encounter them. > + *) > + List.iter ( > + fun ft -> > + let o = sprintf "blank-%s.img" ft in > + rule o [] (fun () -> > + let cmd > + sprintf "guestfish -N %s-t=%s exit && mv %s-t %s" o ft o o in > + if Sys.command cmd <> 0 then > + failwith "guestfish command failed" > + ) > + ) [ "disk"; "part"; "fs"; "bootroot"; "bootrootlv" ]; > + > + (* Make several (phony) Fedora images. *) > + List.iter ( > + fun (layout, o) -> > + rule o [ gaux // "make-fedora-img.pl"; > + gaux // "fedora-journal.tar.xz"; > + gaux // "fedora-name.db"; > + gaux // "fedora-packages.db" ] > + (fun () -> > + let cmd = sprintf "%s/make-fedora-img.pl --layout=%s" > + gaux layout in > + if Sys.command cmd <> 0 then > + failwith "make-fedora-img.pl failed" > + ) > + ) [ "partitions", "fedora.img"; > + "partitions-md", "fedora-md1.img"; > + "btrfs", "fedora-btrfs.img" ]; > + > + (* Make a (phony) Arch image. *) > + let o = "archlinux.img" in > + rule o [ gaux // "make-archlinux-img.sh" ] > + (fun () -> > + let cmd = sprintf "%s/make-archlinux-img.sh" gaux in > + if Sys.command cmd <> 0 then > + failwith "make-archlinux-img.sh failed" > + );Could this common rule for image creation be factorized, so each image could be just one simple line with image file and generation script?> + > + (* Make a (phony) CoreOS image. *) > + let o = "coreos.img" in > + rule o [ gaux // "make-coreos-img.sh" ] > + (fun () -> > + let cmd = sprintf "%s/make-coreos-img.sh" gaux in > + if Sys.command cmd <> 0 then > + failwith "make-coreos-img.sh failed" > + ); > + > + (* Make a (phony) Debian image. *) > + let o = "debian.img" in > + rule o [ gaux // "make-debian-img.sh" ] > + (fun () -> > + let cmd = sprintf "%s/make-debian-img.sh" gaux in > + if Sys.command cmd <> 0 then > + failwith "make-debian-img.sh failed" > + ); > + > + (* Make a (phony) Ubuntu image. *) > + let o = "ubuntu.img" in > + rule o [ gaux // "make-ubuntu-img.sh" ] > + (fun () -> > + let cmd = sprintf "%s/make-ubuntu-img.sh" gaux in > + if Sys.command cmd <> 0 then > + failwith "make-ubuntu-img.sh failed" > + ); > + > + (* Make a (phony) Windows image. *) > + let o = "windows.img" in > + rule o [ gaux // "make-windows-img.sh"; > + gaux // "windows-software"; > + gaux // "windows-system" ] > + (fun () -> > + let cmd = sprintf "%s/make-windows-img.sh" gaux in > + if Sys.command cmd <> 0 then > + failwith "make-windows-img.sh failed" > + ); > + > + (* Make XML describing all guests we managed to create above. *) > + let cmd > + sprintf "%s/make-guests-all-good.pl > guests-all-good.xml blank-disk.img blank-part.img blank-fs.img blank-bootroot.img blank-bootrootlv.img archlinux.img coreos.img debian.img fedora.img fedora-md1.img fedora-md2.img fedora-btrfs.img ubuntu.img windows.img" > + gaux in > + if Sys.command cmd <> 0 then > + failwith "make-guests-all-good.pl failed"; > + > + let cmd = "rm -f *.tmp.*" in > + ignore (Sys.command cmd); > + ) > + > + (* Like 'make', run a rule if target does not exist, or if target is > + * older than any of the sources. > + *) > + and rule target sources f > + let target_stat > + try Some (stat target) > + with Unix_error (ENOENT, _, _) -> > + (* Target file does not exist. *) > + printf "test-harness: building %s\n%!" target; > + f (); None in > + match target_stat with > + | None -> () > + | Some target_stat -> > + let rec loop = function > + | [] -> () > + | source :: sources -> > + let source_stat = stat source in > + if target_stat.st_mtime < source_stat.st_mtime then ( > + printf "test-harness: building %s\n%!" target; > + f () > + ) > + else > + loop sources > + in > + loop sources > + in > + > + let null_results = (0, 0, 0, 0, 0) in > + let add_results (t, s, f, tdo, sk) (t', s', f', tdo', sk') > + (t+t', s+s', f+f', tdo+tdo', sk+sk') > + in > + > + let rec run_all_tests () > + List.fold_left ( > + fun results (dir, tests) -> > + printf "test-harness: entering directory %s\n%!" dir; > + let results > + pushdir dir (fun () -> > + add_results results (run_dir_tests dir tests) > + ) in > + printf "test-harness: leaving directory %s\n%!" dir; > + results > + ) null_results tests > + > + (* Run all of the tests in a single directory. 'dir' is the > + * directory name, and we are chdir'd into this directory > + * already. > + *) > + and run_dir_tests dir tests > + let results = null_results in > + let accumulate > + List.fold_left > + (fun results t -> add_results results (run_one_test dir t [])) > + in > + let results > + if fast then accumulate results tests.check_fast > + else results in > + let results > + if normal then accumulate results tests.check > + else results in > + let results > + if slow then accumulate results tests.check_slow > + else results in > + let results > + if local_guests then > + List.fold_left ( > + fun results t -> > + add_results results (run_local_guests_test dir t) > + ) results tests.check_local_guests > + else results in > + results > + > + (* Run a single test. *) > + and run_one_test dir test args > + let skip_env = try Sys.getenv (skip_name test) with Not_found -> "" in > + if skip_env = "1" then ( > + printf "SKIP: %s\n%!" test; > + (1, 0, 0, 0, 1) > + ) > + else ( > + set_up_environment (); > + > + (* If it's a C program, and we're valgrinding, then we run the > + * C program under valgrind directly. > + *) > + let is_program > + not (Filename.check_suffix test ".pl") && > + not (Filename.check_suffix test ".sh") in > + > + (* We run each test in its own temporary directory. *) > + let tmpdir = mkdtemp () in > + > + let results, clean_up_tmpdir > + pushdir tmpdir (fun () -> > + putenv "tmpdir" tmpdir;Should "TMPDIR" be set as well? This way stuff (say other libraries and tools) indirectly creating temporary directories will use the local temporary one.> + > + let cmd > + sprintf "%s%s%s%s$abs_srcdir/%s%s > output 2>&1" > + (if upstream_libvirt then libvirtdir // "run " else "") > + (if timeout then > + sprintf "timeout --foreground -k %s %s " > + timeout_kill timeout_period > + else "") > + (if have_libtool then "libtool --mode=execute " else "") > + (if is_program && valgrind then "$VG " else "") > + test > + (String.concat "" > + (List.map ((^) " ") (List.map Filename.quote args))) inWouldn't it be better to execute the process as channel, so stdout/stderr can be collected more easily than with a tempfile?> + let start_t = gettimeofday () in > + let r = Sys.command cmd in > + let end_t = gettimeofday () in > + > + let secs = end_t -. start_t in > + > + match r with > + | 0 -> (* successful *) > + ansi_green (); > + printf "PASS: %s (%.1f seconds)" test secs; > + ansi_restore (); > + print_newline (); > + (1, 1, 0, 0, 0), true > + | 77 -> (* skipped *) > + ignore (Sys.command "cat output"); > + ansi_blue (); > + printf "SKIP: %s" test; > + ansi_restore (); > + print_newline (); > + (1, 0, 0, 0, 1), true > + | 119 -> (* valgrind *) > + ignore (Sys.command "cat output"); > + eprintf "test results left in %s\n" tmpdir; > + ansi_blue ~chan:Pervasives.stderr (); > + eprintf "VALGRIND FAIL: %s" test; > + ansi_restore ~chan:Pervasives.stderr (); > + prerr_newline (); > + (1, 0, 1, 0, 0), false > + | 124 -> (* timed out *) > + ignore (Sys.command "cat output"); > + eprintf "command timed out after %s\n" timeout_period; > + ansi_red ~chan:Pervasives.stderr (); > + eprintf "TIMED OUT: %s" test; > + ansi_restore ~chan:Pervasives.stderr (); > + prerr_newline (); > + (1, 0, 0, 1, 0), true > + | r -> (* error *) > + ignore (Sys.command "cat output"); > + eprintf "command failed with exit code %d\n" r; > + eprintf "test results left in %s\n" tmpdir; > + ansi_red ~chan:Pervasives.stderr (); > + eprintf "FAIL: %s" test; > + ansi_restore ~chan:Pervasives.stderr (); > + prerr_newline (); > + (1, 0, 1, 0, 0), false > + ) inInstead of return a tuple of single item results, what about a simplier type, to add up the actual results later?> + > + if clean_up_tmpdir then > + ignore (Sys.command (sprintf "rm -rf %s" (Filename.quote tmpdir))); > + > + results > + ) > + > + (* Run a single test using local guests. *) > + and run_local_guests_test dir test > + let top_builddir = top_builddir () in > + let cmd = sprintf "%s/pick-guests.pl 5" top_builddir in > + let guests = get_lines cmd in > + run_one_test dir test guests > + > + (* Convert a test name like 'test-network.sh' into 'SKIP_TEST_NETWORK_SH'. *) > + and skip_name name > + let skip = Utils.replace_char name '-' '_' in > + let skip = Utils.replace_char skip '.' '_' in > + let skip = "SKIP_" ^ String.uppercase skip in > + skip > + in > + > + (* Make the phony guests? *) > + if make_phony_guests_only || normal || slow then ( > + make_phony_guests (); > + if make_phony_guests_only then exit 0 > + ); > + > + (* Run the tests. *) > + let total, successful, failed, timedout, skipped > + match start_dir with > + | TopDir -> run_all_tests () > + | Dir (dir, tests) -> run_dir_tests dir tests > + | PhonyGuestsDir -> null_results (* do nothing in this directory *) in > + > + (* Print the test results. *) > + printf "--------------------------------------------------\n"; > + printf " TEST SUMMARY\n"; > + printf "--------------------------------------------------\n"; > + printf "Total tests run . . . . . . . %d\n" total; > + ansi_green (); > + printf "Successful . . . . . . . . . . %d\n" successful; > + ansi_restore (); > + if failed > 0 then ( > + ansi_red (); > + printf "Errors . . . . . . . . . . . . %d\n" failed; > + ansi_restore () > + ); > + if timedout > 0 then ( > + ansi_red (); > + printf "Timed out . . . . . . . . . . %d\n" timedout; > + ansi_restore () > + ); > + if skipped > 0 then ( > + ansi_blue (); > + printf "Skipped . . . . . . . . . . . %d\n" skipped; > + ansi_restore () > + ); > + printf "--------------------------------------------------\n"; > + > + (* If there were any errors, then exit with a failure. *) > + exit (if failed = 0 && timedout = 0 then 0 else 1) > diff --git a/generator/tests.ml b/generator/tests.ml > new file mode 100644 > index 0000000..4be899b > --- /dev/null > +++ b/generator/tests.ml > @@ -0,0 +1,71 @@ > +(* 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 > + *) > + > +(* Please read generator/README first. *) > + > +open Printf > + > +open Types > +open Utils > +open Pr > +open Docstrings > + > +let defaults = { > + check = []; check_fast = []; check_slow = []; check_local_guests = []; > + check_data = []; check_scripts = []; check_programs = []; > +} > + > +(* The tests in each subdirectory. *) > +let tests = [ > + "inspector", { > + defaults with > + check = [ > + "test-virt-inspector.sh"; > + ]; > + check_fast = [ > + "test-xmllint.sh"; > + ]; > + check_local_guests = [ > + "test-virt-inspector-local-guests.sh"; > + ]; > + check_data = [ > + "example-debian-netinst-cd.xml"; > + "example-debian.xml"; > + "example-fedora-dvd.xml"; > + "example-fedora-netinst-cd.xml"; > + "example-fedora.xml"; > + "example-rhel-6-dvd.xml"; > + "example-rhel-6-netinst-cd.xml"; > + "example-rhel-6.xml"; > + "example-ubuntu-live-cd.xml"; > + "example-ubuntu.xml"; > + "example-windows-2003-x64-cd.xml"; > + "example-windows-2003-x86-cd.xml"; > + "example-windows.xml"; > + "example-windows-xp-cd.xml"; > + "expected-archlinux.img.xml"; > + "expected-coreos.img.xml"; > + "expected-debian.img.xml"; > + "expected-fedora.img.xml"; > + "expected-ubuntu.img.xml"; > + "expected-windows.img.xml"; > + "virt-inspector.rng"; > + ] > + }; > + > +] > diff --git a/generator/tests_mk.ml b/generator/tests_mk.ml > new file mode 100644 > index 0000000..e2705ce > --- /dev/null > +++ b/generator/tests_mk.ml > @@ -0,0 +1,130 @@ > +(* 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 > + *) > + > +(* Please read generator/README first. *) > + > +open Printf > + > +open Types > +open Tests > +open Utils > +open Pr > +open Docstrings > + > +(* Generate the tests.mk files in each subdirectory. *) > +let generate_tests_mk dir tests () > + generate_header HashStyle GPLv2plus; > + > + pr "localtestsdir = $(alltestsdir)/%s\n" dir; > + > + if tests.check_data <> [] then ( > + pr "\n"; > + pr "localtests_DATA ="; > + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare tests.check_data); > + pr "\n"; > + ); > + > + (* Only add *.sh and *.pl to localtests_SCRIPTS. Others are added to > + * localtests_PROGRAMS. > + *) > + let test_scripts, test_programs > + List.partition ( > + fun file -> > + Filename.check_suffix file ".sh" || Filename.check_suffix file ".pl"Sounds like this "is a script?" check, used also in run_one_test, could be factorized out.> + ) (tests.check @ tests.check_fast @ tests.check_slow > + @ tests.check_local_guests) in > + > + (* Also, check_scripts get added to localtests_SCRIPTS. *) > + let test_scripts = test_scripts @ tests.check_scripts in > + > + (* Also, check_programs get added to localtests_PROGRAMS. *) > + let test_programs = test_programs @ tests.check_programs in > + > + if test_scripts <> [] then ( > + pr "\n"; > + pr "localtests_SCRIPTS ="; > + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare test_scripts); > + pr "\n" > + ); > + if test_programs <> [] then ( > + pr "\n"; > + pr "localtests_PROGRAMS ="; > + List.iter (fun n -> pr " \\\n\t%s" n) (List.sort compare test_programs); > + pr "\n" > + ); > + > + (* Create rules so that 'make -C dir check' etc will do something. *) > + if tests.check_fast <> [] || tests.check <> [] then ( > + pr "\n"; > + pr "# Note that we cannot create a simple 'check:' target since\n"; > + pr "# automake will (silently) overrule it, so we do this instead:\n"; > + pr "\n"; > + pr "TESTS_ENVIRONMENT = $(top_builddir)/run\n"; > + pr "TESTS = $(top_builddir)/test-harness\n"; > + pr "\n"; > + pr "check-valgrind:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind\n"; > + pr "\n"; > + pr "check-direct:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --direct\n"; > + pr "\n"; > + pr "check-valgrind-direct:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct\n"; > + pr "\n"; > + pr "check-libvirt:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --libvirt\n"; > + pr "\n"; > + pr "check-valgrind-libvirt:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt\n"; > + pr "\n"; > + pr "check-uml:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --uml\n"; > + pr "\n"; > + pr "check-valgrind-uml:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml\n"; > + pr "\n"; > + pr "check-with-upstream-qemu:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu\n"; > + pr "\n"; > + pr "check-with-upstream-libvirt:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt\n"; > + ); > + > + if tests.check_fast <> [] then ( > + pr "\n"; > + pr "check-fast:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --fast\n" > + ); > + > + if tests.check_slow <> [] then ( > + pr "\n"; > + pr "check-slow:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --slow\n" > + ); > + > + if tests.check_local_guests <> [] then ( > + pr "\n"; > + pr "check-local-guests:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --local-guests\n"; > + pr "\n"; > + pr "check-valgrind-local-guests:\n"; > + pr "\t$(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests\n" > + ); > + > + pr "\n"; > + pr "EXTRA_DIST += tests.mk\n" > diff --git a/generator/types.ml b/generator/types.ml > index 83a6a98..9083479 100644 > --- a/generator/types.ml > +++ b/generator/types.ml > @@ -207,6 +207,21 @@ type fish_output_t > | FishOutputOctal (* for int return, print in octal *) > | FishOutputHexadecimal (* for int return, print in hex *) > > +type test = { > + check : string list; > + (* "fast" here means the appliance is not needed *) > + check_fast : string list; > + check_slow : string list; > + check_local_guests : string list; > + > + (* Data files, non-executable. *) > + check_data : string list; > + (* Data files, scripts. *) > + check_scripts : string list; > + (* Data files, C programs. *) > + check_programs : string list; > +} > + > (* See guestfs(3)/EXTENDING LIBGUESTFS. *) > type c_api_tests = (c_api_test_init * c_api_test_prereq * c_api_test * c_api_test_cleanup) list > and c_api_test > diff --git a/inspector/Makefile.am b/inspector/Makefile.am > index 9c79bed..1b4bfc7 100644 > --- a/inspector/Makefile.am > +++ b/inspector/Makefile.am > @@ -17,6 +17,8 @@ > > include $(top_srcdir)/subdir-rules.mk > > +generator_built = tests.mk > + > example_xml = \ > example-debian.xml \ > example-fedora.xml \ > @@ -40,6 +42,7 @@ EXTRA_DIST = \ > expected-archlinux.img.xml \ > expected-coreos.img.xml \ > expected-windows.img.xml \ > + test-virt-inspector-local-guests.sh \ > test-virt-inspector.sh \ > test-xmllint.sh.in \ > virt-inspector.pod > @@ -103,16 +106,4 @@ stamp-virt-inspector.pod: virt-inspector.pod > $< > touch $@ > > -TESTS_ENVIRONMENT = $(top_builddir)/run --test > -TESTS = test-virt-inspector.sh > -if HAVE_XMLLINT > -TESTS += test-xmllint.sh > -endif > - > -check-valgrind: > - $(MAKE) TESTS="test-virt-inspector.sh" VG="$(top_builddir)/run @VG@" check > - > -check-valgrind-local-guests: > - for g in $(GUESTS); do \ > - $(top_builddir)/run --test @VG@ ./virt-inspector -c "$(libvirt_ro_uri)" -d "$$g" || exit $$?; \ > - done > +include $(srcdir)/tests.mk > diff --git a/inspector/test-virt-inspector-local-guests.sh.in b/inspector/test-virt-inspector-local-guests.sh.in > new file mode 100755 > index 0000000..91f1a71 > --- /dev/null > +++ b/inspector/test-virt-inspector-local-guests.sh.in > @@ -0,0 +1,26 @@ > +#!/bin/bash - > +# libguestfs virt-inspector test script > +# @configure_input@ > +# Copyright (C) 2012-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. > + > +export LANG=C > +set -e > +set -x > + > +for g in "$@"; do > + $VG virt-inspector -c "@libvirt_ro_uri@" -d "$g" > +done > diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh > index 02bbcad..c8ca0e0 100755 > --- a/inspector/test-virt-inspector.sh > +++ b/inspector/test-virt-inspector.sh > @@ -20,23 +20,17 @@ export LANG=C > set -e > set -x > > -# Allow this test to be skipped. > -if [ -n "$SKIP_TEST_VIRT_INSPECTOR_SH" ]; then > - echo "$0: skipping test because SKIP_TEST_VIRT_INSPECTOR_SH is set." > - exit 77 > -fi > - > # ntfs-3g can't set UUIDs right now, so ignore just that <uuid>. > diff_ignore="-I <uuid>[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]</uuid>" > > -for f in ../tests/guests/{debian,fedora,ubuntu,archlinux,coreos,windows}.img; do > +for f in $phonydir/{debian,fedora,ubuntu,archlinux,coreos,windows}.img; do > # Ignore zero-sized windows.img if ntfs-3g is not installed. > if [ -s "$f" ]; then > b=$(basename "$f" .xml) > - $VG virt-inspector -a "$f" > "actual-$b.xml" > + $VG virt-inspector -a "$f" > 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 -ur $diff_ignore $srcdir/expected-$b.xml actual-$b.xml > fi > done > > diff --git a/inspector/test-xmllint.sh.in b/inspector/test-xmllint.sh.in > index 65654bc..2755414 100755 > --- a/inspector/test-xmllint.sh.in > +++ b/inspector/test-xmllint.sh.in > @@ -19,6 +19,11 @@ > export LANG=C > set -e > > +if ! "@XMLLINT@" --version >/dev/null 2>&1; then > + echo "$0: test skipped before xmllint is not installed"s/before/because/?> + exit 77 > +fi > + > for f in $srcdir/example-*.xml; do > @XMLLINT@ --noout --relaxng $srcdir/virt-inspector.rng $f > done > diff --git a/inspector/tests.mk b/inspector/tests.mk > new file mode 100644 > index 0000000..67fc0bc > --- /dev/null > +++ b/inspector/tests.mk > @@ -0,0 +1,94 @@ > +# libguestfs generated file > +# WARNING: THIS FILE IS GENERATED FROM:I guess this is just to show the results of this commit for review, and this file is not actually meant to be commited, right?> +# generator/ *.ml > +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. > +# > +# Copyright (C) 2009-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. > + > +localtestsdir = $(alltestsdir)/inspector > + > +localtests_DATA = \ > + example-debian-netinst-cd.xml \ > + example-debian.xml \ > + example-fedora-dvd.xml \ > + example-fedora-netinst-cd.xml \ > + example-fedora.xml \ > + example-rhel-6-dvd.xml \ > + example-rhel-6-netinst-cd.xml \ > + example-rhel-6.xml \ > + example-ubuntu-live-cd.xml \ > + example-ubuntu.xml \ > + example-windows-2003-x64-cd.xml \ > + example-windows-2003-x86-cd.xml \ > + example-windows-xp-cd.xml \ > + example-windows.xml \ > + expected-archlinux.img.xml \ > + expected-coreos.img.xml \ > + expected-debian.img.xml \ > + expected-fedora.img.xml \ > + expected-ubuntu.img.xml \ > + expected-windows.img.xml \ > + virt-inspector.rng > + > +localtests_SCRIPTS = \ > + test-virt-inspector-local-guests.sh \ > + test-virt-inspector.sh \ > + test-xmllint.sh > + > +# Note that we cannot create a simple 'check:' target since > +# automake will (silently) overrule it, so we do this instead: > + > +TESTS_ENVIRONMENT = $(top_builddir)/run > +TESTS = $(top_builddir)/test-harness > + > +check-valgrind: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind > + > +check-direct: > + $(top_builddir)/run $(top_builddir)/test-harness --direct > + > +check-valgrind-direct: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct > + > +check-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --libvirt > + > +check-valgrind-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt > + > +check-uml: > + $(top_builddir)/run $(top_builddir)/test-harness --uml > + > +check-valgrind-uml: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml > + > +check-with-upstream-qemu: > + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu > + > +check-with-upstream-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt > + > +check-fast: > + $(top_builddir)/run $(top_builddir)/test-harness --fast > + > +check-local-guests: > + $(top_builddir)/run $(top_builddir)/test-harness --local-guests > + > +check-valgrind-local-guests: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --local-guests > + > +EXTRA_DIST += tests.mk > diff --git a/pick-guests.pl.in b/pick-guests.pl.in > index bfc97d8..14feae6 100755 > --- a/pick-guests.pl.in > +++ b/pick-guests.pl.in > @@ -56,7 +56,5 @@ $n = @accessible if @accessible < $n; > > # Return the first n guests from the list. > for (my $i = 0; $i < $n; ++$i) { > - print " " if $i > 0; > - print $accessible[$i]; > + print $accessible[$i], "\n" > } > -print "\n"; > diff --git a/po-docs/podfiles b/po-docs/podfiles > index 21f1cf1..50c31f2 100644 > --- a/po-docs/podfiles > +++ b/po-docs/podfiles > @@ -56,6 +56,7 @@ > ../sysprep/sysprep-extra-options.pod > ../sysprep/sysprep-operations.pod > ../sysprep/virt-sysprep.pod > +../test-harness.pod > ../test-tool/libguestfs-test-tool.pod > ../tools/virt-list-filesystems > ../tools/virt-list-partitions > diff --git a/test-harness.pod b/test-harness.pod > new file mode 100644 > index 0000000..b08c8b0 > --- /dev/null > +++ b/test-harness.pod > @@ -0,0 +1,252 @@ > +=head1 NAME > + > +test-harness - Run the libguestfs test suite, or parts of it. > + > +=head1 SYNOPSIS > + > + test-harness [--options] [test-directory] > + > +=head1 DESCRIPTION > + > +This program runs the libguestfs test suite, or parts of it. You can > +run it either on a just-built libguestfs source tree, or on the > +installed libguestfs and virt-* tools. > + > +Normally tests in the current directory are run. If the current > +directory is the top level of the test suite then the whole test suite > +is run. If the current directory is a leaf directory, then only tests > +in that directory are run. > + > +If you specify a directory name on the command line, then we run tests > +from that directory instead. > + > +=head1 OPTIONS > + > +=head2 Options to select which tests are run > + > +If neither I<--fast> nor I<--slow>, then I<--fast> + normal tests are run. > + > +=over 4 > + > +=item B<--fast> > + > +Run only tests which do not need the appliance. > + > +=item B<--slow> > + > +Run only long-running tests. > + > +=item B<--local-guests> > + > +Run tests that use locally installed guests read-only. > + > +=back > + > +=head2 Options to run the selected tests under different test conditions > + > +=over 4 > + > +=item B<--debug> > + > +Run tests with debugging enabled [recommended]. > + > +=item B<--valgrind> > + > +Run tests under valgrind. > + > +=item B<--direct> > + > +Run tests using the direct backend. > + > +=item B<--libvirt> > + > +Run tests using the libvirt backend. > + > +=item B<--uml> > + > +Run tests using the UML backend. > + > +=item B<--with-uml VMLINUX> > + > +Select UML binary [default: F<$HOME/d/linux-um/vmlinux>]. > + > +=item B<--upstream-libvirt> > + > +Run tests using upstream libvirt. > + > +=item B<--with-upstream-libvirt LIBVIRTDIR> > + > +Select libvirt directory [default: F<$HOME/d/libvirt>]. > + > +=item B<--upstream-qemu> > + > +Run tests using upstream qemu. > + > +=item B<--with-upstream-qemu QEMUBINARY> > + > +Select qemu binary > +[default: F<$HOME/d/qemu/x86_64-softmmu/qemu-system-x86_64>]. > + > +=back > + > +=head2 Options used internally > + > +=over 4 > + > +=item B<--make-phony-guests-only> > + > +Generate the phony guests used for testing. > + > +=back > + > +=head2 Other options > + > +=over 4 > + > +=item B<--help> > + > +Display short help and exit. > + > +=item B<-v> > + > +=item B<--verbose> > + > +Enables some verbose debugging in the test-harness program itself. > + > +=back > + > +=head1 TEST ENVIRONMENT > + > +=head2 Temporary directory > + > +The test-harness creates a temporary directory for each test and sets > +the test current working directory there. Any temporary files needed > +by the test should be created in the current (ie. temporary) > +directory. > + > +The temporary directory and its contents are deleted after the test > +has run, except where the test failed. > + > +=head2 Environment variables > + > +When running each test, test-harness passes various environment > +variables: > + > +=over 4 > + > +=item C<builddir> > + > +=item C<top_builddir> > + > +=item C<abs_builddir> > + > +=item C<abs_top_builddir> > + > +The path to the build directory and the top build directory. > + > +For example, if running tests in F<libguestfs.git/tests/events> then > +C<builddir> would point to F<libguestfs.git/tests/events>, and > +C<top_builddir> would point to F<libguestfs.git>. > + > +The C<abs_*> variants are absolute paths. (In fact because of the > +current directory being the temporary directory, all environment > +variables contain absolute paths). > + > +=item C<srcdir> > + > +=item C<top_srcdir> > + > +=item C<abs_srcdir> > + > +=item C<abs_top_srcdir> > + > +If you are not using separate source and build directories, then these > +environment variables are the same as the C<builddir> variants above. > + > +If you are using separate source and build directories, then these > +point to the source directories. > + > +=item C<phonydir> > + > +The phony test guests (see F<libguestfs.git/tests/guests>). > + > +=item C<datadir> > + > +The data files (see F<libguestfs.git/tests/data>). > + > +=item C<tmpdir> > + > +The temporary directory created for the test. This is the same as the > +current working directory when the test starts. > + > +=item C<LIBGUESTFS_DEBUG=1> > + > +=item C<LIBGUESTFS_TRACE=1> > + > +If the I<--debug> flag was passed, then these environment variables > +are set. > + > +=item C<LIBGUESTFS_BACKEND=(direct|libvirt|uml)> > + > +If using the I<--direct>, I<--libvirt> or I<--uml> flags, then the > +backend environment variable is set appropriately. > + > +=item C<LIBGUESTFS_HV=>(qemu|uml) > + > +Points to the qemu or UML hypervisor. > + > +=back > + > +=head2 Skipping tests > + > +You can skip tests by setting C<SKIP_*> environment variables. The > +environment variable name is formed by converting all characters to > +uppercase and replacing non-alphanumeric characters with C<_>. For > +example, F<test-network.sh> becomes C<SKIP_TEST_NETWORK_SH>. > + > +Tests can also skip themselves (eg. if they cannot run with the > +requested backend, or if a data file is missing). The test should > +print a diagnostic message and exit with code C<77>. > + > +=head2 Exit code of the test > + > +The test should exit with one of the following exit codes: > + > +=over 4 > + > +=item C<0> > + > +Test successful. > + > +=item C<1>-C<76> > + > +The test failed. > + > +=item C<77> > + > +The test was skipped. > + > +=item C<119> > + > +L<valgrind(1)> returns this code to indicate a valgrind failure. > + > +=item C<124> > + > +L<timeout(1)> returns this code if the test timed out. > + > +=back > + > +=head1 SEE ALSO > + > +L<automake(1)>, > +L<timeout(1)>, > +L<valgrind(1)>, > +L<http://libguestfs.org/>. > + > +=head1 AUTHOR > + > +Richard W.M. Jones. > + > +=head1 COPYRIGHT > + > +Copyright (C) 2014-2015 Red Hat Inc. > diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am > index 305136f..d379826 100644 > --- a/tests/data/Makefile.am > +++ b/tests/data/Makefile.am > @@ -19,13 +19,6 @@ include $(top_srcdir)/subdir-rules.mk > > EXTRA_DIST = \ > README-binfiles \ > - filesanddirs-10M.tar.xz \ > - filesanddirs-100M.tar.xz \ > - helloworld.tar \ > - helloworld.tar.gz \ > - helloworld.tar.xz \ > - mbr-ext2-empty.img.gz \ > - empty known-1 known-2 known-3 known-4 known-5 \ > bin-aarch64-dynamic \ > bin-armv7-dynamic \ > bin-i586-dynamic \ > @@ -37,6 +30,13 @@ EXTRA_DIST = \ > bin-win32.exe \ > bin-win64.exe \ > bin-x86_64-dynamic \ > + empty \ > + filesanddirs-10M.tar.xz \ > + filesanddirs-100M.tar.xz \ > + helloworld.tar \ > + helloworld.tar.gz \ > + helloworld.tar.xz \ > + known-1 known-2 known-3 known-4 known-5 \ > lib-aarch64.so \ > lib-armv7.so \ > lib-i586.so \ > @@ -48,19 +48,11 @@ EXTRA_DIST = \ > lib-win32.dll \ > lib-win64.dll \ > lib-x86_64.so \ > - test-grep.txt \ > - minimal > + mbr-ext2-empty.img.gz \ > + minimal \ > + test-grep.txt > > images_files_src = \ > - $(srcdir)/helloworld.tar \ > - $(srcdir)/helloworld.tar.gz \ > - $(srcdir)/helloworld.tar.xz \ > - $(srcdir)/empty \ > - $(srcdir)/known-1 \ > - $(srcdir)/known-2 \ > - $(srcdir)/known-3 \ > - $(srcdir)/known-4 \ > - $(srcdir)/known-5 \ > $(srcdir)/bin-aarch64-dynamic \ > $(srcdir)/bin-armv7-dynamic \ > $(srcdir)/bin-i586-dynamic \ > @@ -72,6 +64,17 @@ images_files_src = \ > $(srcdir)/bin-win32.exe \ > $(srcdir)/bin-win64.exe \ > $(srcdir)/bin-x86_64-dynamic \ > + $(srcdir)/empty \ > + $(srcdir)/filesanddirs-10M.tar.xz \ > + $(srcdir)/filesanddirs-100M.tar.xz \ > + $(srcdir)/helloworld.tar \ > + $(srcdir)/helloworld.tar.gz \ > + $(srcdir)/helloworld.tar.xz \ > + $(srcdir)/known-1 \ > + $(srcdir)/known-2 \ > + $(srcdir)/known-3 \ > + $(srcdir)/known-4 \ > + $(srcdir)/known-5 \ > $(srcdir)/lib-aarch64.so \ > $(srcdir)/lib-armv7.so \ > $(srcdir)/lib-i586.so \ > @@ -83,8 +86,8 @@ images_files_src = \ > $(srcdir)/lib-win32.dll \ > $(srcdir)/lib-win64.dll \ > $(srcdir)/lib-x86_64.so \ > - $(srcdir)/test-grep.txt \ > - $(srcdir)/minimal > + $(srcdir)/minimal \ > + $(srcdir)/test-grep.txt > > images_files_build = \ > 100kallzeroes \ > @@ -107,12 +110,14 @@ images_files_build = \ > lib-i586.so.xz \ > test-grep.txt.gz > > -check_DATA = $(images_files_build) test.iso > - > -CLEANFILES = $(images_files_build) test.iso > - > images_files = $(images_files_src) $(images_files_build) > > +localtestsdir = $(alltestsdir)/tests/data > + > +localtests_DATA = $(images_files) test.iso > + > +CLEANFILES = $(images_files_build) test.iso > + > test.iso: $(images_files) > rm -f $@ $@-t > mkdir -p directory > @@ -156,21 +161,21 @@ test.iso: $(images_files) > # Blank disk images in various sizes and formats. > blank-disk-1s.raw: > rm -f $@ > - ../../fish/guestfish sparse $@ 512 > + truncate -s 512 $@ > > blank-disk-1s.qcow2: > qemu-img create -f qcow2 -o preallocation=metadata $@ 512 > > blank-disk-1K.raw: > rm -f $@ > - ../../fish/guestfish sparse $@ 1K > + truncate -s 1K $@ > > blank-disk-1K.qcow2: > qemu-img create -f qcow2 -o preallocation=metadata $@ 1K > > blank-disk-1M.raw: > rm -f $@ > - ../../fish/guestfish sparse $@ 1M > + truncate -s 1M $@IMHO these s/guestfish/truncate/ changes could go in regardless of the rest already.> blank-disk-1M.qcow2: > qemu-img create -f qcow2 -o preallocation=metadata $@ 1M > diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am > index 6ada4ec..796d428 100644 > --- a/tests/guests/Makefile.am > +++ b/tests/guests/Makefile.am > @@ -60,70 +60,37 @@ disk_images = \ > # time and we need the tools we have built in order to make it. > check_DATA = $(disk_images) guests-all-good.xml > > -CLEANFILES = $(check_DATA) \ > - guests-all-good.xml \ > - stamp-fedora-md.img \ > - *.tmp.* > +$(disk_images) guests-all-good.xml: stamp-guests > > -# Make several different blank images. These are not guests, but we > -# include them in the libvirt fake XML to make sure that virt-df and > -# virt-alignment-scan don't break when they encounter them. > -blank-%.img: > - rm -f $@ $@-t > - $(top_builddir)/run \ > - ../../fish/guestfish \ > - -N $@-t="$$(echo $@ | $(SED) -e 's/blank-//' -e 's/.img//')" exit > - mv $@-t $@ > - > -# Make a (dummy) Fedora image. > -fedora.img: guest-aux/make-fedora-img.pl \ > - guest-aux/fedora-journal.tar.xz \ > - guest-aux/fedora-name.db \ > - guest-aux/fedora-packages.db > - SRCDIR=$(srcdir) LAYOUT=partitions $(top_builddir)/run --test $< > - > -# Make a (dummy) Fedora image using md devices > -fedora-md1.img fedora-md2.img: stamp-fedora-md.img > - > -stamp-fedora-md.img: guest-aux/make-fedora-img.pl \ > - guest-aux/fedora-journal.tar.xz \ > - guest-aux/fedora-name.db \ > - guest-aux/fedora-packages.db > - rm -f $@ > - SRCDIR=$(srcdir) LAYOUT=partitions-md $(top_builddir)/run --test $< > +stamp-guests: $(top_builddir)/test-harness > + $(top_builddir)/run $< --make-phony-guests-only > touch $@ > > -fedora-btrfs.img: guest-aux/make-fedora-img.pl \ > - guest-aux/fedora-journal.tar.xz \ > - guest-aux/fedora-name.db \ > - guest-aux/fedora-packages.db > - SRCDIR=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test $< > +CLEANFILES = \ > + $(check_DATA) \ > + stamp-guests \ > + *.tmp.* > > -# Make a (dummy) Debian image. > -debian.img: guest-aux/make-debian-img.sh > - SRCDIR=$(srcdir) $(top_builddir)/run --test $< > - > -# Make a (dummy) Ubuntu image. > -ubuntu.img: guest-aux/make-ubuntu-img.sh > - SRCDIR=$(srcdir) $(top_builddir)/run --test $< > - > -# Make a (dummy) Arch Linux image. > -archlinux.img: guest-aux/make-archlinux-img.sh > - SRCDIR=$(srcdir) $(top_builddir)/run --test $< > - > -# Make a (dummy) CoreOS image. > -coreos.img: guest-aux/make-coreos-img.sh > - SRCDIR=$(srcdir) $(top_builddir)/run --test $< > - > -# Make a (dummy) Windows image. > -windows.img: guest-aux/make-windows-img.sh \ > - guest-aux/windows-software guest-aux/windows-system > - SRCDIR=$(srcdir) $(top_builddir)/run --test $< > - > -guests-all-good.xml: guest-aux/make-guests-all-good.pl $(disk_images) > - rm -f $@ $@-t > - $^ > $@-t > - mv $@-t $@ > +# For installed tests. > +localtestsdir = $(alltestsdir)/tests/guests/guest-aux > +localtests_DATA = \ > + guest-aux/archlinux-package \ > + guest-aux/debian-packages \ > + guest-aux/debian-syslog \ > + guest-aux/fedora-journal.tar.xz \ > + guest-aux/fedora-name.db \ > + guest-aux/fedora-packages.db \ > + guest-aux/minimal-hive \ > + guest-aux/windows-software \ > + guest-aux/windows-system > +localtests_SCRIPTS = \ > + guest-aux/make-archlinux-img.sh \ > + guest-aux/make-coreos-img.sh \ > + guest-aux/make-debian-img.sh \ > + guest-aux/make-fedora-img.pl \ > + guest-aux/make-guests-all-good.pl \ > + guest-aux/make-ubuntu-img.sh \ > + guest-aux/make-windows-img.sh > > # Since users might not have the tools needed to create this, we also > # distribute these files and they are only cleaned by 'make distclean' > @@ -155,11 +122,3 @@ DISTCLEANFILES = \ > guest-aux/fedora-packages.db \ > guest-aux/windows-software \ > guest-aux/windows-system > - > -# Don't construct the guests in parallel. In automake 1.13, check_DATA > -# was changed so it can now run in parallel, but this causes everything > -# to fall over on machines with limited memory. > -# > -# ALSO: the guestfish rules above for making the blank-*.img files are > -# NOT safe to run in parallel. > -.NOTPARALLEL: > diff --git a/tests/guests/guest-aux/make-archlinux-img.sh b/tests/guests/guest-aux/make-archlinux-img.sh > index 62babd1..54a27b0 100755 > --- a/tests/guests/guest-aux/make-archlinux-img.sh > +++ b/tests/guests/guest-aux/make-archlinux-img.sh > @@ -47,9 +47,9 @@ write /etc/fstab "/dev/sda1 / ext4 rw,relatime,data=ordered 0 1" > touch /etc/arch-release > write /etc/hostname "archlinux.test" > > -upload $SRCDIR/guest-aux/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc > +upload $srcdir/guest-aux/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc > > -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls > +upload $datadir/../data/bin-x86_64-dynamic /bin/lsIsn't $datadir the ../tests/data subdirectory already?> > mkdir /boot/grub > touch /boot/grub/grub.conf > diff --git a/tests/guests/guest-aux/make-debian-img.sh b/tests/guests/guest-aux/make-debian-img.sh > index 95228ab..af251b4 100755 > --- a/tests/guests/guest-aux/make-debian-img.sh > +++ b/tests/guests/guest-aux/make-debian-img.sh > @@ -82,11 +82,11 @@ upload fstab.tmp.$$ /etc/fstab > write /etc/debian_version "5.0.1" > write /etc/hostname "debian.invalid" > > -upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status > +upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status > > -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls > +upload $datadir/../data/bin-x86_64-dynamic /bin/ls > > -upload $SRCDIR/guest-aux/debian-syslog /var/log/syslog > +upload $srcdir/guest-aux/debian-syslog /var/log/syslog > > mkdir /boot/grub > touch /boot/grub/grub.conf > diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl > index eae11d6..c85271f 100755 > --- a/tests/guests/guest-aux/make-fedora-img.pl > +++ b/tests/guests/guest-aux/make-fedora-img.pl > @@ -44,11 +44,12 @@ my $g = Sys::Guestfs->new (); > > my $bootdev; > > -foreach ('LAYOUT', 'SRCDIR') { > - defined ($ENV{$_}) or die "Missing environment variable: $_"; > +if (@ARGV < 1 || $ARGV[0] !~ /^--layout=(.*)/) { > + die "usage: $0 --layout=(partitions|partitions-md|btrfs)\n" > } > +my $layout = $1; > > -if ($ENV{LAYOUT} eq 'partitions') { > +if ($layout eq 'partitions') { > push (@images, "fedora.img.tmp.$$"); > > open (my $fstab, '>', "fstab.tmp.$$") or die; > @@ -73,7 +74,7 @@ EOF > init_lvm_root ('/dev/sda2'); > } > > -elsif ($ENV{LAYOUT} eq 'partitions-md') { > +elsif ($layout eq 'partitions-md') { > push (@images, "fedora-md1.img.tmp.$$", "fedora-md2.img.tmp.$$"); > > open (my $fstab, '>', "fstab.tmp.$$") or die; > @@ -122,7 +123,7 @@ EOF > init_lvm_root ('/dev/md/root'); > } > > -elsif ($ENV{LAYOUT} eq 'btrfs') { > +elsif ($layout eq 'btrfs') { > push (@images, "fedora-btrfs.img.tmp.$$"); > > open (my $fstab, '>', "fstab.tmp.$$") or die; > @@ -154,7 +155,7 @@ EOF > } > > else { > - print STDERR "$0: Unknown LAYOUT: ",$ENV{LAYOUT},"\n"; > + print STDERR "$0: Unknown layout: ",$layout,"\n"; > exit 1; > } > > @@ -217,12 +218,12 @@ if (-f "mdadm.tmp.$$") { > unlink ("mdadm.tmp.$$") or die; > } > > -$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name'); > -$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages'); > +$g->upload ($ENV{srcdir}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name'); > +$g->upload ($ENV{srcdir}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages'); > > -$g->upload ($ENV{SRCDIR}.'/../data/bin-x86_64-dynamic', '/bin/ls'); > +$g->upload ($ENV{datadir}.'/../data/bin-x86_64-dynamic', '/bin/ls'); > > -$g->txz_in ($ENV{SRCDIR}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal'); > +$g->txz_in ($ENV{srcdir}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal'); > > $g->mkdir ('/boot/grub'); > $g->touch ('/boot/grub/grub.conf');The changes in this file IMHO could go already on their own already.> diff --git a/tests/guests/guest-aux/make-ubuntu-img.sh b/tests/guests/guest-aux/make-ubuntu-img.sh > index 183985b..36abe55 100755 > --- a/tests/guests/guest-aux/make-ubuntu-img.sh > +++ b/tests/guests/guest-aux/make-ubuntu-img.sh > @@ -73,9 +73,9 @@ write /etc/debian_version "5.0.1" > upload release.tmp.$$ /etc/lsb-release > write /etc/hostname "ubuntu.invalid" > > -upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status > +upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status > > -upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls > +upload $datadir/../data/bin-x86_64-dynamic /bin/ls > > mkdir /boot/grub > touch /boot/grub/grub.conf > diff --git a/tests/guests/guest-aux/make-windows-img.sh b/tests/guests/guest-aux/make-windows-img.sh > index cfe59dc..ad3201a 100755 > --- a/tests/guests/guest-aux/make-windows-img.sh > +++ b/tests/guests/guest-aux/make-windows-img.sh > @@ -59,10 +59,10 @@ mount /dev/sda2 / > mkdir-p /Windows/System32/Config > mkdir-p /Windows/System32/Drivers > > -upload $SRCDIR/guest-aux/windows-software /Windows/System32/Config/SOFTWARE > -upload $SRCDIR/guest-aux/windows-system /Windows/System32/Config/SYSTEM > +upload $srcdir/guest-aux/windows-software /Windows/System32/Config/SOFTWARE > +upload $srcdir/guest-aux/windows-system /Windows/System32/Config/SYSTEM > > -upload $SRCDIR/../data/bin-win32.exe /Windows/System32/cmd.exe > +upload $datadir/../data/bin-win32.exe /Windows/System32/cmd.exe > > mkdir "/Program Files" > touch /autoexec.bat >Thanks, -- Pino Toscano
Pino Toscano
2015-Aug-07 15:54 UTC
Re: [Libguestfs] [PATCH v4 02/17] tests/c-api: Convert the C API tests to use the test harness.
On Thursday 06 August 2015 16:05:44 Richard W.M. Jones wrote:> This involves some significant changes to this test framework. > In particular: > > - Instead of just specifying $srcdir at the start of a FileIn > path, you can now specify arbitrary environment variables. > This is necessary to allow the tests to run from a tmpdir.This could go already on its own.> - Use COPYING instead of COPYING.LIB, and copy that file into > the test suite directory.s/COPYING/COPYING.LIB/ looks fine as own commit as well.> - Require the static binaries (test-command, test-pwd) in order > to run tests. > > - Don't conditionalize the C++ tests. Instead if a C++ compiler > is not available then we build a "skip" script. > --- > .gitignore | 3 - > Makefile.am | 4 +- > generator/actions.ml | 150 ++++++++++++++++++++++++---------------------- > generator/tests.ml | 28 +++++++++ > generator/tests_c_api.ml | 9 ++- > inspector/tests.mk | 2 +- > tests/c-api/Makefile.am | 84 +++++++------------------- > tests/c-api/test-dlopen.c | 15 ++--- > tests/c-api/tests-main.c | 56 +++++++++++------ > tests/c-api/tests.h | 2 +- > tests/c-api/tests.mk | 79 ++++++++++++++++++++++++ > 11 files changed, 257 insertions(+), 175 deletions(-) > create mode 100644 tests/c-api/tests.mk > > diff --git a/.gitignore b/.gitignore > index 72f8cc4..045f3de 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -508,16 +508,13 @@ Makefile.in > /tests/c-api/test-dlopen > /tests/c-api/test-environment > /tests/c-api/test-event-string > -/tests/c-api/test*.img > /tests/c-api/test-just-header > /tests/c-api/test-just-header-cxx > /tests/c-api/test-last-errno > -/tests/c-api/test.log > /tests/c-api/test-private-data > /tests/c-api/test-pwd > /tests/c-api/tests > /tests/c-api/tests.c > -/tests/c-api/test*.tmp > /tests/c-api/test-user-cancel > /tests/charsets/test-charset-fidelity > /tests/data/100kallnewlines > diff --git a/Makefile.am b/Makefile.am > index 2c6c8b2..ef66d4c 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -558,8 +558,8 @@ check-slow: build-test-guests > build-test-guests: > $(MAKE) -C tests/guests check > > -# Install valgrind suppressions file in test directory. > -alltests_DATA = valgrind-suppressions > +# Install some files in the test directory. > +alltests_DATA = COPYING valgrind-suppressions > > # Print subdirs. > # > diff --git a/generator/actions.ml b/generator/actions.ml > index 35af981..d2b057d 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -2767,19 +2767,19 @@ data." }; > style = RString "format", [String "filename"], []; > tests = [ > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1s.raw"]], "raw"), []; > + [["disk_format"; "$datadir/blank-disk-1s.raw"]], "raw"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1s.qcow2"]], "qcow2"), []; > + [["disk_format"; "$datadir/blank-disk-1s.qcow2"]], "qcow2"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1K.raw"]], "raw"), []; > + [["disk_format"; "$datadir/blank-disk-1K.raw"]], "raw"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1K.qcow2"]], "qcow2"), []; > + [["disk_format"; "$datadir/blank-disk-1K.qcow2"]], "qcow2"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1M.raw"]], "raw"), []; > + [["disk_format"; "$datadir/blank-disk-1M.raw"]], "raw"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-1M.qcow2"]], "qcow2"), []; > + [["disk_format"; "$datadir/blank-disk-1M.qcow2"]], "qcow2"), []; > InitEmpty, Always, TestResultString ( > - [["disk_format"; "../data/blank-disk-with-backing.qcow2"]], "qcow2"), []; > + [["disk_format"; "$datadir/blank-disk-with-backing.qcow2"]], "qcow2"), []; > ]; > shortdesc = "detect the disk format of a disk image"; > longdesc = "\ > @@ -2797,19 +2797,19 @@ See also: L<guestfs(3)/DISK IMAGE FORMATS>" }; > style = RInt64 "size", [String "filename"], []; > tests = [ > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1s.raw"]], "ret == 512"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1s.raw"]], "ret == 512"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1s.qcow2"]], "ret == 512"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1s.qcow2"]], "ret == 512"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1K.raw"]], "ret == 1024"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1K.raw"]], "ret == 1024"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1K.qcow2"]], "ret == 1024"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1K.qcow2"]], "ret == 1024"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1M.raw"]], "ret == 1024*1024"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1M.raw"]], "ret == 1024*1024"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-1M.qcow2"]], "ret == 1024*1024"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-1M.qcow2"]], "ret == 1024*1024"), []; > InitEmpty, Always, TestResult ( > - [["disk_virtual_size"; "../data/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), []; > + [["disk_virtual_size"; "$datadir/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), []; > ]; > shortdesc = "return virtual size of a disk"; > longdesc = "\ > @@ -2824,19 +2824,19 @@ circumstances. See L<guestfs(3)/CVE-2010-3851>." }; > style = RBool "backingfile", [String "filename"], []; > tests = [ > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1s.raw"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1s.raw"]]), []; > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1s.qcow2"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1s.qcow2"]]), []; > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1K.raw"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1K.raw"]]), []; > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1K.qcow2"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1K.qcow2"]]), []; > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1M.raw"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1M.raw"]]), []; > InitEmpty, Always, TestResultFalse ( > - [["disk_has_backing_file"; "../data/blank-disk-1M.qcow2"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-1M.qcow2"]]), []; > InitEmpty, Always, TestResultTrue ( > - [["disk_has_backing_file"; "../data/blank-disk-with-backing.qcow2"]]), []; > + [["disk_has_backing_file"; "$datadir/blank-disk-with-backing.qcow2"]]), []; > ]; > shortdesc = "return whether disk has a backing file"; > longdesc = "\ > @@ -4303,67 +4303,67 @@ C<guestfs_is_file>, C<guestfs_is_blockdev> (etc), C<guestfs_is_zero>." }; > tests = [ > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command"]; > - ["upload"; "test-command"; "/command/test-command"]; > + ["upload"; "$builddir/test-command"; "/command/test-command"]; > ["chmod"; "0o755"; "/command/test-command"]; > ["command"; "/command/test-command 1"]], "Result1"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command2"]; > - ["upload"; "test-command"; "/command2/test-command"]; > + ["upload"; "$builddir/test-command"; "/command2/test-command"]; > ["chmod"; "0o755"; "/command2/test-command"]; > ["command"; "/command2/test-command 2"]], "Result2\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command3"]; > - ["upload"; "test-command"; "/command3/test-command"]; > + ["upload"; "$builddir/test-command"; "/command3/test-command"]; > ["chmod"; "0o755"; "/command3/test-command"]; > ["command"; "/command3/test-command 3"]], "\nResult3"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command4"]; > - ["upload"; "test-command"; "/command4/test-command"]; > + ["upload"; "$builddir/test-command"; "/command4/test-command"]; > ["chmod"; "0o755"; "/command4/test-command"]; > ["command"; "/command4/test-command 4"]], "\nResult4\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command5"]; > - ["upload"; "test-command"; "/command5/test-command"]; > + ["upload"; "$builddir/test-command"; "/command5/test-command"]; > ["chmod"; "0o755"; "/command5/test-command"]; > ["command"; "/command5/test-command 5"]], "\nResult5\n\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command6"]; > - ["upload"; "test-command"; "/command6/test-command"]; > + ["upload"; "$builddir/test-command"; "/command6/test-command"]; > ["chmod"; "0o755"; "/command6/test-command"]; > ["command"; "/command6/test-command 6"]], "\n\nResult6\n\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command7"]; > - ["upload"; "test-command"; "/command7/test-command"]; > + ["upload"; "$builddir/test-command"; "/command7/test-command"]; > ["chmod"; "0o755"; "/command7/test-command"]; > ["command"; "/command7/test-command 7"]], ""), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command8"]; > - ["upload"; "test-command"; "/command8/test-command"]; > + ["upload"; "$builddir/test-command"; "/command8/test-command"]; > ["chmod"; "0o755"; "/command8/test-command"]; > ["command"; "/command8/test-command 8"]], "\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command9"]; > - ["upload"; "test-command"; "/command9/test-command"]; > + ["upload"; "$builddir/test-command"; "/command9/test-command"]; > ["chmod"; "0o755"; "/command9/test-command"]; > ["command"; "/command9/test-command 9"]], "\n\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command10"]; > - ["upload"; "test-command"; "/command10/test-command"]; > + ["upload"; "$builddir/test-command"; "/command10/test-command"]; > ["chmod"; "0o755"; "/command10/test-command"]; > ["command"; "/command10/test-command 10"]], "Result10-1\nResult10-2\n"), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/command11"]; > - ["upload"; "test-command"; "/command11/test-command"]; > + ["upload"; "$builddir/test-command"; "/command11/test-command"]; > ["chmod"; "0o755"; "/command11/test-command"]; > ["command"; "/command11/test-command 11"]], "Result11-1\nResult11-2"), []; > InitScratchFS, IfNotCrossAppliance, TestLastFail ( > [["mkdir"; "/command12"]; > - ["upload"; "test-command"; "/command12/test-command"]; > + ["upload"; "$builddir/test-command"; "/command12/test-command"]; > ["chmod"; "0o755"; "/command12/test-command"]; > ["command"; "/command12/test-command"]]), []; > InitScratchFS, IfNotCrossAppliance, TestResultString ( > [["mkdir"; "/pwd"]; > - ["upload"; "test-pwd"; "/pwd/test-pwd"]; > + ["upload"; "$builddir/test-pwd"; "/pwd/test-pwd"]; > ["chmod"; "0o755"; "/pwd/test-pwd"]; > ["command"; "/pwd/test-pwd"]], "/"), []; > ]; > @@ -4407,67 +4407,67 @@ locations." }; > tests = [ > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines"]; > - ["upload"; "test-command"; "/command_lines/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines/test-command"]; > ["chmod"; "0o755"; "/command_lines/test-command"]; > ["command_lines"; "/command_lines/test-command 1"]], > "is_string_list (ret, 1, \"Result1\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines2"]; > - ["upload"; "test-command"; "/command_lines2/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines2/test-command"]; > ["chmod"; "0o755"; "/command_lines2/test-command"]; > ["command_lines"; "/command_lines2/test-command 2"]], > "is_string_list (ret, 1, \"Result2\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines3"]; > - ["upload"; "test-command"; "/command_lines3/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines3/test-command"]; > ["chmod"; "0o755"; "/command_lines3/test-command"]; > ["command_lines"; "/command_lines3/test-command 3"]], > "is_string_list (ret, 2, \"\", \"Result3\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines4"]; > - ["upload"; "test-command"; "/command_lines4/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines4/test-command"]; > ["chmod"; "0o755"; "/command_lines4/test-command"]; > ["command_lines"; "/command_lines4/test-command 4"]], > "is_string_list (ret, 2, \"\", \"Result4\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines5"]; > - ["upload"; "test-command"; "/command_lines5/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines5/test-command"]; > ["chmod"; "0o755"; "/command_lines5/test-command"]; > ["command_lines"; "/command_lines5/test-command 5"]], > "is_string_list (ret, 3, \"\", \"Result5\", \"\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines6"]; > - ["upload"; "test-command"; "/command_lines6/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines6/test-command"]; > ["chmod"; "0o755"; "/command_lines6/test-command"]; > ["command_lines"; "/command_lines6/test-command 6"]], > "is_string_list (ret, 4, \"\", \"\", \"Result6\", \"\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines7"]; > - ["upload"; "test-command"; "/command_lines7/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines7/test-command"]; > ["chmod"; "0o755"; "/command_lines7/test-command"]; > ["command_lines"; "/command_lines7/test-command 7"]], > "is_string_list (ret, 0)"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines8"]; > - ["upload"; "test-command"; "/command_lines8/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines8/test-command"]; > ["chmod"; "0o755"; "/command_lines8/test-command"]; > ["command_lines"; "/command_lines8/test-command 8"]], > "is_string_list (ret, 1, \"\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines9"]; > - ["upload"; "test-command"; "/command_lines9/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines9/test-command"]; > ["chmod"; "0o755"; "/command_lines9/test-command"]; > ["command_lines"; "/command_lines9/test-command 9"]], > "is_string_list (ret, 2, \"\", \"\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines10"]; > - ["upload"; "test-command"; "/command_lines10/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines10/test-command"]; > ["chmod"; "0o755"; "/command_lines10/test-command"]; > ["command_lines"; "/command_lines10/test-command 10"]], > "is_string_list (ret, 2, \"Result10-1\", \"Result10-2\")"), []; > InitScratchFS, IfNotCrossAppliance, TestResult ( > [["mkdir"; "/command_lines11"]; > - ["upload"; "test-command"; "/command_lines11/test-command"]; > + ["upload"; "$builddir/test-command"; "/command_lines11/test-command"]; > ["chmod"; "0o755"; "/command_lines11/test-command"]; > ["command_lines"; "/command_lines11/test-command 11"]], > "is_string_list (ret, 2, \"Result11-1\", \"Result11-2\")"), [] > @@ -4680,11 +4680,13 @@ This uses the L<blockdev(8)> command." }; > progress = true; cancellable = true; > tests = [ > InitScratchFS, Always, TestResultString ( > - (* Pick a file from cwd which isn't likely to change. *) > [["mkdir"; "/upload"]; > - ["upload"; "$srcdir/../../COPYING.LIB"; "/upload/COPYING.LIB"]; > - ["checksum"; "md5"; "/upload/COPYING.LIB"]], > - Digest.to_hex (Digest.file "COPYING.LIB")), [] > + (* Pick a file from the top-level directory which is included > + * in the external test suite. > + *) > + ["upload"; "$top_srcdir/COPYING"; "/upload/COPYING"]; > + ["checksum"; "md5"; "/upload/COPYING"]], > + Digest.to_hex (Digest.file "COPYING")), [] > ]; > shortdesc = "upload a file from the local machine"; > longdesc = "\ > @@ -4702,13 +4704,15 @@ See also C<guestfs_download>." }; > progress = true; cancellable = true; > tests = [ > InitScratchFS, Always, TestResultString ( > - (* Pick a file from cwd which isn't likely to change. *) > [["mkdir"; "/download"]; > - ["upload"; "$srcdir/../../COPYING.LIB"; "/download/COPYING.LIB"]; > - ["download"; "/download/COPYING.LIB"; "testdownload.tmp"]; > + (* Pick a file from the top-level directory which is included > + * in the external test suite. > + *) > + ["upload"; "$top_srcdir/COPYING"; "/download/COPYING"]; > + ["download"; "/download/COPYING"; "testdownload.tmp"]; > ["upload"; "testdownload.tmp"; "/download/upload"]; > ["checksum"; "md5"; "/download/upload"]], > - Digest.to_hex (Digest.file "COPYING.LIB")), [] > + Digest.to_hex (Digest.file "COPYING")), [] > ]; > shortdesc = "download a file to the local machine"; > longdesc = "\ > @@ -4800,15 +4804,15 @@ To get the checksums for many files, use C<guestfs_checksums_out>." }; > tests = [ > InitScratchFS, Always, TestResultString ( > [["mkdir"; "/tar_in"]; > - ["tar_in"; "$srcdir/../data/helloworld.tar"; "/tar_in"; "NOARG"; ""; ""; ""]; > + ["tar_in"; "$datadir/helloworld.tar"; "/tar_in"; "NOARG"; ""; ""; ""]; > ["cat"; "/tar_in/hello"]], "hello\n"), []; > InitScratchFS, Always, TestResultString ( > [["mkdir"; "/tar_in_gz"]; > - ["tar_in"; "$srcdir/../data/helloworld.tar.gz"; "/tar_in_gz"; "gzip"; ""; ""; ""]; > + ["tar_in"; "$datadir/helloworld.tar.gz"; "/tar_in_gz"; "gzip"; ""; ""; ""]; > ["cat"; "/tar_in_gz/hello"]], "hello\n"), []; > InitScratchFS, IfAvailable "xz", TestResultString ( > [["mkdir"; "/tar_in_xz"]; > - ["tar_in"; "$srcdir/../data/helloworld.tar.xz"; "/tar_in_xz"; "xz"; ""; ""; ""]; > + ["tar_in"; "$datadir/helloworld.tar.xz"; "/tar_in_xz"; "xz"; ""; ""; ""]; > ["cat"; "/tar_in_xz/hello"]], "hello\n"), [] > ]; > shortdesc = "unpack tarfile to directory"; > @@ -4895,7 +4899,7 @@ If set to true, POSIX ACLs are saved in the output tar. > tests = [ > InitScratchFS, Always, TestResultString ( > [["mkdir"; "/tgz_in"]; > - ["tgz_in"; "$srcdir/../data/helloworld.tar.gz"; "/tgz_in"]; > + ["tgz_in"; "$datadir/helloworld.tar.gz"; "/tgz_in"]; > ["cat"; "/tgz_in/hello"]], "hello\n"), [] > ]; > shortdesc = "unpack compressed tarball to directory"; > @@ -8247,7 +8251,7 @@ or growing unnecessarily." }; > tests = [ > InitScratchFS, Always, TestResultString ( > [["mkdir"; "/txz_in"]; > - ["txz_in"; "$srcdir/../data/helloworld.tar.xz"; "/txz_in"]; > + ["txz_in"; "$datadir/helloworld.tar.xz"; "/txz_in"]; > ["cat"; "/txz_in/hello"]], "hello\n"), [] > ]; > shortdesc = "unpack compressed tarball to directory"; > @@ -8359,7 +8363,7 @@ types (see C<guestfs_part_get_parttype>)." }; > tests = [ > InitISOFS, Always, TestResult ( > [["checksum_device"; "md5"; "/dev/sdd"]], > - "check_file_md5 (ret, \"../data/test.iso\") == 0"), [] > + "check_file_md5 (ret, \"$datadir/test.iso\") == 0"), [] > ]; > shortdesc = "compute MD5, SHAx or CRC checksum of the contents of a device"; > longdesc = "\ > @@ -8433,7 +8437,7 @@ to find out what it is for." }; > cancellable = true; > tests = [ > InitScratchFS, Always, TestResultString ( > - [["base64_in"; "../data/hello.b64"; "/base64_in"]; > + [["base64_in"; "$datadir/hello.b64"; "/base64_in"]; > ["cat"; "/base64_in"]], "hello\n"), [] > ]; > shortdesc = "upload base64-encoded data to file"; > @@ -8993,9 +8997,9 @@ See also C<guestfs_part_to_partnum>, C<guestfs_device_index>." }; > proc_nr = Some 273; > progress = true; cancellable = true; > tests > - (let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in [ > + (let md5 = Digest.to_hex (Digest.file "COPYING") in [ > InitScratchFS, Always, TestResultString ( > - [["upload_offset"; "$srcdir/../../COPYING.LIB"; "/upload_offset"; "0"]; > + [["upload_offset"; "$top_srcdir/COPYING"; "/upload_offset"; "0"]; > ["checksum"; "md5"; "/upload_offset"]], md5), [] > ]); > shortdesc = "upload a file from the local machine with offset"; > @@ -9023,17 +9027,19 @@ See also C<guestfs_upload>, C<guestfs_pwrite>." }; > proc_nr = Some 274; > progress = true; cancellable = true; > tests > - (let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in > + (let md5 = Digest.to_hex (Digest.file "COPYING") in > let offset = string_of_int 100 in > - let size = string_of_int ((Unix.stat "COPYING.LIB").Unix.st_size - 100) in > + let size = string_of_int ((Unix.stat "COPYING").Unix.st_size - 100) in > [ > InitScratchFS, Always, TestResultString ( > - (* Pick a file from cwd which isn't likely to change. *) > [["mkdir"; "/download_offset"]; > - ["upload"; "$srcdir/../../COPYING.LIB"; "/download_offset/COPYING.LIB"]; > - ["download_offset"; "/download_offset/COPYING.LIB"; "testdownload.tmp"; offset; size]; > - ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING.LIB"; offset]; > - ["checksum"; "md5"; "/download_offset/COPYING.LIB"]], md5), [] > + (* Pick a file from the top-level directory which is included > + * in the external test suite. > + *) > + ["upload"; "$top_srcdir/COPYING"; "/download_offset/COPYING"]; > + ["download_offset"; "/download_offset/COPYING"; "testdownload.tmp"; offset; size]; > + ["upload_offset"; "testdownload.tmp"; "/download_offset/COPYING"; offset]; > + ["checksum"; "md5"; "/download_offset/COPYING"]], md5), [] > ]); > shortdesc = "download a file to the local machine with offset and size"; > longdesc = "\ > @@ -10881,7 +10887,7 @@ C<guestfs_xfs_growfs> calls." }; > optional = Some "hivex"; > tests = [ > InitScratchFS, Always, TestRun ( > - [["upload"; "$srcdir/../data/minimal"; "/hivex_open"]; > + [["upload"; "$datadir/minimal"; "/hivex_open"]; > ["hivex_open"; "/hivex_open"; ""; ""; "false"]; > ["hivex_root"]; (* in this hive, it returns 0x1020 *) > ["hivex_node_name"; "0x1020"]; > @@ -11029,11 +11035,11 @@ See also: C<guestfs_hivex_value_utf8>." }; > optional = Some "hivex"; > tests = [ > InitScratchFS, Always, TestRun ( > - [["upload"; "$srcdir/../data/minimal"; "/hivex_commit1"]; > + [["upload"; "$datadir/minimal"; "/hivex_commit1"]; > ["hivex_open"; "/hivex_commit1"; ""; ""; "true"]; > ["hivex_commit"; "NULL"]]), [["hivex_close"]]; > InitScratchFS, Always, TestResultTrue ( > - [["upload"; "$srcdir/../data/minimal"; "/hivex_commit2"]; > + [["upload"; "$datadir/minimal"; "/hivex_commit2"]; > ["hivex_open"; "/hivex_commit2"; ""; ""; "true"]; > ["hivex_commit"; "/hivex_commit2_copy"]; > ["is_file"; "/hivex_commit2_copy"; "false"]]), [["hivex_close"]] > diff --git a/generator/tests.ml b/generator/tests.ml > index 4be899b..d361ef8 100644 > --- a/generator/tests.ml > +++ b/generator/tests.ml > @@ -32,6 +32,34 @@ let defaults = { > > (* The tests in each subdirectory. *) > let tests = [ > + > + "tests/c-api", { > + defaults with > + check_fast = [ > + "test-just-header"; > + "test-just-header-cxx"; > + "test-add-drive-opts"; > + "test-backend-settings"; > + "test-create-handle"; > + "test-config"; > + "test-event-string"; > + "test-environment"; > + "test-private-data"; > + "test-dlopen"; > + ]; > + check = [ > + "tests"; > + "test-last-errno"; > + "test-user-cancel"; > + "test-debug-to-file"; > + "test-add-libvirt-dom"; > + ]; > + check_programs = [ > + "test-command"; > + "test-pwd"; > + ]; > + }; > + > "inspector", { > defaults with > check = [ > diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml > index 1522eff..5062ce1 100644 > --- a/generator/tests_c_api.ml > +++ b/generator/tests_c_api.ml > @@ -403,17 +403,16 @@ and generate_test_command_call ?(expect_error = false) ?test ?ret test_name cmd> | String _, arg, sym > | OptString _, arg, sym > | Key _, arg, sym > - | GUID _, arg, sym -> > - pr " const char *%s = \"%s\";\n" sym (c_quote arg); > + | GUID _, arg, sym > + | FileIn _, arg, sym -> > + pr " CLEANUP_FREE char *%s = substitute_environment (\"%s\");\n" > + sym (c_quote arg) > | BufferIn _, arg, sym -> > pr " const char *%s = \"%s\";\n" sym (c_quote arg); > pr " size_t %s_size = %d;\n" sym (String.length arg) > | Int _, _, _ > | Int64 _, _, _ > | Bool _, _, _ -> () > - | FileIn _, arg, sym -> > - pr " CLEANUP_FREE char *%s = substitute_srcdir (\"%s\");\n" > - sym (c_quote arg) > | FileOut _, _, _ -> () > | StringList _, "", sym > | DeviceList _, "", sym -> > diff --git a/inspector/tests.mk b/inspector/tests.mk > index 67fc0bc..714486c 100644 > --- a/inspector/tests.mk > +++ b/inspector/tests.mk > @@ -3,7 +3,7 @@ > # generator/ *.ml > # ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. > # > -# Copyright (C) 2009-2014 Red Hat Inc. > +# Copyright (C) 2009-2015 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 byI guess this file should not appear.> diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am > index 7bfffe5..5322c5e 100644 > --- a/tests/c-api/Makefile.am > +++ b/tests/c-api/Makefile.am > @@ -17,68 +17,16 @@ > > include $(top_srcdir)/subdir-rules.mk > > -generator_built = tests.c > +generator_built = tests.c tests.mk > > -BUILT_SOURCES = $(generator_built) > +BUILT_SOURCES = tests.c > > -EXTRA_DIST = $(BUILT_SOURCES) > +EXTRA_DIST = \ > + tests.c \ > + test-command.c \ > + test-pwd.c > > -check_PROGRAMS = \ > - tests \ > - test-command \ > - test-just-header \ > - test-create-handle \ > - test-config \ > - test-add-drive-opts \ > - test-last-errno \ > - test-backend-settings \ > - test-private-data \ > - test-user-cancel \ > - test-debug-to-file \ > - test-environment \ > - test-pwd \ > - test-event-string > -if HAVE_LIBDL > -check_PROGRAMS += \ > - test-dlopen > -endif > - > -TESTS = \ > - tests \ > - test-just-header \ > - test-create-handle \ > - test-config \ > - test-add-drive-opts \ > - test-last-errno \ > - test-backend-settings \ > - test-private-data \ > - test-user-cancel \ > - test-debug-to-file \ > - test-environment \ > - test-event-string > -if HAVE_LIBDL > -TESTS += \ > - test-dlopen > -endif > - > -if HAVE_CXX > -check_PROGRAMS += test-just-header-cxx > -TESTS += test-just-header-cxx > -endif > - > -if HAVE_LIBVIRT > -check_PROGRAMS += test-add-libvirt-dom > -TESTS += test-add-libvirt-dom > -endif > -EXTRA_DIST += test-add-libvirt-dom.c > - > -TESTS_ENVIRONMENT = \ > - SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ > - SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \ > - SKIP_TEST_COMMAND=$(shell ldd test-pwd | grep -sq 'not a dynamic executable' || echo 1) \Where have these checks moved to?> - $(top_builddir)/run --test $(VG) > - > -#SKIP_TEST_CHECKSUM_8=$(shell if test `find ../initramfs -name squashfs.ko | wc -l` -eq 0; then echo 1; fi) > +include $(srcdir)/tests.mk > > tests_SOURCES = \ > tests.c \ > @@ -127,6 +75,10 @@ test_just_header_cxx_CXXFLAGS = \ > $(WARN_CFLAGS) $(WERROR_CFLAGS) > test_just_header_cxx_LDADD = \ > $(top_builddir)/src/libguestfs.la > +else > +test-just-header-cxx: > + echo 'exit 77' > $@ > + chmod 0755 $@ > endif > > test_create_handle_SOURCES = test-create-handle.c > @@ -142,10 +94,13 @@ test_dlopen_SOURCES = test-dlopen.c > test_dlopen_CPPFLAGS = \ > -I$(top_srcdir)/src -I$(top_builddir)/src > test_dlopen_CFLAGS = \ > - $(WARN_CFLAGS) $(WERROR_CFLAGS) \ > - -DLIBRARY=\"$(top_builddir)/src/.libs/libguestfs.so.0\" > + $(WARN_CFLAGS) $(WERROR_CFLAGS) > test_dlopen_LDADD = \ > -ldl > +else > +test-dlopen: > + echo 'exit 77' > $@ > + chmod 0755 $@ > endif > > test_config_SOURCES = test-config.c > @@ -251,7 +206,8 @@ test_add_libvirt_dom_LDADD = \ > $(top_builddir)/src/libguestfs.la $(LIBVIRT_LIBS) \ > $(LTLIBINTL) \ > $(LTLIBTHREAD) $(top_builddir)/gnulib/lib/libgnu.la > +else > +test-add-libvirt-dom: > + echo 'exit 77' > $@ > + chmod 0755 $@ > endif > - > -check-valgrind: > - $(MAKE) VG="$(top_builddir)/run @VG@" check > diff --git a/tests/c-api/test-dlopen.c b/tests/c-api/test-dlopen.c > index 3efd847..c9190b0 100644 > --- a/tests/c-api/test-dlopen.c > +++ b/tests/c-api/test-dlopen.c > @@ -25,6 +25,11 @@ > #include <unistd.h> > #include <dlfcn.h> > > +/* This is found on LD_LIBRARY_PATH set by the ./run script, or > + * from the usual libdir. > + */ > +#define LIBRARY "libguestfs.so.0" > + > /* We don't need the <guestfs.h> header file here. */ > typedef struct guestfs_h guestfs_h; > > @@ -32,10 +37,6 @@ typedef guestfs_h *(*guestfs_create_t) (void); > typedef const char * (*guestfs_get_program_t) (guestfs_h *); > typedef void (*guestfs_close_t) (guestfs_h *); > > -#ifndef LIBRARY > -#error "-DLIBRARY was not defined" > -#endif > - > static void * > read_symbol (void *lib, const char *symbol) > { > @@ -60,12 +61,6 @@ main (int argc, char *argv[]) > guestfs_close_t guestfs_close; > guestfs_h *g; > > - if (access (LIBRARY, X_OK) == -1) { > - fprintf (stderr, "test skipped because %s cannot be accessed: %m\n", > - LIBRARY); > - exit (77); > - } > - > lib = dlopen (LIBRARY, RTLD_LAZY); > if (lib == NULL) { > fprintf (stderr, "could not open %s: %s\n", LIBRARY, dlerror ()); > diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c > index 71a361a..5852125 100644 > --- a/tests/c-api/tests-main.c > +++ b/tests/c-api/tests-main.c > @@ -360,35 +360,45 @@ match_re (const char *str, const char *pattern) > return r != PCRE_ERROR_NOMATCH; > } > > -/* Used for FileIn parameters in tests. If the path starts with > - * "$srcdir" then replace that with the contents of the $srcdir > - * environment variable (this is set by automake and run time). The > - * caller must free the returned string. > +/* Used for some parameters in tests. If the string starts with > + * "$variable" then replace that with the contents of the named > + * environment variable. The caller must free the returned string. > */ > char * > -substitute_srcdir (const char *path) > +substitute_environment (const char *str) > { > char *ret; > + size_t len; > + CLEANUP_FREE char *name = NULL; > + const char *value; > > - if (STRPREFIX (path, "$srcdir")) { > - const char *srcdir; > + if (STRPREFIX (str, "$")) { > + len = strspn (str+1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"); > + if (len == 0) { > + fprintf (stderr, "tests: invalid environment variable in string (%s)\n", > + str); > + exit (EXIT_FAILURE); > + } > + name = strndup (str+1, len); > + if (name == NULL) { > + perror ("strndup"); > + exit (EXIT_FAILURE); > + } > > - srcdir = getenv ("srcdir"); > - if (!srcdir) { > - fprintf (stderr, "tests: environment variable $srcdir is not defined.\n" > - "Normally it is defined by automake. If you are running the\n" > - "tests directly, set $srcdir to point to the source tests/c-api\n" > - "directory.\n"); > + value = getenv (name); > + if (!value) { > + fprintf (stderr, "tests: environment variable $%s is not defined.\n", > + name); > exit (EXIT_FAILURE); > } > > - if (asprintf (&ret, "%s%s", srcdir, path + 7) == -1) { > + if (asprintf (&ret, "%s%s", value, str + 1 + len) == -1) { > perror ("asprintf"); > exit (EXIT_FAILURE); > } > } > else { > - ret = strdup (path); > + ret = strdup (str); > if (!ret) { > perror ("strdup"); > exit (EXIT_FAILURE); > @@ -433,6 +443,8 @@ static guestfs_h * > create_handle (void) > { > guestfs_h *g; > + const char *datadir; > + CLEANUP_FREE char *test_iso = NULL; > > g = guestfs_create (); > if (g == NULL) { > @@ -455,8 +467,18 @@ create_handle (void) > exit (EXIT_FAILURE); > } > > - if (guestfs_add_drive_ro (g, "../data/test.iso") == -1) { > - printf ("FAIL: guestfs_add_drive_ro ../data/test.iso\n"); > + datadir = getenv ("datadir"); > + if (datadir == NULL) { > + fprintf (stderr, "environment variable $datadir is not defined\n"); > + exit (EXIT_FAILURE); > + } > + if (asprintf (&test_iso, "%s/test.iso", datadir) == -1) { > + perror ("asprintf"); > + exit (EXIT_FAILURE); > + } > + > + if (guestfs_add_drive_ro (g, test_iso) == -1) { > + printf ("FAIL: guestfs_add_drive_ro $datadir/test.iso\n"); > exit (EXIT_FAILURE); > } > > diff --git a/tests/c-api/tests.h b/tests/c-api/tests.h > index 2631a5d..3e14b07 100644 > --- a/tests/c-api/tests.h > +++ b/tests/c-api/tests.h > @@ -44,7 +44,7 @@ extern const char *get_key (char **hash, const char *key); > extern int check_hash (char **ret, const char *key, const char *expected); > extern int match_re (const char *str, const char *pattern); > extern int using_cross_appliance (void); > -extern char *substitute_srcdir (const char *path); > +extern char *substitute_environment (const char *str); > extern void skipped (const char *test_name, const char *fs, ...) __attribute__((format (printf,2,3))); > > #endif /* TESTS_H_ */ > diff --git a/tests/c-api/tests.mk b/tests/c-api/tests.mk > new file mode 100644 > index 0000000..999221a > --- /dev/null > +++ b/tests/c-api/tests.mk > @@ -0,0 +1,79 @@ > +# libguestfs generated file > +# WARNING: THIS FILE IS GENERATED FROM: > +# generator/ *.mlThis file should not appear either.> +# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. > +# > +# Copyright (C) 2009-2015 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. > + > +localtestsdir = $(alltestsdir)/tests/c-api > + > +localtests_PROGRAMS = \ > + test-add-drive-opts \ > + test-add-libvirt-dom \ > + test-backend-settings \ > + test-command \ > + test-config \ > + test-create-handle \ > + test-debug-to-file \ > + test-dlopen \ > + test-environment \ > + test-event-string \ > + test-just-header \ > + test-just-header-cxx \ > + test-last-errno \ > + test-private-data \ > + test-pwd \ > + test-user-cancel \ > + tests > + > +# Note that we cannot create a simple 'check:' target since > +# automake will (silently) overrule it, so we do this instead: > + > +TESTS_ENVIRONMENT = $(top_builddir)/run > +TESTS = $(top_builddir)/test-harness > + > +check-valgrind: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind > + > +check-direct: > + $(top_builddir)/run $(top_builddir)/test-harness --direct > + > +check-valgrind-direct: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --direct > + > +check-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --libvirt > + > +check-valgrind-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --libvirt > + > +check-uml: > + $(top_builddir)/run $(top_builddir)/test-harness --uml > + > +check-valgrind-uml: > + $(top_builddir)/run $(top_builddir)/test-harness --valgrind --uml > + > +check-with-upstream-qemu: > + $(top_builddir)/run $(top_builddir)/test-harness --upstream-qemu > + > +check-with-upstream-libvirt: > + $(top_builddir)/run $(top_builddir)/test-harness --upstream-libvirt > + > +check-fast: > + $(top_builddir)/run $(top_builddir)/test-harness --fast > + > +EXTRA_DIST += tests.mk >Thanks, -- Pino Toscano
Pino Toscano
2015-Aug-07 15:58 UTC
Re: [Libguestfs] [PATCH v4 05/17] tests/regressions: Remove executable stack test.
On Thursday 06 August 2015 16:05:47 Richard W.M. Jones wrote:> It's not our job to worry about downstream packaging issues ...This can go already, even with the current test framework.> --- > generator/tests.ml | 1 - > tests/regressions/Makefile.am | 3 +- > tests/regressions/test-noexec-stack.pl | 78 ---------------------------------- > tests/regressions/tests.mk | 3 +- > 4 files changed, 2 insertions(+), 83 deletions(-) > delete mode 100755 tests/regressions/test-noexec-stack.pl > > diff --git a/generator/tests.ml b/generator/tests.ml > index 54343ea..6963ab4 100644 > --- a/generator/tests.ml > +++ b/generator/tests.ml > @@ -370,7 +370,6 @@ let tests = [ > "rhbz1054761.sh"; > "rhbz1091803.sh"; > "rhbz1232192.sh"; > - "test-noexec-stack.pl"; > ]; > check_slow = [ > "rhbz909624.sh" > diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am > index c33cd2c..f3f55f0 100644 > --- a/tests/regressions/Makefile.am > +++ b/tests/regressions/Makefile.am > @@ -46,8 +46,7 @@ EXTRA_DIST = \ > rhbz1091803.sh \ > rhbz1175196.sh \ > rhbz1232192.sh \ > - rhbz1232192.xml \ > - test-noexec-stack.pl > + rhbz1232192.xml > > # There are a couple of tests that we don't run: > EXTRA_DIST += \ > diff --git a/tests/regressions/test-noexec-stack.pl b/tests/regressions/test-noexec-stack.pl > deleted file mode 100755 > index e54b1df..0000000 > --- a/tests/regressions/test-noexec-stack.pl > +++ /dev/null > @@ -1,78 +0,0 @@ > -#!/usr/bin/perl > -# Copyright (C) 2009-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. > - > -use strict; > -use warnings; > - > -my @files = ( "$ENV{top_builddir}/src/.libs/libguestfs.so", > - "$ENV{top_builddir}/daemon/guestfsd" ); > - > -FILES: foreach my $file (@files) { > - my $output; > - my @cmd = ('readelf', '-l', $file); > - open ($output, '-|', @cmd) > - or die ("$0: failed to run: '".join(' ', @cmd)."': $!\n"); > - > - my $offset; > - my $line = 1; > - > - # Find the offset of the Flags field > - while (<$output>) { > - next unless /^\s*Type\b/; > - > - my @lines; > - push (@lines, $_); > - > - # Look for a Flg field on this line (32 bit) > - $offset = index ($_, 'Flg '); > - > - if (-1 == $offset) { > - # 64 bit is split over 2 lines. Look for a Flags field on the next > - # line > - $_ = <$output>; > - $offset = index ($_, 'Flags '); > - $line = 2; > - push (@lines, $_); > - } > - > - die "Unrecognised header: ".join("\n", @lines) if -1 == $offset; > - last; > - } > - > - # Find the GNU_STACK entry > - while (<$output>) { > - next unless /^\s*GNU_STACK\b/; > - > - # Skip over input lines according to the header > - for (my $i = 1; $i < $line; $i++) { > - $_ = <$output>; > - } > - > - my $flags = substr ($_, $offset, 3); > - > - $flags =~ /^[ R][ W]([ E])$/ or die "Unrecognised flags: $flags"; > - > - if ('E' eq $1) { > - print "***** $file has an executable stack *****\n"; > - exit 1; > - } > - > - next FILES; > - } > - > - die "Didn't find GNU_STACK entry"; > -} > diff --git a/tests/regressions/tests.mk b/tests/regressions/tests.mk > index d582b91..4d9217b 100644 > --- a/tests/regressions/tests.mk > +++ b/tests/regressions/tests.mk > @@ -46,8 +46,7 @@ localtests_SCRIPTS = \ > rhbz895904.sh \ > rhbz909624.sh \ > rhbz957772.sh \ > - rhbz975797.sh \ > - test-noexec-stack.pl > + rhbz975797.sh > > localtests_PROGRAMS = \ > rhbz1055452 \ >Thanks, -- Pino Toscano
Apparently Analagous Threads
- [PATCH v2 00/14] tests: Introduce test harness for running tests.
- [PATCH v3 01/16] tests: Introduce test harness for running tests.
- [PATCH 00/10] tests: Introduce test harness for running tests.
- [PATCH v5 0/7] tests: Introduce test harness for running tests.
- [PATCH v6 00/10] tests: Introduce test harness for running tests.