From 21ac717d6d438ad7212a67ce1f976954722df22c Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Fri, 3 Jun 2016 17:26:47 -0400 Subject: [PATCH] Configtool: add integrity tests for Configtool output. Add a test that puts the stock config files through the Configtool input/output parsers and verifies the output matches the input. If Configtool breaks down in the future and produces different output, this should catch it. If this fails because of some intentional change in the tool or in the stock config files, then the tool or stock config files should be updated to be compatible again before merging the result. --- Makefile-common | 2 ++ testcases/check_configtool.sh | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 testcases/check_configtool.sh diff --git a/Makefile-common b/Makefile-common index 11f4d8b..bb9b6a0 100644 --- a/Makefile-common +++ b/Makefile-common @@ -150,6 +150,8 @@ regressiontests: EXTRA_CFLAGS=-Werror all # Check config files for integrity. testcases/check_integrity.sh + # Check configtool's view of the config files. + testcases/check_configtool.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/ diff --git a/testcases/check_configtool.sh b/testcases/check_configtool.sh new file mode 100755 index 0000000..0f75dbd --- /dev/null +++ b/testcases/check_configtool.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Check that the output from configtool.py matches the input when no changes +# are made in the GUI. This requires that the distributed config files match +# the format of the configtool template files, but this is desired anyway. + +# Stop on error +set -e + +# Create an output directory for verification +OUTDIR=build/test +rm -rf ${OUTDIR} +mkdir -p ${OUTDIR} + +EXITCODE=0 + +# Check board and printer configurations. +for IN in $(git ls-files config/*.h); do + + # Use configtool.py to regenerate headers for comparison + OUT=${OUTDIR}/$(basename ${IN}) + ./configtool.py --load=${IN} --save=${OUT} --quit + + # Strip the "help text" comments from the source and output files + perl -p0i -e 's#/\*.*?\*/##sg' ${OUT} + perl -p0 -e 's#/\*.*?\*/##sg' ${IN} > ${OUT}.cmp + + # Fail if the result is different except in whitespace + if ! diff -qBbw ${OUT} ${OUT}.cmp ; then + echo "Configtool integrity test failed on file ${IN}" + echo " Executed: ./configtool.py --load=${IN} --save=${OUT} --quit" + echo " Expected resulting settings to match, but they do not." + + diff -Bbw ${OUT} ${OUT}.cmp |sed -e 's/^/ /' || : + EXITCODE=1 + fi +done +exit ${EXITCODE}