1 AT_BANNER([checkpatch])
3 OVS_START_SHELL_HELPERS
4 # try_checkpatch PATCH [ERRORS]
6 # Runs checkpatch under Python 2 and Python 3, if installed, on the given
7 # PATCH, expecting the specified set of ERRORS (and warnings).
9 AT_SKIP_IF([test $HAVE_PYTHON2 = no && test $HAVE_PYTHON3 = no])
10 # Take the patch to test from $1. Remove an initial four-space indent
11 # from it and, if it is just headers with no body, add a null body.
12 echo "$1" | sed 's/^ //' > test.patch
13 if grep '---' expout >/dev/null 2>&1; then :
15 printf '\n---\n' >> test.patch
18 # Take expected output from $2.
20 echo "$2" | sed 's/^ //' > expout
25 try_checkpatch__ "$HAVE_PYTHON2" "$PYTHON2"
26 try_checkpatch__ "$HAVE_PYTHON3" "$PYTHON3"
31 elif test -s expout; then
32 AT_CHECK([$2 $top_srcdir/utilities/checkpatch.py -q test.patch],
34 AT_CHECK([sed '/^Lines checked:/,$d' stdout], [0], [expout])
36 AT_CHECK([$2 $top_srcdir/utilities/checkpatch.py -q test.patch])
41 AT_SETUP([checkpatch - sign-offs])
43 # Sign-off for single author who is also the committer.
52 "ERROR: Author A needs to sign off."
54 # Single author but somehow the mailing list is the author.
56 "Author: Foo Bar via dev <ovs-dev@openvswitch.org>
60 "ERROR: Author should not be mailing list."
62 # Sign-off for single author and different committer.
72 "ERROR: Author A needs to sign off.
73 ERROR: Committer B needs to sign off."
75 # Sign-off for multiple authors with one author also the committer.
89 "ERROR: Author A needs to sign off."
96 "ERROR: Co-author B needs to sign off."
102 "ERROR: Author A needs to sign off.
103 ERROR: Co-author B needs to sign off."
105 # Sign-off for multiple authors and separate committer.
121 "ERROR: Committer C needs to sign off."
125 # - If we know the committer, one extra sign-off raises a warning.
127 # - If we do not know the committer, two extra sign-offs raise a warning.
137 "WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: D"
153 "WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: C, D"
155 # Missing committer is OK, missing author is an error.
164 "ERROR: Patch lacks author."
169 m4_define([COMMON_PATCH_HEADER], [dnl
174 diff --git a/A.c b/A.c
175 index 0000000..1111111 100644
181 AT_SETUP([checkpatch - parenthesized constructs])
182 for ctr in 'if' 'while' 'switch' 'HMAP_FOR_EACH' 'BITMAP_FOR_EACH_1'; do
190 + $ctr ( first_run) {
192 "ERROR: Improper whitespace around control block
199 + $ctr (first_run ) {
201 "ERROR: Inappropriate bracing around statement
210 "ERROR: Inappropriate bracing around statement
219 "ERROR: Improper whitespace around control block
226 + $ctr (first_run) { /* foo */
231 + $ctr (first_run) { \\
242 AT_SETUP([checkpatch - parenthesized constructs - for])
245 + for (init; condition; increment) {
250 + for ( init; condition; increment) {
252 "ERROR: Improper whitespace around control block
254 for ( init; condition; increment) {
259 + for (init; condition; increment ) {
261 "ERROR: Inappropriate bracing around statement
263 for (init; condition; increment ) {
268 + for (init; condition; increment)
270 "ERROR: Inappropriate bracing around statement
272 for (init; condition; increment)
277 + for(init; condition; increment)
279 "ERROR: Improper whitespace around control block
281 for(init; condition; increment)
286 + for (init; condition; increment) { /* foo */
291 + for (init; condition; increment) { \\
297 AT_SETUP([checkpatch - comments])
300 + a = 1; /* C style comment. */
305 + /* http://URL/inside/the/comment.html */
310 + a = 1; // C99 style comment.
312 "ERROR: C99 style comment
314 a = 1; // C99 style comment.
319 AT_SETUP([checkpatch - whitespace around operator])
322 + if (--mcs->n_refs == 0) {
327 + if (--mcs->n_refs==0) {
329 "WARNING: Line lacks whitespace around operator
330 WARNING: Line lacks whitespace around operator
332 if (--mcs->n_refs==0) {