summaryrefslogtreecommitdiffstats
path: root/test/exptest.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2017-06-12 10:01:17 +1000
committerRich Salz <rsalz@openssl.org>2017-06-16 16:15:31 -0400
commit3791646202bb4da21992b0aecae253d394507a9e (patch)
treecc1f33ab05144ec2442df45366fac1175fcaca16 /test/exptest.c
parent5511101ad86fdd5bc3ad4f27143e93ae14737bfe (diff)
Add output routines to allow consistent formatting of memory, strings
and bignums. These have been refactored into their own file, along with their error displays. The formatting follows the output format used on error, except that bignums of sixty four bits or less are displayed in a more compact one line form. Added a TEST_note function for producing output without file and line information. Update the three tests that call BN_print so they use the new test infrastructure instead. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3655)
Diffstat (limited to 'test/exptest.c')
-rw-r--r--test/exptest.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/test/exptest.c b/test/exptest.c
index ee1bff168c..e6f52139a1 100644
--- a/test/exptest.c
+++ b/test/exptest.c
@@ -22,14 +22,7 @@
#define NUM_BITS (BN_BITS2 * 4)
-#define BN_print_var(v) bn_print_var(#v, v)
-
-static void bn_print_var(const char *var, const BIGNUM *bn)
-{
- fprintf(stderr, "%s (%3d) = ", var, BN_num_bits(bn));
- BN_print_fp(stderr, bn);
- fprintf(stderr, "\n");
-}
+#define BN_print_var(v) test_output_bignum(#v, v)
/*
* Test that r == 0 in test_exp_mod_zero(). Returns one on success,
@@ -39,8 +32,7 @@ static int a_is_zero_mod_one(const char *method, const BIGNUM *r,
const BIGNUM *a)
{
if (!BN_is_zero(r)) {
- fprintf(stderr, "%s failed:\n", method);
- fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n");
+ TEST_error("%s failed: a ** 0 mod 1 = r (should be 0)", method);
BN_print_var(a);
BN_print_var(r);
return 0;
@@ -110,8 +102,8 @@ static int test_mod_exp_zero()
goto err;
if (!TEST_BN_eq_zero(r)) {
- fprintf(stderr, "BN_mod_exp_mont_word failed:\n");
- fprintf(stderr, "1 ** 0 mod 1 = r (should be 0)\n");
+ TEST_error("BN_mod_exp_mont_word failed: "
+ "1 ** 0 mod 1 = r (should be 0)");
BN_print_var(r);
goto err;
}