summaryrefslogtreecommitdiff
path: root/tools/patman/test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-03-26 13:09:39 +0000
committerSimon Glass <sjg@chromium.org>2013-04-04 14:04:34 -0700
commitd29fe6e2d2cbcbfd1bfaaf886818d84edde0fc0d (patch)
tree55ea7b71a2d2044769cc1e473bd6594d16f7722c /tools/patman/test.py
parentfe2f8d9e2f1bc00f143a22191a1d7076667ff436 (diff)
downloadu-boot-imx-d29fe6e2d2cbcbfd1bfaaf886818d84edde0fc0d.zip
u-boot-imx-d29fe6e2d2cbcbfd1bfaaf886818d84edde0fc0d.tar.gz
u-boot-imx-d29fe6e2d2cbcbfd1bfaaf886818d84edde0fc0d.tar.bz2
patman: Fix up checkpatch parsing to deal with 'CHECK' lines
checkpatch has a new type of warning, a 'CHECK'. At present patman fails with these, which makes it less than useful. Add support for checks, making it backwards compatible with the old checkpatch. At the same time, clean up formatting of the CheckPatches() output, fix erroneous "internal error" if multiple patches have warnings and be more robust to new types of problems. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Doug Anderson <dianders@chromium.org>
Diffstat (limited to 'tools/patman/test.py')
-rw-r--r--tools/patman/test.py64
1 files changed, 44 insertions, 20 deletions
diff --git a/tools/patman/test.py b/tools/patman/test.py
index f801ced..8cd2647 100644
--- a/tools/patman/test.py
+++ b/tools/patman/test.py
@@ -190,6 +190,11 @@ index 0000000..2234c87
+ rec->time_us = (uint32_t)timer_get_us();
+ rec->name = name;
+ }
++ if (!rec->name &&
++ %ssomething_else) {
++ rec->time_us = (uint32_t)timer_get_us();
++ rec->name = name;
++ }
+%sreturn rec->time_us;
+}
--
@@ -197,15 +202,18 @@ index 0000000..2234c87
'''
signoff = 'Signed-off-by: Simon Glass <sjg@chromium.org>\n'
tab = ' '
+ indent = ' '
if data_type == 'good':
pass
elif data_type == 'no-signoff':
signoff = ''
elif data_type == 'spaces':
tab = ' '
+ elif data_type == 'indent':
+ indent = tab
else:
print 'not implemented'
- return data % (signoff, tab, tab)
+ return data % (signoff, tab, indent, tab)
def SetupData(self, data_type):
inhandle, inname = tempfile.mkstemp()
@@ -215,33 +223,49 @@ index 0000000..2234c87
infd.close()
return inname
- def testCheckpatch(self):
+ def testGood(self):
"""Test checkpatch operation"""
inf = self.SetupData('good')
- result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf)
- self.assertEqual(result, True)
- self.assertEqual(problems, [])
- self.assertEqual(err, 0)
- self.assertEqual(warn, 0)
- self.assertEqual(lines, 67)
+ result = checkpatch.CheckPatch(inf)
+ self.assertEqual(result.ok, True)
+ self.assertEqual(result.problems, [])
+ self.assertEqual(result.errors, 0)
+ self.assertEqual(result.warnings, 0)
+ self.assertEqual(result.checks, 0)
+ self.assertEqual(result.lines, 67)
os.remove(inf)
+ def testNoSignoff(self):
inf = self.SetupData('no-signoff')
- result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf)
- self.assertEqual(result, False)
- self.assertEqual(len(problems), 1)
- self.assertEqual(err, 1)
- self.assertEqual(warn, 0)
- self.assertEqual(lines, 67)
+ result = checkpatch.CheckPatch(inf)
+ self.assertEqual(result.ok, False)
+ self.assertEqual(len(result.problems), 1)
+ self.assertEqual(result.errors, 1)
+ self.assertEqual(result.warnings, 0)
+ self.assertEqual(result.checks, 0)
+ self.assertEqual(result.lines, 67)
os.remove(inf)
+ def testSpaces(self):
inf = self.SetupData('spaces')
- result, problems, err, warn, lines, stdout = checkpatch.CheckPatch(inf)
- self.assertEqual(result, False)
- self.assertEqual(len(problems), 2)
- self.assertEqual(err, 0)
- self.assertEqual(warn, 2)
- self.assertEqual(lines, 67)
+ result = checkpatch.CheckPatch(inf)
+ self.assertEqual(result.ok, False)
+ self.assertEqual(len(result.problems), 1)
+ self.assertEqual(result.errors, 0)
+ self.assertEqual(result.warnings, 1)
+ self.assertEqual(result.checks, 0)
+ self.assertEqual(result.lines, 67)
+ os.remove(inf)
+
+ def testIndent(self):
+ inf = self.SetupData('indent')
+ result = checkpatch.CheckPatch(inf)
+ self.assertEqual(result.ok, False)
+ self.assertEqual(len(result.problems), 1)
+ self.assertEqual(result.errors, 0)
+ self.assertEqual(result.warnings, 0)
+ self.assertEqual(result.checks, 1)
+ self.assertEqual(result.lines, 67)
os.remove(inf)