From: Thomas Haller Date: Mon, 23 Oct 2023 16:13:16 +0000 (+0200) Subject: tools: reject unexpected files in "tests/shell/testcases/" with "check-tree.sh" X-Git-Tag: v1.1.0~264 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c047776f4fd75fcc78feaca558d0db80355b6725;p=thirdparty%2Fnftables.git tools: reject unexpected files in "tests/shell/testcases/" with "check-tree.sh" "check-tree.sh" does consistency checks on the source tree. Extend the check to flag more unexpected files. We don't want to accidentally have left over files. Signed-off-by: Thomas Haller Signed-off-by: Pablo Neira Ayuso --- diff --git a/tools/check-tree.sh b/tools/check-tree.sh index ede3e699..c3aaa08d 100755 --- a/tools/check-tree.sh +++ b/tools/check-tree.sh @@ -2,6 +2,10 @@ # Preform various consistency checks of the source tree. +unset LANGUAGE +export LANG=C +export LC_ALL=C + die() { printf '%s\n' "$*" exit 1 @@ -56,7 +60,7 @@ check_shell_dumps() { fi } -SHELL_TESTS=( $(find "tests/shell/testcases/" -type f -executable | LANG=C sort) ) +SHELL_TESTS=( $(find "tests/shell/testcases/" -type f -executable | sort) ) if [ "${#SHELL_TESTS[@]}" -eq 0 ] ; then echo "No executable tests under \"tests/shell/testcases/\" found" @@ -74,9 +78,20 @@ if [ "${SHELL_TESTS[*]}" != "${SHELL_TESTS2[*]}" ] ; then EXIT_CODE=1 fi +############################################################################## +# +F=( $(find tests/shell/testcases/ -type f | grep '^tests/shell/testcases/[^/]\+/dumps/[^/]\+\.\(nft\|nodump\)$' -v | sort) ) +IGNORED_FILES=( tests/shell/testcases/bogons/nft-f/* ) +for f in "${F[@]}" ; do + if ! array_contains "$f" "${SHELL_TESTS[@]}" "${IGNORED_FILES[@]}" ; then + echo "Unexpected file \"$f\"" + EXIT_CODE=1 + fi +done + ############################################################################## -FILES=( $(find "tests/shell/testcases/" -type f | sed -n 's#\(tests/shell/testcases\(/.*\)\?/\)dumps/\(.*\)\.\(nft\|nodump\)$#\0#p' | LANG=C sort) ) +FILES=( $(find "tests/shell/testcases/" -type f | sed -n 's#\(tests/shell/testcases\(/.*\)\?/\)dumps/\(.*\)\.\(nft\|nodump\)$#\0#p' | sort) ) for f in "${FILES[@]}" ; do f2="$(echo "$f" | sed -n 's#\(tests/shell/testcases\(/.*\)\?/\)dumps/\(.*\)\.\(nft\|nodump\)$#\1\3#p')"