Update CyaSSL to latest version.

This commit is contained in:
Richard Barry 2014-07-18 18:54:25 +00:00
parent 5fcd270398
commit 3d007d0b4b
445 changed files with 162375 additions and 26182 deletions

View file

@ -1,4 +1,10 @@
/* unit.c unit tests driver */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <stdio.h>
#include <tests/unit.h>
@ -11,7 +17,20 @@ int main(int argc, char** argv)
{
int ret;
printf("staring unit tests...\n");
(void)argc;
(void)argv;
printf("starting unit tests...\n");
#ifdef HAVE_CAVIUM
ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID);
if (ret != 0)
err_sys("Cavium OpenNitroxDevice failed");
#endif /* HAVE_CAVIUM */
if (CurrentDir("tests") || CurrentDir("_build"))
ChangeDirBack(1);
else if (CurrentDir("Debug") || CurrentDir("Release"))
ChangeDirBack(3);
if ( (ret = ApiTest()) != 0) {
printf("api test failed with %d\n", ret);
@ -23,18 +42,27 @@ int main(int argc, char** argv)
return ret;
}
#ifndef SINGLE_THREADED
if ( (ret = SuiteTest()) != 0){
printf("suite test failed with %d\n", ret);
return ret;
}
#endif
#ifdef HAVE_CAVIUM
CspShutdown(CAVIUM_DEV_ID);
#endif
return 0;
}
void wait_tcp_ready(func_args* args)
{
#ifdef _POSIX_THREADS
#ifdef SINGLE_THREADED
(void)args;
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_lock(&args->signal->mutex);
if (!args->signal->ready)
@ -42,13 +70,19 @@ void wait_tcp_ready(func_args* args)
args->signal->ready = 0; /* reset */
pthread_mutex_unlock(&args->signal->mutex);
#else
(void)args;
#endif
}
void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
{
#ifdef _POSIX_THREADS
#ifdef SINGLE_THREADED
(void)fun;
(void)args;
(void)thread;
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_create(thread, 0, fun, args);
return;
#else
@ -59,12 +93,14 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
void join_thread(THREAD_TYPE thread)
{
#ifdef _POSIX_THREADS
#ifdef SINGLE_THREADED
(void)thread;
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_join(thread, 0);
#else
int res = WaitForSingleObject(thread, INFINITE);
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
assert(res == WAIT_OBJECT_0);
res = CloseHandle(thread);
res = CloseHandle((HANDLE)thread);
assert(res);
#endif
}
@ -73,7 +109,9 @@ void join_thread(THREAD_TYPE thread)
void InitTcpReady(tcp_ready* ready)
{
ready->ready = 0;
#ifdef _POSIX_THREADS
ready->port = 0;
#ifdef SINGLE_THREADED
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_init(&ready->mutex, 0);
pthread_cond_init(&ready->cond, 0);
#endif
@ -82,8 +120,13 @@ void InitTcpReady(tcp_ready* ready)
void FreeTcpReady(tcp_ready* ready)
{
#ifdef _POSIX_THREADS
#ifdef SINGLE_THREADED
(void)ready;
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_mutex_destroy(&ready->mutex);
pthread_cond_destroy(&ready->cond);
#else
(void)ready;
#endif
}
}