DTLS Test Speedup

Change the example client to use select instead of sleep.
If building for the standalone client, it will wait 1 second.
If built for no main driver, it'll wait 10ms rather than 1 second.
This commit is contained in:
John Safranek
2020-07-20 16:40:20 -07:00
parent 29abd72c39
commit c8e9d058f0
2 changed files with 32 additions and 4 deletions

View File

@@ -65,6 +65,13 @@
#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 { \
struct timeval tv = {(x),(y)}; \
select(0, NULL, NULL, NULL, &tv); \
} while (0)
#define WUSLEEP(x) WXSLEEP(0,x)
#define WSLEEP(x) WXSLEEP(x,0)
/* 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
* test mode and (2) the testsuite which uses this code and sets up the correct * test mode and (2) the testsuite which uses this code and sets up the correct
@@ -3140,7 +3147,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#elif defined(WOLFSSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
Task_sleep(1); Task_sleep(1);
#else #else
sleep(1); /* 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
#endif /* WOLFSSL_SESSION_EXPORT_DEBUG */ #endif /* WOLFSSL_SESSION_EXPORT_DEBUG */
@@ -3245,7 +3259,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#elif defined(WOLFSSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
Task_sleep(1); Task_sleep(1);
#else #else
sleep(1); /* 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
} }
tcp_connect(&sockfd, host, port, dtlsUDP, dtlsSCTP, sslResume); tcp_connect(&sockfd, host, port, dtlsUDP, dtlsSCTP, sslResume);
@@ -3373,7 +3394,14 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#elif defined(WOLFSSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
Task_sleep(1); Task_sleep(1);
#else #else
sleep(1); /* 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
#endif /* WOLFSSL_SESSION_EXPORT_DEBUG */ #endif /* WOLFSSL_SESSION_EXPORT_DEBUG */

View File

@@ -34432,7 +34432,7 @@ static void test_wolfSSL_ASN1_STRING_print(void){
asnStr = ASN1_STRING_type_new(V_ASN1_OCTET_STRING); asnStr = ASN1_STRING_type_new(V_ASN1_OCTET_STRING);
ASN1_STRING_set(asnStr,(const void*)unprintableData, ASN1_STRING_set(asnStr,(const void*)unprintableData,
sizeof(unprintableData)); (int)sizeof(unprintableData));
/* test */ /* test */
p_len = wolfSSL_ASN1_STRING_print(bio, asnStr); p_len = wolfSSL_ASN1_STRING_print(bio, asnStr);
AssertIntEQ(p_len, 46); AssertIntEQ(p_len, 46);