build_and_test_minimal.sh 1.2 KB

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