summaryrefslogtreecommitdiff
path: root/tools/patman/test.py
diff options
context:
space:
mode:
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 f801cedc7b..8cd26471c3 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)