From 9427fa3c666f2435fe0c0a016747bdf1567a36d0 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Sat, 3 Dec 2022 15:41:11 +0100 Subject: [PATCH] Refactor runtests to allow to specify files on command line (#4609) --- test/cfg/runtests.sh | 48 ++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 6923e9da8..8da6f5d58 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -406,9 +406,8 @@ function cppunit_fn { fi } -for f in "${DIR}"*.{c,cpp} -do - f=$(basename $f) +function check_file { + f=$(basename $1) case $f in boost.cpp) boost_fn @@ -506,22 +505,41 @@ do echo "Unhandled file $f" exit_if_strict esac +} + +function check_files +{ +for f in "$@" +do + check_file $f done +} # Check the syntax of the defines in the configuration files -if ! xmlstarlet --version; then - echo "xmlstarlet needed to extract defines, skipping defines check." - exit_if_strict +function check_defines_syntax +{ + if ! xmlstarlet --version; then + echo "xmlstarlet needed to extract defines, skipping defines check." + exit_if_strict + else + for configfile in ${CFG}*.cfg; do + echo "Checking defines in $configfile" + # Disable debugging output temporarily since there could be many defines + set +x + # XMLStarlet returns 1 if no elements were found which is no problem here + EXTRACTED_DEFINES=$(xmlstarlet sel -t -m '//define' -c . -n <$configfile || true) + EXTRACTED_DEFINES=$(echo "$EXTRACTED_DEFINES" | sed 's///g') + echo "$EXTRACTED_DEFINES" | gcc -fsyntax-only -xc -Werror - + done + fi +} + +if [ $# -eq 0 ] +then + check_files "${DIR}"*.{c,cpp} + check_defines_syntax else - for configfile in ${CFG}*.cfg; do - echo "Checking defines in $configfile" - # Disable debugging output temporarily since there could be many defines - set +x - # XMLStarlet returns 1 if no elements were found which is no problem here - EXTRACTED_DEFINES=$(xmlstarlet sel -t -m '//define' -c . -n <$configfile || true) - EXTRACTED_DEFINES=$(echo "$EXTRACTED_DEFINES" | sed 's///g') - echo "$EXTRACTED_DEFINES" | gcc -fsyntax-only -xc -Werror - - done + check_files "$@" fi echo SUCCESS