not just on certain platforms.
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[])
@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 (<STDIN>) {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"
+ @<tmp.bntest sh -c "`sh ./bctest`" 2>&1 | $(PERL) -e '$$i=0; while (<STDIN>) {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)
# 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
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