mirror of https://github.com/wolfSSL/wolfssh.git
SFTP Test Maintenance
1. Modified SignalTcpReady() to test.h. Matched its prototype to the other functions for TcpReady. 2. Add a timeout in WaitTcpReady() specifically for Zephyr builds. 3. Misc few cleanups.pull/646/head
parent
16708d2bb0
commit
ec1248f14d
|
|
@ -2159,21 +2159,18 @@ static void ShowUsage(void)
|
|||
}
|
||||
|
||||
|
||||
static INLINE void SignalTcpReady(func_args* serverArgs, word16 port)
|
||||
static INLINE void SignalTcpReady(tcp_ready* ready, word16 port)
|
||||
{
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && \
|
||||
!defined(__MINGW32__) && !defined(SINGLE_THREADED)
|
||||
tcp_ready* ready = serverArgs->signal;
|
||||
if (ready != NULL) {
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
ready->ready = 1;
|
||||
ready->port = port;
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
}
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
ready->ready = 1;
|
||||
ready->port = port;
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
#else
|
||||
(void)serverArgs;
|
||||
(void)port;
|
||||
WOLFSSH_UNUSED(ready);
|
||||
WOLFSSH_UNUSED(port);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -2543,6 +2540,8 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
#endif
|
||||
}
|
||||
|
||||
SignalTcpReady(serverArgs->signal, port);
|
||||
|
||||
do {
|
||||
WS_SOCKET_T clientFd = WOLFSSH_SOCKET_INVALID;
|
||||
#ifdef WOLFSSL_NUCLEUS
|
||||
|
|
@ -2600,8 +2599,6 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
}
|
||||
#endif
|
||||
|
||||
SignalTcpReady(serverArgs, port);
|
||||
|
||||
#ifdef WOLFSSL_NUCLEUS
|
||||
clientFd = NU_Accept(listenFd, &clientAddr, 0);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -974,7 +974,7 @@ static void test_wolfSSH_SFTP_SendReadPacket(void)
|
|||
ser.signal = &ready;
|
||||
InitTcpReady(ser.signal);
|
||||
ThreadStart(echoserver_test, (void*)&ser, &serThread);
|
||||
WaitTcpReady(&ser);
|
||||
WaitTcpReady(&ready);
|
||||
|
||||
sftp_client_connect(&ctx, &ssh, ready.port);
|
||||
AssertNotNull(ctx);
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ int wolfSSH_SftpTest(int flag)
|
|||
ser.signal = &ready;
|
||||
InitTcpReady(ser.signal);
|
||||
ThreadStart(echoserver_test, (void*)&ser, &serThread);
|
||||
WaitTcpReady(&ser);
|
||||
WaitTcpReady(&ready);
|
||||
|
||||
argsCount = 0;
|
||||
args[argsCount++] = ".";
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ int wolfSSH_TestsuiteTest(int argc, char** argv)
|
|||
serverArgs.signal = &ready;
|
||||
serverArgs.user_auth = NULL;
|
||||
ThreadStart(echoserver_test, &serverArgs, &serverThread);
|
||||
WaitTcpReady(&serverArgs);
|
||||
WaitTcpReady(&ready);
|
||||
|
||||
WSTRNCPY(cA[clientArgc++], "client", ARGLEN);
|
||||
WSTRNCPY(cA[clientArgc++], "-u", ARGLEN);
|
||||
|
|
|
|||
|
|
@ -850,8 +850,8 @@ static INLINE void InitTcpReady(tcp_ready* ready)
|
|||
ready->srfName = NULL;
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && \
|
||||
!defined(__MINGW32__) && !defined(SINGLE_THREADED)
|
||||
pthread_mutex_init(&ready->mutex, 0);
|
||||
pthread_cond_init(&ready->cond, 0);
|
||||
pthread_mutex_init(&ready->mutex, NULL);
|
||||
pthread_cond_init(&ready->cond, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -863,24 +863,30 @@ static INLINE void FreeTcpReady(tcp_ready* ready)
|
|||
pthread_mutex_destroy(&ready->mutex);
|
||||
pthread_cond_destroy(&ready->cond);
|
||||
#else
|
||||
(void)ready;
|
||||
WOLFSSH_UNUSED(ready);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static INLINE void WaitTcpReady(func_args* args)
|
||||
static INLINE void WaitTcpReady(tcp_ready* ready)
|
||||
{
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && \
|
||||
!defined(__MINGW32__) && !defined(SINGLE_THREADED)
|
||||
pthread_mutex_lock(&args->signal->mutex);
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
|
||||
if (!args->signal->ready)
|
||||
pthread_cond_wait(&args->signal->cond, &args->signal->mutex);
|
||||
args->signal->ready = 0; /* reset */
|
||||
while (!ready->ready) {
|
||||
pthread_cond_wait(&ready->cond, &ready->mutex);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&args->signal->mutex);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
#ifdef WOLFSSH_ZEPHYR
|
||||
/* It's like the server isn't ready to accept connections it is
|
||||
* listening for despite this conditional variable. A 300ms wait
|
||||
* seems to help. This is not ideal. (XXX) */
|
||||
k_sleep(Z_TIMEOUT_TICKS(300));
|
||||
#endif /* WOLFSSH_ZEPHYR */
|
||||
#else
|
||||
(void)args;
|
||||
WOLFSSH_UNUSED(ready);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue