Add test for config files integrity.

It happens all to often that a #define is added or removed here
or there, but some related files gets forgotten. Now at least
existence of all the #defines is cross-checked.
This commit is contained in:
Markus Hitter 2016-03-28 01:29:38 +02:00
parent 4c205704ad
commit f0604b5e9d
2 changed files with 77 additions and 0 deletions

View File

@ -141,6 +141,8 @@ regressiontests:
# Don't forget the hostside simulator.
$(MAKE) -f Makefile-SIM USER_CONFIG=testcases/config.regtest-gen7-avr.h \
EXTRA_CFLAGS=-Werror all
# Check config files for integrity.
config/check_integrity.sh
@# Nonstandard builds go into a subdirectory of build/, see definition of
@# $(BUILDDIR) above. Let's clean that up on success.
rm -rf $(BUILDDIR)/testcases/ $(BUILDDIR)/sim/

75
config/check_integrity.sh Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
# Check all our config files for integrity. We often had the case that a
# configuration #define was added, which is entirely fine, but it was forgotten
# to distribute this over all the relevant files.
#
# Maybe it's not too exciting form the single-source-of-information-POV, but
# Teacup maintains configuration items redundant in all the configuration
# files. Point of doing so is to support manual config file editing as well as
# using Configtool.
# Make sure we're inside config/
cd config 2> /dev/null
if [ $(basename ${PWD}) != "config" ]; then
echo "Execute this from within config/."
exit 1
fi
# We can't abort out of subshells, so track our success with a temporary file.
EXITFILE=$(mktemp)
trap "rm -f ${EXITFILE}" 0
echo 0 > ${EXITFILE}
# Check both, board and printer configurations.
for T in "board" "printer"; do
# Test #1: are all #defines in the generic config in all the individual
# files?
awk -c '
/^#define/ {
print $2;
}
/^\/\/#define/ {
print $2;
}
' < ../configtool/${T}.generic.h | while read W; do
for F in ${T}.*.h ../testcases/config.h.Profiling; do
if ! grep "#define" ${F} | grep -q ${W}; then
echo "Missing #define ${W} in ${F}."
echo 1 > ${EXITFILE}
fi
done
done
# Test #2: the opposite, has the generic config all of the latest three
# individual configs?
for F in $(ls -t ${T}.*.h | head -3); do
awk -c '
/^\/\/DEFINE_HEATERS_START/, /^\/\/DEFINE_HEATERS_END/ {
# This section is created on the fly, so not in the generic file.
next;
}
/^#define/ {
print $2;
}
/^\/\/#define/ {
print $2;
}
' < ${F} | while read W; do
if ! grep "#define" ../configtool/${T}.generic.h | grep -q ${W}; then
echo "Missing #define ${W} in configtool/${T}.generic.h."
echo 1 > ${EXITFILE}
fi
done
done
done
EXIT=$(cat ${EXITFILE})
if [ ${EXIT} -ne 0 ]; then
echo "Config integrity tests failed."
else
echo "Config integrity tests succeeded."
fi
exit ${EXIT}