mirror of https://github.com/wolfSSL/wolfssh.git
limit additional nonblocking test
parent
cb6088e339
commit
5780570880
|
@ -91,7 +91,12 @@ static void ShowUsage(void)
|
||||||
printf(" -j <filename> filename for the user's public key\n");
|
printf(" -j <filename> filename for the user's public key\n");
|
||||||
printf(" -x exit after successful connection without doing\n"
|
printf(" -x exit after successful connection without doing\n"
|
||||||
" read/write\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");
|
printf(" -N use non-blocking sockets\n");
|
||||||
|
#endif
|
||||||
#ifdef WOLFSSH_TERM
|
#ifdef WOLFSSH_TERM
|
||||||
printf(" -t use psuedo terminal\n");
|
printf(" -t use psuedo terminal\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,16 @@ if test -n "$WOLFSSH_EXTERNAL_TEST"; then
|
||||||
echo "WOLFSSH_EXTERNAL_TEST set, running test..."
|
echo "WOLFSSH_EXTERNAL_TEST set, running test..."
|
||||||
else
|
else
|
||||||
echo "WOLFSSH_EXTERNAL_TEST NOT set, won't run"
|
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
|
fi
|
||||||
|
|
||||||
do_cleanup() {
|
do_cleanup() {
|
||||||
|
|
|
@ -15,13 +15,21 @@ then
|
||||||
then
|
then
|
||||||
echo "macro NO_WOLFSSH_CLIENT was used"
|
echo "macro NO_WOLFSSH_CLIENT was used"
|
||||||
echo "skipping test"
|
echo "skipping test"
|
||||||
exit 0
|
exit 77
|
||||||
else
|
else
|
||||||
echo "wolfSFTP client not compiled in or not working"
|
echo "wolfSFTP client not compiled in or not working"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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
|
if test ! -x ./examples/echoserver/echoserver
|
||||||
then
|
then
|
||||||
echo "This test requires the wolfSSH echoserver."
|
echo "This test requires the wolfSSH echoserver."
|
||||||
|
|
|
@ -9,6 +9,15 @@ counter=0
|
||||||
|
|
||||||
[ ! -x ./examples/scpclient/wolfscp ] && echo -e "\n\nwolfscp client doesn't exist" && exit 1
|
[ ! -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() {
|
create_port() {
|
||||||
while [ ! -s "$ready_file" ] && [ "$counter" -lt 20 ]; do
|
while [ ! -s "$ready_file" ] && [ "$counter" -lt 20 ]; do
|
||||||
echo -e "waiting for ready file..."
|
echo -e "waiting for ready file..."
|
||||||
|
|
|
@ -6,6 +6,7 @@ no_pid=-1
|
||||||
server_pid=$no_pid
|
server_pid=$no_pid
|
||||||
ready_file=`pwd`/wolfssh_sftp_ready$$
|
ready_file=`pwd`/wolfssh_sftp_ready$$
|
||||||
counter=0
|
counter=0
|
||||||
|
nonblockingOnly=0
|
||||||
|
|
||||||
[ ! -x ./examples/sftpclient/wolfsftp ] && echo -e "\n\nwolfSFTP client doesn't exist" && exit 1
|
[ ! -x ./examples/sftpclient/wolfsftp ] && echo -e "\n\nwolfSFTP client doesn't exist" && exit 1
|
||||||
|
|
||||||
|
@ -15,7 +16,15 @@ if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "macro NO_WOLFSSH_CLIENT was used"
|
echo "macro NO_WOLFSSH_CLIENT was used"
|
||||||
echo "skipping test"
|
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
|
fi
|
||||||
|
|
||||||
#echo "ready file $ready_file"
|
#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
|
[ ! -x ./examples/sftpclient/wolfsftp ] && echo -e "\n\nClient doesn't exist" && exit 1
|
||||||
|
|
||||||
echo "Test basic connection"
|
if [ $nonblockingOnly = 0 ]; then
|
||||||
./examples/echoserver/echoserver -1 -R $ready_file &
|
echo "Test basic connection"
|
||||||
server_pid=$!
|
./examples/echoserver/echoserver -1 -R $ready_file &
|
||||||
create_port
|
server_pid=$!
|
||||||
echo "exit" | ./examples/sftpclient/wolfsftp -u jill -P upthehill -p $port
|
create_port
|
||||||
RESULT=$?
|
echo "exit" | ./examples/sftpclient/wolfsftp -u jill -P upthehill -p $port
|
||||||
remove_ready_file
|
RESULT=$?
|
||||||
if [ $RESULT -ne 0 ]; then
|
remove_ready_file
|
||||||
echo -e "\n\nfailed to connect"
|
if [ $RESULT -ne 0 ]; then
|
||||||
do_cleanup
|
echo -e "\n\nfailed to connect"
|
||||||
exit 1
|
do_cleanup
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test non blocking connection
|
# Test non blocking connection
|
||||||
|
@ -95,18 +106,20 @@ if [ $RESULT -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test of setting directory
|
# Test of setting directory
|
||||||
echo "Test of setting directory"
|
if [ $nonblockingOnly = 0 ]; then
|
||||||
PWD=`pwd`
|
echo "Test of setting directory"
|
||||||
./examples/echoserver/echoserver -d $PWD/examples -1 -R $ready_file &
|
PWD=`pwd`
|
||||||
server_pid=$!
|
./examples/echoserver/echoserver -d $PWD/examples -1 -R $ready_file &
|
||||||
create_port
|
server_pid=$!
|
||||||
echo "exit" | ./examples/sftpclient/wolfsftp -N -u jill -P upthehill -p $port
|
create_port
|
||||||
RESULT=$?
|
echo "exit" | ./examples/sftpclient/wolfsftp -N -u jill -P upthehill -p $port
|
||||||
remove_ready_file
|
RESULT=$?
|
||||||
if [ $RESULT -ne 0 ]; then
|
remove_ready_file
|
||||||
echo -e "\n\nfailed to connect"
|
if [ $RESULT -ne 0 ]; then
|
||||||
do_cleanup
|
echo -e "\n\nfailed to connect"
|
||||||
exit 1
|
do_cleanup
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\nALL Tests Passed"
|
echo -e "\nALL Tests Passed"
|
||||||
|
|
2
src/io.c
2
src/io.c
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
/* percent of time that forced want read/write is done */
|
/* percent of time that forced want read/write is done */
|
||||||
#ifndef WOLFSSH_BLOCK_PROB
|
#ifndef WOLFSSH_BLOCK_PROB
|
||||||
#define WOLFSSH_BLOCK_PROB 75
|
#define WOLFSSH_BLOCK_PROB 50
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
13
tests/api.c
13
tests/api.c
|
@ -42,7 +42,9 @@
|
||||||
#define WOLFSSH_TEST_SERVER
|
#define WOLFSSH_TEST_SERVER
|
||||||
#define WOLFSSH_TEST_ECHOSERVER
|
#define WOLFSSH_TEST_ECHOSERVER
|
||||||
#endif
|
#endif
|
||||||
#define WOLFSSH_TEST_HEX2BIN
|
#ifndef WOLFSSH_TEST_BLOCK
|
||||||
|
#define WOLFSSH_TEST_HEX2BIN
|
||||||
|
#endif
|
||||||
#include <wolfssh/test.h>
|
#include <wolfssh/test.h>
|
||||||
#include "tests/api.h"
|
#include "tests/api.h"
|
||||||
|
|
||||||
|
@ -127,6 +129,8 @@ char* myoptarg = NULL;
|
||||||
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
|
#define AssertPtrLE(x, y) AssertPtr(x, y, <=, >)
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WOLFSSH_TEST_BLOCK
|
||||||
|
|
||||||
enum WS_TestEndpointTypes {
|
enum WS_TestEndpointTypes {
|
||||||
TEST_GOOD_ENDPOINT_SERVER = WOLFSSH_ENDPOINT_SERVER,
|
TEST_GOOD_ENDPOINT_SERVER = WOLFSSH_ENDPOINT_SERVER,
|
||||||
TEST_GOOD_ENDPOINT_CLIENT = WOLFSSH_ENDPOINT_CLIENT,
|
TEST_GOOD_ENDPOINT_CLIENT = WOLFSSH_ENDPOINT_CLIENT,
|
||||||
|
@ -1074,13 +1078,16 @@ static void test_wolfSSH_RealPath(void)
|
||||||
#else
|
#else
|
||||||
static void test_wolfSSH_RealPath(void) { ; }
|
static void test_wolfSSH_RealPath(void) { ; }
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* WOLFSSH_TEST_BLOCK */
|
||||||
|
|
||||||
int wolfSSH_ApiTest(int argc, char** argv)
|
int wolfSSH_ApiTest(int argc, char** argv)
|
||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
|
#ifdef WOLFSSH_TEST_BLOCK
|
||||||
|
return 77;
|
||||||
|
#else
|
||||||
AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);
|
AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);
|
||||||
|
|
||||||
#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2)
|
#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 */
|
/* Either SCP or SFTP */
|
||||||
test_wolfSSH_RealPath();
|
test_wolfSSH_RealPath();
|
||||||
|
|
||||||
AssertIntEQ(wolfSSH_Cleanup(), WS_SUCCESS);
|
AssertIntEQ(wolfSSH_Cleanup(), WS_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ char* myoptarg = NULL;
|
||||||
|
|
||||||
|
|
||||||
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT) && \
|
#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)
|
static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue