diff --git a/.gitignore b/.gitignore index 2fc52e843..31b9947e5 100644 --- a/.gitignore +++ b/.gitignore @@ -423,6 +423,7 @@ Makefile.in /tests/disks/test-add-disks /tests/disks/test-qemu-drive-libvirt.xml /tests/events/test-libvirt-auth-callbacks +/tests/functions.sh /tests/mount-local/test-parallel-mount-local /tests/mountable/test-internal-parse-mountable /tests/parallel/test-parallel diff --git a/bash/test-complete-in-script.sh b/bash/test-complete-in-script.sh index 7fff0bca3..9475db22b 100755 --- a/bash/test-complete-in-script.sh +++ b/bash/test-complete-in-script.sh @@ -19,7 +19,10 @@ # Test that the correct 'complete' command is included in the script. # Mainly prevents symlinking errors and some omissions. -$TEST_FUNCTIONS +source ../tests/functions.sh +set -e +set -x + skip_if_skipped if [ -z "$commands" ]; then diff --git a/common b/common index 4b0f1890a..8137d47d0 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 4b0f1890a41444fdacc71e418e56f6d78b46aa26 +Subproject commit 8137d47d0e654065391151eb275e3b64f230f6f5 diff --git a/configure.ac b/configure.ac index db95daf85..f64df7114 100644 --- a/configure.ac +++ b/configure.ac @@ -191,6 +191,8 @@ AC_CONFIG_FILES([podwrapper.pl], [chmod +x,-w podwrapper.pl]) AC_CONFIG_FILES([run], [chmod +x,-w run]) +AC_CONFIG_FILES([tests/functions.sh], + [chmod +x,-w tests/functions.sh]) AC_CONFIG_FILES([Makefile appliance/Makefile diff --git a/docs/guestfs-hacking.pod b/docs/guestfs-hacking.pod index 987697b27..75764e19b 100644 --- a/docs/guestfs-hacking.pod +++ b/docs/guestfs-hacking.pod @@ -671,8 +671,8 @@ normal test. Modify the test so it checks if the C environment variable is set, and if I set it skips (ie. returns with exit code 77). If -using C<$TEST_FUNCTIONS>, you can call the function C for -this. +using F, you can call the function C +for this. =item * @@ -706,8 +706,8 @@ normal test. =item * Modify the test so it checks if euid == 0, and if I set it skips -(ie. returns with exit code 77). If using C<$TEST_FUNCTIONS>, you can -call the function C for this. +(ie. returns with exit code 77). If using F, you +can call the function C for this. =item * diff --git a/fish/test-a.sh b/fish/test-a.sh index e04570453..4522574ff 100755 --- a/fish/test-a.sh +++ b/fish/test-a.sh @@ -18,9 +18,10 @@ # Test guestfish -a option. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-a.out diff --git a/fish/test-add-domain.sh b/fish/test-add-domain.sh index 8de1126a4..4c328a9f5 100755 --- a/fish/test-add-domain.sh +++ b/fish/test-add-domain.sh @@ -18,9 +18,10 @@ # Test add-domain command. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-add-domain-{1,2,3,4}.img diff --git a/fish/test-add-uri.sh b/fish/test-add-uri.sh index 533a3ce0c..e4e1021db 100755 --- a/fish/test-add-uri.sh +++ b/fish/test-add-uri.sh @@ -18,10 +18,10 @@ # Test guestfish -a URI. +source ../tests/functions.sh set -e set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-add-uri.out diff --git a/fish/test-alloc.sh b/fish/test-alloc.sh index 168e75d47..78052ddc3 100755 --- a/fish/test-alloc.sh +++ b/fish/test-alloc.sh @@ -18,9 +18,10 @@ # Test guestfish alloc and sparse commands. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-alloc.img diff --git a/fish/test-copy.sh b/fish/test-copy.sh index a0739989f..5a46a16b6 100755 --- a/fish/test-copy.sh +++ b/fish/test-copy.sh @@ -18,9 +18,10 @@ # Test guestfish copy-in and copy-out commands. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # This test fails on some versions of mock which lack /dev/fd diff --git a/fish/test-d.sh b/fish/test-d.sh index 6ef8ff05a..21d78fde9 100755 --- a/fish/test-d.sh +++ b/fish/test-d.sh @@ -18,9 +18,10 @@ # Test guestfish -d option. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-d-{1,2,3,4}.img diff --git a/fish/test-docs.sh b/fish/test-docs.sh index 666ec7d1e..5214efa7f 100755 --- a/fish/test-docs.sh +++ b/fish/test-docs.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/guestfish.pod" guestfish \ diff --git a/fish/test-edit.sh b/fish/test-edit.sh index 6bc16c5de..d1a9e201b 100755 --- a/fish/test-edit.sh +++ b/fish/test-edit.sh @@ -18,9 +18,10 @@ # Test guestfish edit command. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # This test fails on some versions of mock which lack /dev/fd diff --git a/fish/test-escapes.sh b/fish/test-escapes.sh index f75e828d1..c413ecd4c 100755 --- a/fish/test-escapes.sh +++ b/fish/test-escapes.sh @@ -18,9 +18,10 @@ # Test guestfish string escapes. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test.output test.error test.error.old diff --git a/fish/test-events.sh b/fish/test-events.sh index 1faec1bb5..48c0319eb 100755 --- a/fish/test-events.sh +++ b/fish/test-events.sh @@ -18,9 +18,10 @@ # Test guestfish events. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-events.out diff --git a/fish/test-file-attrs.sh b/fish/test-file-attrs.sh index f726297ef..78587fad5 100755 --- a/fish/test-file-attrs.sh +++ b/fish/test-file-attrs.sh @@ -18,9 +18,10 @@ # Test guestfish file attributes commands (chmod, copy-attributes, etc). +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-file-attrs.out diff --git a/fish/test-find0.sh b/fish/test-find0.sh index 700e9476c..554dc8288 100755 --- a/fish/test-find0.sh +++ b/fish/test-find0.sh @@ -18,9 +18,10 @@ # Test find0 call. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_test_iso diff --git a/fish/test-glob.sh b/fish/test-glob.sh index cf00d9565..d74fd185e 100755 --- a/fish/test-glob.sh +++ b/fish/test-glob.sh @@ -18,9 +18,10 @@ # Test guestfish glob command. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-glob.img test-glob.out diff --git a/fish/test-inspect.sh b/fish/test-inspect.sh index 3133eeb2d..48060b948 100755 --- a/fish/test-inspect.sh +++ b/fish/test-inspect.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_phony_guest fedora.img diff --git a/fish/test-invalid-params.sh b/fish/test-invalid-params.sh index af548c1c6..8e1b81525 100755 --- a/fish/test-invalid-params.sh +++ b/fish/test-invalid-params.sh @@ -19,9 +19,10 @@ # Test passing invalid parameters for memory size, smp, etc when setting up # the appliance. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # Memory size diff --git a/fish/test-mount-local.sh b/fish/test-mount-local.sh index 3150f8fd4..eb1d8dc6c 100755 --- a/fish/test-mount-local.sh +++ b/fish/test-mount-local.sh @@ -18,7 +18,10 @@ # Test guestfish mount-local / mount-local-run commands. -$TEST_FUNCTIONS +source ../tests/functions.sh +set -e +set -x + skip_if_skipped skip_unless_fuse diff --git a/fish/test-read-file.sh b/fish/test-read-file.sh index f2357a1b2..eb66849c6 100755 --- a/fish/test-read-file.sh +++ b/fish/test-read-file.sh @@ -18,9 +18,10 @@ # Test read_file call. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_test_iso diff --git a/fish/test-remote-events.sh b/fish/test-remote-events.sh index 5e7855210..8a1f9210c 100755 --- a/fish/test-remote-events.sh +++ b/fish/test-remote-events.sh @@ -18,9 +18,10 @@ # Test remote events in guestfish. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped eval "$(guestfish --listen)" diff --git a/fish/test-remote.sh b/fish/test-remote.sh index eb169c6f3..47be7bac6 100755 --- a/fish/test-remote.sh +++ b/fish/test-remote.sh @@ -18,9 +18,10 @@ # Test remote control of guestfish. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-remote.img diff --git a/fish/test-reopen.sh b/fish/test-reopen.sh index 35070b472..7f9b999a5 100755 --- a/fish/test-reopen.sh +++ b/fish/test-reopen.sh @@ -19,9 +19,10 @@ # Test reopening the handle in the same process. This used to fail # but was corrected in 03e1f74ee08dc71bc09cc7655bf4732685f80b43. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-reopen.img diff --git a/fish/test-run.sh b/fish/test-run.sh index 95d861eaa..30177b1fd 100755 --- a/fish/test-run.sh +++ b/fish/test-run.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_phony_guest fedora.img diff --git a/fish/test-stringlist.sh b/fish/test-stringlist.sh index 3d8ebb8b2..b9b26dbe5 100755 --- a/fish/test-stringlist.sh +++ b/fish/test-stringlist.sh @@ -18,9 +18,10 @@ # Test remote control of guestfish. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-stringlist.img diff --git a/fish/test-tilde.sh b/fish/test-tilde.sh index 8db339ff0..ec109b6bf 100755 --- a/fish/test-tilde.sh +++ b/fish/test-tilde.sh @@ -21,9 +21,10 @@ # RHBZ#511372 guestfish doesn't understand '~' in filenames # and multiple other fixes to tilde handling. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # Set XDG_CACHE_HOME correctly, unless set already. See: diff --git a/fish/test-upload-to-dir.sh b/fish/test-upload-to-dir.sh index a94661130..48d72ead9 100755 --- a/fish/test-upload-to-dir.sh +++ b/fish/test-upload-to-dir.sh @@ -20,9 +20,10 @@ # target to a directory instead of the full filename, then previously # libguestfs would hang. It should return an error instead. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_test_iso diff --git a/fuse/test-docs.sh b/fuse/test-docs.sh index 2908b9a26..3fa6641ae 100755 --- a/fuse/test-docs.sh +++ b/fuse/test-docs.sh @@ -18,7 +18,10 @@ set -e -$TEST_FUNCTIONS +source ../tests/functions.sh +set -e +set -x + skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/guestmount.pod" guestmount \ diff --git a/fuse/test-fuse-umount-race.sh b/fuse/test-fuse-umount-race.sh index d69ffbbf4..4e4055af0 100755 --- a/fuse/test-fuse-umount-race.sh +++ b/fuse/test-fuse-umount-race.sh @@ -19,9 +19,10 @@ # https://bugzilla.redhat.com/show_bug.cgi?id=838592 # This tests that the --pid-file option can be used to fix the race. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped "test-fuse.sh" skip_if_skipped skip_unless_phony_guest fedora.img diff --git a/fuse/test-guestunmount-not-mounted.sh b/fuse/test-guestunmount-not-mounted.sh index 5fb4a2ec1..f1089972e 100755 --- a/fuse/test-guestunmount-not-mounted.sh +++ b/fuse/test-guestunmount-not-mounted.sh @@ -20,7 +20,10 @@ # Test that guestunmount returns the correct error code if # there is no mounted FUSE filesystem. -$TEST_FUNCTIONS +source ../tests/functions.sh +#set -e # command below deliberately fails +set -x + skip_if_skipped "test-fuse.sh" skip_if_skipped skip_unless_fuse diff --git a/generator/fish.ml b/generator/fish.ml index 62fd299e8..fc421c41f 100644 --- a/generator/fish.ml +++ b/generator/fish.ml @@ -1154,9 +1154,11 @@ and generate_fish_test_prep_sh () = let all_disks = sprintf "prep{1..%d}.img" (List.length prepopts) in pr "\ -set -e -$TEST_FUNCTIONS +source ../tests/functions.sh +set -e +set -x + skip_if_skipped rm -f %s diff --git a/gobject/run-live-tests b/gobject/run-live-tests index 4cb1385b3..3ad672cc7 100755 --- a/gobject/run-live-tests +++ b/gobject/run-live-tests @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_environment_variable_set GJS skip_unless_phony_guest fedora.img diff --git a/gobject/run-tests b/gobject/run-tests index 5dd21ff6d..cb34aa6af 100755 --- a/gobject/run-tests +++ b/gobject/run-tests @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_environment_variable_set GJS diff --git a/gobject/run-tests-retvalues b/gobject/run-tests-retvalues index d594b4648..c63461c9e 100755 --- a/gobject/run-tests-retvalues +++ b/gobject/run-tests-retvalues @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_environment_variable_set GJS diff --git a/python/test-pycodestyle.sh b/python/test-pycodestyle.sh index 39fc87d2d..73aee258b 100755 --- a/python/test-pycodestyle.sh +++ b/python/test-pycodestyle.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # Gather the list of Python sources. diff --git a/rescue/test-virt-rescue-docs.sh b/rescue/test-virt-rescue-docs.sh index 5afd8a274..b5636ed7e 100755 --- a/rescue/test-virt-rescue-docs.sh +++ b/rescue/test-virt-rescue-docs.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/virt-rescue.pod" virt-rescue \ diff --git a/rescue/test-virt-rescue-suggest.sh b/rescue/test-virt-rescue-suggest.sh index 609396ca7..c5c567e26 100755 --- a/rescue/test-virt-rescue-suggest.sh +++ b/rescue/test-virt-rescue-suggest.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_phony_guest fedora.img diff --git a/subdir-rules.mk b/subdir-rules.mk index 61a3a459e..c85a89f72 100644 --- a/subdir-rules.mk +++ b/subdir-rules.mk @@ -90,24 +90,3 @@ if HAVE_OCAMLOPT %.cmx: %.ml $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ endif - -# Test shell scripts should use '$TEST_FUNCTIONS' to get a predefined -# set of helper functions for running tests (see -# tests/test-functions.sh). -# -# Notes: -# -# (1) This is in fact a single command all on one line. The variables -# are evaluated in test-functions.sh. -# -# (2) We use absolute paths here and in test-functions.sh so that the -# test can change directory freely. But we also include the -# non-absolute values so they can be used by the test script itself. -export TEST_FUNCTIONS := \ - source $(abs_top_srcdir)/tests/test-functions.sh \ - abs_srcdir="$(abs_srcdir)" \ - abs_builddir="$(abs_builddir)" \ - top_srcdir="$(top_srcdir)" \ - top_builddir="$(top_builddir)" \ - abs_top_srcdir="$(abs_top_srcdir)" \ - abs_top_builddir="$(abs_top_builddir)" diff --git a/test-tool/test-libguestfs-test-tool-docs.sh b/test-tool/test-libguestfs-test-tool-docs.sh index 589fe8bb0..3ac5f63df 100755 --- a/test-tool/test-libguestfs-test-tool-docs.sh +++ b/test-tool/test-libguestfs-test-tool-docs.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ../tests/functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl "$srcdir/libguestfs-test-tool.pod" libguestfs-test-tool \ diff --git a/tests/btrfs/test-btrfs-devices.sh b/tests/btrfs/test-btrfs-devices.sh index dece32c2f..195593c51 100755 --- a/tests/btrfs/test-btrfs-devices.sh +++ b/tests/btrfs/test-btrfs-devices.sh @@ -22,9 +22,10 @@ # to the disk, then instructing btrfs to move the data between # devices. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available btrfs diff --git a/tests/btrfs/test-btrfs-replace.sh b/tests/btrfs/test-btrfs-replace.sh index 68fe9a4cd..55b389372 100755 --- a/tests/btrfs/test-btrfs-replace.sh +++ b/tests/btrfs/test-btrfs-replace.sh @@ -18,9 +18,10 @@ # Test btrfs replace devices. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available btrfs diff --git a/tests/create/test-disk-create.sh b/tests/create/test-disk-create.sh index e52f0f608..5d59c3d2c 100755 --- a/tests/create/test-disk-create.sh +++ b/tests/create/test-disk-create.sh @@ -17,9 +17,10 @@ # Test the disk-create API. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f disk*.img file:*.img diff --git a/tests/disks/test-255-disks.sh b/tests/disks/test-255-disks.sh index 861805c66..26cbf5763 100755 --- a/tests/disks/test-255-disks.sh +++ b/tests/disks/test-255-disks.sh @@ -15,9 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_backend libvirt diff --git a/tests/disks/test-27-disks.sh b/tests/disks/test-27-disks.sh index 5f1f82f3b..2c137fa9e 100755 --- a/tests/disks/test-27-disks.sh +++ b/tests/disks/test-27-disks.sh @@ -18,9 +18,10 @@ # The significance of 27 is that it's the minimum number of disks # supported by every known backend in every supported configuration. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped disks/test-add-disks -n 27 diff --git a/tests/disks/test-add-drive-with-blocksize.sh b/tests/disks/test-add-drive-with-blocksize.sh index ae01fd872..055212aa3 100755 --- a/tests/disks/test-add-drive-with-blocksize.sh +++ b/tests/disks/test-add-drive-with-blocksize.sh @@ -18,9 +18,10 @@ # Test blocksize parameter of add-drive command +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped # Test valid values diff --git a/tests/disks/test-add-lots-of-disks.sh b/tests/disks/test-add-lots-of-disks.sh index ce618b3df..432e121ab 100755 --- a/tests/disks/test-add-lots-of-disks.sh +++ b/tests/disks/test-add-lots-of-disks.sh @@ -15,11 +15,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ./functions.sh set -e +set -x + +skip_if_skipped N=255 -$TEST_FUNCTIONS -skip_if_skipped - disks/test-add-disks --just-add -n $N diff --git a/tests/disks/test-max-disks.sh b/tests/disks/test-max-disks.sh index 85b30bb40..48e8c090d 100755 --- a/tests/disks/test-max-disks.sh +++ b/tests/disks/test-max-disks.sh @@ -15,9 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped slow_test diff --git a/tests/disks/test-qemu-drive-libvirt.sh b/tests/disks/test-qemu-drive-libvirt.sh index afbeddec6..7dbe58680 100755 --- a/tests/disks/test-qemu-drive-libvirt.sh +++ b/tests/disks/test-qemu-drive-libvirt.sh @@ -17,10 +17,10 @@ # Test that disks map to the correct qemu -drive parameter. +source ./functions.sh set -e set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_libvirt_minimum_version 1 1 3 diff --git a/tests/disks/test-qemu-drive-with-blocksize-libvirt.sh b/tests/disks/test-qemu-drive-with-blocksize-libvirt.sh index ce5ed9d61..d5f4067eb 100755 --- a/tests/disks/test-qemu-drive-with-blocksize-libvirt.sh +++ b/tests/disks/test-qemu-drive-with-blocksize-libvirt.sh @@ -18,9 +18,10 @@ # Test that disks with tag map to the correct qemu -device # parameters and respect to logical_block_size value. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_libvirt_minimum_version 1 1 3 diff --git a/tests/disks/test-qemu-drive.sh b/tests/disks/test-qemu-drive.sh index 9ee7df389..d6ce0f07f 100755 --- a/tests/disks/test-qemu-drive.sh +++ b/tests/disks/test-qemu-drive.sh @@ -17,9 +17,10 @@ # Test that disks map to the correct qemu -drive parameter. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped export LIBGUESTFS_BACKEND=direct diff --git a/tests/test-functions.sh b/tests/functions.sh.in similarity index 95% rename from tests/test-functions.sh rename to tests/functions.sh.in index 404491204..940dbc963 100755 --- a/tests/test-functions.sh +++ b/tests/functions.sh.in @@ -1,6 +1,6 @@ #!/bin/bash - # libguestfs -# Copyright (C) 2014-2023 Red Hat Inc. +# Copyright (C) 2014-2025 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 @@ -19,19 +19,24 @@ # Most of the tests written in shell script source this file for # useful functions. # -# To include this file, the test must do: +# To include this file, the test should do: # -# $TEST_FUNCTIONS -# -# (this macro is defined in subdir-rules.mk). +# source ./functions.sh +# set -e +# set -x # Clean up the environment in every test script. unset CDPATH export LANG=C -# When test-functions.sh is invoked, a list of variables is passed as -# parameters, so we eval those to define the variables. -while [ $# -ge 1 ]; do eval "$1"; shift; done +# Various variables defined by autoconf that test scripts might want +# to use. +top_srcdir="@top_srcdir@" +top_builddir="@top_builddir@" +abs_top_srcdir="@abs_top_srcdir@" +abs_top_builddir="@abs_top_builddir@" +abs_builddir="$PWD" +abs_srcdir="$(cd "@srcdir@" && pwd)" # Configure check results. source $abs_top_builddir/config.sh diff --git a/tests/luks/test-key-option-inspect-luks-on-lvm.sh b/tests/luks/test-key-option-inspect-luks-on-lvm.sh index 2b60c7975..dce49328e 100755 --- a/tests/luks/test-key-option-inspect-luks-on-lvm.sh +++ b/tests/luks/test-key-option-inspect-luks-on-lvm.sh @@ -19,9 +19,10 @@ # Test the --key option. It is handled by common code so we only need # to test one tool (guestfish). +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available luks skip_unless_phony_guest fedora-luks-on-lvm.img diff --git a/tests/luks/test-key-option-inspect-lvm-on-luks.sh b/tests/luks/test-key-option-inspect-lvm-on-luks.sh index 3d2bb9e6c..87480221d 100755 --- a/tests/luks/test-key-option-inspect-lvm-on-luks.sh +++ b/tests/luks/test-key-option-inspect-lvm-on-luks.sh @@ -19,9 +19,10 @@ # Test the --key option. It is handled by common code so we only need # to test one tool (guestfish). +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available luks skip_unless_phony_guest fedora-lvm-on-luks.img diff --git a/tests/luks/test-key-option.sh b/tests/luks/test-key-option.sh index be50fd887..f6df8654e 100755 --- a/tests/luks/test-key-option.sh +++ b/tests/luks/test-key-option.sh @@ -19,9 +19,10 @@ # Test the --key option. It is handled by common code so we only need # to test one tool (guestfish). +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available luks diff --git a/tests/luks/test-luks-list.sh b/tests/luks/test-luks-list.sh index 0aceb14d4..ee988114b 100755 --- a/tests/luks/test-luks-list.sh +++ b/tests/luks/test-luks-list.sh @@ -18,9 +18,10 @@ # Test LUKS devices appear in the output of list-dm-devices. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available luks diff --git a/tests/luks/test-luks.sh b/tests/luks/test-luks.sh index 9f58264ee..94b888404 100755 --- a/tests/luks/test-luks.sh +++ b/tests/luks/test-luks.sh @@ -18,9 +18,10 @@ # Test LUKS device creation, opening, key slots. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available luks diff --git a/tests/lvm/test-lvm-filtering.sh b/tests/lvm/test-lvm-filtering.sh index abb88ae6c..fb6d1829c 100755 --- a/tests/lvm/test-lvm-filtering.sh +++ b/tests/lvm/test-lvm-filtering.sh @@ -18,9 +18,10 @@ # Test LVM device filtering. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f test-lvm-filtering-1.img test-lvm-filtering-2.img diff --git a/tests/md/test-inspect-fstab-md.sh b/tests/md/test-inspect-fstab-md.sh index 5d381038e..097b68773 100755 --- a/tests/md/test-inspect-fstab-md.sh +++ b/tests/md/test-inspect-fstab-md.sh @@ -18,9 +18,10 @@ # Test the handling of MD devices specified in /etc/fstab +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_phony_guest fedora-md1.img skip_unless_phony_guest fedora-md2.img diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh index dce340d53..dbc1fcca2 100755 --- a/tests/md/test-inspect-fstab.sh +++ b/tests/md/test-inspect-fstab.sh @@ -19,11 +19,12 @@ # Test various aspects of core inspection of /etc/fstab. # This also tests: https://bugzilla.redhat.com/668574 +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS -skip_because "device name hints are broken" ;# XXX Fix before 1.38 skip_if_skipped +skip_because "device name hints are broken" ;# XXX Fix before 1.38 skip_unless_phony_guest fedora.img canonical="sed -r s,/dev/[abce-ln-z]+d,/dev/sd,g" diff --git a/tests/md/test-list-filesystems.sh b/tests/md/test-list-filesystems.sh index 073a355d2..bf2dadff1 100755 --- a/tests/md/test-list-filesystems.sh +++ b/tests/md/test-list-filesystems.sh @@ -18,9 +18,10 @@ # Test guestfish list-mddevices command +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f list-fs.output diff --git a/tests/md/test-list-md-devices.sh b/tests/md/test-list-md-devices.sh index b7db10ade..fe2bfe0a9 100755 --- a/tests/md/test-list-md-devices.sh +++ b/tests/md/test-list-md-devices.sh @@ -18,9 +18,10 @@ # Test guestfish list-md-devices command +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped output=$( diff --git a/tests/md/test-lvm-on-md-device.sh b/tests/md/test-lvm-on-md-device.sh index 4c341de5c..c72fb2a0c 100755 --- a/tests/md/test-lvm-on-md-device.sh +++ b/tests/md/test-lvm-on-md-device.sh @@ -18,9 +18,10 @@ # Test guestfish finds logical volume (LV) created on md device +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped disk1=lvm-on-md-devices-1.img @@ -77,4 +78,4 @@ if [ "$output" != "$expected" ]; then fi # cleanup() is called implicitly which cleans up everything -exit 0 \ No newline at end of file +exit 0 diff --git a/tests/md/test-md-and-lvm-devices.sh b/tests/md/test-md-and-lvm-devices.sh index 5c4fb9319..9b856dba9 100755 --- a/tests/md/test-md-and-lvm-devices.sh +++ b/tests/md/test-md-and-lvm-devices.sh @@ -25,9 +25,10 @@ # is inaccessible so it is easy observable that md device is missing (raid1 in # this case will be operable but in degraded state). +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped disk1=md-and-lvm-devices-1.img diff --git a/tests/md/test-mdadm.sh b/tests/md/test-mdadm.sh index e9be714c3..21bcef378 100755 --- a/tests/md/test-mdadm.sh +++ b/tests/md/test-mdadm.sh @@ -18,9 +18,10 @@ # Test guestfish md-create and md-detail commands. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped rm -f mdadm-{1,2,3,4}.img diff --git a/tests/md/test-partitioned-md-devices.sh b/tests/md/test-partitioned-md-devices.sh index 36b6d8a25..1f9680849 100755 --- a/tests/md/test-partitioned-md-devices.sh +++ b/tests/md/test-partitioned-md-devices.sh @@ -20,9 +20,10 @@ # md device and does't take into account md device itself (similar to as # physical devices are skipped if they are partitioned) +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped disk1=list-filesystems2-1.img diff --git a/tests/mountable/test-mountable-inspect.sh b/tests/mountable/test-mountable-inspect.sh index bd62eab7d..06ff46b43 100755 --- a/tests/mountable/test-mountable-inspect.sh +++ b/tests/mountable/test-mountable-inspect.sh @@ -16,9 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available btrfs diff --git a/tests/network/test-network.sh b/tests/network/test-network.sh index 144b16319..965702d62 100755 --- a/tests/network/test-network.sh +++ b/tests/network/test-network.sh @@ -20,9 +20,10 @@ # especially testing that the network in fact works. For now just # test that the network device can be added. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped guestfish --network -a /dev/null run diff --git a/tests/ntfs/test-ntfscat.sh b/tests/ntfs/test-ntfscat.sh index 9fece4dd5..319ebea2d 100755 --- a/tests/ntfs/test-ntfscat.sh +++ b/tests/ntfs/test-ntfscat.sh @@ -18,9 +18,10 @@ # Test the ntfscat-i command. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available ntfs3g skip_unless_phony_guest windows.img diff --git a/tests/ntfs/test-ntfsclone.sh b/tests/ntfs/test-ntfsclone.sh index ba948e001..c8d82f811 100755 --- a/tests/ntfs/test-ntfsclone.sh +++ b/tests/ntfs/test-ntfsclone.sh @@ -18,9 +18,10 @@ # Test the ntfsclone-in/-out commands. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped skip_unless_feature_available ntfs3g skip_unless_phony_guest windows.img diff --git a/tests/protocol/test-both-ends-cancel.sh b/tests/protocol/test-both-ends-cancel.sh index 903dcab36..3cd251e00 100755 --- a/tests/protocol/test-both-ends-cancel.sh +++ b/tests/protocol/test-both-ends-cancel.sh @@ -20,9 +20,10 @@ # https://bugzilla.redhat.com/show_bug.cgi?id=576879#c5 # where both ends send cancel messages simultaneously. +source ./functions.sh set -e +set -x -$TEST_FUNCTIONS skip_if_skipped guestfish <