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'; 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) { \\
237 AT_SETUP([checkpatch - parenthesized constructs - for])
240 + for (init; condition; increment) {
245 + for ( init; condition; increment) {
247 "ERROR: Improper whitespace around control block
249 for ( init; condition; increment) {
254 + for (init; condition; increment ) {
256 "ERROR: Inappropriate bracing around statement
258 for (init; condition; increment ) {
263 + for (init; condition; increment)
265 "ERROR: Inappropriate bracing around statement
267 for (init; condition; increment)
272 + for(init; condition; increment)
274 "ERROR: Improper whitespace around control block
276 for(init; condition; increment)
281 + for (init; condition; increment) { /* foo */
286 + for (init; condition; increment) { \\