3 # SPDX-License-Identifier: GPL-2.0-only
5 # DESCR: Check for auto-included headers
8 cd -- "$
(dirname "$0")" > /dev/null 2>&1 || return
12 # shellcheck source=helper_functions.sh
13 .
"${LINTDIR}/helper_functions.sh"
16 EXCLUDED_FILES
='src/include/kconfig.h'
18 HEADER_FILES
="k\?config rules compiler"
20 TESTFILE1
="src/lib/version.c"
21 TESTFILE2
="src/lib/string.c"
22 TESTFILE3
="src/lib/malloc.c"
23 TESTFILE4
="src/lib/hardwaremain.c"
26 # Configure to make sure tests fail
27 if [ "$1" = "--test" ]; then
28 sed -i.bak
"s|^.*SPDX-License-Identifier.*|&\n\n#include <config.h>\n|" "${TESTFILE1}"
29 sed -i.bak
"s|^.*SPDX-License-Identifier.*|&\n\n#include \"kconfig.h\"\n|" "${TESTFILE2}"
30 sed -i.bak
"s|^.*SPDX-License-Identifier.*|&\n\n#include \"compiler.h\"\n|" "${TESTFILE3}"
31 sed -i.bak
"s|^.*SPDX-License-Identifier.*|&\n\n#include <rules.h>\n|" "${TESTFILE4}"
32 echo "Expect ${EXPECTED_FAILURES} failures."
34 elif [ "$1" = "--reset" ]; then
35 mv "${TESTFILE1}.bak" "${TESTFILE1}"
36 mv "${TESTFILE2}.bak" "${TESTFILE2}"
37 mv "${TESTFILE3}.bak" "${TESTFILE3}"
38 mv "${TESTFILE4}.bak" "${TESTFILE4}"
42 for header
in $HEADER_FILES; do
43 ${GREP_FILES} -n "#[[:blank:]]*include[[:blank:]]\+[\"<][[:blank:]]*${header}\.h[[:blank:]]*[\">]" | \
44 grep "$INCLUDED_DIRS" | \
45 grep -v "$EXCLUDED_FILES"; \