forked from wolfSSL/wolfssl
Reenabled examples when building single-threaded.
Changed testsuite and unit tests to leave out tests cases that require threading.
This commit is contained in:
@ -1422,7 +1422,6 @@ AC_ARG_ENABLE([examples],
|
|||||||
[ ENABLED_EXAMPLES=yes ]
|
[ ENABLED_EXAMPLES=yes ]
|
||||||
)
|
)
|
||||||
|
|
||||||
AS_IF([test "x$ENABLED_SINGLETHREADED" = "xyes"], [ENABLED_EXAMPLES="no"])
|
|
||||||
AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"])
|
AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"])
|
||||||
AS_IF([test "x$ENABLED_INLINE" = "xno"], [ENABLED_EXAMPLES="no"])
|
AS_IF([test "x$ENABLED_INLINE" = "xno"], [ENABLED_EXAMPLES="no"])
|
||||||
# certs still have sha signatures for now
|
# certs still have sha signatures for now
|
||||||
|
@ -44,7 +44,9 @@ static int test_CyaSSL_CTX_load_verify_locations(void);
|
|||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
static int test_server_CyaSSL_new(void);
|
static int test_server_CyaSSL_new(void);
|
||||||
static int test_client_CyaSSL_new(void);
|
static int test_client_CyaSSL_new(void);
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
static int test_CyaSSL_read_write(void);
|
static int test_CyaSSL_read_write(void);
|
||||||
|
#endif /* SINGLE_THREADED */
|
||||||
#endif /* NO_RSA */
|
#endif /* NO_RSA */
|
||||||
#endif /* NO_FILESYSTEM */
|
#endif /* NO_FILESYSTEM */
|
||||||
#ifdef HAVE_SNI
|
#ifdef HAVE_SNI
|
||||||
@ -107,7 +109,9 @@ int ApiTest(void)
|
|||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
test_server_CyaSSL_new();
|
test_server_CyaSSL_new();
|
||||||
test_client_CyaSSL_new();
|
test_client_CyaSSL_new();
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
test_CyaSSL_read_write();
|
test_CyaSSL_read_write();
|
||||||
|
#endif /* SINGLE_THREADED */
|
||||||
#endif /* NO_RSA */
|
#endif /* NO_RSA */
|
||||||
#endif /* NO_FILESYSTEM */
|
#endif /* NO_FILESYSTEM */
|
||||||
#ifdef HAVE_SNI
|
#ifdef HAVE_SNI
|
||||||
@ -892,6 +896,8 @@ int test_client_CyaSSL_new(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
|
|
||||||
static int test_CyaSSL_read_write(void)
|
static int test_CyaSSL_read_write(void)
|
||||||
{
|
{
|
||||||
/* The unit testing for read and write shall happen simutaneously, since
|
/* The unit testing for read and write shall happen simutaneously, since
|
||||||
@ -1278,4 +1284,6 @@ void test_CyaSSL_client_server(callback_functions* client_callbacks,
|
|||||||
FreeTcpReady(&ready);
|
FreeTcpReady(&ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* SINGLE_THREADED*/
|
||||||
|
|
||||||
#endif /* NO_FILESYSTEM */
|
#endif /* NO_FILESYSTEM */
|
||||||
|
25
tests/unit.c
25
tests/unit.c
@ -42,10 +42,12 @@ int main(int argc, char** argv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
if ( (ret = SuiteTest()) != 0){
|
if ( (ret = SuiteTest()) != 0){
|
||||||
printf("suite test failed with %d\n", ret);
|
printf("suite test failed with %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CAVIUM
|
#ifdef HAVE_CAVIUM
|
||||||
CspShutdown(CAVIUM_DEV_ID);
|
CspShutdown(CAVIUM_DEV_ID);
|
||||||
@ -55,9 +57,12 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wait_tcp_ready(func_args* args)
|
void wait_tcp_ready(func_args* args)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
#ifdef SINGLE_THREADED
|
||||||
|
(void)args;
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
pthread_mutex_lock(&args->signal->mutex);
|
pthread_mutex_lock(&args->signal->mutex);
|
||||||
|
|
||||||
if (!args->signal->ready)
|
if (!args->signal->ready)
|
||||||
@ -73,7 +78,11 @@ void wait_tcp_ready(func_args* args)
|
|||||||
|
|
||||||
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
|
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
#ifdef SINGLE_THREADED
|
||||||
|
(void)fun;
|
||||||
|
(void)args;
|
||||||
|
(void)thread;
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
pthread_create(thread, 0, fun, args);
|
pthread_create(thread, 0, fun, args);
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
@ -84,7 +93,9 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
|
|||||||
|
|
||||||
void join_thread(THREAD_TYPE thread)
|
void join_thread(THREAD_TYPE thread)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
#ifdef SINGLE_THREADED
|
||||||
|
(void)thread;
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
pthread_join(thread, 0);
|
pthread_join(thread, 0);
|
||||||
#else
|
#else
|
||||||
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
|
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
|
||||||
@ -99,7 +110,8 @@ void InitTcpReady(tcp_ready* ready)
|
|||||||
{
|
{
|
||||||
ready->ready = 0;
|
ready->ready = 0;
|
||||||
ready->port = 0;
|
ready->port = 0;
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
#ifdef SINGLE_THREADED
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
pthread_mutex_init(&ready->mutex, 0);
|
pthread_mutex_init(&ready->mutex, 0);
|
||||||
pthread_cond_init(&ready->cond, 0);
|
pthread_cond_init(&ready->cond, 0);
|
||||||
#endif
|
#endif
|
||||||
@ -108,10 +120,13 @@ void InitTcpReady(tcp_ready* ready)
|
|||||||
|
|
||||||
void FreeTcpReady(tcp_ready* ready)
|
void FreeTcpReady(tcp_ready* ready)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
#ifdef SINGLE_THREADED
|
||||||
|
(void)ready;
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
pthread_mutex_destroy(&ready->mutex);
|
pthread_mutex_destroy(&ready->mutex);
|
||||||
pthread_cond_destroy(&ready->cond);
|
pthread_cond_destroy(&ready->cond);
|
||||||
#else
|
#else
|
||||||
(void)ready;
|
(void)ready;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,22 +25,18 @@
|
|||||||
|
|
||||||
#include <cyassl/ctaocrypt/settings.h>
|
#include <cyassl/ctaocrypt/settings.h>
|
||||||
|
|
||||||
#include <cyassl/openssl/ssl.h>
|
|
||||||
#include <cyassl/test.h>
|
#include <cyassl/test.h>
|
||||||
#include <cyassl/ctaocrypt/sha256.h>
|
|
||||||
|
|
||||||
#include "ctaocrypt/test/test.h"
|
#include "ctaocrypt/test/test.h"
|
||||||
|
|
||||||
#ifdef SINGLE_THREADED
|
#ifndef SINGLE_THREADED
|
||||||
#error testsuite needs threads to run, please run ctaocrypt/test, \
|
|
||||||
and the examples/ individually
|
#include <cyassl/openssl/ssl.h>
|
||||||
#endif
|
#include <cyassl/ctaocrypt/sha256.h>
|
||||||
|
|
||||||
#include "examples/echoclient/echoclient.h"
|
#include "examples/echoclient/echoclient.h"
|
||||||
#include "examples/echoserver/echoserver.h"
|
#include "examples/echoserver/echoserver.h"
|
||||||
#include "examples/server/server.h"
|
#include "examples/server/server.h"
|
||||||
#include "examples/client/client.h"
|
#include "examples/client/client.h"
|
||||||
#include "ctaocrypt/test/test.h"
|
|
||||||
|
|
||||||
|
|
||||||
void file_test(const char* file, byte* hash);
|
void file_test(const char* file, byte* hash);
|
||||||
@ -336,3 +332,35 @@ void file_test(const char* file, byte* check)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else /* SINGLE_THREADED */
|
||||||
|
|
||||||
|
|
||||||
|
int myoptind = 0;
|
||||||
|
char* myoptarg = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
func_args server_args;
|
||||||
|
|
||||||
|
server_args.argc = argc;
|
||||||
|
server_args.argv = argv;
|
||||||
|
|
||||||
|
if (CurrentDir("testsuite") || CurrentDir("_build"))
|
||||||
|
ChangeDirBack(1);
|
||||||
|
else if (CurrentDir("Debug") || CurrentDir("Release"))
|
||||||
|
ChangeDirBack(3); /* Xcode->Preferences->Locations->Locations*/
|
||||||
|
/* Derived Data Advanced -> Custom */
|
||||||
|
/* Relative to Workspace, Build/Products */
|
||||||
|
/* Debug or Release */
|
||||||
|
|
||||||
|
ctaocrypt_test(&server_args);
|
||||||
|
if (server_args.return_code != 0) return server_args.return_code;
|
||||||
|
|
||||||
|
printf("\nAll tests passed!\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SINGLE_THREADED */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user