mirror of https://github.com/wolfSSL/wolfssh.git
sftp test script added
parent
1342f25ce6
commit
2c4bca35e0
|
@ -16,6 +16,8 @@ EXTRA_HEADERS =
|
|||
BUILT_SOURCES=
|
||||
EXTRA_DIST=
|
||||
dist_doc_DATA=
|
||||
dist_noinst_SCRIPTS=
|
||||
check_SCRIPTS=
|
||||
|
||||
|
||||
#includes additional rules from aminclude.am
|
||||
|
@ -37,10 +39,15 @@ include tests/include.am
|
|||
include keys/include.am
|
||||
include ide/include.am
|
||||
include wolfsftp/include.am
|
||||
include scripts/include.am
|
||||
|
||||
|
||||
TEST_EXTENSIONS = .test
|
||||
TESTS += $(check_PROGRAMS)
|
||||
|
||||
check_SCRIPTS+= $(dist_noinst_SCRIPTS)
|
||||
TESTS += $(check_SCRIPTS)
|
||||
|
||||
test: check
|
||||
|
||||
DISTCLEANFILES+= wolfssh-config
|
||||
|
|
|
@ -590,13 +590,14 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
int useEcc = 0;
|
||||
char ch;
|
||||
word16 port = wolfSshPort;
|
||||
char* readyFile = NULL;
|
||||
|
||||
int argc = serverArgs->argc;
|
||||
char** argv = serverArgs->argv;
|
||||
serverArgs->return_code = 0;
|
||||
|
||||
if (argc > 0) {
|
||||
while ((ch = mygetopt(argc, argv, "?1ep:")) != -1) {
|
||||
while ((ch = mygetopt(argc, argv, "?1ep:R:")) != -1) {
|
||||
switch (ch) {
|
||||
case '?' :
|
||||
ShowUsage();
|
||||
|
@ -618,6 +619,10 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
#endif
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
readyFile = myoptarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
ShowUsage();
|
||||
exit(MY_EX_USAGE);
|
||||
|
@ -697,7 +702,21 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* if creating a ready file with port then override port to be 0 */
|
||||
if (readyFile != NULL) {
|
||||
port = 0;
|
||||
}
|
||||
tcp_listen(&listenFd, &port, 1);
|
||||
/* write out port number listing to, to user set ready file */
|
||||
if (readyFile != NULL) {
|
||||
WFILE* f = NULL;
|
||||
int ret;
|
||||
ret = WFOPEN(&f, readyFile, "w");
|
||||
if (f != NULL && ret == 0) {
|
||||
fprintf(f, "%d\n", (int)port);
|
||||
WFCLOSE(f);
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
SOCKET_T clientFd = 0;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# vim:ft=automake
|
||||
# included from Top Level Makefile.am
|
||||
# All paths should be given relative to the root
|
||||
|
||||
|
||||
|
||||
if BUILD_SFTP
|
||||
dist_noinst_SCRIPTS+= scripts/sftp.test
|
||||
endif
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/sh
|
||||
|
||||
# sftp local test
|
||||
|
||||
no_pid=-1
|
||||
server_pid=$no_pid
|
||||
ready_file=`pwd`/wolfssh_sftp_ready$$
|
||||
counter=0
|
||||
|
||||
[ ! -x ./wolfsftp/client/wolfsftp ] && echo -e "\n\nwolfSFTP client doesn't exist" && exit 1
|
||||
|
||||
#echo "ready file $ready_file"
|
||||
|
||||
create_port() {
|
||||
while [ ! -s "$ready_file" ] && [ "$counter" -lt 20 ]; do
|
||||
echo -e "waiting for ready file..."
|
||||
sleep 0.1
|
||||
counter=$((counter+ 1))
|
||||
done
|
||||
|
||||
if test -e $ready_file; then
|
||||
echo -e "found ready file, starting client..."
|
||||
|
||||
# get created port 0 ephemeral port
|
||||
port=`cat $ready_file`
|
||||
else
|
||||
echo -e "NO ready file ending test..."
|
||||
do_cleanup
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
remove_ready_file() {
|
||||
if test -e $ready_file; then
|
||||
echo -e "removing existing ready file"
|
||||
rm $ready_file
|
||||
fi
|
||||
}
|
||||
|
||||
do_cleanup() {
|
||||
echo "in cleanup"
|
||||
|
||||
if [ $server_pid != $no_pid ]
|
||||
then
|
||||
echo "killing server"
|
||||
kill -9 $server_pid
|
||||
fi
|
||||
remove_ready_file
|
||||
}
|
||||
|
||||
do_trap() {
|
||||
echo "got trap"
|
||||
do_cleanup
|
||||
exit -1
|
||||
}
|
||||
|
||||
trap do_trap INT TERM
|
||||
|
||||
[ ! -x ./wolfsftp/client/wolfsftp ] && echo -e "\n\nClient doesn't exist" && exit 1
|
||||
|
||||
./examples/echoserver/echoserver -1 -R $ready_file &
|
||||
server_pid=$!
|
||||
create_port
|
||||
echo "ls\nexit" | ./wolfsftp/client/wolfsftp -u jill -P upthehill -p $port
|
||||
RESULT=$?
|
||||
remove_ready_file
|
||||
# if fail here then is a settings issue so return 0
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo -e "\n\nfailed to connect"
|
||||
do_cleanup
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\nALL Tests Passed"
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue