2013-03-09 20:40:31 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-03-09 22:29:22 +01:00
|
|
|
errors=0
|
2013-03-30 10:11:55 +01:00
|
|
|
umask 0002
|
2013-08-24 19:33:21 +02:00
|
|
|
|
2013-10-30 22:08:10 +01:00
|
|
|
DATE="$(date +%s)"
|
|
|
|
unset LOGBASEDIR
|
2013-10-30 14:55:58 +01:00
|
|
|
if [ -z "$LOGDIR" ]; then
|
2013-10-30 22:08:10 +01:00
|
|
|
LOGBASEDIR=logs
|
|
|
|
LOGDIR=$LOGBASEDIR/$DATE
|
|
|
|
mkdir -p $LOGDIR
|
2013-10-30 14:55:58 +01:00
|
|
|
fi
|
2013-10-30 22:08:10 +01:00
|
|
|
export LOGDIR
|
2013-10-30 14:55:58 +01:00
|
|
|
|
2013-10-27 00:05:45 +02:00
|
|
|
if [ -z "$DBFILE" ]; then
|
|
|
|
DB=""
|
|
|
|
else
|
2013-10-30 20:01:11 +01:00
|
|
|
DB="-S $DBFILE --commit $(git rev-parse HEAD)"
|
2013-10-27 00:05:45 +02:00
|
|
|
if [ -n "$BUILD" ]; then
|
|
|
|
DB="$DB -b $BUILD"
|
|
|
|
fi
|
2013-10-31 16:05:11 +01:00
|
|
|
if [ "$PREFILL_DB" = "y" ] ; then
|
|
|
|
DB="$DB --prefill-tests"
|
|
|
|
fi
|
2013-10-27 00:05:45 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:55 +01:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "$0 [-v | --valgrind | valgrind] [-t | --trace | trace]"
|
|
|
|
echo "\t[-n <num> | --channels <num>] [-B | --build]"
|
|
|
|
echo "\t[-c | --codecov ] [run-tests.py parameters]"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2014-10-27 15:00:53 +01:00
|
|
|
unset VALGRIND
|
|
|
|
unset TRACE
|
|
|
|
unset TRACE_ARGS
|
|
|
|
unset RUN_TEST_ARGS
|
2014-10-27 15:00:54 +01:00
|
|
|
unset BUILD
|
|
|
|
unset BUILD_ARGS
|
|
|
|
unset CODECOV
|
2018-10-23 13:07:05 +02:00
|
|
|
unset VM
|
2014-10-27 15:00:53 +01:00
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
-v | --valgrind | valgrind)
|
|
|
|
shift
|
|
|
|
echo "$0: using valgrind"
|
|
|
|
VALGRIND=valgrind
|
|
|
|
;;
|
|
|
|
-t | --trace | trace)
|
|
|
|
shift
|
|
|
|
echo "$0: using Trace"
|
|
|
|
TRACE=trace
|
|
|
|
;;
|
|
|
|
-n | --channels)
|
|
|
|
shift
|
|
|
|
NUM_CH=$1
|
|
|
|
shift
|
|
|
|
echo "$0: using channels=$NUM_CH"
|
|
|
|
;;
|
2014-10-27 15:00:54 +01:00
|
|
|
-B | --build)
|
|
|
|
shift
|
|
|
|
echo "$0: build before running tests"
|
|
|
|
BUILD=build
|
|
|
|
;;
|
|
|
|
-c | --codecov)
|
|
|
|
shift
|
|
|
|
echo "$0: using code coverage"
|
|
|
|
CODECOV=lcov
|
|
|
|
BUILD_ARGS=-c
|
|
|
|
;;
|
2014-10-27 15:00:55 +01:00
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
;;
|
2018-10-23 13:07:05 +02:00
|
|
|
-V | --vm)
|
|
|
|
shift
|
|
|
|
echo "$0: running inside a VM"
|
|
|
|
VM=VM
|
|
|
|
;;
|
|
|
|
|
2014-10-27 15:00:53 +01:00
|
|
|
*)
|
|
|
|
RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$RUN_TEST_ARGS" ]; then
|
|
|
|
echo "$0: passing the following args to run-tests.py: $RUN_TEST_ARGS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset SUFFIX
|
2014-10-27 15:00:54 +01:00
|
|
|
if [ ! -z "$BUILD" ]; then
|
|
|
|
SUFFIX=-build
|
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:53 +01:00
|
|
|
if [ ! -z "$VALGRIND" ]; then
|
2014-10-27 15:00:54 +01:00
|
|
|
SUFFIX=$SUFFIX-valgrind
|
2013-10-30 18:49:12 +01:00
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:53 +01:00
|
|
|
if [ ! -z "$TRACE" ]; then
|
2013-10-30 18:49:12 +01:00
|
|
|
SUFFIX=$SUFFIX-trace
|
2013-10-30 22:37:15 +01:00
|
|
|
TRACE_ARGS="-T"
|
2014-06-10 19:50:29 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:54 +01:00
|
|
|
if [ ! -z "$CODECOV" ]; then
|
|
|
|
SUFFIX=$SUFFIX-codecov
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$BUILD" ]; then
|
|
|
|
echo "Building with args=$BUILD_ARGS"
|
|
|
|
if ! ./build.sh $BUILD_ARGS; then
|
|
|
|
echo "Failed building components"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-10-23 13:07:05 +02:00
|
|
|
if ! ./start.sh $VM $VALGRIND $TRACE channels=$NUM_CH; then
|
2013-10-30 22:08:10 +01:00
|
|
|
if ! [ -z "$LOGBASEDIR" ] ; then
|
|
|
|
echo "Could not start test environment" > $LOGDIR/run
|
|
|
|
fi
|
2013-09-28 17:19:38 +02:00
|
|
|
exit 1
|
2013-10-30 18:49:12 +01:00
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:53 +01:00
|
|
|
sudo ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1
|
2013-10-30 22:08:10 +01:00
|
|
|
|
2013-11-02 14:39:25 +01:00
|
|
|
./stop.sh
|
2013-10-30 18:49:12 +01:00
|
|
|
|
|
|
|
if [ ! -z "$VALGRIND" ] ; then
|
2013-10-30 22:08:10 +01:00
|
|
|
failures=`grep "ERROR SUMMARY" $LOGDIR/valgrind-* | grep -v " 0 errors" | wc -l`
|
2013-08-24 19:33:21 +02:00
|
|
|
if [ $failures -gt 0 ]; then
|
|
|
|
echo "Mark as failed due to valgrind errors"
|
|
|
|
errors=1
|
|
|
|
fi
|
2013-10-30 18:49:12 +01:00
|
|
|
fi
|
2014-10-27 15:00:54 +01:00
|
|
|
|
2019-03-08 15:52:52 +01:00
|
|
|
if tail -100 $LOGDIR/auth_serv | grep -q MEMLEAK; then
|
|
|
|
echo "Mark as failed due to authentication server memory leak"
|
|
|
|
errors=1
|
|
|
|
fi
|
|
|
|
|
2014-10-27 15:00:54 +01:00
|
|
|
if [ ! -z "$CODECOV" ] ; then
|
|
|
|
lcov -q --capture --directory ../../wpa_supplicant --output-file $LOGDIR/wpas_lcov.info
|
|
|
|
genhtml -q $LOGDIR/wpas_lcov.info --output-directory $LOGDIR/wpas_lcov
|
|
|
|
lcov -q --capture --directory ../../hostapd --output-file $LOGDIR/hostapd_lcov.info
|
|
|
|
genhtml -q $LOGDIR/hostapd_lcov.info --output-directory $LOGDIR/hostapd_lcov
|
|
|
|
fi
|
|
|
|
|
2013-10-30 18:49:12 +01:00
|
|
|
if [ $errors -gt 0 ]; then
|
2018-12-01 15:44:53 +01:00
|
|
|
if [ -z $VM ]; then
|
|
|
|
tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/
|
|
|
|
fi
|
2013-10-30 18:49:12 +01:00
|
|
|
exit 1
|
2013-03-09 22:29:22 +01:00
|
|
|
fi
|
2013-09-28 17:19:38 +02:00
|
|
|
|
|
|
|
echo "ALL-PASSED"
|