wolfssh/scripts/fwd.test

60 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env sh
# Prerequisite checking
if [ ! -x "$(command -v expect)" ]
then
echo "skipping: missing expect"
exit 77
fi
# Automake sets $srcdir for tests. When building out-of-tree (e.g.
# make distcheck), the expect script only lives in the source tree,
# not the build tree. Fall back to the current directory otherwise.
expect_script="${srcdir:-.}/scripts/fwd.test.expect"
if [ ! -x "$expect_script" ]
then
echo "fail: missing expect script"
exit 1
fi
if [ ! -x "$(command -v nc)" ]
then
echo "skipping: missing netcat"
exit 77
fi
## libtool can leave behind a script that runs the actual executable.
if [ ! -x ./examples/echoserver/echoserver ] || \
./examples/echoserver/echoserver "-?" 2>&1 | grep -q "does not exist"
then
echo "fail: missing echoserver"
exit 1
fi
## libtool can leave behind a script that runs the actual executable.
if [ ! -x ./examples/portfwd/portfwd ] || \
./examples/portfwd/portfwd "-?" 2>&1 | grep -q "does not exist"
then
echo "skipping: missing forwarding"
exit 77
fi
## test for nonblocking only
WOLFSSH_OPTIONS=$(./apps/wolfssh-options) || {
echo "fail: could not run ./apps/wolfssh-options"
exit 1
}
if echo "$WOLFSSH_OPTIONS" | grep -qx "TEST_BLOCK"
then
echo "skipping: non-blocking test"
exit 77
fi
# Run the expect script
"$expect_script"