aboutsummaryrefslogtreecommitdiff
path: root/test/test_test.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/test_test.c
parent5511101ad86fdd5bc3ad4f27143e93ae14737bfe (diff)
downloadopenssl-3791646202bb4da21992b0aecae253d394507a9e.zip
openssl-3791646202bb4da21992b0aecae253d394507a9e.tar.gz
openssl-3791646202bb4da21992b0aecae253d394507a9e.tar.bz2
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/test_test.c')
-rw-r--r--test/test_test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_test.c b/test/test_test.c
index a1b0456..051058f 100644
--- a/test/test_test.c
+++ b/test/test_test.c
@@ -477,6 +477,38 @@ static int test_single_eval(void)
&& TEST_mem_eq(p--, sizeof("456"), "456", sizeof("456"));
}
+static int test_output(void)
+{
+ const char s[] = "1234567890123456789012345678901234567890123456789012"
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ test_output_string("test", s, sizeof(s) - 1);
+ test_output_memory("test", (const unsigned char *)s, sizeof(s));
+ return 1;
+}
+
+static const char *bn_output_tests[] = {
+ NULL,
+ "0",
+ "-12345678",
+ "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789013"
+ "987657"
+};
+
+static int test_bn_output(int n)
+{
+ BIGNUM *b = NULL;
+
+ if (bn_output_tests[n] != NULL
+ && !TEST_true(BN_hex2bn(&b, bn_output_tests[n])))
+ return 0;
+ test_output_bignum(bn_output_tests[n], b);
+ BN_free(b);
+ return 1;
+}
+
+
void register_tests(void)
{
ADD_TEST(test_int);
@@ -496,4 +528,6 @@ void register_tests(void)
ADD_TEST(test_long_output);
ADD_TEST(test_messages);
ADD_TEST(test_single_eval);
+ ADD_TEST(test_output);
+ ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests));
}