aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssl/test/testutil
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/test/testutil')
-rw-r--r--crypto/openssl/test/testutil/compare.c9
-rw-r--r--crypto/openssl/test/testutil/driver.c68
-rw-r--r--crypto/openssl/test/testutil/fake_random.c51
-rw-r--r--crypto/openssl/test/testutil/format_output.c98
-rw-r--r--crypto/openssl/test/testutil/helper.c9
-rw-r--r--crypto/openssl/test/testutil/load.c4
-rw-r--r--crypto/openssl/test/testutil/main.c1
-rw-r--r--crypto/openssl/test/testutil/options.c6
-rw-r--r--crypto/openssl/test/testutil/output.h42
-rw-r--r--crypto/openssl/test/testutil/provider.c49
-rw-r--r--crypto/openssl/test/testutil/random.c6
-rw-r--r--crypto/openssl/test/testutil/stanza.c17
-rw-r--r--crypto/openssl/test/testutil/tests.c184
-rw-r--r--crypto/openssl/test/testutil/testutil_init.c17
-rw-r--r--crypto/openssl/test/testutil/tu_local.h43
15 files changed, 299 insertions, 305 deletions
diff --git a/crypto/openssl/test/testutil/compare.c b/crypto/openssl/test/testutil/compare.c
index 067fb878b58e..a6fddd088f6d 100644
--- a/crypto/openssl/test/testutil/compare.c
+++ b/crypto/openssl/test/testutil/compare.c
@@ -14,8 +14,9 @@ static void strip_line_ends(char *str)
size_t i;
for (i = strlen(str);
- i > 0 && (str[i - 1] == '\n' || str[i - 1] == '\r');
- i--);
+ i > 0 && (str[i - 1] == '\n' || str[i - 1] == '\r');
+ i--)
+ ;
str[i] = '\0';
}
@@ -77,11 +78,11 @@ int compare_with_reference_file(BIO *membio, const char *reffile)
goto err;
}
if (!TEST_true(BIO_eof(file))
- || !TEST_true(BIO_eof(membio)))
+ || !TEST_true(BIO_eof(membio)))
goto err;
ret = 1;
- err:
+err:
BIO_free(file);
BIO_free(newfile);
return ret;
diff --git a/crypto/openssl/test/testutil/driver.c b/crypto/openssl/test/testutil/driver.c
index 346092b0046d..1097c68fc3da 100644
--- a/crypto/openssl/test/testutil/driver.c
+++ b/crypto/openssl/test/testutil/driver.c
@@ -17,24 +17,23 @@
#include "internal/nelem.h"
#include <openssl/bio.h>
-#include "platform.h" /* From libapps */
+#include "platform.h" /* From libapps */
#if defined(_WIN32) && !defined(__BORLANDC__)
-# define strdup _strdup
+#define strdup _strdup
#endif
-
/*
* Declares the structures needed to register each test case function.
*/
typedef struct test_info {
const char *test_case_name;
- int (*test_fn) (void);
+ int (*test_fn)(void);
int (*param_test_fn)(int idx);
int num;
/* flags */
- int subtest:1;
+ int subtest : 1;
} TEST_INFO;
static TEST_INFO all_tests[1024];
@@ -55,8 +54,7 @@ static int num_test_cases = 0;
static int process_shared_options(void);
-
-void add_test(const char *test_case_name, int (*test_fn) (void))
+void add_test(const char *test_case_name, int (*test_fn)(void))
{
assert(num_tests != OSSL_NELEM(all_tests));
all_tests[num_tests].test_case_name = test_case_name;
@@ -66,8 +64,8 @@ void add_test(const char *test_case_name, int (*test_fn) (void))
++num_test_cases;
}
-void add_all_tests(const char *test_case_name, int(*test_fn)(int idx),
- int num, int subtest)
+void add_all_tests(const char *test_case_name, int (*test_fn)(int idx),
+ int num, int subtest)
{
assert(num_tests != OSSL_NELEM(all_tests));
all_tests[num_tests].test_case_name = test_case_name;
@@ -99,7 +97,6 @@ static void set_seed(int s)
test_random_seed(seed);
}
-
int setup_test_framework(int argc, char *argv[])
{
char *test_rand_order = getenv("OPENSSL_TEST_RAND_ORDER");
@@ -132,7 +129,6 @@ int setup_test_framework(int argc, char *argv[])
return 1;
}
-
/*
* This can only be called after setup() has run, since num_tests and
* all_tests[] are setup at this point
@@ -151,7 +147,6 @@ static int check_single_test_params(char *name, char *testname, char *itname)
single_test = atoi(name);
}
-
/* if only iteration is specified, assume we want the first test */
if (single_test == -1 && single_iter != -1)
single_test = 1;
@@ -160,24 +155,24 @@ static int check_single_test_params(char *name, char *testname, char *itname)
if (single_test < 1 || single_test > num_tests) {
test_printf_stderr("Invalid -%s value "
"(Value must be a valid test name OR a value between %d..%d)\n",
- testname, 1, num_tests);
+ testname, 1, num_tests);
return 0;
}
}
if (single_iter != -1) {
if (all_tests[single_test - 1].num == -1) {
test_printf_stderr("-%s option is not valid for test %d:%s\n",
- itname,
- single_test,
- all_tests[single_test - 1].test_case_name);
+ itname,
+ single_test,
+ all_tests[single_test - 1].test_case_name);
return 0;
} else if (single_iter < 1
- || single_iter > all_tests[single_test - 1].num) {
+ || single_iter > all_tests[single_test - 1].num) {
test_printf_stderr("Invalid -%s value for test %d:%s\t"
"(Value must be in the range %d..%d)\n",
- itname, single_test,
- all_tests[single_test - 1].test_case_name,
- 1, all_tests[single_test - 1].num);
+ itname, single_test,
+ all_tests[single_test - 1].test_case_name,
+ 1, all_tests[single_test - 1].num);
return 0;
}
}
@@ -236,7 +231,6 @@ end:
return ret;
}
-
int pulldown_test_framework(int ret)
{
set_test_title(NULL);
@@ -259,8 +253,9 @@ void set_test_title(const char *title)
test_title = title == NULL ? NULL : strdup(title);
}
-PRINTF_FORMAT(2, 3) static void test_verdict(int verdict,
- const char *description, ...)
+PRINTF_FORMAT(2, 3)
+static void test_verdict(int verdict,
+ const char *description, ...)
{
va_list ap;
@@ -323,17 +318,16 @@ int run_tests(const char *test_prog_name)
for (ii = 0; ii != num_tests; ++ii) {
i = permute[ii];
- if (single_test != -1 && ((i+1) != single_test)) {
+ if (single_test != -1 && ((i + 1) != single_test)) {
continue;
- }
- else if (show_list) {
+ } else if (show_list) {
if (all_tests[i].num != -1) {
test_printf_tapout("%d - %s (%d..%d)\n", ii + 1,
- all_tests[i].test_case_name, 1,
- all_tests[i].num);
+ all_tests[i].test_case_name, 1,
+ all_tests[i].num);
} else {
test_printf_tapout("%d - %s\n", ii + 1,
- all_tests[i].test_case_name);
+ all_tests[i].test_case_name);
}
test_flush_tapout();
} else if (all_tests[i].num == -1) {
@@ -386,11 +380,11 @@ int run_tests(const char *test_prog_name)
if (all_tests[i].subtest)
test_verdict(v, "%d - iteration %d",
- subtest_case_count + 1, j + 1);
+ subtest_case_count + 1, j + 1);
else
test_verdict(v, "%d - %s - iteration %d",
- test_case_count + subtest_case_count + 1,
- test_title, j + 1);
+ test_case_count + subtest_case_count + 1,
+ test_title, j + 1);
subtest_case_count++;
}
@@ -402,7 +396,7 @@ int run_tests(const char *test_prog_name)
++num_failed;
if (all_tests[i].num == -1 || all_tests[i].subtest)
test_verdict(verdict, "%d - %s", test_case_count + 1,
- all_tests[i].test_case_name);
+ all_tests[i].test_case_name);
test_case_count++;
}
}
@@ -438,13 +432,13 @@ char *glue_strings(const char *list[], size_t *out_len)
char *test_mk_file_path(const char *dir, const char *file)
{
-# ifndef OPENSSL_SYS_VMS
+#ifndef OPENSSL_SYS_VMS
const char *sep = "/";
-# else
+#else
const char *sep = "";
char *dir_end;
char dir_end_sep;
-# endif
+#endif
size_t dirlen = dir != NULL ? strlen(dir) : 0;
size_t len = dirlen + strlen(sep) + strlen(file) + 1;
char *full_file = OPENSSL_zalloc(len);
@@ -452,7 +446,7 @@ char *test_mk_file_path(const char *dir, const char *file)
if (full_file != NULL) {
if (dir != NULL && dirlen > 0) {
OPENSSL_strlcpy(full_file, dir, len);
-# ifdef OPENSSL_SYS_VMS
+#ifdef OPENSSL_SYS_VMS
/*
* If |file| contains a directory spec, we need to do some
* careful merging.
diff --git a/crypto/openssl/test/testutil/fake_random.c b/crypto/openssl/test/testutil/fake_random.c
index b211f48625c2..5240a40f0ba2 100644
--- a/crypto/openssl/test/testutil/fake_random.c
+++ b/crypto/openssl/test/testutil/fake_random.c
@@ -33,7 +33,7 @@ static OSSL_FUNC_rand_get_ctx_params_fn fake_rand_get_ctx_params;
static OSSL_FUNC_rand_enable_locking_fn fake_rand_enable_locking;
static void *fake_rand_newctx(void *provctx, void *parent,
- const OSSL_DISPATCH *parent_dispatch)
+ const OSSL_DISPATCH *parent_dispatch)
{
FAKE_RAND *r = OPENSSL_zalloc(sizeof(*r));
@@ -48,10 +48,10 @@ static void fake_rand_freectx(void *vrng)
}
static int fake_rand_instantiate(void *vrng, ossl_unused unsigned int strength,
- ossl_unused int prediction_resistance,
- ossl_unused const unsigned char *pstr,
- size_t pstr_len,
- ossl_unused const OSSL_PARAM params[])
+ ossl_unused int prediction_resistance,
+ ossl_unused const unsigned char *pstr,
+ size_t pstr_len,
+ ossl_unused const OSSL_PARAM params[])
{
FAKE_RAND *frng = (FAKE_RAND *)vrng;
@@ -68,8 +68,8 @@ static int fake_rand_uninstantiate(void *vrng)
}
static int fake_rand_generate(void *vrng, unsigned char *out, size_t outlen,
- unsigned int strength, int prediction_resistance,
- const unsigned char *adin, size_t adinlen)
+ unsigned int strength, int prediction_resistance,
+ const unsigned char *adin, size_t adinlen)
{
FAKE_RAND *frng = (FAKE_RAND *)vrng;
size_t l;
@@ -113,7 +113,7 @@ static int fake_rand_get_ctx_params(ossl_unused void *vrng, OSSL_PARAM params[])
}
static const OSSL_PARAM *fake_rand_gettable_ctx_params(ossl_unused void *vrng,
- ossl_unused void *provctx)
+ ossl_unused void *provctx)
{
static const OSSL_PARAM known_gettable_ctx_params[] = {
OSSL_PARAM_int(OSSL_RAND_PARAM_STATE, NULL),
@@ -132,8 +132,8 @@ static const OSSL_DISPATCH fake_rand_functions[] = {
{ OSSL_FUNC_RAND_GENERATE, (void (*)(void))fake_rand_generate },
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void (*)(void))fake_rand_enable_locking },
{ OSSL_FUNC_RAND_GETTABLE_CTX_PARAMS,
- (void(*)(void))fake_rand_gettable_ctx_params },
- { OSSL_FUNC_RAND_GET_CTX_PARAMS, (void(*)(void))fake_rand_get_ctx_params },
+ (void (*)(void))fake_rand_gettable_ctx_params },
+ { OSSL_FUNC_RAND_GET_CTX_PARAMS, (void (*)(void))fake_rand_get_ctx_params },
OSSL_DISPATCH_END
};
@@ -143,8 +143,8 @@ static const OSSL_ALGORITHM fake_rand_rand[] = {
};
static const OSSL_ALGORITHM *fake_rand_query(void *provctx,
- int operation_id,
- int *no_cache)
+ int operation_id,
+ int *no_cache)
{
*no_cache = 0;
switch (operation_id) {
@@ -162,8 +162,8 @@ static const OSSL_DISPATCH fake_rand_method[] = {
};
static int fake_rand_provider_init(const OSSL_CORE_HANDLE *handle,
- const OSSL_DISPATCH *in,
- const OSSL_DISPATCH **out, void **provctx)
+ const OSSL_DISPATCH *in,
+ const OSSL_DISPATCH **out, void **provctx)
{
if (!TEST_ptr(*provctx = OSSL_LIB_CTX_new()))
return 0;
@@ -190,15 +190,15 @@ OSSL_PROVIDER *fake_rand_start(OSSL_LIB_CTX *libctx)
OSSL_PROVIDER *p;
if (!TEST_true(OSSL_PROVIDER_add_builtin(libctx, "fake-rand",
- fake_rand_provider_init))
- || !TEST_true(RAND_set_DRBG_type(libctx, "fake", NULL, NULL, NULL))
- || !TEST_ptr(p = OSSL_PROVIDER_try_load(libctx, "fake-rand", 1)))
+ fake_rand_provider_init))
+ || !TEST_true(RAND_set_DRBG_type(libctx, "fake", NULL, NULL, NULL))
+ || !TEST_ptr(p = OSSL_PROVIDER_try_load(libctx, "fake-rand", 1)))
return NULL;
/* Ensure that the fake rand is initialized. */
if (!TEST_true(check_rng(RAND_get0_primary(libctx), "primary"))
- || !TEST_true(check_rng(RAND_get0_private(libctx), "private"))
- || !TEST_true(check_rng(RAND_get0_public(libctx), "public"))) {
+ || !TEST_true(check_rng(RAND_get0_private(libctx), "private"))
+ || !TEST_true(check_rng(RAND_get0_public(libctx), "public"))) {
OSSL_PROVIDER_unload(p);
return NULL;
}
@@ -212,20 +212,19 @@ void fake_rand_finish(OSSL_PROVIDER *p)
}
void fake_rand_set_callback(EVP_RAND_CTX *rng,
- int (*cb)(unsigned char *out, size_t outlen,
- const char *name, EVP_RAND_CTX *ctx))
+ int (*cb)(unsigned char *out, size_t outlen,
+ const char *name, EVP_RAND_CTX *ctx))
{
if (rng != NULL)
((FAKE_RAND *)rng->algctx)->cb = cb;
}
void fake_rand_set_public_private_callbacks(OSSL_LIB_CTX *libctx,
- int (*cb)(unsigned char *out,
- size_t outlen,
- const char *name,
- EVP_RAND_CTX *ctx))
+ int (*cb)(unsigned char *out,
+ size_t outlen,
+ const char *name,
+ EVP_RAND_CTX *ctx))
{
fake_rand_set_callback(RAND_get0_private(libctx), cb);
fake_rand_set_callback(RAND_get0_public(libctx), cb);
}
-
diff --git a/crypto/openssl/test/testutil/format_output.c b/crypto/openssl/test/testutil/format_output.c
index 8e84e1a6b6a6..bfab6babbcf2 100644
--- a/crypto/openssl/test/testutil/format_output.c
+++ b/crypto/openssl/test/testutil/format_output.c
@@ -15,9 +15,9 @@
#include <ctype.h>
/* The size of memory buffers to display on failure */
-#define MEM_BUFFER_SIZE (2000)
-#define MAX_STRING_WIDTH (80)
-#define BN_OUTPUT_SIZE (8)
+#define MEM_BUFFER_SIZE (2000)
+#define MAX_STRING_WIDTH (80)
+#define BN_OUTPUT_SIZE (8)
/* Output a diff header */
static void test_diff_header(const char *left, const char *right)
@@ -36,13 +36,12 @@ static void test_string_null_empty(const char *m, char c)
}
static void test_fail_string_common(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const char *m1, size_t l1,
- const char *m2, size_t l2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const char *m1, size_t l1,
+ const char *m2, size_t l2)
{
- const size_t width =
- (MAX_STRING_WIDTH - BIO_get_indent(bio_err) - 12) / 16 * 16;
+ const size_t width = (MAX_STRING_WIDTH - BIO_get_indent(bio_err) - 12) / 16 * 16;
char b1[MAX_STRING_WIDTH + 1], b2[MAX_STRING_WIDTH + 1];
char bdiff[MAX_STRING_WIDTH + 1];
size_t n1, n2, i;
@@ -101,7 +100,7 @@ static void test_fail_string_common(const char *prefix, const char *file,
else if (n1 > 0)
test_printf_stderr("%4u:- '%s'\n", cnt, b1);
if (cnt == 0 && (m2 == NULL || *m2 == '\0'))
- test_string_null_empty(m2, '+');
+ test_string_null_empty(m2, '+');
else if (n2 > 0)
test_printf_stderr("%4u:+ '%s'\n", cnt, b2);
if (diff && i > 0)
@@ -125,20 +124,20 @@ fin:
* fails. The second is the user's call to dump a string.
*/
void test_fail_string_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const char *m1, size_t l1,
- const char *m2, size_t l2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const char *m1, size_t l1,
+ const char *m2, size_t l2)
{
test_fail_string_common(prefix, file, line, type, left, right, op,
- m1, l1, m2, l2);
+ m1, l1, m2, l2);
test_printf_stderr("\n");
}
void test_output_string(const char *name, const char *m, size_t l)
{
test_fail_string_common("string", NULL, 0, NULL, NULL, NULL, name,
- m, l, m, l);
+ m, l, m, l);
}
/* BIGNUM formatted output routines */
@@ -148,7 +147,7 @@ void test_output_string(const char *name, const char *m, size_t l)
* every so often.
*/
static void hex_convert_memory(const unsigned char *m, size_t n, char *b,
- size_t width)
+ size_t width)
{
size_t i;
@@ -168,9 +167,10 @@ static void hex_convert_memory(const unsigned char *m, size_t n, char *b,
* of characters these take.
*/
static const int bn_bytes = (MAX_STRING_WIDTH - 9) / (BN_OUTPUT_SIZE * 2 + 1)
- * BN_OUTPUT_SIZE;
+ * BN_OUTPUT_SIZE;
static const int bn_chars = (MAX_STRING_WIDTH - 9) / (BN_OUTPUT_SIZE * 2 + 1)
- * (BN_OUTPUT_SIZE * 2 + 1) - 1;
+ * (BN_OUTPUT_SIZE * 2 + 1)
+ - 1;
/*
* Output the header line for the bignum
@@ -204,7 +204,7 @@ static void test_bignum_zero_print(const BIGNUM *bn, char sep)
* string with appropriate visual aid spaces inserted.
*/
static int convert_bn_memory(const unsigned char *in, size_t bytes,
- char *out, int *lz, const BIGNUM *bn)
+ char *out, int *lz, const BIGNUM *bn)
{
int n = bytes * 2, i;
char *p = out, *q = NULL;
@@ -241,7 +241,7 @@ static int convert_bn_memory(const unsigned char *in, size_t bytes,
}
}
}
- return n;
+ return n;
}
for (i = 0; i < n; i++) {
@@ -263,10 +263,10 @@ static int convert_bn_memory(const unsigned char *in, size_t bytes,
* pointers for changes (only when there are two).
*/
static void test_fail_bignum_common(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const BIGNUM *bn1, const BIGNUM *bn2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const BIGNUM *bn1, const BIGNUM *bn2)
{
const size_t bytes = bn_bytes;
char b1[MAX_STRING_WIDTH + 1], b2[MAX_STRING_WIDTH + 1];
@@ -322,7 +322,7 @@ static void test_fail_bignum_common(const char *prefix, const char *file,
diff = real_diff = 0;
i = 0;
p = bdiff;
- for (i=0; b1[i] != '\0'; i++)
+ for (i = 0; b1[i] != '\0'; i++)
if (b1[i] == b2[i] || b1[i] == ' ' || b2[i] == ' ') {
*p++ = ' ';
diff |= b1[i] != b2[i];
@@ -343,7 +343,7 @@ static void test_fail_bignum_common(const char *prefix, const char *file,
else if (cnt == 0 || n2 > 0)
test_printf_stderr("+%s:% 5d\n", b2, cnt);
if (real_diff && (cnt == 0 || (n1 > 0 && n2 > 0))
- && bn1 != NULL && bn2 != NULL)
+ && bn1 != NULL && bn2 != NULL)
test_printf_stderr(" %s\n", bdiff);
}
if (m1 != NULL)
@@ -364,19 +364,19 @@ fin:
* fails. The third is the user's call to dump a bignum.
*/
void test_fail_bignum_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const BIGNUM *bn1, const BIGNUM *bn2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const BIGNUM *bn1, const BIGNUM *bn2)
{
test_fail_bignum_common(prefix, file, line, type, left, right, op, bn1, bn2);
test_printf_stderr("\n");
}
void test_fail_bignum_mono_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const BIGNUM *bn)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const BIGNUM *bn)
{
test_fail_bignum_common(prefix, file, line, type, left, right, op, bn, bn);
test_printf_stderr("\n");
@@ -386,7 +386,7 @@ void test_output_bignum(const char *name, const BIGNUM *bn)
{
if (bn == NULL || BN_is_zero(bn)) {
test_printf_stderr("bignum: '%s' = %s\n", name,
- test_bignum_zero_null(bn));
+ test_bignum_zero_null(bn));
} else if (BN_num_bytes(bn) <= BN_OUTPUT_SIZE) {
unsigned char buf[BN_OUTPUT_SIZE];
char out[2 * sizeof(buf) + 1];
@@ -397,10 +397,10 @@ void test_output_bignum(const char *name, const BIGNUM *bn)
while (*p == '0' && *++p != '\0')
;
test_printf_stderr("bignum: '%s' = %s0x%s\n", name,
- BN_is_negative(bn) ? "-" : "", p);
+ BN_is_negative(bn) ? "-" : "", p);
} else {
test_fail_bignum_common("bignum", NULL, 0, NULL, NULL, NULL, name,
- bn, bn);
+ bn, bn);
}
}
@@ -421,11 +421,11 @@ static void test_memory_null_empty(const unsigned char *m, char c)
* Common code to display one or two blocks of memory.
*/
static void test_fail_memory_common(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const unsigned char *m1, size_t l1,
- const unsigned char *m2, size_t l2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const unsigned char *m1, size_t l1,
+ const unsigned char *m2, size_t l2)
{
const size_t bytes = (MAX_STRING_WIDTH - 9) / 17 * 8;
char b1[MAX_STRING_WIDTH + 1], b2[MAX_STRING_WIDTH + 1];
@@ -516,19 +516,19 @@ fin:
* fails. The second is the user's call to dump memory.
*/
void test_fail_memory_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const unsigned char *m1, size_t l1,
- const unsigned char *m2, size_t l2)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const unsigned char *m1, size_t l1,
+ const unsigned char *m2, size_t l2)
{
test_fail_memory_common(prefix, file, line, type, left, right, op,
- m1, l1, m2, l2);
+ m1, l1, m2, l2);
test_printf_stderr("\n");
}
void test_output_memory(const char *name, const unsigned char *m, size_t l)
{
test_fail_memory_common("memory", NULL, 0, NULL, NULL, NULL, name,
- m, l, m, l);
+ m, l, m, l);
}
diff --git a/crypto/openssl/test/testutil/helper.c b/crypto/openssl/test/testutil/helper.c
index 9c985e25a8be..466ceca26f56 100644
--- a/crypto/openssl/test/testutil/helper.c
+++ b/crypto/openssl/test/testutil/helper.c
@@ -16,11 +16,11 @@
* tweak for Windows
*/
#ifdef WIN32
-# define timezone _timezone
+#define timezone _timezone
#endif
#if defined(__FreeBSD__) || defined(__wasi__)
-# define USE_TIMEGM
+#define USE_TIMEGM
#endif
time_t test_asn1_string_to_time_t(const char *asn1_string)
@@ -35,10 +35,9 @@ time_t test_asn1_string_to_time_t(const char *asn1_string)
time_t timestamp_utc;
timestamp_asn1 = ASN1_TIME_new();
- if(timestamp_asn1 == NULL)
+ if (timestamp_asn1 == NULL)
return -1;
- if (!ASN1_TIME_set_string(timestamp_asn1, asn1_string))
- {
+ if (!ASN1_TIME_set_string(timestamp_asn1, asn1_string)) {
ASN1_TIME_free(timestamp_asn1);
return -1;
}
diff --git a/crypto/openssl/test/testutil/load.c b/crypto/openssl/test/testutil/load.c
index 982e0a39a9b2..27496ca6257d 100644
--- a/crypto/openssl/test/testutil/load.c
+++ b/crypto/openssl/test/testutil/load.c
@@ -23,7 +23,7 @@ X509 *load_cert_pem(const char *file, OSSL_LIB_CTX *libctx)
if (!TEST_ptr(file) || !TEST_ptr(bio = BIO_new(BIO_s_file())))
return NULL;
if (TEST_int_gt(BIO_read_filename(bio, file), 0)
- && TEST_ptr(cert = X509_new_ex(libctx, NULL)))
+ && TEST_ptr(cert = X509_new_ex(libctx, NULL)))
(void)TEST_ptr(cert = PEM_read_bio_X509(bio, &cert, NULL, NULL));
BIO_free(bio);
@@ -77,7 +77,7 @@ EVP_PKEY *load_pkey_pem(const char *file, OSSL_LIB_CTX *libctx)
unsigned long err = ERR_peek_error();
if (TEST_ptr(key = PEM_read_bio_PrivateKey_ex(bio, NULL, NULL, NULL,
- libctx, NULL))
+ libctx, NULL))
&& err != ERR_peek_error()) {
TEST_info("Spurious error from reading PEM");
EVP_PKEY_free(key);
diff --git a/crypto/openssl/test/testutil/main.c b/crypto/openssl/test/testutil/main.c
index 32e32d832872..4d18eb2c43e7 100644
--- a/crypto/openssl/test/testutil/main.c
+++ b/crypto/openssl/test/testutil/main.c
@@ -11,7 +11,6 @@
#include "output.h"
#include "tu_local.h"
-
int main(int argc, char *argv[])
{
int ret = EXIT_FAILURE;
diff --git a/crypto/openssl/test/testutil/options.c b/crypto/openssl/test/testutil/options.c
index 35dfa320c48b..37be4facac33 100644
--- a/crypto/openssl/test/testutil/options.c
+++ b/crypto/openssl/test/testutil/options.c
@@ -12,7 +12,6 @@
#include "tu_local.h"
#include "output.h"
-
static int used[100] = { 0 };
int test_skip_common_options(void)
@@ -22,7 +21,7 @@ int test_skip_common_options(void)
while ((o = (OPTION_CHOICE_DEFAULT)opt_next()) != OPT_EOF) {
switch (o) {
case OPT_TEST_CASES:
- break;
+ break;
default:
case OPT_ERR:
return 0;
@@ -60,7 +59,7 @@ void opt_check_usage(void)
for (i = 0; i < n; i++) {
if (used[i] == 0)
test_printf_stderr("Warning ignored command-line argument %d: %s\n",
- i, argv[i]);
+ i, argv[i]);
}
if (i < arg_count)
test_printf_stderr("Warning arguments %d and later unchecked\n", i);
@@ -76,4 +75,3 @@ int opt_printf_stderr(const char *fmt, ...)
va_end(ap);
return ret;
}
-
diff --git a/crypto/openssl/test/testutil/output.h b/crypto/openssl/test/testutil/output.h
index 0e4de09704f8..cee3026b11e3 100644
--- a/crypto/openssl/test/testutil/output.h
+++ b/crypto/openssl/test/testutil/output.h
@@ -8,28 +8,28 @@
*/
#ifndef OSSL_TESTUTIL_OUTPUT_H
-# define OSSL_TESTUTIL_OUTPUT_H
+#define OSSL_TESTUTIL_OUTPUT_H
-# include <stdarg.h>
+#include <stdarg.h>
-# define ossl_test__attr__(x)
-# if defined(__GNUC__) && defined(__STDC_VERSION__) \
+#define ossl_test__attr__(x)
+#if defined(__GNUC__) && defined(__STDC_VERSION__) \
&& !defined(__MINGW32__) && !defined(__MINGW64__) \
&& !defined(__APPLE__)
- /*
- * Because we support the 'z' modifier, which made its appearance in C99,
- * we can't use __attribute__ with pre C99 dialects.
- */
-# if __STDC_VERSION__ >= 199901L
-# undef ossl_test__attr__
-# define ossl_test__attr__ __attribute__
-# if __GNUC__*10 + __GNUC_MINOR__ >= 44
-# define ossl_test__printf__ __gnu_printf__
-# else
-# define ossl_test__printf__ __printf__
-# endif
-# endif
-# endif
+/*
+ * Because we support the 'z' modifier, which made its appearance in C99,
+ * we can't use __attribute__ with pre C99 dialects.
+ */
+#if __STDC_VERSION__ >= 199901L
+#undef ossl_test__attr__
+#define ossl_test__attr__ __attribute__
+#if __GNUC__ * 10 + __GNUC_MINOR__ >= 44
+#define ossl_test__printf__ __gnu_printf__
+#else
+#define ossl_test__printf__ __printf__
+#endif
+#endif
+#endif
/*
* The basic I/O functions used internally by the test framework. These
* can be overridden when needed. Note that if one is, then all must be.
@@ -62,7 +62,7 @@ int test_printf_stderr(const char *fmt, ...)
int test_printf_taperr(const char *fmt, ...)
ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
-# undef ossl_test__printf__
-# undef ossl_test__attr__
+#undef ossl_test__printf__
+#undef ossl_test__attr__
-#endif /* OSSL_TESTUTIL_OUTPUT_H */
+#endif /* OSSL_TESTUTIL_OUTPUT_H */
diff --git a/crypto/openssl/test/testutil/provider.c b/crypto/openssl/test/testutil/provider.c
index 79ae13b42a1f..9d91e804fdc5 100644
--- a/crypto/openssl/test/testutil/provider.c
+++ b/crypto/openssl/test/testutil/provider.c
@@ -14,8 +14,8 @@
#include <string.h>
int test_get_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
- const char *config_file,
- OSSL_PROVIDER **provider, const char *module_name)
+ const char *config_file,
+ OSSL_PROVIDER **provider, const char *module_name)
{
OSSL_LIB_CTX *new_libctx = NULL;
@@ -33,25 +33,25 @@ int test_get_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
}
if (config_file != NULL
- && !OSSL_LIB_CTX_load_config(new_libctx, config_file)) {
+ && !OSSL_LIB_CTX_load_config(new_libctx, config_file)) {
opt_printf_stderr("Error loading config from file %s\n", config_file);
goto err;
}
if (provider != NULL && module_name != NULL
- && (*provider = OSSL_PROVIDER_load(new_libctx, module_name)) == NULL) {
+ && (*provider = OSSL_PROVIDER_load(new_libctx, module_name)) == NULL) {
opt_printf_stderr("Failed to load provider %s\n", module_name);
goto err;
}
return 1;
- err:
+err:
ERR_print_errors_fp(stderr);
return 0;
}
int test_arg_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
- OSSL_PROVIDER **provider, int argn, const char *usage)
+ OSSL_PROVIDER **provider, int argn, const char *usage)
{
const char *module_name;
@@ -62,7 +62,7 @@ int test_arg_libctx(OSSL_LIB_CTX **libctx, OSSL_PROVIDER **default_null_prov,
if (strcmp(module_name, "none") == 0)
return 1;
return test_get_libctx(libctx, default_null_prov,
- test_get_argument(argn + 1), provider, module_name);
+ test_get_argument(argn + 1), provider, module_name);
}
typedef struct {
@@ -86,12 +86,12 @@ static int fips_provider_version(OSSL_LIB_CTX *libctx, FIPS_VERSION *vers)
if ((fips_prov = OSSL_PROVIDER_load(libctx, "fips")) == NULL)
return -1;
if (!OSSL_PROVIDER_get_params(fips_prov, params)
- || sscanf(vs, "%d.%d.%d", &vers->major, &vers->minor, &vers->patch) != 3)
+ || sscanf(vs, "%d.%d.%d", &vers->major, &vers->minor, &vers->patch) != 3)
goto err;
if (!OSSL_PROVIDER_unload(fips_prov))
return -1;
return 1;
- err:
+err:
OSSL_PROVIDER_unload(fips_prov);
return -1;
}
@@ -124,9 +124,9 @@ int fips_provider_version_le(OSSL_LIB_CTX *libctx, int major, int minor, int pat
if ((res = fips_provider_version(libctx, &prov)) <= 0)
return res == 0;
return prov.major < major
- || (prov.major == major
- && (prov.minor < minor
- || (prov.minor == minor && prov.patch <= patch)));
+ || (prov.major == major
+ && (prov.minor < minor
+ || (prov.minor == minor && prov.patch <= patch)));
}
int fips_provider_version_lt(OSSL_LIB_CTX *libctx, int major, int minor, int patch)
@@ -137,9 +137,9 @@ int fips_provider_version_lt(OSSL_LIB_CTX *libctx, int major, int minor, int pat
if ((res = fips_provider_version(libctx, &prov)) <= 0)
return res == 0;
return prov.major < major
- || (prov.major == major
- && (prov.minor < minor
- || (prov.minor == minor && prov.patch < patch)));
+ || (prov.major == major
+ && (prov.minor < minor
+ || (prov.minor == minor && prov.patch < patch)));
}
int fips_provider_version_gt(OSSL_LIB_CTX *libctx, int major, int minor, int patch)
@@ -150,9 +150,9 @@ int fips_provider_version_gt(OSSL_LIB_CTX *libctx, int major, int minor, int pat
if ((res = fips_provider_version(libctx, &prov)) <= 0)
return res == 0;
return prov.major > major
- || (prov.major == major
- && (prov.minor > minor
- || (prov.minor == minor && prov.patch > patch)));
+ || (prov.major == major
+ && (prov.minor > minor
+ || (prov.minor == minor && prov.patch > patch)));
}
int fips_provider_version_ge(OSSL_LIB_CTX *libctx, int major, int minor, int patch)
@@ -163,9 +163,9 @@ int fips_provider_version_ge(OSSL_LIB_CTX *libctx, int major, int minor, int pat
if ((res = fips_provider_version(libctx, &prov)) <= 0)
return res == 0;
return prov.major > major
- || (prov.major == major
- && (prov.minor > minor
- || (prov.minor == minor && prov.patch >= patch)));
+ || (prov.major == major
+ && (prov.minor > minor
+ || (prov.minor == minor && prov.patch >= patch)));
}
int fips_provider_version_match(OSSL_LIB_CTX *libctx, const char *versions)
@@ -173,7 +173,12 @@ int fips_provider_version_match(OSSL_LIB_CTX *libctx, const char *versions)
const char *p;
int major, minor, patch, r;
enum {
- MODE_EQ, MODE_NE, MODE_LE, MODE_LT, MODE_GT, MODE_GE
+ MODE_EQ,
+ MODE_NE,
+ MODE_LE,
+ MODE_LT,
+ MODE_GT,
+ MODE_GE
} mode;
while (*versions != '\0') {
diff --git a/crypto/openssl/test/testutil/random.c b/crypto/openssl/test/testutil/random.c
index 45d0bb5f0589..f3435ab20526 100644
--- a/crypto/openssl/test/testutil/random.c
+++ b/crypto/openssl/test/testutil/random.c
@@ -16,7 +16,8 @@
*/
static uint32_t test_random_state[31];
-uint32_t test_random(void) {
+uint32_t test_random(void)
+{
static unsigned int pos = 3;
if (pos == 31)
@@ -25,7 +26,8 @@ uint32_t test_random(void) {
return test_random_state[pos++] / 2;
}
-void test_random_seed(uint32_t sd) {
+void test_random_seed(uint32_t sd)
+{
int i;
int32_t s;
const unsigned int mod = (1u << 31) - 1;
diff --git a/crypto/openssl/test/testutil/stanza.c b/crypto/openssl/test/testutil/stanza.c
index f1ddfde028cc..a41dcbed25b5 100644
--- a/crypto/openssl/test/testutil/stanza.c
+++ b/crypto/openssl/test/testutil/stanza.c
@@ -30,7 +30,7 @@ int test_start_file(STANZA *s, const char *testfile)
int test_end_file(STANZA *s)
{
TEST_info("Completed %d tests with %d errors and %d skipped",
- s->numtests, s->errors, s->numskip);
+ s->numtests, s->errors, s->numskip);
BIO_free(s->fp);
return 1;
}
@@ -61,7 +61,6 @@ static int read_key(STANZA *s)
return 0;
}
-
/*
* Delete leading and trailing spaces from a string
*/
@@ -75,7 +74,7 @@ static char *strip_spaces(char *p)
if (*p == '\0')
return NULL;
- for (q = p + strlen(p) - 1; q != p && isspace((unsigned char)*q); )
+ for (q = p + strlen(p) - 1; q != p && isspace((unsigned char)*q);)
*q-- = '\0';
return *p ? p : NULL;
}
@@ -90,7 +89,7 @@ int test_readstanza(STANZA *s)
const char *value;
static char buff[131072];
- for (s->numpairs = 0; BIO_gets(s->fp, buff, sizeof(buff)); ) {
+ for (s->numpairs = 0; BIO_gets(s->fp, buff, sizeof(buff));) {
s->curr++;
if (!TEST_ptr(p = strchr(buff, '\n'))) {
TEST_info("Line %d too long", s->curr);
@@ -128,15 +127,15 @@ int test_readstanza(STANZA *s)
s->start = s->curr;
if (strcmp(key, "PrivateKey") == 0
- || strcmp(key, "PublicKey") == 0
- || strcmp(key, "ParamKey") == 0) {
+ || strcmp(key, "PublicKey") == 0
+ || strcmp(key, "ParamKey") == 0) {
if (!read_key(s))
return 0;
}
if (!TEST_int_lt(s->numpairs++, TESTMAXPAIRS)
- || !TEST_ptr(pp->key = OPENSSL_strdup(key))
- || !TEST_ptr(pp->value = OPENSSL_strdup(value)))
+ || !TEST_ptr(pp->key = OPENSSL_strdup(key))
+ || !TEST_ptr(pp->value = OPENSSL_strdup(value)))
return 0;
pp++;
}
@@ -150,7 +149,7 @@ void test_clearstanza(STANZA *s)
PAIR *pp = s->pairs;
int i = s->numpairs;
- for ( ; --i >= 0; pp++) {
+ for (; --i >= 0; pp++) {
OPENSSL_free(pp->key);
OPENSSL_free(pp->value);
}
diff --git a/crypto/openssl/test/testutil/tests.c b/crypto/openssl/test/testutil/tests.c
index 42a3b855c0ce..f67b5ce4bfa7 100644
--- a/crypto/openssl/test/testutil/tests.c
+++ b/crypto/openssl/test/testutil/tests.c
@@ -23,9 +23,9 @@
* and right where a non-failure message is produced if either is NULL.
*/
void test_fail_message_prefix(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op)
{
test_printf_stderr("%s: ", prefix != NULL ? prefix : "ERROR");
if (type)
@@ -66,15 +66,15 @@ void test_fail_message_prefix(const char *prefix, const char *file,
* FAIL oops: (int) value 3 is not 6\n
*/
static void test_fail_message(const char *prefix, const char *file, int line,
- const char *type, const char *left,
- const char *right, const char *op,
- const char *fmt, ...)
- PRINTF_FORMAT(8, 9);
+ const char *type, const char *left,
+ const char *right, const char *op,
+ const char *fmt, ...)
+ PRINTF_FORMAT(8, 9);
static void test_fail_message_va(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const char *fmt, va_list ap)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const char *fmt, va_list ap)
{
test_fail_message_prefix(prefix, file, line, type, left, right, op);
if (fmt != NULL) {
@@ -85,9 +85,9 @@ static void test_fail_message_va(const char *prefix, const char *file,
}
static void test_fail_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const char *fmt, ...)
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const char *fmt, ...)
{
va_list ap;
@@ -157,7 +157,6 @@ void test_note(const char *fmt, ...)
test_flush_stderr();
}
-
int test_skip(const char *file, int line, const char *desc, ...)
{
va_list ap;
@@ -179,7 +178,6 @@ int test_skip_c90(const char *desc, ...)
return TEST_SKIP_CODE;
}
-
void test_openssl_errors(void)
{
ERR_print_errors_cb(openssl_error_cb, NULL);
@@ -208,25 +206,25 @@ void test_openssl_errors(void)
* The desc argument is a printf format string followed by its arguments and
* this is included in the output if the condition being tested for is false.
*/
-#define DEFINE_COMPARISON(type, name, opname, op, fmt, cast) \
- int test_ ## name ## _ ## opname(const char *file, int line, \
- const char *s1, const char *s2, \
- const type t1, const type t2) \
- { \
- if (t1 op t2) \
- return 1; \
- test_fail_message(NULL, file, line, #type, s1, s2, #op, \
- "[" fmt "] compared to [" fmt "]", \
- (cast)t1, (cast)t2); \
- return 0; \
+#define DEFINE_COMPARISON(type, name, opname, op, fmt, cast) \
+ int test_##name##_##opname(const char *file, int line, \
+ const char *s1, const char *s2, \
+ const type t1, const type t2) \
+ { \
+ if (t1 op t2) \
+ return 1; \
+ test_fail_message(NULL, file, line, #type, s1, s2, #op, \
+ "[" fmt "] compared to [" fmt "]", \
+ (cast)t1, (cast)t2); \
+ return 0; \
}
-#define DEFINE_COMPARISONS(type, name, fmt, cast) \
- DEFINE_COMPARISON(type, name, eq, ==, fmt, cast) \
- DEFINE_COMPARISON(type, name, ne, !=, fmt, cast) \
- DEFINE_COMPARISON(type, name, lt, <, fmt, cast) \
- DEFINE_COMPARISON(type, name, le, <=, fmt, cast) \
- DEFINE_COMPARISON(type, name, gt, >, fmt, cast) \
+#define DEFINE_COMPARISONS(type, name, fmt, cast) \
+ DEFINE_COMPARISON(type, name, eq, ==, fmt, cast) \
+ DEFINE_COMPARISON(type, name, ne, !=, fmt, cast) \
+ DEFINE_COMPARISON(type, name, lt, <, fmt, cast) \
+ DEFINE_COMPARISON(type, name, le, <=, fmt, cast) \
+ DEFINE_COMPARISON(type, name, gt, >, fmt, cast) \
DEFINE_COMPARISON(type, name, ge, >=, fmt, cast)
DEFINE_COMPARISONS(int, int, "%d", int)
@@ -276,76 +274,76 @@ int test_false(const char *file, int line, const char *s, int b)
}
int test_str_eq(const char *file, int line, const char *st1, const char *st2,
- const char *s1, const char *s2)
+ const char *s1, const char *s2)
{
if (s1 == NULL && s2 == NULL)
- return 1;
+ return 1;
if (s1 == NULL || s2 == NULL || strcmp(s1, s2) != 0) {
test_fail_string_message(NULL, file, line, "string", st1, st2, "==",
- s1, s1 == NULL ? 0 : strlen(s1),
- s2, s2 == NULL ? 0 : strlen(s2));
+ s1, s1 == NULL ? 0 : strlen(s1),
+ s2, s2 == NULL ? 0 : strlen(s2));
return 0;
}
return 1;
}
int test_str_ne(const char *file, int line, const char *st1, const char *st2,
- const char *s1, const char *s2)
+ const char *s1, const char *s2)
{
if ((s1 == NULL) ^ (s2 == NULL))
- return 1;
+ return 1;
if (s1 == NULL || strcmp(s1, s2) == 0) {
test_fail_string_message(NULL, file, line, "string", st1, st2, "!=",
- s1, s1 == NULL ? 0 : strlen(s1),
- s2, s2 == NULL ? 0 : strlen(s2));
+ s1, s1 == NULL ? 0 : strlen(s1),
+ s2, s2 == NULL ? 0 : strlen(s2));
return 0;
}
return 1;
}
int test_strn_eq(const char *file, int line, const char *st1, const char *st2,
- const char *s1, size_t n1, const char *s2, size_t n2)
+ const char *s1, size_t n1, const char *s2, size_t n2)
{
if (s1 == NULL && s2 == NULL)
- return 1;
+ return 1;
if (n1 != n2 || s1 == NULL || s2 == NULL || strncmp(s1, s2, n1) != 0) {
test_fail_string_message(NULL, file, line, "string", st1, st2, "==",
- s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
- s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+ s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
+ s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
return 0;
}
return 1;
}
int test_strn_ne(const char *file, int line, const char *st1, const char *st2,
- const char *s1, size_t n1, const char *s2, size_t n2)
+ const char *s1, size_t n1, const char *s2, size_t n2)
{
if ((s1 == NULL) ^ (s2 == NULL))
- return 1;
+ return 1;
if (n1 != n2 || s1 == NULL || strncmp(s1, s2, n1) == 0) {
test_fail_string_message(NULL, file, line, "string", st1, st2, "!=",
- s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
- s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+ s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
+ s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
return 0;
}
return 1;
}
int test_mem_eq(const char *file, int line, const char *st1, const char *st2,
- const void *s1, size_t n1, const void *s2, size_t n2)
+ const void *s1, size_t n1, const void *s2, size_t n2)
{
if (s1 == NULL && s2 == NULL)
return 1;
if (n1 != n2 || s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {
test_fail_memory_message(NULL, file, line, "memory", st1, st2, "==",
- s1, n1, s2, n2);
+ s1, n1, s2, n2);
return 0;
}
return 1;
}
int test_mem_ne(const char *file, int line, const char *st1, const char *st2,
- const void *s1, size_t n1, const void *s2, size_t n2)
+ const void *s1, size_t n1, const void *s2, size_t n2)
{
if ((s1 == NULL) ^ (s2 == NULL))
return 1;
@@ -353,38 +351,38 @@ int test_mem_ne(const char *file, int line, const char *st1, const char *st2,
return 1;
if (s1 == NULL || memcmp(s1, s2, n1) == 0) {
test_fail_memory_message(NULL, file, line, "memory", st1, st2, "!=",
- s1, n1, s2, n2);
+ s1, n1, s2, n2);
return 0;
}
return 1;
}
-#define DEFINE_BN_COMPARISONS(opname, op, zero_cond) \
- int test_BN_ ## opname(const char *file, int line, \
- const char *s1, const char *s2, \
- const BIGNUM *t1, const BIGNUM *t2) \
- { \
- if (BN_cmp(t1, t2) op 0) \
- return 1; \
- test_fail_bignum_message(NULL, file, line, "BIGNUM", s1, s2, \
- #op, t1, t2); \
- return 0; \
- } \
- int test_BN_ ## opname ## _zero(const char *file, int line, \
- const char *s, const BIGNUM *a) \
- { \
- if (a != NULL &&(zero_cond)) \
- return 1; \
- test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", \
- s, "0", #op, a); \
- return 0; \
+#define DEFINE_BN_COMPARISONS(opname, op, zero_cond) \
+ int test_BN_##opname(const char *file, int line, \
+ const char *s1, const char *s2, \
+ const BIGNUM *t1, const BIGNUM *t2) \
+ { \
+ if (BN_cmp(t1, t2) op 0) \
+ return 1; \
+ test_fail_bignum_message(NULL, file, line, "BIGNUM", s1, s2, \
+ #op, t1, t2); \
+ return 0; \
+ } \
+ int test_BN_##opname##_zero(const char *file, int line, \
+ const char *s, const BIGNUM *a) \
+ { \
+ if (a != NULL && (zero_cond)) \
+ return 1; \
+ test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", \
+ s, "0", #op, a); \
+ return 0; \
}
DEFINE_BN_COMPARISONS(eq, ==, BN_is_zero(a))
DEFINE_BN_COMPARISONS(ne, !=, !BN_is_zero(a))
-DEFINE_BN_COMPARISONS(gt, >, !BN_is_negative(a) && !BN_is_zero(a))
+DEFINE_BN_COMPARISONS(gt, >, !BN_is_negative(a) && !BN_is_zero(a))
DEFINE_BN_COMPARISONS(ge, >=, !BN_is_negative(a) || BN_is_zero(a))
-DEFINE_BN_COMPARISONS(lt, <, BN_is_negative(a) && !BN_is_zero(a))
+DEFINE_BN_COMPARISONS(lt, <, BN_is_negative(a) && !BN_is_zero(a))
DEFINE_BN_COMPARISONS(le, <=, BN_is_negative(a) || BN_is_zero(a))
int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)
@@ -408,12 +406,12 @@ int test_BN_even(const char *file, int line, const char *s, const BIGNUM *a)
if (a != NULL && !BN_is_odd(a))
return 1;
test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", "EVEN(", ")", s,
- a);
+ a);
return 0;
}
int test_BN_eq_word(const char *file, int line, const char *bns, const char *ws,
- const BIGNUM *a, BN_ULONG w)
+ const BIGNUM *a, BN_ULONG w)
{
BIGNUM *bw;
@@ -427,7 +425,7 @@ int test_BN_eq_word(const char *file, int line, const char *bns, const char *ws,
}
int test_BN_abs_eq_word(const char *file, int line, const char *bns,
- const char *ws, const BIGNUM *a, BN_ULONG w)
+ const char *ws, const BIGNUM *a, BN_ULONG w)
{
BIGNUM *bw, *aa;
@@ -438,7 +436,7 @@ int test_BN_abs_eq_word(const char *file, int line, const char *bns,
if ((bw = BN_new()) != NULL)
BN_set_word(bw, w);
test_fail_bignum_message(NULL, file, line, "BIGNUM", bns, ws, "abs==",
- aa, bw);
+ aa, bw);
BN_free(bw);
BN_free(aa);
return 0;
@@ -449,22 +447,22 @@ static const char *print_time(const ASN1_TIME *t)
return t == NULL ? "<null>" : (const char *)ASN1_STRING_get0_data(t);
}
-#define DEFINE_TIME_T_COMPARISON(opname, op) \
- int test_time_t_ ## opname(const char *file, int line, \
- const char *s1, const char *s2, \
- const time_t t1, const time_t t2) \
- { \
- ASN1_TIME *at1 = ASN1_TIME_set(NULL, t1); \
- ASN1_TIME *at2 = ASN1_TIME_set(NULL, t2); \
- int r = at1 != NULL && at2 != NULL \
- && ASN1_TIME_compare(at1, at2) op 0; \
- if (!r) \
- test_fail_message(NULL, file, line, "time_t", s1, s2, #op, \
- "[%s] compared to [%s]", \
- print_time(at1), print_time(at2)); \
- ASN1_STRING_free(at1); \
- ASN1_STRING_free(at2); \
- return r; \
+#define DEFINE_TIME_T_COMPARISON(opname, op) \
+ int test_time_t_##opname(const char *file, int line, \
+ const char *s1, const char *s2, \
+ const time_t t1, const time_t t2) \
+ { \
+ ASN1_TIME *at1 = ASN1_TIME_set(NULL, t1); \
+ ASN1_TIME *at2 = ASN1_TIME_set(NULL, t2); \
+ int r = at1 != NULL && at2 != NULL \
+ && ASN1_TIME_compare(at1, at2) op 0; \
+ if (!r) \
+ test_fail_message(NULL, file, line, "time_t", s1, s2, #op, \
+ "[%s] compared to [%s]", \
+ print_time(at1), print_time(at2)); \
+ ASN1_STRING_free(at1); \
+ ASN1_STRING_free(at2); \
+ return r; \
}
DEFINE_TIME_T_COMPARISON(eq, ==)
DEFINE_TIME_T_COMPARISON(ne, !=)
diff --git a/crypto/openssl/test/testutil/testutil_init.c b/crypto/openssl/test/testutil/testutil_init.c
index 64224186e477..75ab29418417 100644
--- a/crypto/openssl/test/testutil/testutil_init.c
+++ b/crypto/openssl/test/testutil/testutil_init.c
@@ -16,11 +16,11 @@
#ifndef OPENSSL_NO_TRACE
typedef struct tracedata_st {
BIO *bio;
- unsigned int ingroup:1;
+ unsigned int ingroup : 1;
} tracedata;
static size_t internal_trace_cb(const char *buf, size_t cnt,
- int category, int cmd, void *vdata)
+ int category, int cmd, void *vdata)
{
int ret = 0;
tracedata *trace_data = vdata;
@@ -34,7 +34,7 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
tid = CRYPTO_THREAD_get_current_id();
hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
- hex, OSSL_trace_get_category_name(category));
+ hex, OSSL_trace_get_category_name(category));
OPENSSL_free(hex);
BIO_set_prefix(trace_data->bio, buffer);
break;
@@ -78,19 +78,20 @@ static void setup_trace_category(int category)
bio = BIO_new(BIO_f_prefix());
channel = BIO_push(bio,
- BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT));
+ BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT));
trace_data = OPENSSL_zalloc(sizeof(*trace_data));
if (trace_data == NULL
|| bio == NULL
|| (trace_data->bio = channel) == NULL
|| OSSL_trace_set_callback(category, internal_trace_cb,
- trace_data) == 0
+ trace_data)
+ == 0
|| sk_tracedata_push(trace_data_stack, trace_data) == 0) {
fprintf(stderr,
- "warning: unable to setup trace callback for category '%s'.\n",
- OSSL_trace_get_category_name(category));
+ "warning: unable to setup trace callback for category '%s'.\n",
+ OSSL_trace_get_category_name(category));
OPENSSL_free(trace_data);
OSSL_trace_set_callback(category, NULL, NULL);
@@ -127,7 +128,7 @@ static void setup_trace(const char *str)
setup_trace_category(category);
} else {
fprintf(stderr,
- "warning: unknown trace category: '%s'.\n", item);
+ "warning: unknown trace category: '%s'.\n", item);
}
}
}
diff --git a/crypto/openssl/test/testutil/tu_local.h b/crypto/openssl/test/testutil/tu_local.h
index ede4546948ff..6b900d19b499 100644
--- a/crypto/openssl/test/testutil/tu_local.h
+++ b/crypto/openssl/test/testutil/tu_local.h
@@ -7,44 +7,44 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdlib.h> /* size_t */
+#include <stdlib.h> /* size_t */
#include <openssl/bn.h>
#include <openssl/bio.h>
#include "../testutil.h"
-#define TEST_SKIP_CODE 123
+#define TEST_SKIP_CODE 123
int subtest_level(void);
int openssl_error_cb(const char *str, size_t len, void *u);
const BIO_METHOD *BIO_f_tap(void);
void test_fail_message_prefix(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op);
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op);
void test_fail_string_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const char *m1, size_t l1,
- const char *m2, size_t l2);
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const char *m1, size_t l1,
+ const char *m2, size_t l2);
void test_fail_bignum_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const BIGNUM *bn1, const BIGNUM *bn2);
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const BIGNUM *bn1, const BIGNUM *bn2);
void test_fail_bignum_mono_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op, const BIGNUM *bn);
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op, const BIGNUM *bn);
void test_fail_memory_message(const char *prefix, const char *file,
- int line, const char *type,
- const char *left, const char *right,
- const char *op,
- const unsigned char *m1, size_t l1,
- const unsigned char *m2, size_t l2);
+ int line, const char *type,
+ const char *left, const char *right,
+ const char *op,
+ const unsigned char *m1, size_t l1,
+ const unsigned char *m2, size_t l2);
__owur int setup_test_framework(int argc, char *argv[]);
__owur int pulldown_test_framework(int ret);
@@ -58,4 +58,3 @@ typedef enum OPTION_choice_default {
OPT_TEST_ENUM
} OPTION_CHOICE_DEFAULT;
void opt_check_usage(void);
-