1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/selftests.sh
Andy Green 8829c2f365 selftests
This converts several of the selftests to return a status in their exit code
about whether they 'worked'.

A small bash script framework is added, with a selftest.sh in the mininmal
example dirs that support it, and a ./minimal-examples/selftests.sh script
that can be run from the build dir with no args that discovers and runs all
the selftest.sh scripts underneath.

That is also integrated into travis and the enabled tests must pass now for
travis to pass.  Travis does not have a modern libuv so it can't run a
couple of tests which are nulled out if it sees it's running in travis env.
2018-04-19 16:16:48 +08:00

46 lines
828 B
Bash
Executable file

#/bin/bash
#
# run this from your build dir having configured
# -DLWS_WITH_MINIMAL_EXAMPLES=1 to get all the examples
# that apply built into ./bin
#
# Eg,
#
# build $ ../minimal-examples/selftests.sh
LOGGING_PATH=/tmp/logs
MINEX=`dirname $0`
MINEX=`realpath $MINEX`
TESTS=0
for i in `find $MINEX -name selftest.sh` ; do
C=`cat $i | grep COUNT_TESTS= | cut -d= -f2`
TESTS=$(( $TESTS + $C ))
done
FAILS=0
WH=1
for i in `find $MINEX -name selftest.sh` ; do
C=`cat $i | grep COUNT_TESTS= | cut -d= -f2`
sh $i `pwd`/bin $LOGGING_PATH $WH $TESTS $MINEX
FAILS=$(( $FAILS + $? ))
L=`ps fax | grep lws- | cut -d' ' -f2`
kill $L 2>/dev/null
kill -9 $L 2>/dev/null
wait $L 2>/dev/null
WH=$(( $WH + $C ))
done
if [ $FAILS -eq 0 ] ; then
echo "All $TESTS passed"
exit 0
else
echo "Failed: $FAILS / $TESTS"
exit 1
fi