1#!/bin/bash 2 3 4if test -f "./unittest/build_and_test_minimal.sh" ; then 5 echo "Unit test (minimal features) will run on a local Debian system." 6 rm -rf output 7else 8 echo "This script must be started from the civetweb root directory using ./unittest/build_and_test_minimal.sh" 9 exit 10fi 11 12 13# Exit with an error message when any command fails. 14set -e 15trap 'lastline=$thisline; thisline=$BASH_COMMAND' DEBUG 16trap 'echo "ERROR: \"${lastline}\" command failed (error $?)"' EXIT 17 18 19# Create a test directory and add the CGI test executable 20if test -f "./output/" ; then 21 echo "Removing old \"output\" folder." 22 rm -rf output 23fi 24mkdir output 25gcc unittest/cgi_test.c -o output/cgi_test.cgi 26cd output 27 28 29# Perform build and test steps in "output" directory. 30echo "Starting unit test. Write protocol to \"unittest.log\" file." 31echo "Starting unit test" > unittest.log 32git log -1 >> unittest.log 33cmake -DCIVETWEB_ENABLE_SSL=NO -DCIVETWEB_DISABLE_CGI=YES -DCIVETWEB_ENABLE_WEBSOCKETS=NO -DCIVETWEB_ENABLE_SERVER_STATS=NO -DCIVETWEB_ENABLE_IPV6=NO .. &>> unittest.log 34make all &>> unittest.log 35make test &>> unittest.log 36echo "Unit test completed. See \"unittest.log\" file." 37tail -10 unittest.log | grep " tests passed" 38cd .. 39 40 41# Exit with success 42trap '' EXIT 43exit 0 44