[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [libnbd PATCH 1/5] Fix test requirements



On 5/6/21 6:30 AM, Martin Kletzander wrote:
> Some tests have extra dependencies that may be missing in minimal
> deployments (e.g. hexdump), some require kernel modules or support (nbd, fuse)
> and others need qemu, but were written to only work with qemu-kvm binary.
> 
> All these were fixed to my best knowledge, but of course they are still not
> perfect.
> 
> Signed-off-by: Martin Kletzander <mkletzan redhat com>
> ---

> +# requires_qemu
> +#
> +# Check that qemu-kvm or qemu-system-$(uname -m) works.  If not, skip the test.
> +# If it does, then export the appropriate binary name in $QEMU_BINARY.
> +requires_qemu ()
> +{
> +    local qemu_bin
> +    for qemu_bin in "qemu-kvm" "qemu-system-$(uname -m)"; do
> +        ( "$qemu_bin" --version ) </dev/null >/dev/null 2>&1 || continue
> +
> +        export QEMU_BINARY="$qemu_bin"
> +        break
> +    done
> +
> +    if test -z "$QEMU_BINARY"; then
> +        echo "$0: ‘$*’ failed with error code $?"

$* is empty in the typical case of calling 'requires_qemu' without
arguments, so you may want to reword this message.

> +        echo "$0: test prerequisite is missing or not working"
> +        exit 77
> +    fi
> +}
> +
>  # Tests that run under check-root should use this.
>  requires_root ()
>  {
> +++ b/copy/copy-block-to-nbd.sh
> @@ -23,6 +23,7 @@ set -x
>  
>  requires_root
>  requires nbdkit --exit-with-parent --version
> +requires test -e /sys/module/nbd

Is it enough that the file exists, or do we also want to test that it
can be read?  Then again, since we used requires_root, we should have
privileges to use the file if it exists.

> +++ b/fuse/test-file-mode.sh
> @@ -27,6 +27,7 @@ requires fusermount3 --version
>  requires nbdkit --exit-with-parent --version
>  requires cmp --version
>  requires dd --version
> +requires test -e /dev/fuse

Another spot where -r might make more sense than -e?

Overall, makes sense to me.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]