• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# run this from your build dir having configured
4# -DLWS_WITH_MINIMAL_EXAMPLES=1 to get all the examples
5# that apply built into ./bin
6#
7# Eg,
8#
9# build $ ../minimal-examples/selftests.sh
10
11echo
12echo "----------------------------------------------"
13echo "-------   tests: lws minimal example selftests"
14echo
15
16LOGGING_PATH=/tmp/logs
17
18# for mebedtls, we need the CA certs in ./build where we run from
19
20cp ../minimal-examples/http-client/minimal-http-client-multi/warmcat.com.cer .
21cp ../minimal-examples/http-client/minimal-http-client-post/libwebsockets.org.cer .
22
23MINEX=`dirname $0`
24MINEX=`realpath $MINEX`
25TESTS=0
26for i in `find $MINEX -name selftest.sh` ; do
27	BN=`echo -n "$i" | sed "s/\/[^\/]*\$//g" | sed "s/.*\///g"`
28	if [ -e `pwd`/bin/lws-$BN ] ; then
29		C=`cat $i | grep COUNT_TESTS= | cut -d= -f2`
30		TESTS=$(( $TESTS + $C ))
31	fi
32done
33
34FAILS=0
35WH=1
36
37for i in `find $MINEX -name selftest.sh` ; do
38	BN=`echo -n "$i" | sed "s/\/[^\/]*\$//g" | sed "s/.*\///g"`
39	if [ -e `pwd`/bin/lws-$BN ] ; then
40		C=`cat $i | grep COUNT_TESTS= | cut -d= -f2`
41		sh $i `pwd`/bin $LOGGING_PATH $WH $TESTS $MINEX
42		FAILS=$(( $FAILS + $? ))
43
44		L=`ps fax | grep lws- | cut -d' ' -f2`
45		kill $L 2>/dev/null
46		kill -9 $L 2>/dev/null
47		wait $L 2>/dev/null
48
49		WH=$(( $WH + $C ))
50	fi
51done
52
53if [ $FAILS -eq 0 ] ; then
54	echo "All $TESTS passed"
55	exit 0
56else
57	echo "Failed: $FAILS / $TESTS"
58	exit 1
59fi
60
61
62