[Rpm-maint] [PATCH] tests/tpmbuild.at: Make file sed regexp more strict to extract BuildID.

Igor Gnatenko ignatenko at redhat.com
Sat Mar 4 10:06:59 UTC 2017


On Fri, 2017-03-03 at 23:51 +0100, Mark Wielaard wrote:
> From: Mark Wielaard <mark at klomp.org>
> 
> In some testcases we extract the BuildID with the file command.
> Unfortunately the file command output changed slightly between
> versions.
> Make the sed regexp more strict by only matching a hex-string.
> Also properly "escape" [ and ] which inside an AT_CHECK should be [[
> and ]].
> 
> Tested against file versions 5.11, 5.29 and 5.30.
> 
> Signed-off-by: Mark Wielaard <mark at klomp.org>
Tested-by: Igor Gnatenko <ignatenko at redhat.com>
> ---
>  tests/rpmbuild.at | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
> index 0a2c01e..1c18740 100644
> --- a/tests/rpmbuild.at
> +++ b/tests/rpmbuild.at
> @@ -422,11 +422,11 @@ hello2_file=./usr/local/bin/hello2
>  test -f $hello_file || echo "no hello file: $hello_file"
>  test -f $hello2_file || echo "no hello2 file: $hello2_file"
>  
> -id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
> -id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
> -id1debug=$(file $hello_file_debug | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> -id2debug=$(file $hello2_file_debug | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> -idmulti=$(file $hello_multi_file | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> +id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-
> f]]*\),.*/\1/')
> +id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-
> f]]*\),.*/\1/')
> +id1debug=$(file $hello_file_debug | sed 's/.*,
> BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
> +id2debug=$(file $hello2_file_debug | sed 's/.*,
> BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
> +idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-
> 9a-f]]*\),.*/\1/')
>  
>  test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
>  test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"
> @@ -515,11 +515,11 @@ hello2_file=./usr/local/bin/hello2
>  test -f $hello_file || echo "no hello file: $hello_file"
>  test -f $hello2_file || echo "no hello2 file: $hello2_file"
>  
> -id1=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
> -id2=$(file $hello2_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/')
> -id1debug=$(file $hello_file_debug | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> -id2debug=$(file $hello2_file_debug | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> -idmulti=$(file $hello_multi_file | sed 's/.*,
> BuildID[.*]=\(.*\),.*/\1/')
> +id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-
> f]]*\),.*/\1/')
> +id2=$(file $hello2_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-
> f]]*\),.*/\1/')
> +id1debug=$(file $hello_file_debug | sed 's/.*,
> BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
> +id2debug=$(file $hello2_file_debug | sed 's/.*,
> BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
> +idmulti=$(file $hello_multi_file | sed 's/.*, BuildID\[[.*\]]=\([[0-
> 9a-f]]*\),.*/\1/')
>  
>  test "$id1" = "$id1debug" || echo "id1: $id1 != id1debug: $id1debug"
>  test "$id2" = "$id2debug" || echo "id2: $id2 != id2debug: $id2debug"

-- 
-Igor Gnatenko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170304/fb72ea2f/attachment.asc>


More information about the Rpm-maint mailing list