Improved test sleep. Cleanup sleep calls.

This commit is contained in:
David Garske
2020-07-22 13:08:57 -07:00
parent c8e9d058f0
commit fe08f23a50
3 changed files with 27 additions and 52 deletions

View File

@ -1285,7 +1285,7 @@ static int bench_tls_server(info_t* info)
ret = SocketWaitClient(info); ret = SocketWaitClient(info);
#ifdef BENCH_USE_NONBLOCK #ifdef BENCH_USE_NONBLOCK
if (ret == -2) { if (ret == -2) {
sleep(0); XSLEEP_MS(0);
continue; continue;
} }
#endif #endif
@ -1831,7 +1831,7 @@ int bench_tls(void* args)
info = &theadInfo[i]; info = &theadInfo[i];
if (!info->to_client.done || !info->to_server.done) { if (!info->to_client.done || !info->to_server.done) {
doShutdown = 0; doShutdown = 0;
sleep(1); /* Allow other threads to run */ XSLEEP_MS(1000); /* Allow other threads to run */
} }
} }

View File

@ -65,12 +65,14 @@
#define OCSP_STAPLINGV2_MULTI 3 #define OCSP_STAPLINGV2_MULTI 3
#define OCSP_STAPLING_OPT_MAX OCSP_STAPLINGV2_MULTI #define OCSP_STAPLING_OPT_MAX OCSP_STAPLINGV2_MULTI
#define WXSLEEP(x,y) do { \ #if defined(XUSLEEP) && defined(NO_MAIN_DRIVER)
struct timeval tv = {(x),(y)}; \ /* This is to force the server's thread to get a chance to
select(0, NULL, NULL, NULL, &tv); \ * execute before continuing the resume in non-blocking
} while (0) * DTLS test cases. */
#define WUSLEEP(x) WXSLEEP(0,x) #define TEST_DELAY() XSLEEP_US(10000)
#define WSLEEP(x) WXSLEEP(x,0) #else
#define TEST_DELAY() XSLEEP_MS(1000)
#endif
/* Note on using port 0: the client standalone example doesn't utilize the /* Note on using port 0: the client standalone example doesn't utilize the
* port 0 port sharing; that is used by (1) the server in external control * port 0 port sharing; that is used by (1) the server in external control
@ -3142,20 +3144,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
/* allow some time for exporting the session */ /* allow some time for exporting the session */
#ifdef WOLFSSL_SESSION_EXPORT_DEBUG #ifdef WOLFSSL_SESSION_EXPORT_DEBUG
#ifdef USE_WINDOWS_API TEST_DELAY();
Sleep(500);
#elif defined(WOLFSSL_TIRTOS)
Task_sleep(1);
#else
/* This is to force the server's thread to get a chance to
* execute before continuing the resume in non-blocking
* DTLS test cases. */
#ifdef NO_MAIN_DRIVER
WUSLEEP(10000);
#else
WSLEEP(1);
#endif
#endif
#endif /* WOLFSSL_SESSION_EXPORT_DEBUG */ #endif /* WOLFSSL_SESSION_EXPORT_DEBUG */
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
@ -3254,20 +3243,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#endif #endif
if (dtlsUDP) { if (dtlsUDP) {
#ifdef USE_WINDOWS_API TEST_DELAY();
Sleep(500);
#elif defined(WOLFSSL_TIRTOS)
Task_sleep(1);
#else
/* This is to force the server's thread to get a chance to
* execute before continuing the resume in non-blocking
* DTLS test cases. */
#ifdef NO_MAIN_DRIVER
WUSLEEP(10000);
#else
WSLEEP(1);
#endif
#endif
} }
tcp_connect(&sockfd, host, port, dtlsUDP, dtlsSCTP, sslResume); tcp_connect(&sockfd, host, port, dtlsUDP, dtlsSCTP, sslResume);
if (wolfSSL_set_fd(sslResume, sockfd) != WOLFSSL_SUCCESS) { if (wolfSSL_set_fd(sslResume, sockfd) != WOLFSSL_SUCCESS) {
@ -3389,20 +3365,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
/* allow some time for exporting the session */ /* allow some time for exporting the session */
#ifdef WOLFSSL_SESSION_EXPORT_DEBUG #ifdef WOLFSSL_SESSION_EXPORT_DEBUG
#ifdef USE_WINDOWS_API TEST_DELAY();
Sleep(500);
#elif defined(WOLFSSL_TIRTOS)
Task_sleep(1);
#else
/* This is to force the server's thread to get a chance to
* execute before continuing the resume in non-blocking
* DTLS test cases. */
#ifdef NO_MAIN_DRIVER
WUSLEEP(10000);
#else
WSLEEP(1);
#endif
#endif
#endif /* WOLFSSL_SESSION_EXPORT_DEBUG */ #endif /* WOLFSSL_SESSION_EXPORT_DEBUG */
#ifdef HAVE_SECURE_RENEGOTIATION #ifdef HAVE_SECURE_RENEGOTIATION

View File

@ -55,6 +55,7 @@
#endif #endif
#define SOCKET_T SOCKET #define SOCKET_T SOCKET
#define SNPRINTF _snprintf #define SNPRINTF _snprintf
#define XSLEEP_MS(t) Sleep(t)
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) #elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
#include <string.h> #include <string.h>
#include "rl_net.h" #include "rl_net.h"
@ -69,9 +70,9 @@
return(ret) ; return(ret) ;
} }
#if defined(HAVE_KEIL_RTX) #if defined(HAVE_KEIL_RTX)
#define sleep(t) os_dly_wait(t/1000+1); #define XSLEEP_MS(t) os_dly_wait(t)
#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2) #elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2)
#define sleep(t) osDelay(t/1000+1); #define XSLEEP_MS(t) osDelay(t)
#endif #endif
#elif defined(WOLFSSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
#include <string.h> #include <string.h>
@ -88,6 +89,7 @@
char **h_addr_list; /* list of addresses from name server */ char **h_addr_list; /* list of addresses from name server */
}; };
#define SOCKET_T int #define SOCKET_T int
#define XSLEEP_MS(t) Task_sleep(t/1000)
#elif defined(WOLFSSL_VXWORKS) #elif defined(WOLFSSL_VXWORKS)
#include <hostLib.h> #include <hostLib.h>
#include <sockLib.h> #include <sockLib.h>
@ -148,8 +150,18 @@
#include <signal.h> /* ignore SIGPIPE */ #include <signal.h> /* ignore SIGPIPE */
#endif #endif
#define SNPRINTF snprintf #define SNPRINTF snprintf
#define XSELECT_WAIT(x,y) do { \
struct timeval tv = {(x),(y)}; \
select(0, NULL, NULL, NULL, &tv); \
} while (0)
#define XSLEEP_US(u) XSELECT_WAIT(0,u)
#endif /* USE_WINDOWS_API */ #endif /* USE_WINDOWS_API */
#ifndef XSLEEP_MS
#define XSLEEP_MS(t) sleep(t/1000)
#endif
#ifdef WOLFSSL_ASYNC_CRYPT #ifdef WOLFSSL_ASYNC_CRYPT
#include <wolfssl/wolfcrypt/async.h> #include <wolfssl/wolfcrypt/async.h>
#endif #endif