Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 0/7] tests: Introduce test harness for running tests.
Since v4: - More tests have been converted. - Testing local guests fixed. - Drop no-exec-stack test.
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 1/7] 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 --help' 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 to refer to test data. This is only implemented for a single directory at the moment (ie. inspector/) --- .gitignore | 5 +- Makefile.am | 4 + common-rules.mk | 3 + configure.ac | 2 + generator/Makefile.am | 24 + generator/main.ml | 9 + generator/test_harness.ml | 709 +++++++++++++++++++++++ generator/tests.ml | 69 +++ generator/tests_mk.ml | 124 ++++ generator/types.ml | 15 + inspector/Makefile.am | 17 +- inspector/test-virt-inspector-local-guests.sh.in | 26 + inspector/test-virt-inspector.sh | 13 +- inspector/test-xmllint.sh.in | 5 + inspector/tests.mk | 86 +++ pick-guests.pl.in | 4 +- tests/data/Makefile.am | 49 +- tests/guests/Makefile.am | 84 +-- 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 +- 22 files changed, 1157 insertions(+), 128 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 diff --git a/.gitignore b/.gitignore index 269d735..e4b8881 100644 --- a/.gitignore +++ b/.gitignore @@ -263,8 +263,8 @@ Makefile.in /html/virt-tar-out.1.html /html/virt-v2v.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 @@ -475,6 +475,7 @@ Makefile.in /sysprep/virt-sysprep.1 /test.err /test.out +/test-harness /tests/c-api/test-add-drive-opts /tests/c-api/test-add-libvirt-dom /tests/c-api/test-backend-settings @@ -524,7 +525,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/windows.img /tests/mount-local/test-parallel-mount-local diff --git a/Makefile.am b/Makefile.am index d55d8d6..510a97e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -201,6 +201,7 @@ EXTRA_DIST = \ logo/fish-5yrs.svg logo/fish-5yrs.png \ logo/virt-builder.svg \ m4/.gitignore \ + test-harness \ tests/run-xml-to-junit.sh \ tests/run-xml-to-junit.xsl \ tmp/.gitignore \ @@ -517,6 +518,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 0d99aa0..c717981 100644 --- a/configure.ac +++ b/configure.ac @@ -1618,6 +1618,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 3716c77..3bcff61 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -52,6 +52,9 @@ sources = \ ruby.ml \ structs.ml \ structs.mli \ + tests.ml \ + tests_mk.ml \ + test_harness.ml \ tests_c_api.ml \ types.ml \ utils.ml \ @@ -71,6 +74,8 @@ objects = \ pr.cmo \ docstrings.cmo \ checks.cmo \ + tests.cmo \ + tests_mk.cmo \ c.cmo \ xdr.cmo \ daemon.cmo \ @@ -93,17 +98,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 = -warn-error CDEFLMPSUVYZX-3 -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 $@ @@ -136,6 +154,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 c0ad146..3ae2ff7 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -30,6 +30,8 @@ open Types open C open Xdr open Daemon +open Tests +open Tests_mk open Tests_c_api open Fish open Ocaml @@ -48,6 +50,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) @@ -214,6 +218,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..6aa5e6a --- /dev/null +++ b/generator/test_harness.ml @@ -0,0 +1,709 @@ +(* 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 + +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 + try (stat path).st_perm land 0o111 <> 0 + with Unix_error _ -> false + +let relative_path_to_absolute path + let cmd = sprintf "unset CDPATH; cd %s && pwd" (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 (sprintf "failed to convert relative path to absolute path: %s" + cmd) + ); + 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 debug = ref false in + let direct = ref false in + let fast = 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 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"; + "--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"; + "--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 + sprintf "\ +test-harness: Run the libguestfs test suite, or parts of it. + +Usage: + + test-harness [--options] [directory] + +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. + +Options to select which tests to run: + + --fast Run only tests which do not need the appliance + --slow Run only long-running tests +(if neither --fast nor --slow, then --fast + normal tests are run) + --local-guests Run tests that use locally installed guests r/o + +Options to run the selected tests under different test conditions: + + --debug Run tests with debugging enabled [recommended] + --valgrind Run tests under valgrind + --direct Run tests using the direct backend + --uml Run tests using the UML backend + --with-uml VMLINUX Select UML binary + [default %s] + --upstream-libvirt Run tests using upstream libvirt + --with-upstream-libvirt LIBVIRTDIR + Select libvirt directory + [default %s] + --upstream-qemu Run tests using upstream qemu + --with-upstream-qemu QEMUBINARY + Select qemu binary + [default %s] + +Options used internally: + + --make-phony-guests-only + Generate the phony guests used for testing + +Full list of options in alphabetical order:" + !uml_binary !libvirtdir !qemu_binary 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 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 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 and --uml cannot be combined. *) + if direct && uml then + failwith "cannot use --direct and --uml options together"; + + (* 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 (home // ".cache") 0o755 + with Unix_error _ -> ()); + (try mkdir (home // ".cache/libguestfs-tests") 0o755 + with Unix_error _ -> ()); + (try mkdir (home // ".cache/libguestfs-tests/phony-guests") 0o755 + with Unix_error _ -> ()); + home // ".cache/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 + + (* 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" + + (* 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"); + + 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 + + (* 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) 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 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 () -> + 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 -> (0, 0, 0, 0, 0) (* 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..3882a09 --- /dev/null +++ b/generator/tests.ml @@ -0,0 +1,69 @@ +(* 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-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..bc3d0cd --- /dev/null +++ b/generator/tests_mk.ml @@ -0,0 +1,124 @@ +(* 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-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 63aa235..57dbe3a 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 86e0cd7..2bf78e9 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 \ @@ -38,6 +40,7 @@ EXTRA_DIST = \ expected-fedora.img.xml \ expected-ubuntu.img.xml \ expected-windows.img.xml \ + test-virt-inspector-local-guests.sh \ test-virt-inspector.sh \ test-xmllint.sh.in \ virt-inspector.pod @@ -100,16 +103,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..7eade26 --- /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 + virt-inspector -c "@libvirt_ro_uri@" -d "$g" || exit 1 +done diff --git a/inspector/test-virt-inspector.sh b/inspector/test-virt-inspector.sh index 6fab253..d666e7b 100755 --- a/inspector/test-virt-inspector.sh +++ b/inspector/test-virt-inspector.sh @@ -20,23 +20,16 @@ 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,windows}.img; do - # Ignore zero-sized windows.img if ntfs-3g is not installed. +for f in $phonydir/{debian,fedora,ubuntu,windows}.img; do 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 aef5ebc..f1195fd 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..a3e3dba --- /dev/null +++ b/inspector/tests.mk @@ -0,0 +1,86 @@ +# 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-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-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 553876c..a1d470a 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/tests/data/Makefile.am b/tests/data/Makefile.am index d00400d..5c15892 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -19,52 +19,55 @@ 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-i586-dynamic \ bin-sparc-dynamic \ 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-i586.so \ lib-sparc.so \ 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)/bin-aarch64-dynamic \ + $(srcdir)/bin-i586-dynamic \ + $(srcdir)/bin-sparc-dynamic \ + $(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)/empty \ $(srcdir)/known-1 \ $(srcdir)/known-2 \ $(srcdir)/known-3 \ $(srcdir)/known-4 \ $(srcdir)/known-5 \ - $(srcdir)/bin-aarch64-dynamic \ - $(srcdir)/bin-i586-dynamic \ - $(srcdir)/bin-sparc-dynamic \ - $(srcdir)/bin-win32.exe \ - $(srcdir)/bin-win64.exe \ - $(srcdir)/bin-x86_64-dynamic \ $(srcdir)/lib-aarch64.so \ $(srcdir)/lib-i586.so \ $(srcdir)/lib-sparc.so \ $(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 \ @@ -85,12 +88,14 @@ images_files_build = \ initrd-x86_64.img.gz \ 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 diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 62f5d14..7cfdbd3 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -55,62 +55,34 @@ 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) 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/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-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' @@ -142,11 +114,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-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 1c23b6d..95bd6e4 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 575c2ee..3504658 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.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 2/7] 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 | 26 ++++++++ generator/tests_c_api.ml | 9 ++- tests/c-api/Makefile.am | 65 ++++---------------- tests/c-api/tests-main.c | 56 ++++++++++++------ tests/c-api/tests.h | 2 +- tests/c-api/tests.mk | 71 ++++++++++++++++++++++ 9 files changed, 233 insertions(+), 153 deletions(-) create mode 100644 tests/c-api/tests.mk diff --git a/.gitignore b/.gitignore index e4b8881..859a264 100644 --- a/.gitignore +++ b/.gitignore @@ -485,16 +485,13 @@ Makefile.in /tests/c-api/test-debug-to-file /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 510a97e..f6feaa8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -518,8 +518,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 eec3b94..fde0b25 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -2732,19 +2732,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 = "\ @@ -2762,19 +2762,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 = "\ @@ -2789,19 +2789,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 = "\ @@ -4226,67 +4226,67 @@ C<guestfs_is_file>, C<guestfs_is_blockdev> (etc), C<guestfs_is_zero>." }; tests = [ InitScratchFS, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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"]], "/"), []; ]; @@ -4330,67 +4330,67 @@ locations." }; tests = [ InitScratchFS, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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, Always, 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\")"), [] @@ -4603,11 +4603,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 = "\ @@ -4625,13 +4627,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 = "\ @@ -4723,15 +4727,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"; @@ -4788,7 +4792,7 @@ instead of user/group names. 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"; @@ -8118,7 +8122,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"; @@ -8230,7 +8234,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 = "\ @@ -8304,7 +8308,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"; @@ -8850,9 +8854,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"; @@ -8880,17 +8884,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 = "\ @@ -10696,7 +10702,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"]; @@ -10844,11 +10850,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 3882a09..53f3a17 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -32,6 +32,32 @@ 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"; + ]; + check = [ + "tests"; + "test-last-errno"; + "test-user-cancel"; + "test-debug-to-file"; + ]; + 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 88aa07e..86bf08e 100644 --- a/generator/tests_c_api.ml +++ b/generator/tests_c_api.ml @@ -385,17 +385,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/tests/c-api/Makefile.am b/tests/c-api/Makefile.am index 6ea22e9..f626d50 100644 --- a/tests/c-api/Makefile.am +++ b/tests/c-api/Makefile.am @@ -17,62 +17,20 @@ 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 +include $(srcdir)/tests.mk -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_CXX -check_PROGRAMS += test-just-header-cxx -TESTS += test-just-header-cxx -endif - -# The API behind this test is not baked yet. -#if HAVE_LIBVIRT -#check_PROGRAMS += test-add-libvirt-dom -#TESTS += test-add-libvirt-dom -#endif +# The API behind this test is not baked yet, so we only distribute the source. 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) - tests_SOURCES = \ tests.c \ tests.h \ @@ -119,6 +77,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 @@ -227,6 +189,3 @@ test_event_string_LDADD = \ # $(top_builddir)/src/libguestfs.la $(LIBVIRT_LIBS) \ # $(LTLIBTHREAD) $(top_builddir)/gnulib/lib/libgnu.la #endif - -check-valgrind: - $(MAKE) VG="$(top_builddir)/run @VG@" check diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c index e81e15e..d98445e 100644 --- a/tests/c-api/tests-main.c +++ b/tests/c-api/tests-main.c @@ -357,35 +357,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); @@ -424,6 +434,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) { @@ -446,8 +458,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 7959570..129aee6 100644 --- a/tests/c-api/tests.h +++ b/tests/c-api/tests.h @@ -43,7 +43,7 @@ extern int check_file_md5 (const char *ret, const char *filename); 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 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..9b52f25 --- /dev/null +++ b/tests/c-api/tests.mk @@ -0,0 +1,71 @@ +# 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)/tests/c-api + +localtests_PROGRAMS = \ + test-add-drive-opts \ + test-backend-settings \ + test-command \ + test-config \ + test-create-handle \ + test-debug-to-file \ + 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-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.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 3/7] 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 | 3 - generator/tests.ml | 266 ++++++++++++++++++++++++++ tests/9p/Makefile.am | 7 +- tests/9p/test-9p.sh | 5 - tests/9p/tests.mk | 54 ++++++ tests/bigdirs/Makefile.am | 12 +- tests/bigdirs/tests.mk | 30 +++ tests/btrfs/Makefile.am | 11 +- 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 | 56 ++++++ tests/charsets/Makefile.am | 7 +- tests/charsets/test-charset-fidelity.c | 12 +- tests/charsets/tests.mk | 54 ++++++ tests/create/Makefile.am | 9 +- tests/create/tests.mk | 57 ++++++ 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 | 56 ++++++ tests/disk-labels/Makefile.am | 10 +- tests/disk-labels/test-disk-labels.pl | 4 +- tests/disk-labels/tests.mk | 54 ++++++ tests/disks/Makefile.am | 14 +- tests/disks/test-max-disks.pl | 2 +- tests/disks/test-qemu-drive-libvirt.sh | 4 +- tests/disks/tests.mk | 57 ++++++ tests/events/Makefile.am | 19 +- tests/events/test-console-debug.pl | 4 +- tests/events/tests.mk | 63 ++++++ tests/fuzz/Makefile.am | 15 +- tests/fuzz/fuzz-inspection.pl | 11 +- tests/fuzz/tests.mk | 54 ++++++ tests/hotplug/Makefile.am | 13 +- tests/hotplug/test-hot-add.pl | 4 +- tests/hotplug/test-hot-remove.pl | 4 +- tests/hotplug/tests.mk | 55 ++++++ tests/journal/Makefile.am | 10 +- tests/journal/test-journal.pl | 6 +- tests/journal/tests.mk | 54 ++++++ tests/luks/Makefile.am | 11 +- tests/luks/test-luks-list.sh | 7 +- tests/luks/test-luks.sh | 7 +- tests/luks/tests.mk | 55 ++++++ tests/lvm/Makefile.am | 9 +- tests/lvm/test-lvm-filtering.sh | 7 +- tests/lvm/tests.mk | 55 ++++++ 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 | 58 ++++++ tests/mount-local/Makefile.am | 19 +- tests/mount-local/test-parallel-mount-local.c | 36 ++-- tests/mount-local/tests.mk | 54 ++++++ tests/mountable/Makefile.am | 10 +- tests/mountable/test-mountable-inspect.sh | 9 +- tests/mountable/tests.mk | 57 ++++++ tests/nbd/Makefile.am | 10 +- tests/nbd/test-nbd.pl | 6 +- tests/nbd/tests.mk | 54 ++++++ tests/network/Makefile.am | 10 +- tests/network/test-network.sh | 5 - tests/network/tests.mk | 54 ++++++ tests/ntfsclone/Makefile.am | 10 +- tests/ntfsclone/test-ntfsclone.sh | 11 +- tests/ntfsclone/tests.mk | 54 ++++++ 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 | 63 ++++++ tests/qemu/Makefile.am | 16 +- tests/qemu/qemu-force-tcg.sh | 5 - tests/qemu/tests.mk | 60 ++++++ tests/relative-paths/Makefile.am | 11 +- tests/relative-paths/test-relative-paths.sh | 8 +- tests/relative-paths/tests.mk | 54 ++++++ tests/rsync/Makefile.am | 8 +- tests/rsync/test-rsync.sh | 8 +- tests/rsync/tests.mk | 54 ++++++ tests/selinux/Makefile.am | 18 +- tests/selinux/run-test.pl | 10 +- tests/selinux/tests.mk | 58 ++++++ tests/syslinux/Makefile.am | 13 +- tests/syslinux/test-syslinux.pl | 4 +- tests/syslinux/tests.mk | 56 ++++++ tests/tmpdirs/Makefile.am | 10 +- tests/tmpdirs/tests.mk | 57 ++++++ tests/xfs/Makefile.am | 10 +- tests/xfs/test-xfs-misc.pl | 4 +- tests/xfs/tests.mk | 54 ++++++ tests/xml/Makefile.am | 29 ++- tests/xml/rhbz701814.pl | 4 +- tests/xml/rhbz701814.sh | 22 +++ tests/xml/tests.mk | 62 ++++++ 100 files changed, 2127 insertions(+), 435 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 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 859a264..93bcf38 100644 --- a/.gitignore +++ b/.gitignore @@ -536,9 +536,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/generator/tests.ml b/generator/tests.ml index 53f3a17..9fe63ec 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -33,6 +33,36 @@ 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"; + ]; + }; + + "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 = [ @@ -58,6 +88,242 @@ 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"; + ]; + }; + + "tests/charsets", { + defaults with + check = [ + "test-charset-fidelity"; + ]; + }; + + "tests/create", { + defaults with + check_fast = [ + "test-disk-create.sh"; + ]; + }; + + "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 9b3c880..eb16fdf 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..b73cfd2 --- /dev/null +++ b/tests/9p/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..b0d7f9e --- /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-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)/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 3d9f675..cfe4aa6 100644 --- a/tests/btrfs/Makefile.am +++ b/tests/btrfs/Makefile.am @@ -17,12 +17,11 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ - test-btrfs-misc.pl \ +generator_built = tests.mk + +EXTRA_DIST = \ test-btrfs-devices.sh \ + test-btrfs-misc.pl \ test-btrfs-subvolume-default.pl -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -EXTRA_DIST = \ - $(TESTS) +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 2fe7c59..e10c158 100755 --- a/tests/btrfs/test-btrfs-misc.pl +++ b/tests/btrfs/test-btrfs-misc.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_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..eb10cf2 --- /dev/null +++ b/tests/btrfs/tests.mk @@ -0,0 +1,56 @@ +# 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)/tests/btrfs + +localtests_SCRIPTS = \ + test-btrfs-devices.sh \ + test-btrfs-misc.pl \ + 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-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 b7ec703..954dbe7 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 4b34b0e..cabb929 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 && STREQ (str, "1")) { - printf ("%s: test skipped because environment variable is set.\n", - 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..41a5489 --- /dev/null +++ b/tests/charsets/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..abfc623 --- /dev/null +++ b/tests/create/tests.mk @@ -0,0 +1,57 @@ +# 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)/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-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..b856d36 --- /dev/null +++ b/tests/discard/tests.mk @@ -0,0 +1,56 @@ +# 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)/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-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..3f8afb8 --- /dev/null +++ b/tests/disk-labels/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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 9930865..5241a78 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..a4f7b2b --- /dev/null +++ b/tests/disks/tests.mk @@ -0,0 +1,57 @@ +# 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)/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-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 9f31e9e..836f474 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 \ @@ -44,4 +39,8 @@ test_libvirt_auth_callbacks_LDADD = \ $(LIBVIRT_LIBS) \ $(LIBXML2_LIBS) \ $(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/tests.mk b/tests/events/tests.mk new file mode 100644 index 0000000..f07d494 --- /dev/null +++ b/tests/events/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-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)/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-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..d78f631 --- /dev/null +++ b/tests/fuzz/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..0bd7a7b --- /dev/null +++ b/tests/hotplug/tests.mk @@ -0,0 +1,55 @@ +# 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)/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-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..a781605 --- /dev/null +++ b/tests/journal/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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 ffc9a03..d726278 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..ee7b36d --- /dev/null +++ b/tests/luks/tests.mk @@ -0,0 +1,55 @@ +# 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)/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-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 11c98df..61a01c5 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..1ec9e8b --- /dev/null +++ b/tests/lvm/tests.mk @@ -0,0 +1,55 @@ +# 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)/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-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 25abf0d..d3969d8 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..d43d7b7 --- /dev/null +++ b/tests/md/tests.mk @@ -0,0 +1,58 @@ +# 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)/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-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 17cfa73..4aa27ce 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 \ $(top_srcdir)/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 fa6cd79..382cd89 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 && STREQ (skip, "1")) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - program_name); - exit (77); - } - if (access ("/dev/fuse", W_OK) == -1) { fprintf (stderr, "%s: test skipped because /dev/fuse is not writable.\n", 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..ca3b433 --- /dev/null +++ b/tests/mount-local/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..72768cd --- /dev/null +++ b/tests/mountable/tests.mk @@ -0,0 +1,57 @@ +# 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)/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-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 c7361fd..23b36fa 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..813ca4f --- /dev/null +++ b/tests/nbd/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..9dc2fa0 --- /dev/null +++ b/tests/network/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..7114f39 --- /dev/null +++ b/tests/ntfsclone/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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 be63256..c092e4a 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 = \ @@ -36,9 +34,3 @@ test_parallel_CFLAGS = \ test_parallel_LDADD = \ $(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 edd87d9..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 && STREQ (skip, "1")) { - fprintf (stderr, "%s: test skipped because environment variable set.\n", - 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..74a4f0d --- /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-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)/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 8c57733..45f2cfd 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..3c08de4 --- /dev/null +++ b/tests/protocol/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-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)/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-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 b1b3555..cfca95b 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,22 +21,16 @@ include $(top_srcdir)/subdir-rules.mk -TESTS = \ +generator_built = tests.mk + +EXTRA_DIST = \ qemu-liveness.sh \ qemu-snapshot-isolation.sh \ qemu-force-tcg.sh - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -EXTRA_DIST = \ - $(TESTS) \ 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..ce187d5 --- /dev/null +++ b/tests/qemu/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-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)/tests/qemu + +localtests_SCRIPTS = \ + 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-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..3cebf7f --- /dev/null +++ b/tests/relative-paths/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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 3d1325e..268e4e8 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..337d957 --- /dev/null +++ b/tests/rsync/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..6743185 --- /dev/null +++ b/tests/selinux/tests.mk @@ -0,0 +1,58 @@ +# 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)/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-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 ac1e1cb..303b34c 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..9248211 --- /dev/null +++ b/tests/syslinux/tests.mk @@ -0,0 +1,56 @@ +# 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)/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-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..cfd71a2 --- /dev/null +++ b/tests/tmpdirs/tests.mk @@ -0,0 +1,57 @@ +# 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)/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-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..010c41b --- /dev/null +++ b/tests/xfs/tests.mk @@ -0,0 +1,54 @@ +# 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)/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-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..0ccc73d --- /dev/null +++ b/tests/xml/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-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)/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-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.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 4/7] tests/regressions: Convert the regression tests to use the test harness.
--- generator/tests.ml | 38 +++++++++++++++ tests/regressions/Makefile.am | 46 ++---------------- tests/regressions/rhbz1001875.sh | 7 +-- tests/regressions/rhbz1044014.sh | 9 +--- 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 | 89 ++++++++++++++++++++++++++++++++++ 13 files changed, 166 insertions(+), 115 deletions(-) create mode 100644 tests/regressions/tests.mk diff --git a/generator/tests.ml b/generator/tests.ml index 9fe63ec..4ffbec4 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -324,6 +324,44 @@ let tests = [ ]; }; + "tests/regressions", { + defaults with + check_fast = [ + "rhbz501893"; + "rhbz1055452"; + ]; + 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"; + "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 a5e7cfc..8d477ee 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 \ @@ -44,47 +46,12 @@ EXTRA_DIST = \ rhbz1091803.sh \ 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 \ - 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 = \ @@ -122,6 +89,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..7296eba 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,12 +29,12 @@ 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 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 faa3dd2..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 && STREQ (str, "1")) { - printf ("%s: test skipped because environment variable is set.\n", - 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..4fa0414 --- /dev/null +++ b/tests/regressions/tests.mk @@ -0,0 +1,89 @@ +# 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)/tests/regressions + +localtests_DATA = \ + rhbz557655-expected.stderr \ + rhbz557655-expected.stdout + +localtests_SCRIPTS = \ + rhbz1001875.sh \ + rhbz1044014.sh \ + rhbz1054761.sh \ + rhbz1091803.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-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.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 5/7] 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 4ffbec4..d8a6ec0 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -351,7 +351,6 @@ let tests = [ "rhbz1044014.sh"; "rhbz1054761.sh"; "rhbz1091803.sh"; - "test-noexec-stack.pl"; ]; check_slow = [ "rhbz909624.sh" diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index 8d477ee..171040d 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -43,8 +43,7 @@ EXTRA_DIST = \ rhbz1044014.in \ rhbz1044014.xml \ rhbz1054761.sh \ - rhbz1091803.sh \ - test-noexec-stack.pl + rhbz1091803.sh # 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 4fa0414..3175d56 100644 --- a/tests/regressions/tests.mk +++ b/tests/regressions/tests.mk @@ -44,8 +44,7 @@ localtests_SCRIPTS = \ rhbz895904.sh \ rhbz909624.sh \ rhbz957772.sh \ - rhbz975797.sh \ - test-noexec-stack.pl + rhbz975797.sh localtests_PROGRAMS = \ rhbz1055452 \ -- 2.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 6/7] 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 | 79 ++++++++++++++++++++++++++++++++++++++++++++++ generator/tests.ml | 31 ++++++++++++++++++ 9 files changed, 123 insertions(+), 49 deletions(-) create mode 100644 fish/tests.mk diff --git a/fish/Makefile.am b/fish/Makefile.am index d28a94b..55a7f11 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) \ @@ -265,39 +266,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 845f707..b3ef03a 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..87cf1de --- /dev/null +++ b/fish/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-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)/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-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 d8a6ec0..d395c3d 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -361,6 +361,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.0.4
Richard W.M. Jones
2014-Oct-05 13:08 UTC
[Libguestfs] [PATCH v5 7/7] 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 | 64 ++++++++++++++++++++++++++++ configure.ac | 2 + generator/tests.ml | 13 ++++++ 10 files changed, 117 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 93bcf38..b96c1fa 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,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 14b8e81..a6016c4 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 \ @@ -185,22 +188,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 fbf09ea..a1683e1 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..b64089b --- /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 $builddir/virt-filesystems -c "@libvirt_ro_uri@" -d "$g" --all --long -h --uuid || exit 1 +done diff --git a/cat/test-virt-filesystems.sh b/cat/test-virt-filesystems.sh index 2999950..043a6fe 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 af6bb95..f38fc9a 100755 --- a/cat/test-virt-log.sh +++ b/cat/test-virt-log.sh @@ -20,6 +20,6 @@ export LANG=C set -e # 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 if [ -s "$f" ]; then $VG virt-log -a "$f"; fi done 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..b47bcb0 --- /dev/null +++ b/cat/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-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)/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-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 c717981..fec9a61 100644 --- a/configure.ac +++ b/configure.ac @@ -1618,6 +1618,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([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 d395c3d..1db3fbe 100644 --- a/generator/tests.ml +++ b/generator/tests.ml @@ -361,6 +361,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.0.4
Pino Toscano
2014-Oct-21 14:40 UTC
Re: [Libguestfs] [PATCH v5 5/7] tests/regressions: Remove executable stack test.
On Sunday 05 October 2014 14:08:39 Richard W.M. Jones wrote:> 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.plMake sense even without test harness, LGTM. -- Pino Toscano
Pino Toscano
2014-Oct-21 14:40 UTC
Re: [Libguestfs] [PATCH v5 2/7] tests/c-api: Convert the C API tests to use the test harness.
On Sunday 05 October 2014 14:08:36 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. > > - 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.I'd be fine to the part that changes tests/c-api/tests so the data are read from $datadir. I will split that out. -- Pino Toscano
Pino Toscano
2014-Oct-21 15:56 UTC
Re: [Libguestfs] [PATCH v5 1/7] tests: Introduce test harness for running tests.
On Sunday 05 October 2014 14:08:35 Richard W.M. Jones wrote:> +# Install the test harness. > +localtestsdir = $(alltestsdir) > +localtests_SCRIPTS = ../test-harnessShouldn't it rather go to libexec?> +../test-harness: > + rm -f $@ $@-t > + echo 'echo Warning: Install OCaml compiler in order to rebuild the test-harness.' > $@-t > + chmod +x $@-t > + mv $@-t $@ > + > endifI guess this needs a configure check to disable the test suite when OCaml is not present.> +let is_executable path > + try (stat path).st_perm land 0o111 <> 0 > + with Unix_error _ -> falseI guess Unix.access might be better here.> +let relative_path_to_absolute path > + let cmd = sprintf "unset CDPATH; cd %s && pwd" (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 (sprintf "failed to convert relative path to absolute path: %s" > + cmd) > + ); > + pathInteresting, it seems OCaml has nothing in the core libraries to resolve paths, nor realpath implemented in the Unix module... Beside that, I'd just invoke realpath, available from GNU coreutils.> + 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"; > + "--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"; > + "--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"; > + ] inWhile I understand that the priority is the libvirt backend, I'd make the backend choice generic; something like: --backend NAME (direct, libvirt, uml, etc) --backend-option NAME=VAL (e.g. binary=/path/to/qemu for qemu, etc; can be specified multiple times)> + (* 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") inThe logic above would fool the runner if $srcdir is not set, and there's a file called Makefile.am in the current directory. Maybe something like: let srcdir, running_in_builddir try let srcdir = Sys.getenv "srcdir" in srcdir, is_file (srcdir // "Makefile.am") with Not_found -> ".", false in Or, maybe it would be even clearer/better, just have a --uninstalled parameter to explicitly turn the runner into that mode, without implicit logic.> + (* 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 (home // ".cache") 0o755 > + with Unix_error _ -> ()); > + (try mkdir (home // ".cache/libguestfs-tests") 0o755 > + with Unix_error _ -> ()); > + (try mkdir (home // ".cache/libguestfs-tests/phony-guests") 0o755 > + with Unix_error _ -> ()); > + home // ".cache/libguestfs-tests/phony-guests" > + ) inWould it be possible to use use $XDG_CACHE_HOME if available, falling back to $HOME/.cache if not?> + (* 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") inI think this should be extended to .lua files as well.> + (* 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 -> (0, 0, 0, 0, 0) (* do nothing in this directory *) inMight use null_results, I guess.> diff --git a/inspector/test-xmllint.sh.in b/inspector/test-xmllint.sh.in > index aef5ebc..f1195fd 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 > doneThis bit could go in even now, I guess.> 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/syslogReplacing $SRCDIR with $srcdir is something doable even right now, I guess. I will send a patch for this. -- Pino Toscano
Pino Toscano
2014-Oct-21 17:09 UTC
Re: [Libguestfs] [PATCH v5 0/7] tests: Introduce test harness for running tests.
Hi, On Sunday 05 October 2014 14:08:34 Richard W.M. Jones wrote:> Since v4: > > - More tests have been converted. > - Testing local guests fixed. > - Drop no-exec-stack test.I've sent few particular notes already to the separate patches. As a general notes: I look forward too to something to run the tests as installed, and we discussed (mostly on IRC) about it a couple of times. What I don't like particularly is the generation of the test list at generator time, and some tests at configure time; currently it is easy to just drop a new test in some directory and add it to TESTS. On the other hand, I understand the need to avoid duplication between in-tree and uninstalled tests. A possible idea just came into my mind is installing the current tests, like: installedtestsdir = $(libdir)/guestfs/tests/somesubdir installedtests_SCRIPTS = $(TESTS) at the bottom of each Makefile.am providing tests, maybe automating that using a small make function; this could make sure all the tests in each directory get installed properly, without moving the logic away from the build system. Regarding the "how to find tests": maybe it is a waste, but an idea could be add, next to test.sh, a test.sh.testinfo (or whatever), in plain text format, with entries like: [Test] Need=appliance,fake-guests CompatSkip=SKIP_OLD_NAME (we have a .ini parser in virt-builder, so that comes for free.) For example, the runner could get a parameter to know whether the appliance has been enabled, and not run tests with "appliance" in Need key. The bigger drawback is that even the tests with nothing to specify in such .testinfo file would need one, even if just with an empty [Test] section. -- Pino Toscano
Richard W.M. Jones
2014-Oct-24 09:44 UTC
Re: [Libguestfs] [PATCH v5 0/7] tests: Introduce test harness for running tests.
On Tue, Oct 21, 2014 at 07:09:14PM +0200, Pino Toscano wrote:> A possible idea just came into my mind is installing the current tests, > like: > installedtestsdir = $(libdir)/guestfs/tests/somesubdir > installedtests_SCRIPTS = $(TESTS) > at the bottom of each Makefile.am providing tests, maybe automating that > using a small make function; this could make sure all the tests in each > directory get installed properly, without moving the logic away from the > build system. > Regarding the "how to find tests": maybe it is a waste, but an idea > could be add, next to test.sh, a test.sh.testinfo (or whatever), in > plain text format, with entries like: > [Test] > Need=appliance,fake-guests > CompatSkip=SKIP_OLD_NAME > (we have a .ini parser in virt-builder, so that comes for free.) > For example, the runner could get a parameter to know whether the > appliance has been enabled, and not run tests with "appliance" in Need > key. The bigger drawback is that even the tests with nothing to specify > in such .testinfo file would need one, even if just with an empty [Test] > section.I was trying to avoid defining another source for generated files, on the general principle that everything that is generated come from one place (in the directory generator/). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Seemingly Similar Threads
- [PATCH v4 05/17] tests/regressions: Remove executable stack test.
- [PATCH] tests/regressions: Remove executable stack test.
- [PATCH] Add a regression test for RHBZ#1011907 / RHBZ#1165785
- [PATCH 2/2] lib: Add comment and regression test for case where main process has large heap.
- [PATCH 1/3] tests: specify the image format when possible