Refactor runtests to allow to specify files on command line (#4609)

This commit is contained in:
Rikard Falkeborn 2022-12-03 15:41:11 +01:00 committed by GitHub
parent 0854fda28a
commit 9427fa3c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 15 deletions

View File

@ -406,9 +406,8 @@ function cppunit_fn {
fi fi
} }
for f in "${DIR}"*.{c,cpp} function check_file {
do f=$(basename $1)
f=$(basename $f)
case $f in case $f in
boost.cpp) boost.cpp)
boost_fn boost_fn
@ -506,22 +505,41 @@ do
echo "Unhandled file $f" echo "Unhandled file $f"
exit_if_strict exit_if_strict
esac esac
}
function check_files
{
for f in "$@"
do
check_file $f
done done
}
# Check the syntax of the defines in the configuration files # Check the syntax of the defines in the configuration files
if ! xmlstarlet --version; then function check_defines_syntax
echo "xmlstarlet needed to extract defines, skipping defines check." {
exit_if_strict 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/<define name="/#define /g' | sed 's/" value="/ /g' | 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 else
for configfile in ${CFG}*.cfg; do check_files "$@"
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/<define name="/#define /g' | sed 's/" value="/ /g' | sed 's/"\/>//g')
echo "$EXTRACTED_DEFINES" | gcc -fsyntax-only -xc -Werror -
done
fi fi
echo SUCCESS echo SUCCESS