Re: [spice-streaming-agent 1/2] tests: Fix hexdump.sh when builddir != srcdir

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

 



> 
> This script currently expects the reference file and the generated file
> to both be in the same directory, which is not the case when doing a
> build with builddir != srcdir (or when running make distcheck)
> ---
>  src/unittests/Makefile.am |  1 +
>  src/unittests/hexdump.sh  | 13 +++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/src/unittests/Makefile.am b/src/unittests/Makefile.am
> index 0dc2328..1a5f339 100644
> --- a/src/unittests/Makefile.am
> +++ b/src/unittests/Makefile.am
> @@ -16,6 +16,7 @@ check_PROGRAMS = \
>  	test-hexdump \
>  	$(NULL)
>  
> +AM_TESTS_ENVIRONMENT = SRCDIR=$(srcdir); export SRCDIR;
> BUILDDIR=$(builddir); export BUILDDIR;

quite long and confusing. The shortest version is

AM_TESTS_ENVIRONMENT = export SRCDIR=$(srcdir) BUILDDIR=$(builddir);

export NAME=VALUE was added in Posix in 2002, another more compatible version
is

AM_TESTS_ENVIRONMENT = SRCDIR=$(srcdir); BUILDDIR=$(builddir); export SRCDIR BUILDDIR;

>  TESTS = \
>  	hexdump.sh \
>  	$(NULL)
> diff --git a/src/unittests/hexdump.sh b/src/unittests/hexdump.sh
> index 602b501..4509a7b 100755
> --- a/src/unittests/hexdump.sh
> +++ b/src/unittests/hexdump.sh
> @@ -6,10 +6,11 @@ set -e
>  # ascii part of the dump
>  export LANG=C
>  
> -for f in hexdump*.in; do
> -    out=`echo $f | sed 's,\.in,.out,'`
> -    rm -f $out.test
> -    ./test-hexdump $out.test < $f
> -    cmp $out.test $out
> -    rm -f $out.test
> +for f in "$SRCDIR"/hexdump*.in; do
> +    reference=`echo $f | sed 's,\.in,.out,'`
> +    out="$BUILDDIR"/`basename $reference`.test
> +    rm -f $out
> +    ./test-hexdump $out < $f
> +    cmp $out $reference
> +    rm -f $out
>  done

this however prevents the user to just call ./hexdump.sh
as SRCDIR and BUILDDIR are not defined.

Maybe adding some lines like

SRCDIR="${SRCDIR:-.}"

to support the normal case.

Another approach would be to have a hexdump.sh.in instead
and having the paths replaced during configure generating
the correct hexdump.sh file.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]