blob: 24c75c98980da7b380d13e7d1a24f41fb47bf498 [file] [log] [blame]
Martin Rothd12e4f52022-06-05 11:59:11 -06001#!/usr/bin/env sh
2
3rootdir=${PWD}
Martin Rothef5a2382016-03-30 14:51:31 -06004
5# test to make sure the lint tests fail
6SPACE=' '
7UNDERSCORE='_'
8
Martin Rothd12e4f52022-06-05 11:59:11 -06009# lint-stable-000-license-headers
10TESTFILE000a="${rootdir}/src/arch/x86/thread.c"
11TESTFILE000b="${rootdir}/src/arch/riscv/misc.c"
12TESTFILE000c="${rootdir}/src/lib/hardwaremain.c"
Martin Rothef5a2382016-03-30 14:51:31 -060013
Martin Rothd12e4f52022-06-05 11:59:11 -060014# lint-stable-003-whitespace
15TESTFILE003="${rootdir}/src/acpi/sata.c"
16# lint-stable-004-style-labels
17TESTFILE004="${rootdir}/src/soc/nvidia/tegra124/spi.c"
18# lint-stable-005-board-status
19TESTFILE005a="${rootdir}/src/mainboard/google/storm/board_info.txt"
20# lint-stable-006-board-name
21TESTFILE006="${rootdir}/src/mainboard/ibase/mb899/Kconfig.name"
22# lint-stable-008-kconfig
23TESTFILE008="${rootdir}/src/lib/Kconfig"
24# lint-stable-009-old-licenses
25TESTFILE009="${rootdir}/src/superio/common/conf_mode.c"
26# lint-stable-010-asm-syntax
27TESTFILE010="${rootdir}/src/arch/x86/assembly_entry.S"
28# lint-stable-012-executable-bit
29TESTFILE012="${rootdir}/src/lib/libgcc.c"
30# lint-stable-013-site-local
31TESTFILE013="$(mktemp --tmpdir=site-local)"
32# lint-stable-016-non-ascii
33TESTFILE016="${rootdir}/src/lib/halt.c"
34# lint-stable-017-configs
35TESTFILE017="${rootdir}/configs/testconfig"
36# lint-stable-018-symlinks
37TESTFILE018="${rootdir}/src/testKconfig"
38# lint-stable-019-header-files
39TESTFILE019=${rootdir}/test
40# lint-stable-021-coreboot-lowercase
41TESTFILE021=${rootdir}/test
42# lint-stable-022-clang-format
43TESTFILE022=${rootdir}/test
44# lint-stable-023-filenames
45TESTFILE023=${rootdir}/test
46# lint-stable-024-kconfig-no-subsystem
47TESTFILE024=${rootdir}/test
48# lint-stable-026-line-endings
49TESTFILE026=${rootdir}/test
50# lint-stable-027-maintainers-syntax
51TESTFILE027="${rootdir}/MAINTAINERS"
Martin Rothef5a2382016-03-30 14:51:31 -060052
Martin Rothd12e4f52022-06-05 11:59:11 -060053if [ "$1" = "--reset" ]; then
54 echo "Resetting testfiles"
55 echo "lint-stable-000-license-headers"
56 git checkout "${TESTFILE000a}" "${TESTFILE000b}" "${TESTFILE000c}"
57 echo "lint-stable-003-whitespace"
58 git checkout "${TESTFILE003}"
59 echo "lint-stable-004-style-labels"
60 git checkout "${TESTFILE004}"
61 echo "lint-stable-005-board-status"
62 git checkout "${TESTFILE005a}"
63 echo "lint-stable-006-board-name"
64 git checkout "${TESTFILE006}"
65 echo "lint-stable-008-kconfig"
66 git checkout "${TESTFILE008}"
67 echo "lint-stable-009-old-licenses"
68 git checkout "${TESTFILE009}"
69 echo "lint-stable-010-asm-syntax"
70 git checkout "${TESTFILE010}"
71 echo "lint-stable-012-executable-bit"
72 git checkout "${TESTFILE012}"
73 echo "lint-stable-013-site-local"
74 git reset "${TESTFILE013}"; rm -vf "${TESTFILE013}"
75 echo "lint-stable-016-non-ascii"
76 git checkout "${TESTFILE016}"
77 echo "lint-stable-017-configs"
78 rm -vf "${TESTFILE017}"
79 echo "lint-stable-018-symlinks"
80 rm -vf "${TESTFILE018}"
81 echo "lint-stable-019-header-files"
82 git checkout "${TESTFILE019}"
83 echo "lint-stable-021-coreboot-lowercase"
84 git checkout "${TESTFILE021}"
85 echo "lint-stable-022-clang-format"
86 git checkout "${TESTFILE022}"
87 echo "lint-stable-023-filenames"
88 git checkout "${TESTFILE023}"
89 echo "lint-stable-024-kconfig-no-subsystem"
90 git checkout "${TESTFILE024}"
91 echo "lint-stable-026-line-endings"
92 git checkout "${TESTFILE026}"
Martin Rothef5a2382016-03-30 14:51:31 -060093
Martin Rothd12e4f52022-06-05 11:59:11 -060094 echo "lint-stable-027-maintainers-syntax"
95 git checkout "${TESTFILE027}"
Martin Rothef5a2382016-03-30 14:51:31 -060096
Martin Rothef5a2382016-03-30 14:51:31 -060097
Martin Rothd12e4f52022-06-05 11:59:11 -060098else
99 echo "Modifying files for linter testing"
Martin Rothef5a2382016-03-30 14:51:31 -0600100
Martin Rothd12e4f52022-06-05 11:59:11 -0600101 echo "lint-stable-000-license-headers"
102 sed -i.bak 's|^/\*.*||' "${TESTFILE000a}"
103 #sed -i.bak 's|^.*]SPDX-License-Identifier.*||' "${TESTFILE000b}"
104 #sed -i.bak 's|^.*]GPL-2.0-only|GPL-2.0|' "${TESTFILE000c}"
Martin Rothef5a2382016-03-30 14:51:31 -0600105
Martin Rothd12e4f52022-06-05 11:59:11 -0600106 echo "lint-stable-003-whitespace"
107 sed -i.bak 's/^$/ /' "${TESTFILE003}"
Martin Rothef5a2382016-03-30 14:51:31 -0600108
Martin Rothd12e4f52022-06-05 11:59:11 -0600109 echo "lint-stable-004-style-labels"
110 sed -i.bak 's/^done:/ done:/' "${TESTFILE004}"
Martin Rothef5a2382016-03-30 14:51:31 -0600111
Martin Rothd12e4f52022-06-05 11:59:11 -0600112 echo "lint-stable-005-board-status"
113 sed -i.bak 's/^Category:.*/Category: lint/' "${TESTFILE005a}"
114
115 echo "lint-stable-006-board-name"
116 rm -f "${TESTFILE006}"
117
118 echo "lint-stable-008-kconfig"
119 sed -i.bak 's|config MISSING_BOARD_RESET|config MISSINGBOARDRESET|' "${TESTFILE008}"
120
121 echo "lint-stable-009-old-licenses"
122 sed -i "s|^.*]SPDX-License-Identifier.*|\* for more details.\n \* You${SPACE}should${SPACE}have received a copy of the GNU General Public License\n \* along with this program; if not, write to the Free Software\n \* Foundation, Inc.|" "${TESTFILE009}"
123 git add "${TESTFILE009}"
124
125 echo "lint-stable-010-asm-syntax"
126 sed -i "1s/^/.att${UNDERSCORE}syntax noprefix\n/" "${TESTFILE010}"
127 git add "${TESTFILE010}"
128
129 echo "lint-stable-012-executable-bit"
130 chmod +x "${TESTFILE012}"
131
132 echo "lint-stable-013-site-local"
133 mkdir -p site-local
134 git add -f "${TESTFILE013}"
135
136 echo "lint-stable-016-non-ascii"
137 sed -i.bak 's|halt(|halt'"$(echo "\007")"'(|' "${TESTFILE016}"
138
139 echo "lint-stable-017-configs"
140 make olddefconfig
141 cp .config "${TESTFILE017}"
142
143 echo "lint-stable-018-symlinks"
144 rm -f "${TESTFILE018}"
145 ln -s src/Kconfig "${TESTFILE018}"
146 git add -f "${TESTFILE018}"
147
148 # lint-stable-019-header-files
149 # lint-stable-021-coreboot-lowercase
150 # lint-stable-022-clang-format
151 # lint-stable-023-filenames
152 # lint-stable-024-kconfig-no-subsystem
153 # lint-stable-026-line-endings
154 echo "lint-stable-027-maintainers-syntax"
155 sed -i.bak 's|src/cpu/x86/$|src/cpu/x86|' "${TESTFILE027}"
156
157fi