Merge pull request #329 from JacobBarthelmeh/testing

fixes for build with NO_WOLFSSH_CLIENT macro and --enable-all
pull/334/head^2
John Safranek 2021-04-20 17:36:40 -07:00 committed by GitHub
commit e90c033c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 5 deletions

View File

@ -34,6 +34,8 @@
#include <wolfssh/test.h>
#include <wolfssh/port.h>
#include <wolfssl/wolfcrypt/ecc.h>
#ifndef NO_WOLFSSH_CLIENT
#include "examples/portfwd/wolfssh_portfwd.h"
@ -482,3 +484,10 @@ char* myoptarg = NULL;
#endif /* NO_MAIN_DRIVER */
#else
int main()
{
printf("NO_WOLFSSH_CLIENT macro used, wolfSSH client not compiled in.\n");
return -1;
}
#endif /* NO_WOLFSSH_CLIENT */

View File

@ -29,6 +29,7 @@
#include <wolfssh/test.h>
#include <wolfssh/port.h>
#ifndef NO_WOLFSSH_CLIENT
#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)
#include <wolfssl/wolfcrypt/ecc.h>
#endif
@ -396,3 +397,12 @@ int myoptind = 0;
char* myoptarg = NULL;
#endif /* NO_MAIN_DRIVER */
#else
int main()
{
printf("wolfSSH built with NO_WOLFSSH_CLIENT\n");
printf("SCP client unavailable\n");
return -1;
}
#endif /* NO_WOLFSSH_CLIENT */

View File

@ -31,7 +31,7 @@
#include <termios.h>
#endif
#ifdef WOLFSSH_SFTP
#if defined(WOLFSSH_SFTP) && !defined(NO_WOLFSSH_CLIENT)
/* static so that signal handler can access and interrupt get/put */
static WOLFSSH* ssh = NULL;
@ -1523,7 +1523,12 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
{
printf("Not compiled in!\nPlease recompile with WOLFSSH_SFTP or --enable-sftp");
#ifdef NO_WOLFSSH_CLIENT
printf("NO_WOLFSSH_CLIENT macro was used. Can not have a client example\n");
#else
printf("Not compiled in!\n"
"Please recompile with WOLFSSH_SFTP or --enable-sftp\n");
#endif
(void)args;
return 0;
}
@ -1556,7 +1561,11 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args)
wolfSSH_Cleanup();
return args.return_code;
#if defined(WOLFSSH_SFTP) && !defined(NO_WOLFSSH_CLIENT)
return args.return_code;
#else
return -1; /* return error when not compiled in */
#endif
}
int myoptind = 0;

View File

@ -6,6 +6,22 @@ then
exit 1
fi
# test SFTP client is working (that NO_WOLFSSH_CLIENT was not used)
./examples/sftpclient/wolfsftp -h
if [ $? -ne 0 ]
then
./examples/sftpclient/wolfsftp -h | grep NO_WOLFSSH_CLIENT
if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping test"
exit 0
else
echo "wolfSFTP client not compiled in or not working"
exit 1
fi
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/sftpclient/wolfsftp ] && echo -e "\n\nwolfSFTP client doesn't exist" && exit 1
# test for if the SFTP client works
./examples/sftpclient/wolfsftp -h | grep NO_WOLFSSH_CLIENT
if [ $? -eq 0 ]
then
echo "macro NO_WOLFSSH_CLIENT was used"
echo "skipping test"
exit 0
fi
#echo "ready file $ready_file"
create_port() {

View File

@ -246,7 +246,7 @@ static int ConvertHexToBin(const char* h1, byte** b1, word32* b1Sz,
return 0;
}
#ifdef WOLFSSH_SFTP
#if defined(WOLFSSH_SFTP) && !defined(NO_WOLFSSH_CLIENT)
byte userPassword[256];
static int sftpUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
{
@ -274,6 +274,7 @@ static int sftpUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
return ret;
}
#ifndef NO_WOLFSSH_CLIENT
/* preforms connection to port, sets WOLFSSH_CTX and WOLFSSH on success
* caller needs to free ctx and ssh when done
*/
@ -331,6 +332,7 @@ static void sftp_client_connect(WOLFSSH_CTX** ctx, WOLFSSH** ssh, int port)
return;
}
}
#endif /* NO_WOLFSSH_CLIENT */
#endif /* WOLFSSH_SFTP */
@ -702,7 +704,7 @@ static void test_wolfSSH_SCP_CB(void)
static void test_wolfSSH_SFTP_SendReadPacket(void)
{
#ifdef WOLFSSH_SFTP
#if defined(WOLFSSH_SFTP) && !defined(NO_WOLFSSH_CLIENT)
func_args ser;
tcp_ready ready;
int argsCount;