]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tools: reject unexpected files in "tests/shell/testcases/" with "check-tree.sh"
authorThomas Haller <thaller@redhat.com>
Mon, 23 Oct 2023 16:13:16 +0000 (18:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Oct 2023 09:31:02 +0000 (11:31 +0200)
"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 <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tools/check-tree.sh

index ede3e6998ecc5f663da762d4233c3cd49d43c031..c3aaa08d05ceb88b8f28290cdbd2ddb2063b1941 100755 (executable)
@@ -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')"