Skip to content

Commit 494b1da

Browse files
Add test for non-existing file
1 parent 2276d94 commit 494b1da

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/sftp.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,32 @@ if [ $nonblockingOnly = 0 ]; then
139139
fi
140140
fi
141141

142+
# Test SFTP status failure for non-existing file
143+
if [ $nonblockingOnly = 0 ]; then
144+
echo "Test SFTP status failure for non-existing file"
145+
./examples/echoserver/echoserver -N -1 -R $ready_file &
146+
server_pid=$!
147+
create_port
148+
./examples/sftpclient/wolfsftp -N -u jill -P upthehill -p $port -G -r $PWD/this_file_does_not_exist_12345.txt -l $PWD/test_output.txt > sftp_status_failure.log 2>&1
149+
RESULT=$?
150+
grep "Unable to copy remote file" sftp_status_failure.log > /dev/null
151+
RESULT_MSG=$?
152+
remove_ready_file
153+
rm -f sftp_status_failure.log
154+
rm -f $PWD/test_output.txt
155+
if [ $RESULT -eq 0 ]; then
156+
echo -e "\n\nERROR: Should have failed for non-existing file"
157+
do_cleanup
158+
exit 1
159+
fi
160+
if [ $RESULT_MSG -ne 0 ]; then
161+
echo -e "\n\nERROR: Unexpected failure path while testing missing remote file"
162+
do_cleanup
163+
exit 1
164+
fi
165+
echo "Successfully received failure status packet"
166+
fi
167+
142168
echo -e "\nALL Tests Passed"
143169

144170
exit 0

0 commit comments

Comments
 (0)