X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fbctest;h=bdb3218f7acaa2cac934c96c62a402ba5677636c;hp=b9ef95bf8277dff67723ca2e5a8f81130c48fa8b;hb=1d97c8435171a7af575f73c526d79e1ef0ee5960;hpb=884e26080f494634728bfb599245d414f2787067 diff --git a/test/bctest b/test/bctest index b9ef95bf82..bdb3218f7a 100755 --- a/test/bctest +++ b/test/bctest @@ -11,9 +11,28 @@ # running) bc. -# Test for SunOS 5.[78] bc bug -SunOStest() { -${1} >tmp.bctest <<\EOF +IFS=: +try_without_dir=true +# First we try "bc", then "$dir/bc" for each item in $PATH. +for dir in dummy:$PATH; do + if [ "$try_without_dir" = true ]; then + # first iteration + bc=bc + try_without_dir=false + else + # second and later iterations + bc="$dir/bc" + if [ ! -f "$bc" ]; then # '-x' is not available on Ultrix + bc='' + fi + fi + + if [ ! "$bc" = '' ]; then + failure=none + + + # Test for SunOS 5.[78] bc bug + "$bc" >tmp.bctest <<\EOF obase=16 ibase=16 a=AD88C418F31B3FC712D0425001D522B3AE9134FF3A98C13C1FCC1682211195406C1A6C66C6A\ @@ -28,17 +47,14 @@ b=DCE91E7D120B983EA9A104B5A96D634DD644C37657B1C7860B45E6838999B3DCE5A555583C6\ 3ED0E2017D60A68775B75481449 (a/b)*b + (a%b) - a EOF -if [ 0 != "`cat tmp.bctest`" ] -then - # failure - return 1 -fi -} + if [ 0 != "`cat tmp.bctest`" ]; then + failure=SunOStest + fi -# Test for SCO bc bug. -SCOtest() { -${1} >tmp.bctest <<\EOF + if [ "$failure" = none ]; then + # Test for SCO bc bug. + "$bc" >tmp.bctest <<\EOF obase=16 ibase=16 -FFDD63BA1A4648F0D804F8A1C66C53F0D2110590E8A3907EC73B4AEC6F15AC177F176F2274D2\ @@ -65,21 +81,14 @@ F617E3145BBFBE9AFD0D6E437EA4FF6F04BC67C4F1458B4F0F47B64 - 1C2BBBB19B74E86FD32\ D97935A7E1A14AD209D6CF811F55C6DB83AA9E6DFECFCD6669DED7171EE22A40C6181615CAF3F\ 5296964 EOF -if [ "0 -0" != "`cat tmp.bctest`" ] -then - # failure - return 1 -fi -} - + if [ "0 +0" != "`cat tmp.bctest`" ]; then + failure=SCOtest + fi + fi -IFS=: -for dir in $PATH; do - bc="$dir/bc" - if [ -x "$bc" -a ! -d "$bc" ]; then - if SunOStest "$bc" && SCOtest "$bc"; then + if [ "$failure" = none ]; then # bc works; now check if it knows the 'print' command. if [ "OK" = "`echo 'print \"OK\"' | $bc 2>/dev/null`" ] then @@ -90,10 +99,13 @@ for dir in $PATH; do exit 0 fi - echo "$bc does not work properly. Looking for another bc ..." >&2 + echo "$bc does not work properly ('$failure' failed). Looking for another bc ..." >&2 fi done echo "No working bc found. Consider installing GNU bc." >&2 -echo "cat >/dev/null" +if [ "$1" = ignore ]; then + echo "cat >/dev/null" + exit 0 +fi exit 1