From a982c5d74fbc7ff5bd2f2f73af61ae48e9b1bcc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <u@pkh.me>
Date: Mon, 19 Jan 2015 22:56:59 +0100
Subject: [PATCH] tests: drop bc dependency
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We already have a dependency on awk and bc is sometimes not found in the
base system.

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 doc/platform.texi | 4 +---
 tests/fate-run.sh | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/doc/platform.texi b/doc/platform.texi
index 300c9ad84b5..edd75770d6b 100644
--- a/doc/platform.texi
+++ b/doc/platform.texi
@@ -130,8 +130,6 @@ You will need the following prerequisites:
 @item @uref{http://msys2.github.io/, MSYS2}
 @item @uref{http://yasm.tortall.net/, YASM}
 (Also available via MSYS2's package manager.)
-@item @uref{http://gnuwin32.sourceforge.net/packages/bc.htm, bc for Windows} if
-you want to run @uref{fate.html, FATE}.
 @end itemize
 
 To set up a proper environment in MSYS2, you need to run @code{msys_shell.bat} from
@@ -278,7 +276,7 @@ binutils, gcc4-core, make, git, mingw-runtime, texi2html
 
 In order to run FATE you will also need the following "Utils" packages:
 @example
-bc, diffutils
+diffutils
 @end example
 
 If you want to build Libav with additional libraries, download Cygwin
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 91de177a2ae..f8de18290e0 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 ((v < 0 ? -v : v) > $3) }"
 }
 
 do_tiny_psnr(){
-- 
GitLab