From: Bodo Möller Date: Wed, 6 Dec 2000 10:32:55 +0000 (+0000) Subject: Use bc's "print" feature whenever it is available, X-Git-Tag: OpenSSL_0_9_6a-beta1~107^2~23 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=0a52d38b31ee56479c80509716c3bd46b764190a;hp=902d1051b140d6677e05a0e6eb8a429d2f81ee46;ds=sidebyside Use bc's "print" feature whenever it is available, not just on certain platforms. --- diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c index 12d68fc526..f27087d59c 100644 --- a/crypto/bn/bntest.c +++ b/crypto/bn/bntest.c @@ -109,11 +109,9 @@ static const char rnd_seed[] = "string to make the random number generator think static void message(BIO *out, char *m) { fprintf(stderr, "test %s\n", m); -#if defined(linux) || defined(__FreeBSD__) /* can we use GNU bc features? */ BIO_puts(out, "print \"test "); BIO_puts(out, m); BIO_puts(out, "\\n\"\n"); -#endif } int main(int argc, char *argv[]) diff --git a/test/Makefile.ssl b/test/Makefile.ssl index 867789847c..9b96f64062 100644 --- a/test/Makefile.ssl +++ b/test/Makefile.ssl @@ -195,12 +195,8 @@ test_bn: @echo starting big number library test, could take a while... @./$(BNTEST) >tmp.bntest @echo quit >>tmp.bntest - @if sh ./bctest; then \ - echo "running bc"; \ - bc tmp.bntest 2>&1 | $(PERL) -e 'while () {if (/^test (.*)/) {print STDERR "\nverify $$1";} elsif (!/^0$$/) {die "\nFailed! bc: $$_";} print STDERR "."; $$i++;} print STDERR "\n$$i tests passed\n"'; \ - else \ - echo "skipping bc-based verification"; \ - fi + @echo "running bc" + @&1 | $(PERL) -e '$$i=0; while () {if (/^test (.*)/) {print STDERR "\nverify $$1";} elsif (!/^0$$/) {die "\nFailed! bc: $$_";} print STDERR "."; $$i++;} print STDERR "\n$$i tests passed\n"' @echo 'test a^b%c implementations' ./$(EXPTEST) diff --git a/test/bctest b/test/bctest index 38e43efecc..33fa79d7cf 100755 --- a/test/bctest +++ b/test/bctest @@ -4,6 +4,11 @@ # is installed. # ('make test_bn' should not try to run 'bc' if it does not exist or if # it is the broken SunOS 5.[78] bc, which fails the following test.) +# +# If 'bc' works, we also test if it knows the 'print' command. +# +# In any case, output an appropriate command line for running (or not +# running) bc. if [ 0 != "`bc <<\EOF obase=16 @@ -22,7 +27,18 @@ b=DCE91E7D120B983EA9A104B5A96D634DD644C37657B1C7860B45E6838999B3DCE5A555583C6\ EOF`" ] then echo "bc does not work. Consider installing GNU bc." >&2 + echo "cat >/dev/null" exit 1 else + # bc works, good. + # Now check if it knows the 'print' command. + if [ "OK" = "`bc 2>/dev/null <<\EOF +print \"OK\" +EOF`" ] + then + echo "bc" + else + echo "sed 's/print.*//' | bc" + fi exit 0 fi