
* Adds compatibility API's for: * `sk_ASN1_OBJECT_free` * `sk_ASN1_OBJECT_num` * `sk_ASN1_OBJECT_value` * `sk_X509_OBJECT_num` * `sk_X509_OBJECT_value` * `sk_X509_OBJECT_delete` * `sk_X509_NAME_find` * `sk_X509_INFO_free` * `BIO_get_len` * `BIO_set_ssl` * `BIO_should_retry` (stub) * `X509_OBJECT_free` * `X509_NAME_get_index_by_OBJ` * `X509_INFO_free` * `X509_STORE_get0_objects` * `X509_check_purpose` (stub) * `PEM_read_bio_X509_CRL` * `PEM_X509_INFO_read_bio` * `ASN1_BIT_STRING_new` * `ASN1_BIT_STRING_free` * `ASN1_BIT_STRING_get_bit` * `ASN1_BIT_STRING_set_bit` * `DES_check_key_parity` * `EC_GROUP_order_bits` * `EC_get_builtin_curves` * `EVP_CIPHER_CTX_cipher` * `EVP_PKEY_get0_EC_KEY` * `EVP_PKEY_get0_RSA` * `EVP_PKEY_get0_DSA` (stub) * `HMAC_CTX_new` * `HMAC_CTX_free` * `HMAC_CTX_reset` * `HMAC_size` * `OBJ_txt2obj` * `RSA_meth_new` * `RSA_meth_free` * `RSA_meth_set_pub_enc` * `RSA_meth_set_pub_dec` * `RSA_meth_set_priv_enc` * `RSA_meth_set_priv_dec` * `RSA_meth_set_init` * `RSA_meth_set_finish` * `RSA_meth_set0_app_data` * `RSA_get_method_data` * `RSA_set_method` * `RSA_get0_key` * `RSA_set0_key` * `RSA_flags` * `RSA_set_flags` * `RSA_bits` * `SSL_CTX_set_ciphersuites` * `SSL_CTX_set_security_level` (stub) * `SSL_export_keying_material` (stub) * `DSA_bits` (stub) * Changes to support password callback trial and NO_PASSWORD. Replaces PR #2505. * Renamed `wolfSSL_SSL_CTX_get_client_CA_list` to `wolfSSL_CTX_get_client_CA_list`. * Cleanup of "sk" compatibility.
113 lines
4.7 KiB
C
113 lines
4.7 KiB
C
/* unit.c API unit tests driver
|
|
*
|
|
* Copyright (C) 2006-2019 wolfSSL Inc.
|
|
*
|
|
* This file is part of wolfSSL.
|
|
*
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
|
*/
|
|
|
|
|
|
#ifndef CyaSSL_UNIT_H
|
|
#define CyaSSL_UNIT_H
|
|
|
|
#include <wolfssl/ssl.h>
|
|
#include <wolfssl/test.h> /* thread and tcp stuff */
|
|
|
|
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
|
|
#define XABORT()
|
|
#else
|
|
#define XABORT() abort()
|
|
#endif
|
|
|
|
#ifndef WOLFSSL_PASSTHRU_ERR
|
|
#define Fail(description, result) do { \
|
|
printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
|
|
printf("\n expected: "); printf description; \
|
|
printf("\n result: "); printf result; printf("\n\n"); \
|
|
XABORT(); \
|
|
} while(0)
|
|
#else
|
|
#define Fail(description, result) do { \
|
|
printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
|
|
printf("\n expected: ");printf description; \
|
|
printf("\n result: "); printf result; printf("\n\n"); \
|
|
} while (0)
|
|
#endif
|
|
|
|
#define Assert(test, description, result) if (!(test)) Fail(description, result)
|
|
|
|
#define AssertTrue(x) Assert( (x), ("%s is true", #x), (#x " => FALSE"))
|
|
#define AssertFalse(x) Assert(!(x), ("%s is false", #x), (#x " => TRUE"))
|
|
#define AssertNotNull(x) Assert( (x), ("%s is not null", #x), (#x " => NULL"))
|
|
|
|
#define AssertNull(x) do { \
|
|
void* _x = (void *) (x); \
|
|
\
|
|
Assert(!_x, ("%s is null", #x), (#x " => %p", _x)); \
|
|
} while(0)
|
|
|
|
#define AssertInt(x, y, op, er) do { \
|
|
int _x = (int)x; \
|
|
int _y = (int)y; \
|
|
\
|
|
Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%d " #er " %d", _x, _y)); \
|
|
} while(0)
|
|
|
|
#define AssertIntEQ(x, y) AssertInt(x, y, ==, !=)
|
|
#define AssertIntNE(x, y) AssertInt(x, y, !=, ==)
|
|
#define AssertIntGT(x, y) AssertInt(x, y, >, <=)
|
|
#define AssertIntLT(x, y) AssertInt(x, y, <, >=)
|
|
#define AssertIntGE(x, y) AssertInt(x, y, >=, <)
|
|
#define AssertIntLE(x, y) AssertInt(x, y, <=, >)
|
|
|
|
#define AssertStr(x, y, op, er) do { \
|
|
const char* _x = x; \
|
|
const char* _y = y; \
|
|
int _z = (_x && _y) ? strcmp(_x, _y) : -1; \
|
|
\
|
|
Assert(_z op 0, ("%s " #op " %s", #x, #y), \
|
|
("\"%s\" " #er " \"%s\"", _x, _y));\
|
|
} while(0)
|
|
|
|
#define AssertStrEQ(x, y) AssertStr(x, y, ==, !=)
|
|
#define AssertStrNE(x, y) AssertStr(x, y, !=, ==)
|
|
#define AssertStrGT(x, y) AssertStr(x, y, >, <=)
|
|
#define AssertStrLT(x, y) AssertStr(x, y, <, >=)
|
|
#define AssertStrGE(x, y) AssertStr(x, y, >=, <)
|
|
#define AssertStrLE(x, y) AssertStr(x, y, <=, >)
|
|
|
|
#define AssertPtr(x, y, op, er) do { \
|
|
void* _x = (void*)x; \
|
|
void* _y = (void*)y; \
|
|
Assert(_x op _y, ("%s " #op " %s", #x, #y), ("%p " #er " %p", _x, _y)); \
|
|
} while(0)
|
|
|
|
#define AssertPtrEq(x, y) AssertPtr(x, y, ==, !=)
|
|
#define AssertPtrNE(x, y) AssertInt(x, y, !=, ==)
|
|
#define AssertPtrGT(x, y) AssertInt(x, y, >, <=)
|
|
#define AssertPtrLT(x, y) AssertInt(x, y, <, >=)
|
|
#define AssertPtrGE(x, y) AssertInt(x, y, >=, <)
|
|
#define AssertPtrLE(x, y) AssertInt(x, y, <=, >)
|
|
|
|
|
|
void ApiTest(void);
|
|
int SuiteTest(int argc, char** argv);
|
|
int HashTest(void);
|
|
void SrpTest(void);
|
|
|
|
|
|
#endif /* CyaSSL_UNIT_H */
|