diff --git a/check.sh b/check.sh index 95bdfee..2fa530b 100755 --- a/check.sh +++ b/check.sh @@ -1,11 +1,16 @@ #!/bin/bash + +red=`tput setaf 1` +green=`tput setaf 2` +reset=`tput sgr0` + FILE="$1" if ([ -f "$FILE" ] && [ -s "$FILE" ]) || ([ -d "$FILE" ] && [ "$(ls -A "$FILE")" ]); then - echo "[OK ] $FILE" + echo "${green}[OK ]${reset} $FILE" exit 0 else - echo "[FAIL] $FILE" >&2 + echo "${red}[FAIL]${reset} $FILE" >&2 exit 1 fi diff --git a/tests/results/README.md b/tests/results/README.md new file mode 100644 index 0000000..93f738c --- /dev/null +++ b/tests/results/README.md @@ -0,0 +1,4 @@ +Unit Test Results +==== + +This directory contains the temporary and resultant output files for the docker-based unit tests. Upon the conclusion of the suite of unit tests a check will be run, and all files in this directory will be deleted. See `start.sh` for more information. \ No newline at end of file diff --git a/tests/unit/docker/start.sh b/tests/unit/docker/start.sh index bd62ba6..27cc29f 100755 --- a/tests/unit/docker/start.sh +++ b/tests/unit/docker/start.sh @@ -1,11 +1,21 @@ #!/bin/bash -# Runs test image and monitor image as daemons +# Before running this script, run: make unit_tests [COMPILE_FLAGS] to build the necessary docker images + +# Runs test sdk and monitor containers based on the images built by the makefile test_name="docker_demo" echo 'Starting containers for: ' "$test_name" touch "$test_name".name -test_container=$(docker run -d -it -v $PWD/_results:/opt/results --privileged --device=/dev/net/tun "$test_name":latest) -monitor_container=$(docker run -d -it -v $PWD/_results:/opt/results --privileged --device=/dev/net/tun "$test_name"_monitor:latest) +test_container=$(docker run -d -it -v $PWD/tests/results:/opt/results --privileged --device=/dev/net/tun "$test_name":latest) +monitor_container=$(docker run -d -it -v $PWD/tests/results:/opt/results --privileged --device=/dev/net/tun "$test_name"_monitor:latest) sleep 90 -./check.sh _results/OK.docker_demo.txt + +# By this stage, enough time should have passed for all of the unit tests to conclude +RESULTS_DIR=tests/results + +./check.sh $RESULTS_DIR/OK.docker_demo.txt +echo $(cat $RESULTS_DIR/OK.docker_demo.txt) + +rm -rf *.tmp +rm -rf *.txt \ No newline at end of file