1 AT_BANNER([checkpatch])
3 OVS_START_SHELL_HELPERS
4 # try_checkpatch PATCH [ERRORS]
6 # Runs checkpatch, if installed, on the given PATCH, expecting the
7 # specified set of ERRORS (and warnings).
9 # Take the patch to test from $1. Remove an initial four-space indent
10 # from it and, if it is just headers with no body, add a null body.
11 echo "$1" | sed 's/^ //' > test.patch
12 if grep '---' expout >/dev/null 2>&1; then :
14 printf '\n---\n' >> test.patch
17 # Take expected output from $2.
19 echo "$2" | sed 's/^ //' > expout
24 if test -s expout; then
25 AT_CHECK([$PYTHON3 $top_srcdir/utilities/checkpatch.py -q test.patch],
27 AT_CHECK([sed '/^Lines checked:/,$d' stdout], [0], [expout])
29 AT_CHECK([$PYTHON3 $top_srcdir/utilities/checkpatch.py -q test.patch])
34 AT_SETUP([checkpatch - sign-offs])
36 # Sign-off for single author who is also the committer.
45 "ERROR: Author A needs to sign off."
47 # Single author but somehow the mailing list is the author.
49 "Author: Foo Bar via dev <ovs-dev@openvswitch.org>
53 "ERROR: Author should not be mailing list."
55 # Sign-off for single author and different committer.
65 "ERROR: Author A needs to sign off.
66 ERROR: Committer B needs to sign off."
68 # Sign-off for multiple authors with one author also the committer.
82 "ERROR: Author A needs to sign off."
89 "ERROR: Co-author B needs to sign off."
95 "ERROR: Author A needs to sign off.
96 ERROR: Co-author B needs to sign off."
98 # Sign-off for multiple authors and separate committer.
114 "ERROR: Committer C needs to sign off."
118 # - If we know the committer, one extra sign-off raises a warning.
120 # - If we do not know the committer, two extra sign-offs raise a warning.
130 "WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: D"
146 "WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: C, D"
148 # Missing committer is OK, missing author is an error.
157 "ERROR: Patch lacks author."
162 m4_define([COMMON_PATCH_HEADER], [dnl
167 diff --git a/A.c b/A.c
168 index 0000000..1111111 100644
174 AT_SETUP([checkpatch - parenthesized constructs])
175 for ctr in 'if' 'while' 'switch' 'HMAP_FOR_EACH' 'BITMAP_FOR_EACH_1'; do
183 + $ctr ( first_run) {
185 "ERROR: Improper whitespace around control block
192 + $ctr (first_run ) {
194 "ERROR: Inappropriate bracing around statement
203 "ERROR: Inappropriate bracing around statement
212 "ERROR: Improper whitespace around control block
219 + $ctr (first_run) { /* foo */
224 + $ctr (first_run) { \\
235 AT_SETUP([checkpatch - parenthesized constructs - for])
238 + for (init; condition; increment) {
243 + for ( init; condition; increment) {
245 "ERROR: Improper whitespace around control block
247 for ( init; condition; increment) {
252 + for (init; condition; increment ) {
254 "ERROR: Inappropriate bracing around statement
256 for (init; condition; increment ) {
261 + for (init; condition; increment)
263 "ERROR: Inappropriate bracing around statement
265 for (init; condition; increment)
270 + for(init; condition; increment)
272 "ERROR: Improper whitespace around control block
274 for(init; condition; increment)
279 + for (init; condition; increment) { /* foo */
284 + for (init; condition; increment) { \\
290 AT_SETUP([checkpatch - comments])
293 + a = 1; /* C style comment. */
298 + /* http://URL/inside/the/comment.html */
303 + a = 1; // C99 style comment.
305 "ERROR: C99 style comment
307 a = 1; // C99 style comment.
312 AT_SETUP([checkpatch - whitespace around operator])
315 + if (--mcs->n_refs == 0) {
320 + if (--mcs->n_refs==0) {
322 "WARNING: Line lacks whitespace around operator
323 WARNING: Line lacks whitespace around operator
325 if (--mcs->n_refs==0) {