From c4e91a831fd238b8708bcec008ada62889bf2685 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 19 Mar 2012 11:30:48 -0700 Subject: [PATCH] Fixed unit test case. Updated a constant list to be ANSI-C compliant. --- cyassl/internal.h | 7 ++----- tests/api.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cyassl/internal.h b/cyassl/internal.h index d9ce4cf91..187da1dfc 100644 --- a/cyassl/internal.h +++ b/cyassl/internal.h @@ -357,6 +357,7 @@ enum Misc { MAX_PSK_KEY_LEN = 64, /* max psk key supported */ #ifdef FORTRESS + MAX_EX_DATA = 3, /* allow for three items of ex_data */ MAX_CHAIN_DEPTH = 9, /* max cert chain peer depth, FORTRESS option */ #else MAX_CHAIN_DEPTH = 4, /* max cert chain peer depth */ @@ -376,11 +377,7 @@ enum Misc { HASH_SIG_SIZE = 2, /* default SHA1 RSA */ NO_COPY = 0, /* should we copy static buffer for write */ - COPY = 1, /* should we copy static buffer for write */ - -#ifdef FORTRESS - MAX_EX_DATA = 3, /* allow for three items of ex_data */ -#endif + COPY = 1 /* should we copy static buffer for write */ }; diff --git a/tests/api.c b/tests/api.c index 06574e71b..8cb651407 100644 --- a/tests/api.c +++ b/tests/api.c @@ -307,7 +307,12 @@ int test_lvl(CYASSL_CTX *ctx, const char* file, const char* path, int cond, int result; printf(testingFmt, name); - result = CyaSSL_CTX_load_verify_locations(ctx, file, path); + /* + * CyaSSL_CTX_load_verify_locations() returns SSL_SUCCESS (1) for + * success, SSL_FAILURE (0) for a non-specific failure, or a specific + * failure code (<0). Need to normalize the return code to 1 or 0. + */ + result = CyaSSL_CTX_load_verify_locations(ctx, file, path) >= SSL_SUCCESS; if (result != cond) { printf(resultFmt, failed); @@ -343,8 +348,9 @@ int test_CyaSSL_CTX_load_verify_locations(void) "CyaSSL_CTX_load_verify_locations(ctx, NULL, NULL)"); test_lvl(NULL, caCert, NULL, SSL_FAILURE, "CyaSSL_CTX_load_verify_locations(ctx, NULL, NULL)"); - test_lvl(ctx, caCert, bogusFile, SSL_SUCCESS, + test_lvl(ctx, caCert, bogusFile, SSL_FAILURE, "CyaSSL_CTX_load_verify_locations(ctx, caCert, bogusFile)"); + /* Add a test for the certs directory path loading. */ /* There is a leak here. If you load a second cert, the first one is lost. */ test_lvl(ctx, caCert, 0, SSL_SUCCESS,