Add cryptest.sh tests for includio of <assert.h> and <cassert>; and use of NDEBUG or assert\(...\)

pull/286/head
Jeffrey Walton 2016-09-17 14:38:52 -04:00
parent 3815b908ab
commit c207012123
1 changed files with 35 additions and 1 deletions

View File

@ -109,7 +109,7 @@ if [[ "$IS_SOLARIS" -ne "0" ]]; then
IS_X86=0
fi
# Need something more powerful than the non-Posix versions
# Need something more powerful than the Posix versions
if [[ (-e "/usr/gnu/bin/grep") ]]; then
GREP=/usr/gnu/bin/grep;
fi
@ -1116,6 +1116,40 @@ TEST_BEGIN=$(date)
echo | tee -a "$TEST_RESULTS"
echo "Start time: $TEST_BEGIN" | tee -a "$TEST_RESULTS"
############################################
# Posix assert
if true; then
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: No Posix assert" | tee -a "$TEST_RESULTS"
echo
FAILED=0
COUNT=$(cat *.h *.cpp | "$GREP" -v '//' | "$GREP" -c '(assert.h|cassert)')
if [[ "$COUNT" -ne "0" ]]; then
FAILED=1
echo "Found Posix assert headers" | tee -a "$TEST_RESULTS"
fi
COUNT=$(cat *.h *.cpp | "$GREP" -v '//' | "$GREP" -c 'assert[[:space:]]*\\(')
if [[ "$COUNT" -ne "0" ]]; then
FAILED=1
echo "Found use of Posix assert" | tee -a "$TEST_RESULTS"
fi
# Filter out use of C++ and Doxygen comments.
COUNT=$(cat *.h *.cpp | "$GREP" -v '//' | "$GREP" -c 'NDEBUG')
if [[ "$COUNT" -ne "0" ]]; then
FAILED=1
echo "Found use of Posix NDEBUG" | tee -a "$TEST_RESULTS"
fi
if [[ ("$FAILED" -eq "0") ]]; then
echo "Verified no Posix NDEBUG or assert" | tee -a "$TEST_RESULTS"
fi
fi
############################################
# X86 code generation tests
if [[ ("$HAVE_DISASS" -ne "0" && ("$IS_X86" -ne "0" || "$IS_X64" -ne "0")) ]]; then