mirror of
https://github.com/openssl/openssl.git
synced 2025-03-19 19:50:42 +08:00
Test infrastructure additions.
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3011)
This commit is contained in:
parent
a6ac1ed686
commit
2fae041d6c
49
test/README
49
test/README
@ -86,25 +86,52 @@ A script to start from could be this:
|
||||
}
|
||||
|
||||
|
||||
Changes to test/Makefile
|
||||
========================
|
||||
Changes to test/build.info
|
||||
==========================
|
||||
|
||||
Whenever a new test involves a new test executable you need to do the
|
||||
following (at all times, replace {NAME} and {name} with the name of your
|
||||
test):
|
||||
|
||||
* among the variables for test executables at the beginning, add a line like
|
||||
this:
|
||||
* add {name} to the list of programs under PROGRAMS_NO_INST
|
||||
|
||||
{NAME}TEST= {name}test
|
||||
* create a three line description of how to build the test, you will have
|
||||
to modify the include paths and source files if you don't want to use the
|
||||
basic test framework:
|
||||
|
||||
* add `$({NAME}TEST)$(EXE_EXT)' to the assignment of EXE:
|
||||
SOURCE[{name}]={name}.c testutil.c test_main.c
|
||||
INCLUDE[{name}]=.. ../include
|
||||
DEPEND[{name}]=../libcrypto
|
||||
|
||||
* add `$({NAME}TEST).o' to the assignment of OBJ:
|
||||
Generic form of C test executables
|
||||
==================================
|
||||
|
||||
* add `$({NAME}TEST).c' to the assignment of SRC:
|
||||
#include "test_main.h"
|
||||
#include "testutil.h"
|
||||
|
||||
* add the following lines for building the executable:
|
||||
static int my_test(void)
|
||||
{
|
||||
int testresult = 0; /* Assume the test will fail */
|
||||
int observed;
|
||||
|
||||
$({NAME}TEST)$(EXE_EXT): $({NAME}TEST).o $(DLIBCRYPTO)
|
||||
@target=$({NAME}TEST); $(BUILD_CMD)
|
||||
observed = function(); /* Call the code under test */
|
||||
if (!TEST_int_equal(observed, 2)) /* Check the result is correct */
|
||||
goto end; /* Exit on failure - optional */
|
||||
|
||||
testresult = 1; /* Mark the test case a success */
|
||||
end:
|
||||
cleanup(); /* Any cleanup you require */
|
||||
return testresult;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
{
|
||||
ADD_TEST(my_test); /* Add each test separately */
|
||||
}
|
||||
|
||||
You should use the TEST_xxx macros provided by testutil.h to test all failure
|
||||
conditions. These macros produce an error message in a standard format if the
|
||||
condition is not met (and nothing if the condition is met). Additional
|
||||
information can be presented with the TEST_info macro that takes a printf
|
||||
format string and arguments. TEST_error is useful for complicated conditions,
|
||||
it also takes a printf format string and argument.
|
||||
|
@ -82,6 +82,7 @@ static int test_standard_methods()
|
||||
return 1;
|
||||
}
|
||||
|
||||
TEST_error("asn1 standard methods out of order");
|
||||
for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods);
|
||||
i++, tmp++)
|
||||
fprintf(stderr, "asn1 standard methods: Index %" OSSLzu
|
||||
|
@ -11,7 +11,7 @@
|
||||
-}
|
||||
IF[{- !$disabled{tests} -}]
|
||||
PROGRAMS_NO_INST=\
|
||||
aborttest \
|
||||
aborttest test_test \
|
||||
sanitytest exdatatest bntest \
|
||||
ectest ecdsatest ecdhtest gmdifftest pbelutest ideatest \
|
||||
md2test \
|
||||
@ -38,6 +38,10 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[sanitytest]=../include
|
||||
DEPEND[sanitytest]=../libcrypto
|
||||
|
||||
SOURCE[test_test]=test_test.c testutil.c test_main.c
|
||||
INCLUDE[test_test]=.. ../include
|
||||
DEPEND[test_test]=../libcrypto
|
||||
|
||||
SOURCE[exdatatest]=exdatatest.c
|
||||
INCLUDE[exdatatest]=../include
|
||||
DEPEND[exdatatest]=../libcrypto
|
||||
|
@ -136,18 +136,14 @@ static int test_default_cipherlist(SSL_CTX *ctx)
|
||||
OPENSSL_assert(ciphers != NULL);
|
||||
num_expected_ciphers = OSSL_NELEM(default_ciphers_in_order);
|
||||
num_ciphers = sk_SSL_CIPHER_num(ciphers);
|
||||
if (num_ciphers != num_expected_ciphers) {
|
||||
fprintf(stderr, "Expected %d supported ciphers, got %d.\n",
|
||||
num_expected_ciphers, num_ciphers);
|
||||
if (!TEST_int_eq(num_ciphers, num_expected_ciphers))
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_ciphers; i++) {
|
||||
expected_cipher_id = default_ciphers_in_order[i];
|
||||
cipher_id = SSL_CIPHER_get_id(sk_SSL_CIPHER_value(ciphers, i));
|
||||
if (cipher_id != expected_cipher_id) {
|
||||
fprintf(stderr, "Wrong cipher at position %d: expected %x, "
|
||||
"got %x\n", i, expected_cipher_id, cipher_id);
|
||||
if (!TEST_int_eq(cipher_id, expected_cipher_id)) {
|
||||
TEST_info("Wrong cipher at position %d", i);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
@ -243,21 +243,27 @@ static int verify(X509 *leaf, X509 *root, STACK_OF(X509_CRL) *crls,
|
||||
STACK_OF(X509) *roots = sk_X509_new_null();
|
||||
int status = X509_V_ERR_UNSPECIFIED;
|
||||
|
||||
if (ctx == NULL || store == NULL || param == NULL || roots == NULL)
|
||||
if (!TEST_ptr(ctx))
|
||||
goto err;
|
||||
if (!TEST_ptr(store))
|
||||
goto err;
|
||||
if (!TEST_ptr(param))
|
||||
goto err;
|
||||
if (!TEST_ptr(roots))
|
||||
goto err;
|
||||
|
||||
/* Create a stack; upref the cert because we free it below. */
|
||||
X509_up_ref(root);
|
||||
if (!sk_X509_push(roots, root))
|
||||
if (!TEST_true(sk_X509_push(roots, root)))
|
||||
goto err;
|
||||
|
||||
if (!X509_STORE_CTX_init(ctx, store, leaf, NULL))
|
||||
if (!TEST_true(X509_STORE_CTX_init(ctx, store, leaf, NULL)))
|
||||
goto err;
|
||||
X509_STORE_CTX_set0_trusted_stack(ctx, roots);
|
||||
X509_STORE_CTX_set0_crls(ctx, crls);
|
||||
X509_VERIFY_PARAM_set_time(param, PARAM_TIME);
|
||||
if (X509_VERIFY_PARAM_get_time(param) != PARAM_TIME) {
|
||||
fprintf(stderr, "set_time/get_time mismatch.\n");
|
||||
if (!TEST_long_eq(X509_VERIFY_PARAM_get_time(param), PARAM_TIME)) {
|
||||
TEST_info("set_time/get_time mismatch.");
|
||||
goto err;
|
||||
}
|
||||
X509_VERIFY_PARAM_set_depth(param, 16);
|
||||
@ -306,55 +312,64 @@ static int test_crl()
|
||||
X509_CRL *unknown_critical_crl2 = CRL_from_strings(kUnknownCriticalCRL2);
|
||||
int status = 0;
|
||||
|
||||
if (root == NULL || leaf == NULL || basic_crl == NULL
|
||||
|| revoked_crl == NULL || bad_issuer_crl == NULL
|
||||
|| known_critical_crl == NULL || unknown_critical_crl == NULL
|
||||
|| unknown_critical_crl2 == NULL) {
|
||||
fprintf(stderr, "Failed to parse certificates and CRLs.\n");
|
||||
if (!TEST_ptr(root))
|
||||
goto err;
|
||||
if (!TEST_ptr(leaf))
|
||||
goto err;
|
||||
if (!TEST_ptr(basic_crl))
|
||||
goto err;
|
||||
if (!TEST_ptr(revoked_crl))
|
||||
goto err;
|
||||
if (!TEST_ptr(bad_issuer_crl))
|
||||
goto err;
|
||||
if (!TEST_ptr(known_critical_crl))
|
||||
goto err;
|
||||
if (!TEST_ptr(unknown_critical_crl))
|
||||
goto err;
|
||||
if (!TEST_ptr(unknown_critical_crl2))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(basic_crl, NULL),
|
||||
X509_V_FLAG_CRL_CHECK) != X509_V_OK) {
|
||||
fprintf(stderr, "Cert with CRL didn't verify.\n");
|
||||
TEST_info("Cert with CRL didn't verify.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(basic_crl, revoked_crl),
|
||||
X509_V_FLAG_CRL_CHECK) != X509_V_ERR_CERT_REVOKED) {
|
||||
fprintf(stderr, "Revoked CRL wasn't checked.\n");
|
||||
TEST_info("Revoked CRL wasn't checked.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, NULL,
|
||||
X509_V_FLAG_CRL_CHECK) != X509_V_ERR_UNABLE_TO_GET_CRL) {
|
||||
fprintf(stderr, "CRLs were not required.\n");
|
||||
TEST_info("CRLs were not required.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(bad_issuer_crl, NULL),
|
||||
X509_V_FLAG_CRL_CHECK) != X509_V_ERR_UNABLE_TO_GET_CRL) {
|
||||
fprintf(stderr, "Bad CRL issuer was unnoticed.\n");
|
||||
TEST_info("Bad CRL issuer was unnoticed.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(known_critical_crl, NULL),
|
||||
X509_V_FLAG_CRL_CHECK) != X509_V_OK) {
|
||||
fprintf(stderr, "CRL with known critical extension was rejected.\n");
|
||||
TEST_info("CRL with known critical extension was rejected.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(unknown_critical_crl, NULL),
|
||||
X509_V_FLAG_CRL_CHECK) !=
|
||||
X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION) {
|
||||
fprintf(stderr, "CRL with unknown critical extension was accepted.\n");
|
||||
TEST_info("CRL with unknown critical extension was accepted.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verify(leaf, root, make_CRL_stack(unknown_critical_crl2, NULL),
|
||||
X509_V_FLAG_CRL_CHECK) !=
|
||||
X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION) {
|
||||
fprintf(stderr, "CRL with unknown critical extension (2) was accepted.\n");
|
||||
TEST_info("CRL with unknown critical extension (2) was accepted.");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -88,62 +88,50 @@ static int test_int_lhash(void)
|
||||
unsigned int i;
|
||||
int testresult = 0, j, *p;
|
||||
|
||||
if (h == NULL) {
|
||||
fprintf(stderr, "test lhash int allocation\n");
|
||||
if (!TEST_ptr(h))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* insert */
|
||||
for (i = 0; i < n_int_tests; i++)
|
||||
if (lh_int_insert(h, int_tests + i) != NULL) {
|
||||
fprintf(stderr, "test lhash int insert %d\n", i);
|
||||
if (!TEST_ptr_null(lh_int_insert(h, int_tests + i))) {
|
||||
TEST_info("int insert %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* num_items */
|
||||
if (lh_int_num_items(h) != n_int_tests) {
|
||||
fprintf(stderr, "test lhash int num items\n");
|
||||
goto end;
|
||||
}
|
||||
if (!TEST_int_eq(lh_int_num_items(h), n_int_tests))
|
||||
goto end;
|
||||
|
||||
/* retrieve */
|
||||
for (i = 0; i < n_int_tests; i++)
|
||||
if (*lh_int_retrieve(h, int_tests + i) != int_tests[i]) {
|
||||
fprintf(stderr, "test lhash int retrieve value %d\n", i);
|
||||
if (!TEST_int_eq(*lh_int_retrieve(h, int_tests + i), int_tests[i])) {
|
||||
TEST_info("lhash int retrieve value %d", i);
|
||||
goto end;
|
||||
}
|
||||
for (i = 0; i < n_int_tests; i++)
|
||||
if (lh_int_retrieve(h, int_tests + i) != int_tests + i) {
|
||||
fprintf(stderr, "test lhash int retrieve address %d\n", i);
|
||||
if (!TEST_ptr_eq(lh_int_retrieve(h, int_tests + i), int_tests + i)) {
|
||||
TEST_info("lhash int retrieve address %d", i);
|
||||
goto end;
|
||||
}
|
||||
j = 1;
|
||||
if (lh_int_retrieve(h, &j) != int_tests + 2) {
|
||||
fprintf(stderr, "test lhash int retrieve other\n");
|
||||
if (!TEST_ptr_eq(lh_int_retrieve(h, &j), int_tests + 2))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* replace */
|
||||
j = 13;
|
||||
if ((p = lh_int_insert(h, &j)) == NULL) {
|
||||
fprintf(stderr, "test lhash int replacement insert\n");
|
||||
if (!TEST_ptr(p = lh_int_insert(h, &j)))
|
||||
goto end;
|
||||
}
|
||||
if (p != int_tests + 1) {
|
||||
fprintf(stderr, "test lhash int replacement pointer\n");
|
||||
if (!TEST_ptr_eq(p, int_tests + 1))
|
||||
goto end;
|
||||
}
|
||||
if (lh_int_retrieve(h, int_tests + 1) != &j) {
|
||||
fprintf(stderr, "test lhash int replacement variable\n");
|
||||
if (!TEST_ptr_eq(lh_int_retrieve(h, int_tests + 1), &j))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* do_all */
|
||||
memset(int_found, 0, sizeof(int_found));
|
||||
lh_int_doall(h, &int_doall);
|
||||
for (i = 0; i < n_int_tests; i++)
|
||||
if (int_found[i] != 1) {
|
||||
fprintf(stderr, "test lhash int doall %d\n", i);
|
||||
if (!TEST_int_eq(int_found[i], 1)) {
|
||||
TEST_info("lhash int doall %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -151,25 +139,23 @@ static int test_int_lhash(void)
|
||||
memset(int_found, 0, sizeof(int_found));
|
||||
lh_int_doall_short(h, int_doall_arg, int_found);
|
||||
for (i = 0; i < n_int_tests; i++)
|
||||
if (int_found[i] != 1) {
|
||||
fprintf(stderr, "test lhash int doall arg %d\n", i);
|
||||
if (!TEST_int_eq(int_found[i], 1)) {
|
||||
TEST_info("lhash int doall arg %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* delete */
|
||||
for (i = 0; i < n_dels; i++) {
|
||||
const int b = lh_int_delete(h, &dels[i].data) == NULL;
|
||||
if ((b ^ dels[i].null) != 0) {
|
||||
fprintf(stderr, "test lhash int delete %d\n", i);
|
||||
if (!TEST_int_eq(b ^ dels[i].null, 0)) {
|
||||
TEST_info("lhash int delete %d", i);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
/* error */
|
||||
if (lh_int_error(h) != 0) {
|
||||
fprintf(stderr, "test lhash int error\n");
|
||||
if (!TEST_int_eq(lh_int_error(h), 0))
|
||||
goto end;
|
||||
}
|
||||
|
||||
testresult = 1;
|
||||
end:
|
||||
@ -189,16 +175,14 @@ static int test_stress(void)
|
||||
unsigned int i;
|
||||
int testresult = 0, *p;
|
||||
|
||||
if (h == NULL) {
|
||||
fprintf(stderr, "test lhash stress allocation\n");
|
||||
if (!TEST_ptr(h))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* insert */
|
||||
for (i = 0; i < n; i++) {
|
||||
p = OPENSSL_malloc(sizeof(i));
|
||||
if (p == NULL) {
|
||||
fprintf(stderr, "test lhash stress out of memory %d\n", i);
|
||||
if (!TEST_ptr(p)) {
|
||||
TEST_info("lhash stress out of memory %d", i);
|
||||
goto end;
|
||||
}
|
||||
*p = 3 * i + 1;
|
||||
@ -206,10 +190,8 @@ static int test_stress(void)
|
||||
}
|
||||
|
||||
/* num_items */
|
||||
if (lh_int_num_items(h) != n) {
|
||||
fprintf(stderr, "test lhash stress num items\n");
|
||||
if (!TEST_int_eq(lh_int_num_items(h), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
fprintf(stderr, "hash full statistics:\n");
|
||||
OPENSSL_LH_stats((OPENSSL_LHASH *)h, stderr);
|
||||
@ -220,12 +202,12 @@ static int test_stress(void)
|
||||
for (i = 0; i < n; i++) {
|
||||
const int j = (7 * i + 4) % n * 3 + 1;
|
||||
|
||||
if ((p = lh_int_delete(h, &j)) == NULL) {
|
||||
fprintf(stderr, "test lhash stress delete %d\n", i);
|
||||
if (!TEST_ptr(p = lh_int_delete(h, &j))) {
|
||||
TEST_info("lhash stress delete %d\n", i);
|
||||
goto end;
|
||||
}
|
||||
if (*p != j) {
|
||||
fprintf(stderr, "test lhash stress bad value %d\n", i);
|
||||
if (!TEST_int_eq(*p, j)) {
|
||||
TEST_info("lhash stress bad value %d", i);
|
||||
goto end;
|
||||
}
|
||||
OPENSSL_free(p);
|
||||
|
@ -56,8 +56,9 @@ static int test_mdc2(int idx)
|
||||
strlen(testdata.input));
|
||||
MDC2_Final(&(md[0]), &c);
|
||||
|
||||
if (memcmp(testdata.expected, md, MDC2_DIGEST_LENGTH)) {
|
||||
fprintf(stderr, "mdc2 test %d: unexpected output\n", idx);
|
||||
if (!TEST_mem_eq(testdata.expected, MDC2_DIGEST_LENGTH,
|
||||
md, MDC2_DIGEST_LENGTH)) {
|
||||
TEST_info("mdc2 test %d: unexpected output", idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ static int test_asn1_meths()
|
||||
|
||||
}
|
||||
if (!good) {
|
||||
fprintf(stderr, "EVP_PKEY_ASN1_METHOD table out of order!\n");
|
||||
TEST_error("EVP_PKEY_ASN1_METHOD table out of order");
|
||||
for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
|
||||
const char *info;
|
||||
|
||||
|
@ -1565,14 +1565,14 @@ static int test_poly1305(int idx)
|
||||
size_t expectedlen = test.expected.size;
|
||||
unsigned char out[16];
|
||||
|
||||
if (expectedlen != sizeof(out))
|
||||
if (!TEST_size_t_eq(expectedlen, sizeof(out)))
|
||||
return 0;
|
||||
|
||||
Poly1305_Init(&poly1305, key);
|
||||
Poly1305_Update(&poly1305, in, inlen);
|
||||
Poly1305_Final(&poly1305, out);
|
||||
|
||||
if (memcmp(out, expected, expectedlen) != 0) {
|
||||
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
|
||||
fprintf(stderr, "Poly1305 test #%d failed.\n", idx);
|
||||
fprintf(stderr, "got: ");
|
||||
hexdump(out, sizeof(out));
|
||||
@ -1588,7 +1588,7 @@ static int test_poly1305(int idx)
|
||||
Poly1305_Update(&poly1305, in+1, inlen-1);
|
||||
Poly1305_Final(&poly1305, out);
|
||||
|
||||
if (memcmp(out, expected, expectedlen) != 0) {
|
||||
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
|
||||
fprintf(stderr, "Poly1305 test #%d/1+(N-1) failed.\n", idx);
|
||||
fprintf(stderr, "got: ");
|
||||
hexdump(out, sizeof(out));
|
||||
@ -1607,7 +1607,7 @@ static int test_poly1305(int idx)
|
||||
Poly1305_Update(&poly1305, in+half, inlen-half);
|
||||
Poly1305_Final(&poly1305, out);
|
||||
|
||||
if (memcmp(out, expected, expectedlen) != 0) {
|
||||
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
|
||||
fprintf(stderr, "Poly1305 test #%d/2 failed.\n", idx);
|
||||
fprintf(stderr, "got: ");
|
||||
hexdump(out, sizeof(out));
|
||||
@ -1623,7 +1623,7 @@ static int test_poly1305(int idx)
|
||||
Poly1305_Update(&poly1305, in+half, inlen-half);
|
||||
Poly1305_Final(&poly1305, out);
|
||||
|
||||
if (memcmp(out, expected, expectedlen) != 0) {
|
||||
if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
|
||||
fprintf(stderr, "Poly1305 test #%d/%" OSSLzu "+%" OSSLzu " failed.\n",
|
||||
idx, half, inlen-half);
|
||||
fprintf(stderr, "got: ");
|
||||
|
14
test/recipes/01-test_test.t
Normal file
14
test/recipes/01-test_test.t
Normal file
@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
#
|
||||
# ======================================================================
|
||||
# Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
use OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_test", "test_test");
|
130
test/ssl_test.c
130
test/ssl_test.c
@ -31,10 +31,10 @@ static const char *print_alert(int alert)
|
||||
|
||||
static int check_result(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->result != test_ctx->expected_result) {
|
||||
fprintf(stderr, "ExpectedResult mismatch: expected %s, got %s.\n",
|
||||
ssl_test_result_name(test_ctx->expected_result),
|
||||
ssl_test_result_name(result->result));
|
||||
if (!TEST_int_eq(result->result, test_ctx->expected_result)) {
|
||||
TEST_info("ExpectedResult mismatch: expected %s, got %s.",
|
||||
ssl_test_result_name(test_ctx->expected_result),
|
||||
ssl_test_result_name(result->result));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -42,10 +42,11 @@ static int check_result(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
|
||||
static int check_alerts(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->client_alert_sent != result->client_alert_received) {
|
||||
fprintf(stderr, "Client sent alert %s but server received %s\n.",
|
||||
print_alert(result->client_alert_sent),
|
||||
print_alert(result->client_alert_received));
|
||||
if (!TEST_int_eq(result->client_alert_sent,
|
||||
result->client_alert_received)) {
|
||||
TEST_info("Client sent alert %s but server received %s.",
|
||||
print_alert(result->client_alert_sent),
|
||||
print_alert(result->client_alert_received));
|
||||
/*
|
||||
* We can't bail here because the peer doesn't always get far enough
|
||||
* to process a received alert. Specifically, in protocol version
|
||||
@ -60,10 +61,11 @@ static int check_alerts(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
/* return 0; */
|
||||
}
|
||||
|
||||
if (result->server_alert_sent != result->server_alert_received) {
|
||||
fprintf(stderr, "Server sent alert %s but client received %s\n.",
|
||||
print_alert(result->server_alert_sent),
|
||||
print_alert(result->server_alert_received));
|
||||
if (!TEST_int_eq(result->server_alert_sent,
|
||||
result->server_alert_received)) {
|
||||
TEST_info("Server sent alert %s but client received %s.",
|
||||
print_alert(result->server_alert_sent),
|
||||
print_alert(result->server_alert_received));
|
||||
/* return 0; */
|
||||
}
|
||||
|
||||
@ -75,47 +77,42 @@ static int check_alerts(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
* where the low byte is the alert code and the high byte is other stuff.
|
||||
*/
|
||||
&& (result->client_alert_sent & 0xff) != test_ctx->expected_client_alert) {
|
||||
fprintf(stderr, "ClientAlert mismatch: expected %s, got %s.\n",
|
||||
print_alert(test_ctx->expected_client_alert),
|
||||
print_alert(result->client_alert_sent));
|
||||
TEST_error("ClientAlert mismatch: expected %s, got %s.",
|
||||
print_alert(test_ctx->expected_client_alert),
|
||||
print_alert(result->client_alert_sent));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (test_ctx->expected_server_alert
|
||||
&& (result->server_alert_sent & 0xff) != test_ctx->expected_server_alert) {
|
||||
fprintf(stderr, "ServerAlert mismatch: expected %s, got %s.\n",
|
||||
print_alert(test_ctx->expected_server_alert),
|
||||
print_alert(result->server_alert_sent));
|
||||
TEST_error("ServerAlert mismatch: expected %s, got %s.",
|
||||
print_alert(test_ctx->expected_server_alert),
|
||||
print_alert(result->server_alert_sent));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (result->client_num_fatal_alerts_sent > 1) {
|
||||
fprintf(stderr, "Client sent %d fatal alerts.\n",
|
||||
result->client_num_fatal_alerts_sent);
|
||||
if (!TEST_int_le(result->client_num_fatal_alerts_sent, 1))
|
||||
return 0;
|
||||
}
|
||||
if (result->server_num_fatal_alerts_sent > 1) {
|
||||
fprintf(stderr, "Server sent %d alerts.\n",
|
||||
result->server_num_fatal_alerts_sent);
|
||||
if (!TEST_int_le(result->server_num_fatal_alerts_sent, 1))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int check_protocol(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->client_protocol != result->server_protocol) {
|
||||
fprintf(stderr, "Client has protocol %s but server has %s\n.",
|
||||
ssl_protocol_name(result->client_protocol),
|
||||
ssl_protocol_name(result->server_protocol));
|
||||
if (!TEST_int_eq(result->client_protocol, result->server_protocol)) {
|
||||
TEST_info("Client has protocol %s but server has %s.",
|
||||
ssl_protocol_name(result->client_protocol),
|
||||
ssl_protocol_name(result->server_protocol));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (test_ctx->expected_protocol) {
|
||||
if (result->client_protocol != test_ctx->expected_protocol) {
|
||||
fprintf(stderr, "Protocol mismatch: expected %s, got %s.\n",
|
||||
ssl_protocol_name(test_ctx->expected_protocol),
|
||||
ssl_protocol_name(result->client_protocol));
|
||||
if (!TEST_int_eq(result->client_protocol,
|
||||
test_ctx->expected_protocol)) {
|
||||
TEST_info("Protocol mismatch: expected %s, got %s.\n",
|
||||
ssl_protocol_name(test_ctx->expected_protocol),
|
||||
ssl_protocol_name(result->client_protocol));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -124,10 +121,10 @@ static int check_protocol(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
|
||||
static int check_servername(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->servername != test_ctx->expected_servername) {
|
||||
fprintf(stderr, "Client ServerName mismatch, expected %s, got %s\n.",
|
||||
ssl_servername_name(test_ctx->expected_servername),
|
||||
ssl_servername_name(result->servername));
|
||||
if (!TEST_int_eq(result->servername, test_ctx->expected_servername)) {
|
||||
TEST_info("Client ServerName mismatch, expected %s, got %s.",
|
||||
ssl_servername_name(test_ctx->expected_servername),
|
||||
ssl_servername_name(result->servername));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -137,10 +134,11 @@ static int check_session_ticket(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx
|
||||
{
|
||||
if (test_ctx->session_ticket_expected == SSL_TEST_SESSION_TICKET_IGNORE)
|
||||
return 1;
|
||||
if (result->session_ticket != test_ctx->session_ticket_expected) {
|
||||
fprintf(stderr, "Client SessionTicketExpected mismatch, expected %s, got %s\n.",
|
||||
ssl_session_ticket_name(test_ctx->session_ticket_expected),
|
||||
ssl_session_ticket_name(result->session_ticket));
|
||||
if (!TEST_int_eq(result->session_ticket,
|
||||
test_ctx->session_ticket_expected)) {
|
||||
TEST_info("Client SessionTicketExpected mismatch, expected %s, got %s.",
|
||||
ssl_session_ticket_name(test_ctx->session_ticket_expected),
|
||||
ssl_session_ticket_name(result->session_ticket));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -148,24 +146,20 @@ static int check_session_ticket(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx
|
||||
|
||||
static int check_compression(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->compression != test_ctx->compression_expected) {
|
||||
fprintf(stderr, "Client CompressionExpected mismatch, expected %d, got %d\n.",
|
||||
test_ctx->compression_expected,
|
||||
result->compression);
|
||||
if (!TEST_int_eq(result->compression, test_ctx->compression_expected))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
static int check_npn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
int ret = 1;
|
||||
ret &= strings_equal("NPN Negotiated (client vs server)",
|
||||
result->client_npn_negotiated,
|
||||
result->server_npn_negotiated);
|
||||
ret &= strings_equal("ExpectedNPNProtocol",
|
||||
test_ctx->expected_npn_protocol,
|
||||
result->client_npn_negotiated);
|
||||
if (!TEST_str_eq(result->client_npn_negotiated,
|
||||
result->server_npn_negotiated))
|
||||
ret = 0;
|
||||
if (!TEST_str_eq(test_ctx->expected_npn_protocol,
|
||||
result->client_npn_negotiated))
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -173,27 +167,21 @@ static int check_npn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
static int check_alpn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
int ret = 1;
|
||||
ret &= strings_equal("ALPN Negotiated (client vs server)",
|
||||
result->client_alpn_negotiated,
|
||||
result->server_alpn_negotiated);
|
||||
ret &= strings_equal("ExpectedALPNProtocol",
|
||||
test_ctx->expected_alpn_protocol,
|
||||
result->client_alpn_negotiated);
|
||||
if (!TEST_str_eq(result->client_alpn_negotiated,
|
||||
result->server_alpn_negotiated))
|
||||
ret = 0;
|
||||
if (!TEST_str_eq(test_ctx->expected_alpn_protocol,
|
||||
result->client_alpn_negotiated))
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_resumption(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
|
||||
{
|
||||
if (result->client_resumed != result->server_resumed) {
|
||||
fprintf(stderr, "Resumption mismatch (client vs server): %d vs %d\n",
|
||||
result->client_resumed, result->server_resumed);
|
||||
if (!TEST_int_eq(result->client_resumed, result->server_resumed))
|
||||
return 0;
|
||||
}
|
||||
if (result->client_resumed != test_ctx->resumption_expected) {
|
||||
fprintf(stderr, "ResumptionExpected mismatch: %d vs %d\n",
|
||||
test_ctx->resumption_expected, result->client_resumed);
|
||||
if (!TEST_int_eq(result->client_resumed, test_ctx->resumption_expected))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -201,9 +189,9 @@ static int check_nid(const char *name, int expected_nid, int nid)
|
||||
{
|
||||
if (expected_nid == 0 || expected_nid == nid)
|
||||
return 1;
|
||||
fprintf(stderr, "%s type mismatch, %s vs %s\n",
|
||||
name, OBJ_nid2ln(expected_nid),
|
||||
nid == NID_undef ? "absent" : OBJ_nid2ln(nid));
|
||||
TEST_error("%s type mismatch, %s vs %s\n",
|
||||
name, OBJ_nid2ln(expected_nid),
|
||||
nid == NID_undef ? "absent" : OBJ_nid2ln(nid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -356,7 +344,7 @@ static int test_handshake(int idx)
|
||||
BIO_snprintf(test_app, sizeof(test_app), "test-%d", idx);
|
||||
|
||||
test_ctx = SSL_TEST_CTX_create(conf, test_app);
|
||||
if (test_ctx == NULL)
|
||||
if (!TEST_ptr(test_ctx))
|
||||
goto err;
|
||||
|
||||
#ifndef OPENSSL_NO_DTLS
|
||||
|
@ -37,28 +37,26 @@ typedef struct ssl_test_ctx_test_fixture {
|
||||
static int SSL_TEST_CLIENT_CONF_equal(SSL_TEST_CLIENT_CONF *client,
|
||||
SSL_TEST_CLIENT_CONF *client2)
|
||||
{
|
||||
if (client->verify_callback != client2->verify_callback) {
|
||||
fprintf(stderr, "ClientVerifyCallback mismatch: %s vs %s.\n",
|
||||
ssl_verify_callback_name(client->verify_callback),
|
||||
ssl_verify_callback_name(client2->verify_callback));
|
||||
if (!TEST_int_eq(client->verify_callback, client2->verify_callback)) {
|
||||
TEST_info("ClientVerifyCallback mismatch: %s vs %s.",
|
||||
ssl_verify_callback_name(client->verify_callback),
|
||||
ssl_verify_callback_name(client2->verify_callback));
|
||||
return 0;
|
||||
}
|
||||
if (client->servername != client2->servername) {
|
||||
fprintf(stderr, "ServerName mismatch: %s vs %s.\n",
|
||||
ssl_servername_name(client->servername),
|
||||
ssl_servername_name(client2->servername));
|
||||
if (!TEST_int_eq(client->servername, client2->servername)) {
|
||||
TEST_info("ServerName mismatch: %s vs %s.",
|
||||
ssl_servername_name(client->servername),
|
||||
ssl_servername_name(client2->servername));
|
||||
return 0;
|
||||
}
|
||||
if (!strings_equal("Client NPNProtocols", client->npn_protocols,
|
||||
client2->npn_protocols))
|
||||
if (!TEST_str_eq(client->npn_protocols, client2->npn_protocols))
|
||||
return 0;
|
||||
if (!strings_equal("Client ALPNProtocols", client->alpn_protocols,
|
||||
client2->alpn_protocols))
|
||||
if (!TEST_str_eq(client->alpn_protocols, client2->alpn_protocols))
|
||||
return 0;
|
||||
if (client->ct_validation != client2->ct_validation) {
|
||||
fprintf(stderr, "CTValidation mismatch: %s vs %s.\n",
|
||||
ssl_ct_validation_name(client->ct_validation),
|
||||
ssl_ct_validation_name(client2->ct_validation));
|
||||
if (!TEST_int_eq(client->ct_validation, client2->ct_validation)) {
|
||||
TEST_info("CTValidation mismatch: %s vs %s.",
|
||||
ssl_ct_validation_name(client->ct_validation),
|
||||
ssl_ct_validation_name(client2->ct_validation));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -67,27 +65,24 @@ static int SSL_TEST_CLIENT_CONF_equal(SSL_TEST_CLIENT_CONF *client,
|
||||
static int SSL_TEST_SERVER_CONF_equal(SSL_TEST_SERVER_CONF *server,
|
||||
SSL_TEST_SERVER_CONF *server2)
|
||||
{
|
||||
if (server->servername_callback != server2->servername_callback) {
|
||||
fprintf(stderr, "ServerNameCallback mismatch: %s vs %s.\n",
|
||||
ssl_servername_callback_name(server->servername_callback),
|
||||
ssl_servername_callback_name(server2->servername_callback));
|
||||
if (!TEST_int_eq(server->servername_callback,
|
||||
server2->servername_callback)) {
|
||||
TEST_info("ServerNameCallback mismatch: %s vs %s.",
|
||||
ssl_servername_callback_name(server->servername_callback),
|
||||
ssl_servername_callback_name(server2->servername_callback));
|
||||
return 0;
|
||||
}
|
||||
if (!strings_equal("Server NPNProtocols", server->npn_protocols,
|
||||
server2->npn_protocols))
|
||||
if (!TEST_str_eq(server->npn_protocols, server2->npn_protocols))
|
||||
return 0;
|
||||
if (!strings_equal("Server ALPNProtocols", server->alpn_protocols,
|
||||
server2->alpn_protocols))
|
||||
if (!TEST_str_eq(server->alpn_protocols, server2->alpn_protocols))
|
||||
return 0;
|
||||
if (server->broken_session_ticket != server2->broken_session_ticket) {
|
||||
fprintf(stderr, "Broken session ticket mismatch: %d vs %d.\n",
|
||||
server->broken_session_ticket, server2->broken_session_ticket);
|
||||
if (!TEST_int_eq(server->broken_session_ticket,
|
||||
server2->broken_session_ticket))
|
||||
return 0;
|
||||
}
|
||||
if (server->cert_status != server2->cert_status) {
|
||||
fprintf(stderr, "CertStatus mismatch: %s vs %s.\n",
|
||||
ssl_certstatus_name(server->cert_status),
|
||||
ssl_certstatus_name(server2->cert_status));
|
||||
if (!TEST_int_eq(server->cert_status, server2->cert_status)) {
|
||||
TEST_info("CertStatus mismatch: %s vs %s.",
|
||||
ssl_certstatus_name(server->cert_status),
|
||||
ssl_certstatus_name(server2->cert_status));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -104,92 +99,78 @@ static int SSL_TEST_EXTRA_CONF_equal(SSL_TEST_EXTRA_CONF *extra,
|
||||
/* Returns 1 if the contexts are equal, 0 otherwise. */
|
||||
static int SSL_TEST_CTX_equal(SSL_TEST_CTX *ctx, SSL_TEST_CTX *ctx2)
|
||||
{
|
||||
if (ctx->method != ctx2->method) {
|
||||
fprintf(stderr, "Method mismatch: %s vs %s.\n",
|
||||
ssl_test_method_name(ctx->method),
|
||||
ssl_test_method_name(ctx2->method));
|
||||
if (!TEST_int_eq(ctx->method, ctx2->method)) {
|
||||
TEST_info("Method mismatch: %s vs %s.",
|
||||
ssl_test_method_name(ctx->method),
|
||||
ssl_test_method_name(ctx2->method));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->handshake_mode != ctx2->handshake_mode) {
|
||||
fprintf(stderr, "HandshakeMode mismatch: %s vs %s.\n",
|
||||
ssl_handshake_mode_name(ctx->handshake_mode),
|
||||
ssl_handshake_mode_name(ctx2->handshake_mode));
|
||||
if (!TEST_int_eq(ctx->handshake_mode, ctx2->handshake_mode)) {
|
||||
TEST_info("HandshakeMode mismatch: %s vs %s.",
|
||||
ssl_handshake_mode_name(ctx->handshake_mode),
|
||||
ssl_handshake_mode_name(ctx2->handshake_mode));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->app_data_size != ctx2->app_data_size) {
|
||||
fprintf(stderr, "ApplicationData mismatch: %d vs %d.\n",
|
||||
ctx->app_data_size, ctx2->app_data_size);
|
||||
if (!TEST_int_eq(ctx->app_data_size, ctx2->app_data_size))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->max_fragment_size != ctx2->max_fragment_size) {
|
||||
fprintf(stderr, "MaxFragmentSize mismatch: %d vs %d.\n",
|
||||
ctx->max_fragment_size, ctx2->max_fragment_size);
|
||||
if (!TEST_int_eq(ctx->max_fragment_size, ctx2->max_fragment_size))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!SSL_TEST_EXTRA_CONF_equal(&ctx->extra, &ctx2->extra)) {
|
||||
fprintf(stderr, "Extra conf mismatch.\n");
|
||||
if (!SSL_TEST_EXTRA_CONF_equal(&ctx->extra, &ctx2->extra))
|
||||
return 0;
|
||||
}
|
||||
if (!SSL_TEST_EXTRA_CONF_equal(&ctx->resume_extra, &ctx2->resume_extra)) {
|
||||
fprintf(stderr, "Resume extra conf mismatch.\n");
|
||||
if (!SSL_TEST_EXTRA_CONF_equal(&ctx->resume_extra, &ctx2->resume_extra))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->expected_result != ctx2->expected_result) {
|
||||
fprintf(stderr, "ExpectedResult mismatch: %s vs %s.\n",
|
||||
ssl_test_result_name(ctx->expected_result),
|
||||
ssl_test_result_name(ctx2->expected_result));
|
||||
if (!TEST_int_eq(ctx->expected_result, ctx2->expected_result)) {
|
||||
TEST_info("ExpectedResult mismatch: %s vs %s.",
|
||||
ssl_test_result_name(ctx->expected_result),
|
||||
ssl_test_result_name(ctx2->expected_result));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->expected_client_alert != ctx2->expected_client_alert) {
|
||||
fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
|
||||
ssl_alert_name(ctx->expected_client_alert),
|
||||
ssl_alert_name(ctx2->expected_client_alert));
|
||||
if (!TEST_int_eq(ctx->expected_client_alert, ctx2->expected_client_alert)) {
|
||||
TEST_info("ClientAlert mismatch: %s vs %s.",
|
||||
ssl_alert_name(ctx->expected_client_alert),
|
||||
ssl_alert_name(ctx2->expected_client_alert));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->expected_server_alert != ctx2->expected_server_alert) {
|
||||
fprintf(stderr, "ServerAlert mismatch: %s vs %s.\n",
|
||||
ssl_alert_name(ctx->expected_server_alert),
|
||||
ssl_alert_name(ctx2->expected_server_alert));
|
||||
if (!TEST_int_eq(ctx->expected_server_alert, ctx2->expected_server_alert)) {
|
||||
TEST_info("ServerAlert mismatch: %s vs %s.",
|
||||
ssl_alert_name(ctx->expected_server_alert),
|
||||
ssl_alert_name(ctx2->expected_server_alert));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->expected_protocol != ctx2->expected_protocol) {
|
||||
fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
|
||||
ssl_protocol_name(ctx->expected_protocol),
|
||||
ssl_protocol_name(ctx2->expected_protocol));
|
||||
if (!TEST_int_eq(ctx->expected_protocol, ctx2->expected_protocol)) {
|
||||
TEST_info("ClientAlert mismatch: %s vs %s.",
|
||||
ssl_protocol_name(ctx->expected_protocol),
|
||||
ssl_protocol_name(ctx2->expected_protocol));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->expected_servername != ctx2->expected_servername) {
|
||||
fprintf(stderr, "ExpectedServerName mismatch: %s vs %s.\n",
|
||||
ssl_servername_name(ctx->expected_servername),
|
||||
ssl_servername_name(ctx2->expected_servername));
|
||||
if (!TEST_int_eq(ctx->expected_servername, ctx2->expected_servername)) {
|
||||
TEST_info("ExpectedServerName mismatch: %s vs %s.",
|
||||
ssl_servername_name(ctx->expected_servername),
|
||||
ssl_servername_name(ctx2->expected_servername));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->session_ticket_expected != ctx2->session_ticket_expected) {
|
||||
fprintf(stderr, "SessionTicketExpected mismatch: %s vs %s.\n",
|
||||
if (!TEST_int_eq(ctx->session_ticket_expected,
|
||||
ctx2->session_ticket_expected)) {
|
||||
TEST_info("SessionTicketExpected mismatch: %s vs %s.",
|
||||
ssl_session_ticket_name(ctx->session_ticket_expected),
|
||||
ssl_session_ticket_name(ctx2->session_ticket_expected));
|
||||
return 0;
|
||||
}
|
||||
if (ctx->compression_expected != ctx2->compression_expected) {
|
||||
fprintf(stderr, "ComrpessionExpected mismatch: %d vs %d.\n",
|
||||
ctx->compression_expected,
|
||||
ctx2->compression_expected);
|
||||
if (!TEST_int_eq(ctx->compression_expected, ctx2->compression_expected)) {
|
||||
TEST_info("ComrpessionExpected mismatch: %d vs %d.",
|
||||
ctx->compression_expected,
|
||||
ctx2->compression_expected);
|
||||
return 0;
|
||||
}
|
||||
if (!strings_equal("ExpectedNPNProtocol", ctx->expected_npn_protocol,
|
||||
ctx2->expected_npn_protocol))
|
||||
if (!TEST_str_eq(ctx->expected_npn_protocol, ctx2->expected_npn_protocol))
|
||||
return 0;
|
||||
if (!strings_equal("ExpectedALPNProtocol", ctx->expected_alpn_protocol,
|
||||
ctx2->expected_alpn_protocol))
|
||||
if (!TEST_str_eq(ctx->expected_alpn_protocol, ctx2->expected_alpn_protocol))
|
||||
return 0;
|
||||
if (ctx->resumption_expected != ctx2->resumption_expected) {
|
||||
fprintf(stderr, "ResumptionExpected mismatch: %d vs %d.\n",
|
||||
ctx->resumption_expected, ctx2->resumption_expected);
|
||||
if (!TEST_int_eq(ctx->resumption_expected, ctx2->resumption_expected))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -208,9 +189,9 @@ static int execute_test(SSL_TEST_CTX_TEST_FIXTURE fixture)
|
||||
|
||||
SSL_TEST_CTX *ctx = SSL_TEST_CTX_create(conf, fixture.test_section);
|
||||
|
||||
if (ctx == NULL) {
|
||||
fprintf(stderr, "Failed to parse good configuration %s.\n",
|
||||
fixture.test_section);
|
||||
if (!TEST_ptr(ctx)) {
|
||||
TEST_info("Failed to parse good configuration %s.",
|
||||
fixture.test_section);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -302,9 +283,9 @@ static int test_bad_configuration(int idx)
|
||||
{
|
||||
SSL_TEST_CTX *ctx = SSL_TEST_CTX_create(conf, bad_configurations[idx]);
|
||||
|
||||
if (ctx != NULL) {
|
||||
fprintf(stderr, "Parsing bad configuration %s succeeded.\n",
|
||||
bad_configurations[idx]);
|
||||
if (!TEST_ptr_null(ctx)) {
|
||||
TEST_info("Parsing bad configuration %s succeeded.",
|
||||
bad_configurations[idx]);
|
||||
SSL_TEST_CTX_free(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
@ -90,21 +90,19 @@ static int test_int_stack(void)
|
||||
|
||||
/* Check push and num */
|
||||
for (i = 0; i < n; i++) {
|
||||
if (sk_sint_num(s) != i) {
|
||||
fprintf(stderr, "test int stack size %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_num(s), i)) {
|
||||
TEST_info("int stack size %d", i);
|
||||
goto end;
|
||||
}
|
||||
sk_sint_push(s, v + i);
|
||||
}
|
||||
if (sk_sint_num(s) != n) {
|
||||
fprintf(stderr, "test int stack size %d\n", n);
|
||||
if (!TEST_int_eq(sk_sint_num(s), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* check the values */
|
||||
for (i = 0; i < n; i++)
|
||||
if (sk_sint_value(s, i) != v + i) {
|
||||
fprintf(stderr, "test int value %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_sint_value(s, i), v + i)) {
|
||||
TEST_info("int value %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -113,8 +111,8 @@ static int test_int_stack(void)
|
||||
int *val = (finds[i].unsorted == -1) ? ¬present
|
||||
: v + finds[i].unsorted;
|
||||
|
||||
if (sk_sint_find(s, val) != finds[i].unsorted) {
|
||||
fprintf(stderr, "test int unsorted find %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_find(s, val), finds[i].unsorted)) {
|
||||
TEST_info("int unsorted find %d", i);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@ -124,48 +122,42 @@ static int test_int_stack(void)
|
||||
int *val = (finds[i].unsorted == -1) ? ¬present
|
||||
: v + finds[i].unsorted;
|
||||
|
||||
if (sk_sint_find_ex(s, val) != finds[i].unsorted) {
|
||||
fprintf(stderr, "test int unsorted find_ex %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_find_ex(s, val), finds[i].unsorted)) {
|
||||
TEST_info("int unsorted find_ex %d", i);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
/* sorting */
|
||||
if (sk_sint_is_sorted(s)) {
|
||||
fprintf(stderr, "test int unsorted\n");
|
||||
if (!TEST_false(sk_sint_is_sorted(s)))
|
||||
goto end;
|
||||
}
|
||||
sk_sint_set_cmp_func(s, &int_compare);
|
||||
sk_sint_sort(s);
|
||||
if (!sk_sint_is_sorted(s)) {
|
||||
fprintf(stderr, "test int sorted\n");
|
||||
if (!TEST_true(sk_sint_is_sorted(s)))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* find sorted -- the value is matched so we don't need to locate it */
|
||||
for (i = 0; i < n_finds; i++)
|
||||
if (sk_sint_find(s, &finds[i].value) != finds[i].sorted) {
|
||||
fprintf(stderr, "test int sorted find %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_find(s, &finds[i].value), finds[i].sorted)) {
|
||||
TEST_info("int sorted find %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* find_ex sorted */
|
||||
for (i = 0; i < n_finds; i++)
|
||||
if (sk_sint_find_ex(s, &finds[i].value) != finds[i].ex) {
|
||||
fprintf(stderr, "test int sorted find_ex present %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_find_ex(s, &finds[i].value), finds[i].ex)) {
|
||||
TEST_info("int sorted find_ex present %d", i);
|
||||
goto end;
|
||||
}
|
||||
for (i = 0; i < n_exfinds; i++)
|
||||
if (sk_sint_find_ex(s, &exfinds[i].value) != exfinds[i].ex) {
|
||||
fprintf(stderr, "test int sorted find_ex absent %d\n", i);
|
||||
if (!TEST_int_eq(sk_sint_find_ex(s, &exfinds[i].value), exfinds[i].ex)){
|
||||
TEST_info("int sorted find_ex absent %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* shift */
|
||||
if (sk_sint_shift(s) != v + 6) {
|
||||
fprintf(stderr, "test int shift\n");
|
||||
if (!TEST_ptr_eq(sk_sint_shift(s), v + 6))
|
||||
goto end;
|
||||
}
|
||||
|
||||
testresult = 1;
|
||||
end:
|
||||
@ -189,29 +181,25 @@ static int test_uchar_stack(void)
|
||||
|
||||
/* unshift and num */
|
||||
for (i = 0; i < n; i++) {
|
||||
if (sk_uchar_num(s) != i) {
|
||||
fprintf(stderr, "test uchar stack size %d\n", i);
|
||||
if (!TEST_int_eq(sk_uchar_num(s), i)) {
|
||||
TEST_info("uchar stack size %d", i);
|
||||
goto end;
|
||||
}
|
||||
sk_uchar_unshift(s, v + i);
|
||||
}
|
||||
if (sk_uchar_num(s) != n) {
|
||||
fprintf(stderr, "test uchar stack size %d\n", n);
|
||||
if (!TEST_int_eq(sk_uchar_num(s), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* dup */
|
||||
r = sk_uchar_dup(s);
|
||||
if (sk_uchar_num(r) != n) {
|
||||
fprintf(stderr, "test uchar dup size %d\n", n);
|
||||
if (!TEST_int_eq(sk_uchar_num(r), n))
|
||||
goto end;
|
||||
}
|
||||
sk_uchar_sort(r);
|
||||
|
||||
/* pop */
|
||||
for (i = 0; i < n; i++)
|
||||
if (sk_uchar_pop(s) != v + i) {
|
||||
fprintf(stderr, "test uchar pop %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_uchar_pop(s), v + i)) {
|
||||
TEST_info("uchar pop %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -220,43 +208,35 @@ static int test_uchar_stack(void)
|
||||
s = NULL;
|
||||
|
||||
/* dup again */
|
||||
if (sk_uchar_num(r) != n) {
|
||||
fprintf(stderr, "test uchar dup size %d\n", n);
|
||||
if (!TEST_int_eq(sk_uchar_num(r), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* zero */
|
||||
sk_uchar_zero(r);
|
||||
if (sk_uchar_num(r) != 0) {
|
||||
fprintf(stderr, "test uchar zero %d\n", n);
|
||||
if (!TEST_int_eq(sk_uchar_num(r), 0))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* insert */
|
||||
sk_uchar_insert(r, v, 0);
|
||||
sk_uchar_insert(r, v + 2, -1);
|
||||
sk_uchar_insert(r, v + 1, 1);
|
||||
for (i = 0; i < 3; i++)
|
||||
if (sk_uchar_value(r, i) != v + i) {
|
||||
fprintf(stderr, "test uchar insert %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) {
|
||||
TEST_info("uchar insert %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* delete */
|
||||
if (sk_uchar_delete(r, 12) != NULL) {
|
||||
fprintf(stderr, "test uchar delete missing %d\n", n);
|
||||
if (!TEST_ptr_null(sk_uchar_delete(r, 12)))
|
||||
goto end;
|
||||
}
|
||||
if (sk_uchar_delete(r, 1) != v + 1) {
|
||||
fprintf(stderr, "test uchar delete middle %d\n", n);
|
||||
if (!TEST_ptr_eq(sk_uchar_delete(r, 1), v + 1))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* set */
|
||||
sk_uchar_set(r, 1, v + 1);
|
||||
for (i = 0; i < 2; i++)
|
||||
if (sk_uchar_value(r, i) != v + i) {
|
||||
fprintf(stderr, "test uchar set %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_uchar_value(r, i), v + i)) {
|
||||
TEST_info("uchar set %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -293,37 +273,35 @@ static int test_SS_stack(void)
|
||||
for (i = 0; i < n; i++) {
|
||||
v[i] = OPENSSL_malloc(sizeof(*v[i]));
|
||||
|
||||
if (v[i] == NULL) {
|
||||
fprintf(stderr, "test SS memory allocation failure\n");
|
||||
if (!TEST_ptr(v[i]))
|
||||
goto end;
|
||||
}
|
||||
v[i]->n = i;
|
||||
v[i]->c = 'A' + i;
|
||||
if (sk_SS_num(s) != i) {
|
||||
fprintf(stderr, "test SS stack size %d\n", i);
|
||||
if (!TEST_int_eq(sk_SS_num(s), i)) {
|
||||
TEST_info("SS stack size %d", i);
|
||||
goto end;
|
||||
}
|
||||
sk_SS_push(s, v[i]);
|
||||
}
|
||||
if (sk_SS_num(s) != n) {
|
||||
fprintf(stderr, "test SS size %d\n", n);
|
||||
if (!TEST_int_eq(sk_SS_num(s), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* deepcopy */
|
||||
r = sk_SS_deep_copy(s, &SS_copy, &SS_free);
|
||||
if (r == NULL) {
|
||||
fprintf(stderr, "test SS deepcopy failure\n");
|
||||
if (!TEST_ptr(r))
|
||||
goto end;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
p = sk_SS_value(r, i);
|
||||
if (p == v[i]) {
|
||||
fprintf(stderr, "test SS deepcopy non-copy %d\n", i);
|
||||
if (!TEST_ptr_ne(p, v[i])) {
|
||||
TEST_info("SS deepcopy non-copy %d", i);
|
||||
goto end;
|
||||
}
|
||||
if (p->n != v[i]->n || p->c != v[i]->c) {
|
||||
fprintf(stderr, "test SS deepcopy values %d\n", i);
|
||||
if (!TEST_int_eq(p->n, v[i]->n)) {
|
||||
TEST_info("test SS deepcopy int %d", i);
|
||||
goto end;
|
||||
}
|
||||
if (!TEST_char_eq(p->c, v[i]->c)) {
|
||||
TEST_info("SS deepcopy char %d", i);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@ -333,18 +311,15 @@ static int test_SS_stack(void)
|
||||
r = NULL;
|
||||
|
||||
/* delete_ptr */
|
||||
if ((p = sk_SS_delete_ptr(s, v[3])) == NULL) {
|
||||
fprintf(stderr, "test SS delete ptr not found\n");
|
||||
p = sk_SS_delete_ptr(s, v[3]);
|
||||
if (!TEST_ptr(p))
|
||||
goto end;
|
||||
}
|
||||
SS_free(p);
|
||||
if (sk_SS_num(s) != n-1) {
|
||||
fprintf(stderr, "test SS delete ptr size\n");
|
||||
if (!TEST_int_eq(sk_SS_num(s), n - 1))
|
||||
goto end;
|
||||
}
|
||||
for (i = 0; i < n-1; i++)
|
||||
if (sk_SS_value(s, i) != v[i<3 ? i : 1+i]) {
|
||||
fprintf(stderr, "test SS delete ptr item %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_SS_value(s, i), v[i<3 ? i : 1+i])) {
|
||||
TEST_info("SS delete ptr item %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -369,21 +344,19 @@ static int test_SU_stack(void)
|
||||
v[i].n = i;
|
||||
else
|
||||
v[i].c = 'A' + i;
|
||||
if (sk_SU_num(s) != i) {
|
||||
fprintf(stderr, "test SU stack size %d\n", i);
|
||||
if (!TEST_int_eq(sk_SU_num(s), i)) {
|
||||
TEST_info("SU stack size %d", i);
|
||||
goto end;
|
||||
}
|
||||
sk_SU_push(s, v + i);
|
||||
}
|
||||
if (sk_SU_num(s) != n) {
|
||||
fprintf(stderr, "test SU size %d\n", n);
|
||||
if (!TEST_int_eq(sk_SU_num(s), n))
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* check the pointers are correct */
|
||||
for (i = 0; i < n; i++)
|
||||
if (sk_SU_value(s, i) != v + i) {
|
||||
fprintf(stderr, "test SU pointer check %d\n", i);
|
||||
if (!TEST_ptr_eq(sk_SU_value(s, i), v + i)) {
|
||||
TEST_info("SU pointer check %d", i);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
276
test/test_test.c
Normal file
276
test/test_test.c
Normal file
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#include "e_os.h"
|
||||
#include "test_main.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define C(l, b, t) \
|
||||
if ((t) != b) { \
|
||||
fprintf(stderr, "FATAL : %s != %d\n", #t, b); \
|
||||
goto l; \
|
||||
}
|
||||
|
||||
static int test_int(void)
|
||||
{
|
||||
C(err, 1, TEST_int_eq(1, 1));
|
||||
C(err, 0, TEST_int_eq(1, -1));
|
||||
C(err, 1, TEST_int_ne(1, 2));
|
||||
C(err, 0, TEST_int_ne(3, 3));
|
||||
C(err, 1, TEST_int_lt(4, 9));
|
||||
C(err, 0, TEST_int_lt(9, 4));
|
||||
C(err, 1, TEST_int_le(4, 9));
|
||||
C(err, 1, TEST_int_le(5, 5));
|
||||
C(err, 0, TEST_int_le(9, 4));
|
||||
C(err, 1, TEST_int_gt(8, 5));
|
||||
C(err, 0, TEST_int_gt(5, 8));
|
||||
C(err, 1, TEST_int_ge(8, 5));
|
||||
C(err, 1, TEST_int_ge(6, 6));
|
||||
C(err, 0, TEST_int_ge(5, 8));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_uint(void)
|
||||
{
|
||||
C(err, 1, TEST_uint_eq(3u, 3u));
|
||||
C(err, 0, TEST_uint_eq(3u, 5u));
|
||||
C(err, 1, TEST_uint_ne(4u, 2u));
|
||||
C(err, 0, TEST_uint_ne(6u, 6u));
|
||||
C(err, 1, TEST_uint_lt(5u, 9u));
|
||||
C(err, 0, TEST_uint_lt(9u, 5u));
|
||||
C(err, 1, TEST_uint_le(5u, 9u));
|
||||
C(err, 1, TEST_uint_le(7u, 7u));
|
||||
C(err, 0, TEST_uint_le(9u, 5u));
|
||||
C(err, 1, TEST_uint_gt(11u, 1u));
|
||||
C(err, 0, TEST_uint_gt(1u, 11u));
|
||||
C(err, 1, TEST_uint_ge(11u, 1u));
|
||||
C(err, 1, TEST_uint_ge(6u, 6u));
|
||||
C(err, 0, TEST_uint_ge(1u, 11u));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_char(void)
|
||||
{
|
||||
C(err, 1, TEST_char_eq('a', 'a'));
|
||||
C(err, 0, TEST_char_eq('a', 'A'));
|
||||
C(err, 1, TEST_char_ne('a', 'c'));
|
||||
C(err, 0, TEST_char_ne('e', 'e'));
|
||||
C(err, 1, TEST_char_lt('i', 'x'));
|
||||
C(err, 0, TEST_char_lt('x', 'i'));
|
||||
C(err, 1, TEST_char_le('i', 'x'));
|
||||
C(err, 1, TEST_char_le('n', 'n'));
|
||||
C(err, 0, TEST_char_le('x', 'i'));
|
||||
C(err, 1, TEST_char_gt('w', 'n'));
|
||||
C(err, 0, TEST_char_gt('n', 'w'));
|
||||
C(err, 1, TEST_char_ge('w', 'n'));
|
||||
C(err, 1, TEST_char_ge('p', 'p'));
|
||||
C(err, 0, TEST_char_ge('n', 'w'));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_uchar(void)
|
||||
{
|
||||
C(err, 1, TEST_uchar_eq(49, 49));
|
||||
C(err, 0, TEST_uchar_eq(49, 60));
|
||||
C(err, 1, TEST_uchar_ne(50, 2));
|
||||
C(err, 0, TEST_uchar_ne(66, 66));
|
||||
C(err, 1, TEST_uchar_lt(60, 80));
|
||||
C(err, 0, TEST_uchar_lt(80, 60));
|
||||
C(err, 1, TEST_uchar_le(60, 80));
|
||||
C(err, 1, TEST_uchar_le(78, 78));
|
||||
C(err, 0, TEST_uchar_le(80, 60));
|
||||
C(err, 1, TEST_uchar_gt(88, 37));
|
||||
C(err, 0, TEST_uchar_gt(37, 88));
|
||||
C(err, 1, TEST_uchar_ge(88, 37));
|
||||
C(err, 1, TEST_uchar_ge(66, 66));
|
||||
C(err, 0, TEST_uchar_ge(37, 88));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_long(void)
|
||||
{
|
||||
C(err, 1, TEST_long_eq(123l, 123l));
|
||||
C(err, 0, TEST_long_eq(123l, -123l));
|
||||
C(err, 1, TEST_long_ne(123l, 500l));
|
||||
C(err, 0, TEST_long_ne(1000l, 1000l));
|
||||
C(err, 1, TEST_long_lt(-8923l, 102934563l));
|
||||
C(err, 0, TEST_long_lt(102934563l, -8923l));
|
||||
C(err, 1, TEST_long_le(-8923l, 102934563l));
|
||||
C(err, 1, TEST_long_le(12345l, 12345l));
|
||||
C(err, 0, TEST_long_le(102934563l, -8923l));
|
||||
C(err, 1, TEST_long_gt(84325677l, 12345l));
|
||||
C(err, 0, TEST_long_gt(12345l, 84325677l));
|
||||
C(err, 1, TEST_long_ge(84325677l, 12345l));
|
||||
C(err, 1, TEST_long_ge(465869l, 465869l));
|
||||
C(err, 0, TEST_long_ge(12345l, 84325677l));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_ulong(void)
|
||||
{
|
||||
C(err, 1, TEST_ulong_eq(919ul, 919ul));
|
||||
C(err, 0, TEST_ulong_eq(919ul, 10234ul));
|
||||
C(err, 1, TEST_ulong_ne(8190ul, 66ul));
|
||||
C(err, 0, TEST_ulong_ne(10555ul, 10555ul));
|
||||
C(err, 1, TEST_ulong_lt(10234ul, 1000000ul));
|
||||
C(err, 0, TEST_ulong_lt(1000000ul, 10234ul));
|
||||
C(err, 1, TEST_ulong_le(10234ul, 1000000ul));
|
||||
C(err, 1, TEST_ulong_le(100000ul, 100000ul));
|
||||
C(err, 0, TEST_ulong_le(1000000ul, 10234ul));
|
||||
C(err, 1, TEST_ulong_gt(100000000ul, 22ul));
|
||||
C(err, 0, TEST_ulong_gt(22ul, 100000000ul));
|
||||
C(err, 1, TEST_ulong_ge(100000000ul, 22ul));
|
||||
C(err, 1, TEST_ulong_ge(10555ul, 10555ul));
|
||||
C(err, 0, TEST_ulong_ge(22ul, 100000000ul));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_size_t(void)
|
||||
{
|
||||
C(err, 1, TEST_int_eq((size_t)10, (size_t)10));
|
||||
C(err, 0, TEST_int_eq((size_t)10, (size_t)12));
|
||||
C(err, 1, TEST_int_ne((size_t)10, (size_t)12));
|
||||
C(err, 0, TEST_int_ne((size_t)24, (size_t)24));
|
||||
C(err, 1, TEST_int_lt((size_t)30, (size_t)88));
|
||||
C(err, 0, TEST_int_lt((size_t)88, (size_t)30));
|
||||
C(err, 1, TEST_int_le((size_t)30, (size_t)88));
|
||||
C(err, 1, TEST_int_le((size_t)33, (size_t)33));
|
||||
C(err, 0, TEST_int_le((size_t)88, (size_t)30));
|
||||
C(err, 1, TEST_int_gt((size_t)52, (size_t)33));
|
||||
C(err, 0, TEST_int_gt((size_t)33, (size_t)52));
|
||||
C(err, 1, TEST_int_ge((size_t)52, (size_t)33));
|
||||
C(err, 1, TEST_int_ge((size_t)38, (size_t)38));
|
||||
C(err, 0, TEST_int_ge((size_t)33, (size_t)52));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_pointer(void)
|
||||
{
|
||||
int x = 0;
|
||||
char y = 1;
|
||||
|
||||
C(err, 1, TEST_ptr(&y));
|
||||
C(err, 0, TEST_ptr(NULL));
|
||||
C(err, 0, TEST_ptr_null(&y));
|
||||
C(err, 1, TEST_ptr_null(NULL));
|
||||
C(err, 1, TEST_ptr_eq(NULL, NULL));
|
||||
C(err, 0, TEST_ptr_eq(NULL, &y));
|
||||
C(err, 0, TEST_ptr_eq(&y, NULL));
|
||||
C(err, 0, TEST_ptr_eq(&y, &x));
|
||||
C(err, 1, TEST_ptr_eq(&x, &x));
|
||||
C(err, 0, TEST_ptr_ne(NULL, NULL));
|
||||
C(err, 1, TEST_ptr_ne(NULL, &y));
|
||||
C(err, 1, TEST_ptr_ne(&y, NULL));
|
||||
C(err, 1, TEST_ptr_ne(&y, &x));
|
||||
C(err, 0, TEST_ptr_ne(&x, &x));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_bool(void)
|
||||
{
|
||||
C(err, 0, TEST_true(0));
|
||||
C(err, 1, TEST_true(1));
|
||||
C(err, 1, TEST_false(0));
|
||||
C(err, 0, TEST_false(1));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_string(void)
|
||||
{
|
||||
static char buf[] = "abc";
|
||||
C(err, 1, TEST_str_eq(NULL, NULL));
|
||||
C(err, 1, TEST_str_eq("abc", buf));
|
||||
C(err, 0, TEST_str_eq("abc", NULL));
|
||||
C(err, 0, TEST_str_eq(NULL, buf));
|
||||
C(err, 0, TEST_str_ne(NULL, NULL));
|
||||
C(err, 0, TEST_str_ne("abc", buf));
|
||||
C(err, 1, TEST_str_ne("abc", NULL));
|
||||
C(err, 1, TEST_str_ne(NULL, buf));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_memory(void)
|
||||
{
|
||||
static char buf[] = "xyz";
|
||||
C(err, 1, TEST_mem_eq(NULL, 0, NULL, 0));
|
||||
C(err, 1, TEST_mem_eq(NULL, 1, NULL, 2));
|
||||
C(err, 0, TEST_mem_eq(NULL, 0, "xyz", 3));
|
||||
C(err, 0, TEST_mem_eq(NULL, 0, "", 0));
|
||||
C(err, 0, TEST_mem_eq("xyz", 3, NULL, 0));
|
||||
C(err, 0, TEST_mem_eq("xyz", 3, buf, sizeof(buf)));
|
||||
C(err, 1, TEST_mem_eq("xyz", 4, buf, sizeof(buf)));
|
||||
return 1;
|
||||
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_messages(void)
|
||||
{
|
||||
TEST_info("This is an %s message.", "info");
|
||||
TEST_error("This is an %s message.", "error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void register_tests(void)
|
||||
{
|
||||
ADD_TEST(test_int);
|
||||
ADD_TEST(test_uint);
|
||||
ADD_TEST(test_char);
|
||||
ADD_TEST(test_uchar);
|
||||
ADD_TEST(test_long);
|
||||
ADD_TEST(test_ulong);
|
||||
ADD_TEST(test_size_t);
|
||||
ADD_TEST(test_pointer);
|
||||
ADD_TEST(test_bool);
|
||||
ADD_TEST(test_string);
|
||||
ADD_TEST(test_memory);
|
||||
ADD_TEST(test_messages);
|
||||
}
|
275
test/testutil.c
275
test/testutil.c
@ -19,6 +19,9 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
/* The size of memory buffers to display on failure */
|
||||
#define MEM_BUFFER_SIZE (21)
|
||||
|
||||
/*
|
||||
* Declares the structures needed to register each test case function.
|
||||
*/
|
||||
@ -145,18 +148,284 @@ int run_tests(const char *test_prog_name)
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* A common routine to output test failure messages. Generally this should not
|
||||
* be called directly, rather it should be called by the following functions.
|
||||
*
|
||||
* |desc| is a printf formatted description with arguments |args| that is
|
||||
* supplied by the user and |desc| can be NULL. |type| is the data type
|
||||
* that was tested (int, char, ptr, ...). |fmt| is a system provided
|
||||
* printf format with following arguments that spell out the failure
|
||||
* details i.e. the actual values compared and the operator used.
|
||||
*
|
||||
* The typical use for this is from an utility test function:
|
||||
*
|
||||
* int test6(const char *file, int line, int n) {
|
||||
* if (n != 6) {
|
||||
* test_fail_message(1, file, line, "int", "value %d is not %d", n, 6);
|
||||
* return 0;
|
||||
* }
|
||||
* return 1;
|
||||
* }
|
||||
*
|
||||
* calling test6(3, "oops") will return 0 and produce out along the lines of:
|
||||
* FAIL oops: (int) value 3 is not 6\n
|
||||
*
|
||||
* It general, test_fail_message should not be called directly.
|
||||
*/
|
||||
static void test_fail_message(const char *prefix, const char *file, int line,
|
||||
const char *type, const char *fmt, ...)
|
||||
PRINTF_FORMAT(5, 6);
|
||||
|
||||
static void test_fail_message_va(const char *prefix, const char *file, int line,
|
||||
const char *type, const char *fmt, va_list ap)
|
||||
{
|
||||
fputs(prefix != NULL ? prefix : "ERROR", stderr);
|
||||
fputs(":", stderr);
|
||||
if (type)
|
||||
fprintf(stderr, " (%s)", type);
|
||||
if (fmt != NULL) {
|
||||
fputc(' ', stderr);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
}
|
||||
if (file != NULL) {
|
||||
fprintf(stderr, " @ %s:%d", file, line);
|
||||
}
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
static void test_fail_message(const char *prefix, const char *file, int line,
|
||||
const char *type, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
test_fail_message_va(prefix, file, line, type, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void test_info_c90(const char *desc, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, desc);
|
||||
test_fail_message_va("INFO", NULL, -1, NULL, desc, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void test_info(const char *file, int line, const char *desc, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, desc);
|
||||
test_fail_message_va("INFO", file, line, NULL, desc, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void test_error_c90(const char *desc, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, desc);
|
||||
test_fail_message(NULL, NULL, -1, NULL, desc, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void test_error(const char *file, int line, const char *desc, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, desc);
|
||||
test_fail_message_va(NULL, file, line, NULL, desc, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Define some comparisons between pairs of various types.
|
||||
* These functions return 1 if the test is true.
|
||||
* Otherwise, they return 0 and pretty-print diagnostics.
|
||||
*
|
||||
* In each case the functions produced are:
|
||||
* int test_name_eq(const type t1, const type t2, const char *desc, ...);
|
||||
* int test_name_ne(const type t1, const type t2, const char *desc, ...);
|
||||
* int test_name_lt(const type t1, const type t2, const char *desc, ...);
|
||||
* int test_name_le(const type t1, const type t2, const char *desc, ...);
|
||||
* int test_name_gt(const type t1, const type t2, const char *desc, ...);
|
||||
* int test_name_ge(const type t1, const type t2, const char *desc, ...);
|
||||
*
|
||||
* The t1 and t2 arguments are to be compared for equality, inequality,
|
||||
* less than, less than or equal to, greater than and greater than or
|
||||
* equal to respectively. If the specified condition holds, the functions
|
||||
* return 1. If the condition does not hold, the functions print a diagnostic
|
||||
* message and return 0.
|
||||
*
|
||||
* 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) \
|
||||
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, \
|
||||
"%s [" fmt "] " #op " %s [" fmt "]", \
|
||||
s1, t1, s2, t2); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define DEFINE_COMPARISONS(type, name, fmt) \
|
||||
DEFINE_COMPARISON(type, name, eq, ==, fmt) \
|
||||
DEFINE_COMPARISON(type, name, ne, !=, fmt) \
|
||||
DEFINE_COMPARISON(type, name, lt, <, fmt) \
|
||||
DEFINE_COMPARISON(type, name, le, <=, fmt) \
|
||||
DEFINE_COMPARISON(type, name, gt, >, fmt) \
|
||||
DEFINE_COMPARISON(type, name, ge, >=, fmt)
|
||||
|
||||
DEFINE_COMPARISONS(int, int, "%d")
|
||||
DEFINE_COMPARISONS(unsigned int, uint, "%u")
|
||||
DEFINE_COMPARISONS(char, char, "%c")
|
||||
DEFINE_COMPARISONS(unsigned char, uchar, "%u")
|
||||
DEFINE_COMPARISONS(long, long, "%ld")
|
||||
DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
|
||||
DEFINE_COMPARISONS(size_t, size_t, "%" OSSLzu)
|
||||
|
||||
DEFINE_COMPARISON(void *, ptr, eq, ==, "%p")
|
||||
DEFINE_COMPARISON(void *, ptr, ne, !=, "%p")
|
||||
|
||||
int test_ptr_null(const char *file, int line, const char *s, const void *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
return 1;
|
||||
test_fail_message(NULL, file, line, "ptr", "%s [%p] == NULL", s, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_ptr(const char *file, int line, const char *s, const void *p)
|
||||
{
|
||||
if (p != NULL)
|
||||
return 1;
|
||||
test_fail_message(NULL, file, line, "ptr", "%s [%p] != NULL", s, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_true(const char *file, int line, const char *s, int b)
|
||||
{
|
||||
if (b)
|
||||
return 1;
|
||||
test_fail_message(NULL, file, line, "bool", "%s [false] == true", s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_false(const char *file, int line, const char *s, int b)
|
||||
{
|
||||
if (!b)
|
||||
return 1;
|
||||
test_fail_message(NULL, file, line, "bool", "%s [true] == false", s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *print_string_maybe_null(const char *s)
|
||||
{
|
||||
return s == NULL ? "(NULL)" : s;
|
||||
}
|
||||
|
||||
int strings_equal(const char *desc, const char *s1, const char *s2)
|
||||
int test_str_eq(const char *file, int line, const char *st1, const char *st2,
|
||||
const char *s1, const char *s2)
|
||||
{
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return 1;
|
||||
if (s1 == NULL || s2 == NULL || strcmp(s1, s2) != 0) {
|
||||
fprintf(stderr, "%s mismatch: %s vs %s\n", desc, print_string_maybe_null(s1),
|
||||
print_string_maybe_null(s2));
|
||||
test_fail_message(NULL, file, line, "string", "%s [%s] == %s [%s]",
|
||||
st1, print_string_maybe_null(s1),
|
||||
st2, print_string_maybe_null(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)
|
||||
{
|
||||
if ((s1 == NULL) ^ (s2 == NULL))
|
||||
return 1;
|
||||
if (s1 == NULL || strcmp(s1, s2) == 0) {
|
||||
test_fail_message(NULL, file, line, "string", "%s [%s] != %s [%s]",
|
||||
st1, print_string_maybe_null(s1),
|
||||
st2, print_string_maybe_null(s2));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* We could use OPENSSL_buf2hexstr() to do this but trying to allocate memory
|
||||
* in a failure state isn't generally a great idea.
|
||||
*/
|
||||
static const char *print_mem_maybe_null(const void *s, size_t n,
|
||||
char out[MEM_BUFFER_SIZE])
|
||||
{
|
||||
size_t i;
|
||||
const unsigned char *p = (const unsigned char *)s;
|
||||
int pad = 2*n >= MEM_BUFFER_SIZE;
|
||||
|
||||
if (s == NULL)
|
||||
return "(NULL)";
|
||||
if (pad)
|
||||
n = MEM_BUFFER_SIZE-4;
|
||||
|
||||
for (i=0; i<2*n; i++) {
|
||||
unsigned char c = (i & 1) != 0 ? p[i / 2] & 15 : p[i / 2] >> 4;
|
||||
out[i] = "0123456789abcdef"[c];
|
||||
}
|
||||
if (pad) {
|
||||
out[i++] = '.';
|
||||
out[i++] = '.';
|
||||
out[i++] = '.';
|
||||
}
|
||||
out[i] = '\0';
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char b1[MEM_BUFFER_SIZE], b2[MEM_BUFFER_SIZE];
|
||||
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return 1;
|
||||
if (n1 != n2) {
|
||||
test_fail_message(NULL, file, line, "memory",
|
||||
"size mismatch %s %s [%"OSSLzu"] != %s %s [%"OSSLzu"]",
|
||||
st1, print_mem_maybe_null(s1, n1, b1), n1,
|
||||
st2, print_mem_maybe_null(s2, n2, b2), n2);
|
||||
return 0;
|
||||
}
|
||||
if (s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {
|
||||
test_fail_message(NULL, file, line, "memory",
|
||||
"%s %s [%"OSSLzu"] != %s %s [%"OSSLzu"]",
|
||||
st1, print_mem_maybe_null(s1, n1, b1), n1,
|
||||
st2, print_mem_maybe_null(s2, n2, b2), 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)
|
||||
{
|
||||
char b1[MEM_BUFFER_SIZE], b2[MEM_BUFFER_SIZE];
|
||||
|
||||
if ((s1 == NULL) ^ (s2 == NULL))
|
||||
return 1;
|
||||
if (n1 != n2)
|
||||
return 1;
|
||||
if (s1 == NULL || memcmp(s1, s2, n1) == 0) {
|
||||
test_fail_message(NULL, file, line, "memory",
|
||||
"%s %s [%"OSSLzu"] != %s %s [%"OSSLzu"]",
|
||||
st1, print_mem_maybe_null(s1, n1, b1), n1,
|
||||
st2, print_mem_maybe_null(s2, n2, b2), n2);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
168
test/testutil.h
168
test/testutil.h
@ -10,6 +10,8 @@
|
||||
#ifndef HEADER_TESTUTIL_H
|
||||
# define HEADER_TESTUTIL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
@ -140,18 +142,176 @@ __owur int run_tests(const char *test_prog_name);
|
||||
* Test assumption verification helpers.
|
||||
*/
|
||||
|
||||
# if defined(__GNUC__)
|
||||
#define PRINTF_FORMAT(a, b) __attribute__ ((format(printf, a, b)))
|
||||
# else
|
||||
#define PRINTF_FORMAT(a, b)
|
||||
#endif
|
||||
|
||||
# define DECLARE_COMPARISON(type, name, opname) \
|
||||
int test_ ## name ## _ ## opname(const char *, int, \
|
||||
const char *, const char *, \
|
||||
const type, const type);
|
||||
|
||||
# define DECLARE_COMPARISONS(type, name) \
|
||||
DECLARE_COMPARISON(type, name, eq) \
|
||||
DECLARE_COMPARISON(type, name, ne) \
|
||||
DECLARE_COMPARISON(type, name, lt) \
|
||||
DECLARE_COMPARISON(type, name, le) \
|
||||
DECLARE_COMPARISON(type, name, gt) \
|
||||
DECLARE_COMPARISON(type, name, ge)
|
||||
|
||||
DECLARE_COMPARISONS(int, int)
|
||||
DECLARE_COMPARISONS(unsigned int, uint)
|
||||
DECLARE_COMPARISONS(char, char)
|
||||
DECLARE_COMPARISONS(unsigned char, uchar)
|
||||
DECLARE_COMPARISONS(long, long)
|
||||
DECLARE_COMPARISONS(unsigned long, ulong)
|
||||
DECLARE_COMPARISONS(size_t, size_t)
|
||||
|
||||
/*
|
||||
* Returns 1 if |s1| and |s2| are both NULL or equal.
|
||||
* Otherwise, returns 0 and pretty-prints diagnostics using |desc|.
|
||||
* Pointer comparisons against other pointers and null.
|
||||
* These functions return 1 if the test is true.
|
||||
* Otherwise, they return 0 and pretty-print diagnostics.
|
||||
* These should not be called directly, use the TEST_xxx macros below instead.
|
||||
*/
|
||||
int strings_equal(const char *desc, const char *s1, const char *s2);
|
||||
DECLARE_COMPARISON(void *, ptr, eq)
|
||||
DECLARE_COMPARISON(void *, ptr, ne)
|
||||
int test_ptr(const char *file, int line, const char *s, const void *p);
|
||||
int test_ptr_null(const char *file, int line, const char *s, const void *p);
|
||||
|
||||
/*
|
||||
* Equality tests for strings where NULL is a legitimate value.
|
||||
* These calls return 1 if the two passed strings compare true.
|
||||
* Otherwise, they return 0 and pretty-print diagnostics.
|
||||
* These should not be called directly, use the TEST_xxx macros below instead.
|
||||
*/
|
||||
DECLARE_COMPARISON(char *, str, eq)
|
||||
DECLARE_COMPARISON(char *, str, ne)
|
||||
|
||||
/*
|
||||
* Equality test for memory blocks where NULL is a legitimate value.
|
||||
* These calls return 1 if the two memory blocks compare true.
|
||||
* Otherwise, they return 0 and pretty-print diagnostics.
|
||||
* These should not be called directly, use the TEST_xxx macros below instead.
|
||||
*/
|
||||
int test_mem_eq(const char *, int, const char *, const char *,
|
||||
const void *, size_t, const void *, size_t);
|
||||
int test_mem_ne(const char *, int, const char *, const char *,
|
||||
const void *, size_t, const void *, size_t);
|
||||
|
||||
/*
|
||||
* Check a boolean result for being true or false.
|
||||
* They return 1 if the condition is true (i.e. the value is non-zro).
|
||||
* Otherwise, they return 0 and pretty-prints diagnostics using |desc|.
|
||||
* These should not be called directly, use the TEST_xxx macros below instead.
|
||||
*/
|
||||
int test_true(const char *file, int line, const char *s, int b);
|
||||
int test_false(const char *file, int line, const char *s, int b);
|
||||
|
||||
/*
|
||||
* Pretty print a failure message.
|
||||
* These should not be called directly, use the TEST_xxx macros below instead.
|
||||
*/
|
||||
void test_error(const char *file, int line, const char *desc, ...)
|
||||
PRINTF_FORMAT(3, 4);
|
||||
void test_error_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
|
||||
void test_info(const char *file, int line, const char *desc, ...)
|
||||
PRINTF_FORMAT(3, 4);
|
||||
void test_info_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
|
||||
|
||||
/*
|
||||
* The following macros provide wrapper calls to the test functions with
|
||||
* a default description that indicates the file and line number of the error.
|
||||
*/
|
||||
# define TEST_int_eq(a, b) test_int_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_ne(a, b) test_int_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_lt(a, b) test_int_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_le(a, b) test_int_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_gt(a, b) test_int_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_ge(a, b) test_int_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_int_eq(a, b) test_int_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_ne(a, b) test_int_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_lt(a, b) test_int_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_le(a, b) test_int_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_gt(a, b) test_int_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_int_ge(a, b) test_int_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_uint_eq(a, b) test_uint_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uint_ne(a, b) test_uint_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uint_lt(a, b) test_uint_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uint_le(a, b) test_uint_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uint_gt(a, b) test_uint_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uint_ge(a, b) test_uint_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_char_eq(a, b) test_char_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_char_ne(a, b) test_char_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_char_lt(a, b) test_char_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_char_le(a, b) test_char_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_char_gt(a, b) test_char_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_char_ge(a, b) test_char_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_uchar_eq(a, b) test_uchar_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uchar_ne(a, b) test_uchar_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uchar_lt(a, b) test_uchar_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uchar_le(a, b) test_uchar_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uchar_gt(a, b) test_uchar_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_uchar_ge(a, b) test_uchar_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_long_eq(a, b) test_long_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_long_ne(a, b) test_long_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_long_lt(a, b) test_long_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_long_le(a, b) test_long_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_long_gt(a, b) test_long_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_long_ge(a, b) test_long_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_ulong_eq(a, b) test_ulong_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ulong_ne(a, b) test_ulong_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ulong_lt(a, b) test_ulong_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ulong_le(a, b) test_ulong_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ulong_gt(a, b) test_ulong_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ulong_ge(a, b) test_ulong_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_size_t_eq(a, b) test_size_t_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_size_t_ne(a, b) test_size_t_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_size_t_lt(a, b) test_size_t_lt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_size_t_le(a, b) test_size_t_le(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_size_t_gt(a, b) test_size_t_gt(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_size_t_ge(a, b) test_size_t_ge(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_ptr_eq(a, b) test_ptr_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ptr_ne(a, b) test_ptr_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_ptr(a) test_ptr(__FILE__, __LINE__, #a, a)
|
||||
# define TEST_ptr_null(a) test_ptr_null(__FILE__, __LINE__, #a, a)
|
||||
|
||||
# define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
|
||||
# define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
|
||||
|
||||
# define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
# define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
|
||||
|
||||
# define TEST_true(a) test_true(__FILE__, __LINE__, #a, a)
|
||||
# define TEST_false(a) test_false(__FILE__, __LINE__, #a, a)
|
||||
|
||||
/*
|
||||
* TEST_error(desc, ...) prints an informative error message in the standard
|
||||
* format. |desc| is a printf format string.
|
||||
*/
|
||||
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
||||
# define TEST_error test_error_c90
|
||||
# define TEST_info test_info_c90
|
||||
# else
|
||||
# define TEST_error(...) test_error(__FILE__, __LINE__, __VA_ARGS__)
|
||||
# define TEST_info(...) test_info(__FILE__, __LINE__, __VA_ARGS__)
|
||||
# endif
|
||||
|
||||
/*
|
||||
* For "impossible" conditions such as malloc failures or bugs in test code,
|
||||
* where continuing the test would be meaningless. Note that OPENSSL_assert
|
||||
* is fatal, and is never compiled out.
|
||||
*/
|
||||
#define TEST_check(condition) \
|
||||
# define TEST_check(condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
ERR_print_errors_fp(stderr); \
|
||||
|
@ -269,20 +269,13 @@ static int test_record(SSL3_RECORD *rec, RECORD_DATA *recd, int enc)
|
||||
else
|
||||
refd = multihexstr2buf(recd->plaintext, &refdatalen);
|
||||
|
||||
if (refd == NULL) {
|
||||
fprintf(stderr, "Failed to get reference data\n");
|
||||
if (!TEST_ptr(refd)) {
|
||||
TEST_info("Failed to get reference data");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (rec->length != refdatalen) {
|
||||
fprintf(stderr, "Unexpected length\n");
|
||||
if (!TEST_mem_eq(rec->data, rec->length, refd, refdatalen))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (memcmp(rec->data, refd, refdatalen) != 0) {
|
||||
fprintf(stderr, "Data does not match\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
@ -306,27 +299,28 @@ static int test_tls13_encryption(void)
|
||||
rec.data = NULL;
|
||||
|
||||
ctx = SSL_CTX_new(TLS_method());
|
||||
if (ctx == NULL) {
|
||||
fprintf(stderr, "Failed creating SSL_CTX\n");
|
||||
if (!TEST_ptr(ctx)) {
|
||||
TEST_info("Failed creating SSL_CTX");
|
||||
goto err;
|
||||
}
|
||||
|
||||
s = SSL_new(ctx);
|
||||
if (s == NULL) {
|
||||
fprintf(stderr, "Failed creating SSL\n");
|
||||
if (!TEST_ptr(s)) {
|
||||
TEST_info("Failed creating SSL");
|
||||
goto err;
|
||||
}
|
||||
|
||||
s->enc_read_ctx = EVP_CIPHER_CTX_new();
|
||||
s->enc_write_ctx = EVP_CIPHER_CTX_new();
|
||||
if (s->enc_read_ctx == NULL || s->enc_write_ctx == NULL) {
|
||||
fprintf(stderr, "Failed creating EVP_CIPHER_CTX\n");
|
||||
if (!TEST_ptr(s->enc_read_ctx))
|
||||
goto err;
|
||||
|
||||
s->enc_write_ctx = EVP_CIPHER_CTX_new();
|
||||
if (!TEST_ptr(s->enc_write_ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
s->s3->tmp.new_cipher = SSL_CIPHER_find(s, TLS13_AES_128_GCM_SHA256_BYTES);
|
||||
if (s->s3->tmp.new_cipher == NULL) {
|
||||
fprintf(stderr, "Failed to find cipher\n");
|
||||
if (!TEST_ptr(s->s3->tmp.new_cipher)) {
|
||||
TEST_info("Failed to find cipher");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -335,7 +329,7 @@ static int test_tls13_encryption(void)
|
||||
ivlen = EVP_CIPHER_iv_length(ciph);
|
||||
if (!load_record(&rec, &refdata[ctr], &key, s->read_iv, ivlen,
|
||||
RECORD_LAYER_get_read_sequence(&s->rlayer))) {
|
||||
fprintf(stderr, "Failed loading key into EVP_CIPHER_CTX\n");
|
||||
TEST_error("Failed loading key into EVP_CIPHER_CTX");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -348,27 +342,27 @@ static int test_tls13_encryption(void)
|
||||
if (EVP_CipherInit_ex(s->enc_write_ctx, ciph, NULL, key, NULL, 1) <= 0
|
||||
|| EVP_CipherInit_ex(s->enc_read_ctx, ciph, NULL, key, NULL, 0)
|
||||
<= 0) {
|
||||
fprintf(stderr, "Failed loading key into EVP_CIPHER_CTX\n");
|
||||
TEST_error("Failed loading key into EVP_CIPHER_CTX\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Encrypt it */
|
||||
if (tls13_enc(s, &rec, 1, 1) != 1) {
|
||||
fprintf(stderr, "Failed to encrypt record %"OSSLzu"\n", ctr);
|
||||
if (!TEST_size_t_eq(tls13_enc(s, &rec, 1, 1), 1)) {
|
||||
TEST_info("Failed to encrypt record %"OSSLzu"", ctr);
|
||||
goto err;
|
||||
}
|
||||
if (!test_record(&rec, &refdata[ctr], 1)) {
|
||||
fprintf(stderr, "Record %"OSSLzu" encryption test failed\n", ctr);
|
||||
if (!TEST_true(test_record(&rec, &refdata[ctr], 1))) {
|
||||
TEST_info("Record %"OSSLzu" encryption test failed", ctr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Decrypt it */
|
||||
if (tls13_enc(s, &rec, 1, 0) != 1) {
|
||||
fprintf(stderr, "Failed to decrypt record %"OSSLzu"\n", ctr);
|
||||
if (!TEST_int_eq(tls13_enc(s, &rec, 1, 0), 1)) {
|
||||
TEST_info("Failed to decrypt record %"OSSLzu"", ctr);
|
||||
goto err;
|
||||
}
|
||||
if (!test_record(&rec, &refdata[ctr], 0)) {
|
||||
fprintf(stderr, "Record %"OSSLzu" decryption test failed\n", ctr);
|
||||
if (!TEST_true(test_record(&rec, &refdata[ctr], 0))) {
|
||||
TEST_info("Record %"OSSLzu" decryption test failed", ctr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -213,40 +213,34 @@ static int test_secret(SSL *s, unsigned char *prk,
|
||||
const EVP_MD *md = ssl_handshake_md(s);
|
||||
|
||||
if (!ssl_handshake_hash(s, hash, sizeof(hash), &hashsize)) {
|
||||
fprintf(stderr, "Failed to get hash\n");
|
||||
TEST_error("Failed to get hash");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tls13_hkdf_expand(s, md, prk, label, labellen, hash, gensecret,
|
||||
hashsize)) {
|
||||
fprintf(stderr, "Secret generation failed\n");
|
||||
TEST_error("Secret generation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (memcmp(gensecret, ref_secret, hashsize) != 0) {
|
||||
fprintf(stderr, "Generated secret does not match\n");
|
||||
if (!TEST_mem_eq(gensecret, hashsize, ref_secret, hashsize))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tls13_derive_key(s, md, gensecret, key, KEYLEN)) {
|
||||
fprintf(stderr, "Key generation failed\n");
|
||||
TEST_error("Key generation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (memcmp(key, ref_key, KEYLEN) != 0) {
|
||||
fprintf(stderr, "Generated key does not match\n");
|
||||
if (!TEST_mem_eq(key, KEYLEN, ref_key, KEYLEN))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tls13_derive_iv(s, md, gensecret, iv, IVLEN)) {
|
||||
fprintf(stderr, "IV generation failed\n");
|
||||
TEST_error("IV generation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (memcmp(iv, ref_iv, IVLEN) != 0) {
|
||||
fprintf(stderr, "Generated IV does not match\n");
|
||||
if (!TEST_mem_eq(iv, IVLEN, ref_iv, IVLEN))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -261,64 +255,67 @@ static int test_handshake_secrets(void)
|
||||
size_t master_secret_length;
|
||||
|
||||
ctx = SSL_CTX_new(TLS_method());
|
||||
if (ctx == NULL)
|
||||
if (!TEST_ptr(ctx))
|
||||
goto err;
|
||||
|
||||
s = SSL_new(ctx);
|
||||
if (s == NULL)
|
||||
if (!TEST_ptr(s ))
|
||||
goto err;
|
||||
|
||||
s->session = SSL_SESSION_new();
|
||||
if (s->session == NULL)
|
||||
if (!TEST_ptr(s->session))
|
||||
goto err;
|
||||
|
||||
if (!tls13_generate_secret(s, ssl_handshake_md(s), NULL, NULL, 0,
|
||||
(unsigned char *)&s->early_secret)) {
|
||||
fprintf(stderr, "Early secret generation failed\n");
|
||||
if (!TEST_true(tls13_generate_secret(s, ssl_handshake_md(s), NULL, NULL, 0,
|
||||
(unsigned char *)&s->early_secret))) {
|
||||
TEST_info("Early secret generation failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (memcmp(s->early_secret, early_secret, sizeof(early_secret)) != 0) {
|
||||
fprintf(stderr, "Early secret does not match\n");
|
||||
if (!TEST_mem_eq(s->early_secret, sizeof(early_secret),
|
||||
early_secret, sizeof(early_secret))) {
|
||||
TEST_info("Early secret does not match");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!tls13_generate_handshake_secret(s, ecdhe_secret,
|
||||
sizeof(ecdhe_secret))) {
|
||||
fprintf(stderr, "Hanshake secret generation failed\n");
|
||||
if (!TEST_true(tls13_generate_handshake_secret(s, ecdhe_secret,
|
||||
sizeof(ecdhe_secret)))) {
|
||||
TEST_info("Hanshake secret generation failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (memcmp(s->handshake_secret, handshake_secret,
|
||||
sizeof(handshake_secret)) != 0) {
|
||||
fprintf(stderr, "Handshake secret does not match\n");
|
||||
if (!TEST_mem_eq(s->handshake_secret, sizeof(handshake_secret),
|
||||
handshake_secret, sizeof(handshake_secret)))
|
||||
goto err;
|
||||
}
|
||||
|
||||
hashsize = EVP_MD_size(ssl_handshake_md(s));
|
||||
if (sizeof(client_hts) != hashsize || sizeof(client_hts_key) != KEYLEN
|
||||
|| sizeof(client_hts_iv) != IVLEN) {
|
||||
fprintf(stderr, "Internal test error\n");
|
||||
if (!TEST_size_t_eq(sizeof(client_hts), hashsize))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(client_hts_key), KEYLEN))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(client_hts_iv), IVLEN))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(test_secret(s, s->handshake_secret,
|
||||
(unsigned char *)client_hts_label,
|
||||
strlen(client_hts_label), client_hts,
|
||||
client_hts_key, client_hts_iv))) {
|
||||
TEST_info("Client handshake secret test failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!test_secret(s, s->handshake_secret, (unsigned char *)client_hts_label,
|
||||
strlen(client_hts_label), client_hts, client_hts_key,
|
||||
client_hts_iv)) {
|
||||
fprintf(stderr, "Client handshake secret test failed\n");
|
||||
if (!TEST_size_t_eq(sizeof(server_hts), hashsize))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (sizeof(server_hts) != hashsize || sizeof(server_hts_key) != KEYLEN
|
||||
|| sizeof(server_hts_iv) != IVLEN) {
|
||||
fprintf(stderr, "Internal test error\n");
|
||||
if (!TEST_size_t_eq(sizeof(server_hts_key), KEYLEN))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(server_hts_iv), IVLEN))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!test_secret(s, s->handshake_secret, (unsigned char *)server_hts_label,
|
||||
strlen(server_hts_label), server_hts, server_hts_key,
|
||||
server_hts_iv)) {
|
||||
fprintf(stderr, "Server handshake secret test failed\n");
|
||||
if (!TEST_true(test_secret(s, s->handshake_secret,
|
||||
(unsigned char *)server_hts_label,
|
||||
strlen(server_hts_label), server_hts,
|
||||
server_hts_key, server_hts_iv))) {
|
||||
TEST_info("Server handshake secret test failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -328,43 +325,46 @@ static int test_handshake_secrets(void)
|
||||
*/
|
||||
full_hash = 1;
|
||||
|
||||
if (!tls13_generate_master_secret(s, out_master_secret,
|
||||
s->handshake_secret, hashsize,
|
||||
&master_secret_length)) {
|
||||
fprintf(stderr, "Master secret generation failed\n");
|
||||
if (!TEST_true(tls13_generate_master_secret(s, out_master_secret,
|
||||
s->handshake_secret, hashsize,
|
||||
&master_secret_length))) {
|
||||
TEST_info("Master secret generation failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (master_secret_length != sizeof(master_secret) ||
|
||||
memcmp(out_master_secret, master_secret,
|
||||
sizeof(master_secret)) != 0) {
|
||||
fprintf(stderr, "Master secret does not match\n");
|
||||
if (!TEST_mem_eq(out_master_secret, master_secret_length,
|
||||
master_secret, sizeof(master_secret))) {
|
||||
TEST_info("Master secret does not match");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (sizeof(client_ats) != hashsize || sizeof(client_ats_key) != KEYLEN
|
||||
|| sizeof(client_ats_iv) != IVLEN) {
|
||||
fprintf(stderr, "Internal test error\n");
|
||||
if (!TEST_size_t_eq(sizeof(client_ats), hashsize))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(client_ats_key), KEYLEN))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(client_ats_iv), IVLEN))
|
||||
goto err;
|
||||
|
||||
if (!TEST_true(test_secret(s, out_master_secret,
|
||||
(unsigned char *)client_ats_label,
|
||||
strlen(client_ats_label), client_ats,
|
||||
client_ats_key, client_ats_iv))) {
|
||||
TEST_info("Client application data secret test failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!test_secret(s, out_master_secret, (unsigned char *)client_ats_label,
|
||||
strlen(client_ats_label), client_ats, client_ats_key,
|
||||
client_ats_iv)) {
|
||||
fprintf(stderr, "Client application data secret test failed\n");
|
||||
if (!TEST_size_t_eq(sizeof(server_ats), hashsize))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (sizeof(server_ats) != hashsize || sizeof(server_ats_key) != KEYLEN
|
||||
|| sizeof(server_ats_iv) != IVLEN) {
|
||||
fprintf(stderr, "Internal test error\n");
|
||||
if (!TEST_size_t_eq(sizeof(server_ats_key), KEYLEN))
|
||||
goto err;
|
||||
if (!TEST_size_t_eq(sizeof(server_ats_iv), IVLEN))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!test_secret(s, out_master_secret, (unsigned char *)server_ats_label,
|
||||
strlen(server_ats_label), server_ats, server_ats_key,
|
||||
server_ats_iv)) {
|
||||
fprintf(stderr, "Server application data secret test failed\n");
|
||||
if (!TEST_true(test_secret(s, out_master_secret,
|
||||
(unsigned char *)server_ats_label,
|
||||
strlen(server_ats_label), server_ats,
|
||||
server_ats_key, server_ats_iv))) {
|
||||
TEST_info("Server application data secret test failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ static int test_standard_exts()
|
||||
}
|
||||
if (!good) {
|
||||
tmp = standard_exts;
|
||||
fprintf(stderr, "Extensions out of order!\n");
|
||||
TEST_error("Extensions out of order!");
|
||||
for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
|
||||
fprintf(stderr, "%d : %s\n", (*tmp)->ext_nid,
|
||||
OBJ_nid2sn((*tmp)->ext_nid));
|
||||
|
@ -156,8 +156,8 @@ static int test_x509_cmp_time(int idx)
|
||||
t.length = strlen(x509_cmp_tests[idx].data);
|
||||
|
||||
result = X509_cmp_time(&t, &x509_cmp_tests[idx].cmp_time);
|
||||
if (result != x509_cmp_tests[idx].expected) {
|
||||
fprintf(stderr, "test_x509_cmp_time(%d) failed: expected %d, got %d\n",
|
||||
if (!TEST_int_eq(result, x509_cmp_tests[idx].expected)) {
|
||||
TEST_info("test_x509_cmp_time(%d) failed: expected %d, got %d\n",
|
||||
idx, x509_cmp_tests[idx].expected, result);
|
||||
return 0;
|
||||
}
|
||||
@ -175,18 +175,12 @@ static int test_x509_cmp_time_current()
|
||||
asn1_after = ASN1_TIME_adj(NULL, now, 1, 0);
|
||||
|
||||
cmp_result = X509_cmp_time(asn1_before, NULL);
|
||||
if (cmp_result != -1) {
|
||||
fprintf(stderr, "test_x509_cmp_time_current failed: expected -1, got %d\n",
|
||||
cmp_result);
|
||||
if (!TEST_int_eq(cmp_result, -1))
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
cmp_result = X509_cmp_time(asn1_after, NULL);
|
||||
if (cmp_result != 1) {
|
||||
fprintf(stderr, "test_x509_cmp_time_current failed: expected 1, got %d\n",
|
||||
cmp_result);
|
||||
if (!TEST_int_eq(cmp_result, 1))
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
ASN1_TIME_free(asn1_before);
|
||||
ASN1_TIME_free(asn1_after);
|
||||
|
Loading…
x
Reference in New Issue
Block a user