[Libguestfs] [PATCH v2 nbdkit 3/5] tests: Move common code for testing every plugin to tests/functions.sh.

Eric Blake eblake at redhat.com
Thu Sep 13 17:51:26 UTC 2018


On 9/13/18 11:09 AM, Richard W.M. Jones wrote:
> This resurrects the unused tests/functions.sh file (although now we
> need to generate it from tests/functions.sh.in).  Put the common code
> for running a test against every plugin here.
> 
> Because of the previous commits we can now use the plugins list
> directly from configure.ac instead of needing to use weird shell
> script, although we still need to preserve the test that the plugin
> was built so that the tests continue to work if a plugin is disabled
> or not built through missing dependencies.
> ---

> -# (Currently empty)
> +# foreach_plugin f
> +#
> +# For each plugin that was built, call test function f with the plugin
> +# name as argument.

Possible improvement - allow callers to pass parameters, as in:

foreach_plugin f arg1 arg2

> +foreach_plugin ()
> +{

f=$1; shift

> +    for p in @plugins@; do
> +        # Was the plugin built?
> +        d="@top_builddir@/plugins/$p"
> +        if [ -f "$d/.libs/nbdkit-$p-plugin.so" ] ||
> +           [ -f "$d/nbdkit-$p-plugin" ]; then
> +            # Yes so run the test.
> +            "$1" "$p"

"$f" "$p" "$@"

Up to you if you want that (if you even have a use where additional 
arguments would make sense); I'm also fine with this patch going in as-is.

> +++ b/tests/test-help.sh

> +test ()
> +{
> +    case "$1${NBDKIT_VALGRIND:+-valgrind}" in
>           vddk | vddk-valgrind)
>               # VDDK won't run without special environment variables
>               # being set, so ignore it.

Not for this patch, but is it worth making 'nbdkit vddk --help' display 
something useful even when env-vars are not set?

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




More information about the Libguestfs mailing list