[FFmpeg-devel] [PATCH] tests: drop bc dependency
Clément Bœsch
u at pkh.me
Sun Feb 8 10:32:52 CET 2015
On Sun, Feb 08, 2015 at 10:27:14AM +0100, Clément Bœsch wrote:
> On Tue, Jan 20, 2015 at 09:58:33PM +0100, Reimar Döffinger wrote:
> > On Mon, Jan 19, 2015 at 10:58:02PM +0100, Clément Bœsch wrote:
> > > - echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
> > > + awk "BEGIN { v=$1-$2; printf \"%d\\n\", ((v<0?v:-v) > $3) ? 1 : 0 }"
> >
> > I'd suggest single quotes for the outer ones, then you do not need to
> > escape \ and ".
>
> Done. I kind of forgot i could 'foo '$1' bar'...
>
> > Also it's broken, you inverted the absolute value condition.
>
> Oh derp... fixed, sorry.
>
> > Lastly, at least with gawk the last ?: is pointless, conditions evaluate
> > to 1/0 like in C.
>
> I originally tried it but probably did it wrong with the parenthesis.
> Seems it works fine indeed. New patch attached. Thanks.
>
> --
> Clément B.
> From b558464bc43787a2aa50c17373905ce146682595 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <u at pkh.me>
> Date: Mon, 19 Jan 2015 22:56:59 +0100
> Subject: [PATCH] tests: drop bc dependency
>
> We already have a dependency on awk, bc is sometimes not found in the
> base system.
> ---
> tests/fate-run.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index f78e4fc..4a6d354 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> @@ -38,7 +38,7 @@ target_path(){
> # $1=value1, $2=value2, $3=threshold
> # prints 0 if absolute difference between value1 and value2 is <= threshold
> compare(){
> - echo "scale=2; v = $1 - $2; if (v < 0) v = -v; if (v > $3) r = 1; r" | bc
> + awk 'BEGIN { v='$1'-'$2'; printf "%d\n", ((v<0?-v:v) > '$3') }'
> }
>
> do_tiny_psnr(){
And now I realize that the \n is not actually even required, so new patch
again.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-tests-drop-bc-dependency.patch
Type: text/x-diff
Size: 825 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150208/2cc8ce70/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150208/2cc8ce70/attachment.asc>
More information about the ffmpeg-devel
mailing list