limit additional nonblocking test

pull/597/head
JacobBarthelmeh 2023-09-29 16:12:21 -07:00
parent cb6088e339
commit 5780570880
8 changed files with 82 additions and 31 deletions

View File

@ -91,7 +91,12 @@ static void ShowUsage(void)
printf(" -j <filename> filename for the user's public key\n");
printf(" -x exit after successful connection without doing\n"
" read/write\n");
#ifdef WOLFSSH_TEST_BLOCK
printf("-N non-blocking sockets required when compiled with "
"WOLFSSH_TEST_BLOCK\n");
#else
printf(" -N use non-blocking sockets\n");
#endif
#ifdef WOLFSSH_TERM
printf(" -t use psuedo terminal\n");
#endif

View File

@ -9,7 +9,16 @@ if test -n "$WOLFSSH_EXTERNAL_TEST"; then
echo "WOLFSSH_EXTERNAL_TEST set, running test..."
else
echo "WOLFSSH_EXTERNAL_TEST NOT set, won't run"
exit 0
exit 77
fi
# test for nonblocking only
./examples/client/client -h | grep WOLFSSH_TEST_BLOCK
if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping for now"
exit 77
fi
do_cleanup() {

View File

@ -15,13 +15,21 @@ then
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping test"
exit 0
exit 77
else
echo "wolfSFTP client not compiled in or not working"
exit 1
fi
fi
# test for nonblocking only
./examples/client/client -h | grep WOLFSSH_TEST_BLOCK
if [ $? -eq 0 ]
then
echo "macro WOLFSSH_TEST_BLOCK was used"
exit 77
fi
if test ! -x ./examples/echoserver/echoserver
then
echo "This test requires the wolfSSH echoserver."

View File

@ -9,6 +9,15 @@ counter=0
[ ! -x ./examples/scpclient/wolfscp ] && echo -e "\n\nwolfscp client doesn't exist" && exit 1
# test for nonblocking only
./examples/client/client -h | grep WOLFSSH_TEST_BLOCK
if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping for now"
exit 77
fi
create_port() {
while [ ! -s "$ready_file" ] && [ "$counter" -lt 20 ]; do
echo -e "waiting for ready file..."

View File

@ -6,6 +6,7 @@ no_pid=-1
server_pid=$no_pid
ready_file=`pwd`/wolfssh_sftp_ready$$
counter=0
nonblockingOnly=0
[ ! -x ./examples/sftpclient/wolfsftp ] && echo -e "\n\nwolfSFTP client doesn't exist" && exit 1
@ -15,7 +16,15 @@ if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping test"
exit 0
exit 77
fi
# test for nonblocking only
./examples/client/client -h | grep WOLFSSH_TEST_BLOCK
if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
nonblockingOnly=1
fi
#echo "ready file $ready_file"
@ -67,17 +76,19 @@ trap do_trap INT TERM
[ ! -x ./examples/sftpclient/wolfsftp ] && echo -e "\n\nClient doesn't exist" && exit 1
echo "Test basic connection"
./examples/echoserver/echoserver -1 -R $ready_file &
server_pid=$!
create_port
echo "exit" | ./examples/sftpclient/wolfsftp -u jill -P upthehill -p $port
RESULT=$?
remove_ready_file
if [ $RESULT -ne 0 ]; then
if [ $nonblockingOnly = 0 ]; then
echo "Test basic connection"
./examples/echoserver/echoserver -1 -R $ready_file &
server_pid=$!
create_port
echo "exit" | ./examples/sftpclient/wolfsftp -u jill -P upthehill -p $port
RESULT=$?
remove_ready_file
if [ $RESULT -ne 0 ]; then
echo -e "\n\nfailed to connect"
do_cleanup
exit 1
fi
fi
# Test non blocking connection
@ -95,18 +106,20 @@ if [ $RESULT -ne 0 ]; then
fi
# Test of setting directory
echo "Test of setting directory"
PWD=`pwd`
./examples/echoserver/echoserver -d $PWD/examples -1 -R $ready_file &
server_pid=$!
create_port
echo "exit" | ./examples/sftpclient/wolfsftp -N -u jill -P upthehill -p $port
RESULT=$?
remove_ready_file
if [ $RESULT -ne 0 ]; then
if [ $nonblockingOnly = 0 ]; then
echo "Test of setting directory"
PWD=`pwd`
./examples/echoserver/echoserver -d $PWD/examples -1 -R $ready_file &
server_pid=$!
create_port
echo "exit" | ./examples/sftpclient/wolfsftp -N -u jill -P upthehill -p $port
RESULT=$?
remove_ready_file
if [ $RESULT -ne 0 ]; then
echo -e "\n\nfailed to connect"
do_cleanup
exit 1
fi
fi
echo -e "\nALL Tests Passed"

View File

@ -44,7 +44,7 @@
/* percent of time that forced want read/write is done */
#ifndef WOLFSSH_BLOCK_PROB
#define WOLFSSH_BLOCK_PROB 75
#define WOLFSSH_BLOCK_PROB 50
#endif
#endif

View File

@ -42,7 +42,9 @@
#define WOLFSSH_TEST_SERVER
#define WOLFSSH_TEST_ECHOSERVER
#endif
#define WOLFSSH_TEST_HEX2BIN
#ifndef WOLFSSH_TEST_BLOCK
#define WOLFSSH_TEST_HEX2BIN
#endif
#include <wolfssh/test.h>
#include "tests/api.h"
@ -127,6 +129,8 @@ char* myoptarg = NULL;
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
#ifndef WOLFSSH_TEST_BLOCK
enum WS_TestEndpointTypes {
TEST_GOOD_ENDPOINT_SERVER = WOLFSSH_ENDPOINT_SERVER,
TEST_GOOD_ENDPOINT_CLIENT = WOLFSSH_ENDPOINT_CLIENT,
@ -1074,13 +1078,16 @@ static void test_wolfSSH_RealPath(void)
#else
static void test_wolfSSH_RealPath(void) { ; }
#endif
#endif /* WOLFSSH_TEST_BLOCK */
int wolfSSH_ApiTest(int argc, char** argv)
{
(void)argc;
(void)argv;
#ifdef WOLFSSH_TEST_BLOCK
return 77;
#else
AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2)
@ -1111,10 +1118,10 @@ int wolfSSH_ApiTest(int argc, char** argv)
/* Either SCP or SFTP */
test_wolfSSH_RealPath();
AssertIntEQ(wolfSSH_Cleanup(), WS_SUCCESS);
return 0;
#endif
}

View File

@ -66,7 +66,7 @@ char* myoptarg = NULL;
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT) && \
!defined(SINGLE_THREADED)
!defined(SINGLE_THREADED) && !defined(WOLFSSH_TEST_BLOCK)
static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
{