Skip to content

Commit

Permalink
Update unit test script for local use on Debian Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bel2125 committed Aug 29, 2021
1 parent 50a768a commit 1b0896e
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions unittest/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
#!/bin/sh
rm -rf output
#!/bin/bash


if test -f "./unittest/build_and_run.sh" ; then
echo "Unit test will run on a local Debian system."
rm -rf output
else
echo "This script must be started from the civetweb root directory using ./unittest/build_and_run.sh"
exit
fi


# Exit with an error message when any command fails.
set -e
trap 'lastline=$thisline; thisline=$BASH_COMMAND' DEBUG
trap 'echo "ERROR: \"${lastline}\" command failed (error $?)"' EXIT


# Create a test directory and add the CGI test executable
if test -f "./output/" ; then
echo "Removing old \"output\" folder."
rm -rf output
fi
mkdir output
gcc unittest/cgi_test.c -o output/cgi_test.cgi
cd output
cmake ..
make all
make test


# Perform build and test steps in "output" directory.
echo "Starting unit test. Write protocol to \"unittest.log\" file."
echo "Starting unit test" > unittest.log
git log -1 >> unittest.log
cmake .. &>> unittest.log
make all &>> unittest.log
make test &>> unittest.log
echo "Unit test completed. See \"unittest.log\" file."
tail -10 unittest.log | grep " tests passed"
cd ..


# Exit with success
trap '' EXIT
exit 0

0 comments on commit 1b0896e

Please sign in to comment.