blob: b39e3f671dc9c6681d2078f5731d802eb4c192e0 [file] [log] [blame]
Simon Glass6e87ae12017-05-29 15:31:31 -06001# -*- coding: utf-8 -*-
Tom Rini83d290c2018-05-06 17:58:06 -04002# SPDX-License-Identifier: GPL-2.0+
Simon Glass6e87ae12017-05-29 15:31:31 -06003#
4# Copyright 2017 Google, Inc
5#
Simon Glass6e87ae12017-05-29 15:31:31 -06006
Simon Glassfca99112020-10-29 21:46:15 -06007"""Functional tests for checking that patman behaves correctly"""
8
Simon Glass6e87ae12017-05-29 15:31:31 -06009import os
10import re
11import shutil
12import sys
13import tempfile
14import unittest
15
Simon Glassfd709862020-07-05 21:41:50 -060016from patman import control
Simon Glassbf776672020-04-17 18:09:04 -060017from patman import gitutil
18from patman import patchstream
Simon Glass47f62952020-10-29 21:46:26 -060019from patman.patchstream import PatchStream
Simon Glassbf776672020-04-17 18:09:04 -060020from patman import settings
Simon Glassfd709862020-07-05 21:41:50 -060021from patman import terminal
Simon Glassbf776672020-04-17 18:09:04 -060022from patman import tools
Simon Glassfd709862020-07-05 21:41:50 -060023from patman.test_util import capture_sys_output
24
25try:
26 import pygit2
Simon Glass427b0282020-10-29 21:46:13 -060027 HAVE_PYGIT2 = True
Simon Glassfd709862020-07-05 21:41:50 -060028except ModuleNotFoundError:
29 HAVE_PYGIT2 = False
Simon Glass6e87ae12017-05-29 15:31:31 -060030
31
Simon Glass6e87ae12017-05-29 15:31:31 -060032class TestFunctional(unittest.TestCase):
Simon Glassfca99112020-10-29 21:46:15 -060033 """Functional tests for checking that patman behaves correctly"""
Simon Glass74570512020-10-29 21:46:27 -060034 leb = (b'Lord Edmund Blackadd\xc3\xabr <weasel@blackadder.org>'.
35 decode('utf-8'))
Simon Glass4af99872020-10-29 21:46:28 -060036 fred = 'Fred Bloggs <f.bloggs@napier.net>'
37 joe = 'Joe Bloggs <joe@napierwallies.co.nz>'
38 mary = 'Mary Bloggs <mary@napierwallies.co.nz>'
Simon Glass74570512020-10-29 21:46:27 -060039
Simon Glass6e87ae12017-05-29 15:31:31 -060040 def setUp(self):
41 self.tmpdir = tempfile.mkdtemp(prefix='patman.')
Simon Glassfd709862020-07-05 21:41:50 -060042 self.gitdir = os.path.join(self.tmpdir, 'git')
43 self.repo = None
Simon Glass6e87ae12017-05-29 15:31:31 -060044
45 def tearDown(self):
46 shutil.rmtree(self.tmpdir)
47
48 @staticmethod
Simon Glassfca99112020-10-29 21:46:15 -060049 def _get_path(fname):
50 """Get the path to a test file
51
52 Args:
53 fname (str): Filename to obtain
54
55 Returns:
56 str: Full path to file in the test directory
57 """
Simon Glass6e87ae12017-05-29 15:31:31 -060058 return os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
59 'test', fname)
60
61 @classmethod
Simon Glassfca99112020-10-29 21:46:15 -060062 def _get_text(cls, fname):
63 """Read a file as text
64
65 Args:
66 fname (str): Filename to read
67
68 Returns:
69 str: Contents of file
70 """
71 return open(cls._get_path(fname), encoding='utf-8').read()
Simon Glass6e87ae12017-05-29 15:31:31 -060072
73 @classmethod
Simon Glassfca99112020-10-29 21:46:15 -060074 def _get_patch_name(cls, subject):
75 """Get the filename of a patch given its subject
76
77 Args:
78 subject (str): Patch subject
79
80 Returns:
81 str: Filename for that patch
82 """
Simon Glass6e87ae12017-05-29 15:31:31 -060083 fname = re.sub('[ :]', '-', subject)
84 return fname.replace('--', '-')
85
Simon Glassfca99112020-10-29 21:46:15 -060086 def _create_patches_for_test(self, series):
87 """Create patch files for use by tests
88
89 This copies patch files from the test directory as needed by the series
90
91 Args:
92 series (Series): Series containing commits to convert
93
94 Returns:
95 tuple:
96 str: Cover-letter filename, or None if none
97 fname_list: list of str, each a patch filename
98 """
Simon Glass6e87ae12017-05-29 15:31:31 -060099 cover_fname = None
100 fname_list = []
101 for i, commit in enumerate(series.commits):
Simon Glassfca99112020-10-29 21:46:15 -0600102 clean_subject = self._get_patch_name(commit.subject)
Simon Glass6e87ae12017-05-29 15:31:31 -0600103 src_fname = '%04d-%s.patch' % (i + 1, clean_subject[:52])
104 fname = os.path.join(self.tmpdir, src_fname)
Simon Glassfca99112020-10-29 21:46:15 -0600105 shutil.copy(self._get_path(src_fname), fname)
Simon Glass6e87ae12017-05-29 15:31:31 -0600106 fname_list.append(fname)
107 if series.get('cover'):
108 src_fname = '0000-cover-letter.patch'
109 cover_fname = os.path.join(self.tmpdir, src_fname)
110 fname = os.path.join(self.tmpdir, src_fname)
Simon Glassfca99112020-10-29 21:46:15 -0600111 shutil.copy(self._get_path(src_fname), fname)
Simon Glass6e87ae12017-05-29 15:31:31 -0600112
113 return cover_fname, fname_list
114
115 def testBasic(self):
116 """Tests the basic flow of patman
117
118 This creates a series from some hard-coded patches build from a simple
119 tree with the following metadata in the top commit:
120
121 Series-to: u-boot
122 Series-prefix: RFC
123 Series-cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
124 Cover-letter-cc: Lord Mëlchett <clergy@palace.gov>
Sean Andersondc03ba42020-05-04 16:28:36 -0400125 Series-version: 3
126 Patch-cc: fred
127 Series-process-log: sort, uniq
Simon Glass6e87ae12017-05-29 15:31:31 -0600128 Series-changes: 4
129 - Some changes
Sean Andersondc03ba42020-05-04 16:28:36 -0400130 - Multi
131 line
132 change
133
134 Commit-changes: 2
135 - Changes only for this commit
136
137 Cover-changes: 4
138 - Some notes for the cover letter
Simon Glass6e87ae12017-05-29 15:31:31 -0600139
140 Cover-letter:
141 test: A test patch series
142 This is a test of how the cover
Sean Andersondc03ba42020-05-04 16:28:36 -0400143 letter
Simon Glass6e87ae12017-05-29 15:31:31 -0600144 works
145 END
146
147 and this in the first commit:
148
Sean Andersondc03ba42020-05-04 16:28:36 -0400149 Commit-changes: 2
150 - second revision change
151
Simon Glass6e87ae12017-05-29 15:31:31 -0600152 Series-notes:
153 some notes
154 about some things
155 from the first commit
156 END
157
158 Commit-notes:
159 Some notes about
160 the first commit
161 END
162
163 with the following commands:
164
165 git log -n2 --reverse >/path/to/tools/patman/test/test01.txt
166 git format-patch --subject-prefix RFC --cover-letter HEAD~2
167 mv 00* /path/to/tools/patman/test
168
169 It checks these aspects:
170 - git log can be processed by patchstream
171 - emailing patches uses the correct command
172 - CC file has information on each commit
173 - cover letter has the expected text and subject
174 - each patch has the correct subject
175 - dry-run information prints out correctly
176 - unicode is handled correctly
177 - Series-to, Series-cc, Series-prefix, Cover-letter
178 - Cover-letter-cc, Series-version, Series-changes, Series-notes
179 - Commit-notes
180 """
181 process_tags = True
182 ignore_bad_tags = True
Simon Glasse6dca5e2019-05-14 15:53:53 -0600183 stefan = b'Stefan Br\xc3\xbcns <stefan.bruens@rwth-aachen.de>'.decode('utf-8')
Simon Glass6e87ae12017-05-29 15:31:31 -0600184 rick = 'Richard III <richard@palace.gov>'
Simon Glasse6dca5e2019-05-14 15:53:53 -0600185 mel = b'Lord M\xc3\xablchett <clergy@palace.gov>'.decode('utf-8')
Simon Glass6e87ae12017-05-29 15:31:31 -0600186 add_maintainers = [stefan, rick]
187 dry_run = True
188 in_reply_to = mel
189 count = 2
190 settings.alias = {
Simon Glass427b0282020-10-29 21:46:13 -0600191 'fdt': ['simon'],
192 'u-boot': ['u-boot@lists.denx.de'],
Simon Glass74570512020-10-29 21:46:27 -0600193 'simon': [self.leb],
Simon Glass4af99872020-10-29 21:46:28 -0600194 'fred': [self.fred],
Simon Glass6e87ae12017-05-29 15:31:31 -0600195 }
196
Simon Glassfca99112020-10-29 21:46:15 -0600197 text = self._get_text('test01.txt')
Simon Glassd93720e2020-10-29 21:46:19 -0600198 series = patchstream.get_metadata_for_test(text)
Simon Glassfca99112020-10-29 21:46:15 -0600199 cover_fname, args = self._create_patches_for_test(series)
Simon Glass366954f2020-10-29 21:46:14 -0600200 with capture_sys_output() as out:
Simon Glassd93720e2020-10-29 21:46:19 -0600201 patchstream.fix_patches(series, args)
Simon Glass6e87ae12017-05-29 15:31:31 -0600202 if cover_fname and series.get('cover'):
Simon Glassd93720e2020-10-29 21:46:19 -0600203 patchstream.insert_cover_letter(cover_fname, series, count)
Simon Glass6e87ae12017-05-29 15:31:31 -0600204 series.DoChecks()
205 cc_file = series.MakeCcFile(process_tags, cover_fname,
Chris Packham4fb35022018-06-07 20:45:06 +1200206 not ignore_bad_tags, add_maintainers,
207 None)
Simon Glass427b0282020-10-29 21:46:13 -0600208 cmd = gitutil.EmailPatches(
209 series, cover_fname, args, dry_run, not ignore_bad_tags,
210 cc_file, in_reply_to=in_reply_to, thread=None)
Simon Glass6e87ae12017-05-29 15:31:31 -0600211 series.ShowActions(args, cmd, process_tags)
Simon Glass272cd852019-10-31 07:42:51 -0600212 cc_lines = open(cc_file, encoding='utf-8').read().splitlines()
Simon Glass6e87ae12017-05-29 15:31:31 -0600213 os.remove(cc_file)
214
Simon Glass8c17f8c2020-10-29 21:46:29 -0600215 lines = iter(out[0].getvalue().splitlines())
216 self.assertEqual('Cleaned %s patches' % len(series.commits),
217 next(lines))
218 self.assertEqual('Change log missing for v2', next(lines))
219 self.assertEqual('Change log missing for v3', next(lines))
220 self.assertEqual('Change log for unknown version v4', next(lines))
221 self.assertEqual("Alias 'pci' not found", next(lines))
222 self.assertIn('Dry run', next(lines))
223 self.assertEqual('', next(lines))
224 self.assertIn('Send a total of %d patches' % count, next(lines))
225 prev = next(lines)
226 for i, commit in enumerate(series.commits):
227 self.assertEqual(' %s' % args[i], prev)
228 while True:
229 prev = next(lines)
230 if 'Cc:' not in prev:
231 break
232 self.assertEqual('To: u-boot@lists.denx.de', prev)
233 self.assertEqual('Cc: %s' % tools.FromUnicode(stefan), next(lines))
234 self.assertEqual('Version: 3', next(lines))
235 self.assertEqual('Prefix:\t RFC', next(lines))
236 self.assertEqual('Cover: 4 lines', next(lines))
237 self.assertEqual(' Cc: %s' % self.fred, next(lines))
Simon Glass74570512020-10-29 21:46:27 -0600238 self.assertEqual(' Cc: %s' % tools.FromUnicode(self.leb),
Simon Glass8c17f8c2020-10-29 21:46:29 -0600239 next(lines))
240 self.assertEqual(' Cc: %s' % tools.FromUnicode(mel), next(lines))
241 self.assertEqual(' Cc: %s' % rick, next(lines))
Simon Glass6e87ae12017-05-29 15:31:31 -0600242 expected = ('Git command: git send-email --annotate '
243 '--in-reply-to="%s" --to "u-boot@lists.denx.de" '
244 '--cc "%s" --cc-cmd "%s --cc-cmd %s" %s %s'
245 % (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname,
Simon Glasse6dca5e2019-05-14 15:53:53 -0600246 ' '.join(args)))
Simon Glass8c17f8c2020-10-29 21:46:29 -0600247 self.assertEqual(expected, tools.ToUnicode(next(lines)))
Simon Glass6e87ae12017-05-29 15:31:31 -0600248
Dmitry Torokhov8ab452d2019-10-21 20:09:56 -0700249 self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)),
Simon Glasse6dca5e2019-05-14 15:53:53 -0600250 tools.ToUnicode(cc_lines[0]))
Simon Glass427b0282020-10-29 21:46:13 -0600251 self.assertEqual(
Simon Glass4af99872020-10-29 21:46:28 -0600252 '%s %s\0%s\0%s\0%s' % (args[1], self.fred, self.leb, rick, stefan),
Simon Glass427b0282020-10-29 21:46:13 -0600253 tools.ToUnicode(cc_lines[1]))
Simon Glass6e87ae12017-05-29 15:31:31 -0600254
255 expected = '''
256This is a test of how the cover
Sean Andersondc03ba42020-05-04 16:28:36 -0400257letter
Simon Glass6e87ae12017-05-29 15:31:31 -0600258works
259
260some notes
261about some things
262from the first commit
263
264Changes in v4:
Sean Andersondc03ba42020-05-04 16:28:36 -0400265- Multi
266 line
267 change
Simon Glass6e87ae12017-05-29 15:31:31 -0600268- Some changes
Sean Andersondc03ba42020-05-04 16:28:36 -0400269- Some notes for the cover letter
Simon Glass6e87ae12017-05-29 15:31:31 -0600270
271Simon Glass (2):
272 pci: Correct cast for sandbox
Siva Durga Prasad Paladugu12308b12018-07-16 15:56:11 +0530273 fdt: Correct cast for sandbox in fdtdec_setup_mem_size_base()
Simon Glass6e87ae12017-05-29 15:31:31 -0600274
275 cmd/pci.c | 3 ++-
276 fs/fat/fat.c | 1 +
277 lib/efi_loader/efi_memory.c | 1 +
278 lib/fdtdec.c | 3 ++-
279 4 files changed, 6 insertions(+), 2 deletions(-)
280
281--\x20
2822.7.4
283
284'''
Simon Glass272cd852019-10-31 07:42:51 -0600285 lines = open(cover_fname, encoding='utf-8').read().splitlines()
Simon Glass6e87ae12017-05-29 15:31:31 -0600286 self.assertEqual(
Simon Glass427b0282020-10-29 21:46:13 -0600287 'Subject: [RFC PATCH v3 0/2] test: A test patch series',
288 lines[3])
Simon Glass6e87ae12017-05-29 15:31:31 -0600289 self.assertEqual(expected.splitlines(), lines[7:])
290
291 for i, fname in enumerate(args):
Simon Glass272cd852019-10-31 07:42:51 -0600292 lines = open(fname, encoding='utf-8').read().splitlines()
Simon Glass6e87ae12017-05-29 15:31:31 -0600293 subject = [line for line in lines if line.startswith('Subject')]
294 self.assertEqual('Subject: [RFC %d/%d]' % (i + 1, count),
295 subject[0][:18])
Sean Andersondc03ba42020-05-04 16:28:36 -0400296
297 # Check that we got our commit notes
298 start = 0
299 expected = ''
300
Simon Glass6e87ae12017-05-29 15:31:31 -0600301 if i == 0:
Sean Andersondc03ba42020-05-04 16:28:36 -0400302 start = 17
303 expected = '''---
304Some notes about
305the first commit
306
307(no changes since v2)
308
309Changes in v2:
310- second revision change'''
311 elif i == 1:
312 start = 17
313 expected = '''---
314
315Changes in v4:
316- Multi
317 line
318 change
319- Some changes
320
321Changes in v2:
322- Changes only for this commit'''
323
324 if expected:
325 expected = expected.splitlines()
326 self.assertEqual(expected, lines[start:(start+len(expected))])
Simon Glassfd709862020-07-05 21:41:50 -0600327
328 def make_commit_with_file(self, subject, body, fname, text):
329 """Create a file and add it to the git repo with a new commit
330
331 Args:
332 subject (str): Subject for the commit
333 body (str): Body text of the commit
334 fname (str): Filename of file to create
335 text (str): Text to put into the file
336 """
337 path = os.path.join(self.gitdir, fname)
338 tools.WriteFile(path, text, binary=False)
339 index = self.repo.index
340 index.add(fname)
Simon Glass427b0282020-10-29 21:46:13 -0600341 author = pygit2.Signature('Test user', 'test@email.com')
Simon Glassfd709862020-07-05 21:41:50 -0600342 committer = author
343 tree = index.write_tree()
344 message = subject + '\n' + body
345 self.repo.create_commit('HEAD', author, committer, message, tree,
346 [self.repo.head.target])
347
348 def make_git_tree(self):
349 """Make a simple git tree suitable for testing
350
351 It has three branches:
352 'base' has two commits: PCI, main
353 'first' has base as upstream and two more commits: I2C, SPI
354 'second' has base as upstream and three more: video, serial, bootm
355
356 Returns:
Simon Glassfca99112020-10-29 21:46:15 -0600357 pygit2.Repository: repository
Simon Glassfd709862020-07-05 21:41:50 -0600358 """
359 repo = pygit2.init_repository(self.gitdir)
360 self.repo = repo
361 new_tree = repo.TreeBuilder().write()
362
363 author = pygit2.Signature('Test user', 'test@email.com')
364 committer = author
Simon Glassfca99112020-10-29 21:46:15 -0600365 _ = repo.create_commit('HEAD', author, committer, 'Created master',
366 new_tree, [])
Simon Glassfd709862020-07-05 21:41:50 -0600367
368 self.make_commit_with_file('Initial commit', '''
369Add a README
370
371''', 'README', '''This is the README file
372describing this project
373in very little detail''')
374
375 self.make_commit_with_file('pci: PCI implementation', '''
376Here is a basic PCI implementation
377
378''', 'pci.c', '''This is a file
379it has some contents
380and some more things''')
381 self.make_commit_with_file('main: Main program', '''
382Hello here is the second commit.
383''', 'main.c', '''This is the main file
384there is very little here
385but we can always add more later
386if we want to
387
388Series-to: u-boot
389Series-cc: Barry Crump <bcrump@whataroa.nz>
390''')
391 base_target = repo.revparse_single('HEAD')
392 self.make_commit_with_file('i2c: I2C things', '''
393This has some stuff to do with I2C
394''', 'i2c.c', '''And this is the file contents
395with some I2C-related things in it''')
396 self.make_commit_with_file('spi: SPI fixes', '''
397SPI needs some fixes
398and here they are
399''', 'spi.c', '''Some fixes for SPI in this
400file to make SPI work
401better than before''')
402 first_target = repo.revparse_single('HEAD')
403
404 target = repo.revparse_single('HEAD~2')
405 repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE)
406 self.make_commit_with_file('video: Some video improvements', '''
407Fix up the video so that
408it looks more purple. Purple is
409a very nice colour.
410''', 'video.c', '''More purple here
411Purple and purple
412Even more purple
413Could not be any more purple''')
414 self.make_commit_with_file('serial: Add a serial driver', '''
415Here is the serial driver
416for my chip.
417
418Cover-letter:
419Series for my board
420This series implements support
421for my glorious board.
422END
Simon Glassf9e42842020-10-29 21:46:16 -0600423Series-links: 183237
Simon Glassfd709862020-07-05 21:41:50 -0600424''', 'serial.c', '''The code for the
425serial driver is here''')
426 self.make_commit_with_file('bootm: Make it boot', '''
427This makes my board boot
428with a fix to the bootm
429command
430''', 'bootm.c', '''Fix up the bootm
431command to make the code as
432complicated as possible''')
433 second_target = repo.revparse_single('HEAD')
434
435 repo.branches.local.create('first', first_target)
436 repo.config.set_multivar('branch.first.remote', '', '.')
437 repo.config.set_multivar('branch.first.merge', '', 'refs/heads/base')
438
439 repo.branches.local.create('second', second_target)
440 repo.config.set_multivar('branch.second.remote', '', '.')
441 repo.config.set_multivar('branch.second.merge', '', 'refs/heads/base')
442
443 repo.branches.local.create('base', base_target)
444 return repo
445
446 @unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2')
447 def testBranch(self):
448 """Test creating patches from a branch"""
449 repo = self.make_git_tree()
450 target = repo.lookup_reference('refs/heads/first')
451 self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE)
452 control.setup()
453 try:
454 orig_dir = os.getcwd()
455 os.chdir(self.gitdir)
456
457 # Check that it can detect the current branch
Simon Glass262130f2020-07-05 21:41:51 -0600458 self.assertEqual(2, gitutil.CountCommitsToBranch(None))
Simon Glassfd709862020-07-05 21:41:50 -0600459 col = terminal.Color()
460 with capture_sys_output() as _:
461 _, cover_fname, patch_files = control.prepare_patches(
Simon Glass137947e2020-07-05 21:41:52 -0600462 col, branch=None, count=-1, start=0, end=0,
463 ignore_binary=False)
Simon Glassfd709862020-07-05 21:41:50 -0600464 self.assertIsNone(cover_fname)
465 self.assertEqual(2, len(patch_files))
Simon Glass262130f2020-07-05 21:41:51 -0600466
467 # Check that it can detect a different branch
468 self.assertEqual(3, gitutil.CountCommitsToBranch('second'))
469 with capture_sys_output() as _:
470 _, cover_fname, patch_files = control.prepare_patches(
Simon Glass137947e2020-07-05 21:41:52 -0600471 col, branch='second', count=-1, start=0, end=0,
Simon Glass262130f2020-07-05 21:41:51 -0600472 ignore_binary=False)
473 self.assertIsNotNone(cover_fname)
474 self.assertEqual(3, len(patch_files))
Simon Glass137947e2020-07-05 21:41:52 -0600475
476 # Check that it can skip patches at the end
477 with capture_sys_output() as _:
478 _, cover_fname, patch_files = control.prepare_patches(
479 col, branch='second', count=-1, start=0, end=1,
480 ignore_binary=False)
481 self.assertIsNotNone(cover_fname)
482 self.assertEqual(2, len(patch_files))
Simon Glassfd709862020-07-05 21:41:50 -0600483 finally:
484 os.chdir(orig_dir)
Simon Glass74570512020-10-29 21:46:27 -0600485
486 def testTags(self):
487 """Test collection of tags in a patchstream"""
488 text = '''This is a patch
489
490Signed-off-by: Terminator
Simon Glass4af99872020-10-29 21:46:28 -0600491Reviewed-by: %s
492Reviewed-by: %s
Simon Glass74570512020-10-29 21:46:27 -0600493Tested-by: %s
Simon Glass4af99872020-10-29 21:46:28 -0600494''' % (self.joe, self.mary, self.leb)
Simon Glass74570512020-10-29 21:46:27 -0600495 pstrm = PatchStream.process_text(text)
496 self.assertEqual(pstrm.commit.rtags, {
Simon Glass4af99872020-10-29 21:46:28 -0600497 'Reviewed-by': {self.joe, self.mary},
Simon Glass74570512020-10-29 21:46:27 -0600498 'Tested-by': {self.leb}})
Simon Glass4af99872020-10-29 21:46:28 -0600499
500 def testMissingEnd(self):
501 """Test a missing END tag"""
502 text = '''This is a patch
503
504Cover-letter:
505This is the title
506missing END after this line
507Signed-off-by: Fred
508'''
509 pstrm = PatchStream.process_text(text)
510 self.assertEqual(["Missing 'END' in section 'cover'"],
511 pstrm.commit.warn)
512
513 def testMissingBlankLine(self):
514 """Test a missing blank line after a tag"""
515 text = '''This is a patch
516
517Series-changes: 2
518- First line of changes
519- Missing blank line after this line
520Signed-off-by: Fred
521'''
522 pstrm = PatchStream.process_text(text)
523 self.assertEqual(["Missing 'blank line' in section 'Series-changes'"],
524 pstrm.commit.warn)
525
526 def testInvalidCommitTag(self):
527 """Test an invalid Commit-xxx tag"""
528 text = '''This is a patch
529
530Commit-fred: testing
531'''
532 pstrm = PatchStream.process_text(text)
533 self.assertEqual(["Line 3: Ignoring Commit-fred"], pstrm.commit.warn)
534
535 def testSelfTest(self):
536 """Test a tested by tag by this user"""
537 test_line = 'Tested-by: %s@napier.com' % os.getenv('USER')
538 text = '''This is a patch
539
540%s
541''' % test_line
542 pstrm = PatchStream.process_text(text)
543 self.assertEqual(["Ignoring '%s'" % test_line], pstrm.commit.warn)
544
545 def testSpaceBeforeTab(self):
546 """Test a space before a tab"""
547 text = '''This is a patch
548
549+ \tSomething
550'''
551 pstrm = PatchStream.process_text(text)
552 self.assertEqual(["Line 3/0 has space before tab"], pstrm.commit.warn)
553
554 def testLinesAfterTest(self):
555 """Test detecting lines after TEST= line"""
556 text = '''This is a patch
557
558TEST=sometest
559more lines
560here
561'''
562 pstrm = PatchStream.process_text(text)
563 self.assertEqual(["Found 2 lines after TEST="], pstrm.commit.warn)
564
565 def testBlankLineAtEnd(self):
566 """Test detecting a blank line at the end of a file"""
567 text = '''This is a patch
568
569diff --git a/lib/fdtdec.c b/lib/fdtdec.c
570index c072e54..942244f 100644
571--- a/lib/fdtdec.c
572+++ b/lib/fdtdec.c
573@@ -1200,7 +1200,8 @@ int fdtdec_setup_mem_size_base(void)
574 }
575
576 gd->ram_size = (phys_size_t)(res.end - res.start + 1);
577- debug("%s: Initial DRAM size %llx\n", __func__, (u64)gd->ram_size);
578+ debug("%s: Initial DRAM size %llx\n", __func__,
579+ (unsigned long long)gd->ram_size);
580+
581diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
582
583--
5842.7.4
585
586 '''
587 pstrm = PatchStream.process_text(text)
588 self.assertEqual(
589 ["Found possible blank line(s) at end of file 'lib/fdtdec.c'"],
590 pstrm.commit.warn)