Files
astronomy/generate/unit_test_c
2024-07-06 15:30:30 -04:00

34 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
Fail()
{
echo "ERROR($0): $1"
exit 1
}
[[ "$1" == "" || "$1" == "-v" ]] || Fail "Invalid command line options."
[[ -z "${CPP}" ]] && CPP=g++
CPPCHECK_OPTIONS="-I ../source/c --enable=all --inline-suppr --suppress=unmatchedSuppression --suppress=variableScope --suppress=shadowFunction --suppress=unusedFunction --suppress=missingIncludeSystem --suppress=constParameterCallback --error-exitcode=9"
if [[ "${OS_NAME}" == "macOS" ]]; then
CPPCHECK_OPTIONS+=" --check-level=exhaustive"
fi
cppcheck ${CPPCHECK_OPTIONS} ../source/c ../demo/c/*.c ctest.c || exit 1
# Verify that the source can be built as modern C++.
${CPP} -x c++ -std=c++17 -c -Wall -Werror -O3 ../source/c/astronomy.c || Fail "Cannot compile as C++"
rm -f astronomy.o
./ctbuild || exit 1
time ./ctest $1 check || Fail "Failure in ctest check"
./generate check temp/c_check.txt || Fail "Verification failure for C unit test output."
rm -f temp/c_geoid.txt
./ctest $1 all || Fail "Failure in C unit tests"
diff temp/c_geoid.txt topostate/geoid.txt || Fail "Unexpected geoid output."
for file in temp/c_longitude_*.txt; do
./generate $1 check ${file} || Fail "Failed verification of file ${file}"
done
echo "unit_test_c: success"
exit 0