summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-11-06 10:34:12 -0500
committerSteve Sakoman <steve@sakoman.com>2023-11-24 05:01:37 -1000
commit1ce41a86e3f81a1e9d817cccb0a879731a4c1ac3 (patch)
tree8def4ada34bc4d1f89b78289ba5193112614ff70 /meta
parentbee889b6a184ed2d1855b10a326a14e0e18b2297 (diff)
downloadpoky-1ce41a86e3f81a1e9d817cccb0a879731a4c1ac3.tar.gz
patchtest: rework license checksum tests
Remove the pretest_lic_files_chksum_modified_not_mentioned test entirely and use pyparsing in test_lic_files_chksum_modified_not_mentioned to scan the patches for lines starting with either "+LIC_FILES_CHKSUM" or "-LIC_FILES_CHKSUM". If either is found but no "License-Update" tag is present in the commit, fail the test. (From OE-Core rev: d1871afcec769b6503852adf6217460897ecf301) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit 8e1bda0eb225ada22fdf5990edfec512be1d6629) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/patchtest/tests/test_metadata.py40
1 files changed, 8 insertions, 32 deletions
diff --git a/meta/lib/patchtest/tests/test_metadata.py b/meta/lib/patchtest/tests/test_metadata.py
index 3742760b45..b6f4456ad2 100644
--- a/meta/lib/patchtest/tests/test_metadata.py
+++ b/meta/lib/patchtest/tests/test_metadata.py
@@ -16,6 +16,8 @@ class TestMetadata(base.Metadata):
16 license_var = 'LICENSE' 16 license_var = 'LICENSE'
17 closed = 'CLOSED' 17 closed = 'CLOSED'
18 lictag_re = pyparsing.AtLineStart("License-Update:") 18 lictag_re = pyparsing.AtLineStart("License-Update:")
19 lic_chksum_added = pyparsing.AtLineStart("+" + metadata_chksum)
20 lic_chksum_removed = pyparsing.AtLineStart("-" + metadata_chksum)
19 add_mark = pyparsing.Regex('\+ ') 21 add_mark = pyparsing.Regex('\+ ')
20 max_length = 200 22 max_length = 200
21 metadata_src_uri = 'SRC_URI' 23 metadata_src_uri = 'SRC_URI'
@@ -76,48 +78,22 @@ class TestMetadata(base.Metadata):
76 if not lic_files_chksum: 78 if not lic_files_chksum:
77 self.fail('%s is missing in newly added recipe' % self.metadata_chksum) 79 self.fail('%s is missing in newly added recipe' % self.metadata_chksum)
78 80
79 def pretest_lic_files_chksum_modified_not_mentioned(self):
80 if not self.modified:
81 self.skip('No modified recipes, skipping pretest')
82 # get the proper metadata values
83 for pn in self.modified:
84 rd = self.tinfoil.parse_recipe(pn)
85 pathname = rd.getVar('FILE')
86 # we are not interested in images
87 if '/images/' in pathname:
88 continue
89 PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata_chksum,pn)] = rd.getVar(self.metadata_chksum)
90
91 def test_lic_files_chksum_modified_not_mentioned(self): 81 def test_lic_files_chksum_modified_not_mentioned(self):
92 if not self.modified: 82 if not self.modified:
93 self.skip('No modified recipes, skipping test') 83 self.skip('No modified recipes, skipping test')
94 84
95 # get the proper metadata values 85 for patch in self.patchset:
96 for pn in self.modified: 86 # for the moment, we are just interested in metadata
97 rd = self.tinfoil.parse_recipe(pn) 87 if patch.path.endswith('.patch'):
98 pathname = rd.getVar('FILE')
99 # we are not interested in images
100 if '/images/' in pathname:
101 continue 88 continue
102 PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata_chksum,pn)] = rd.getVar(self.metadata_chksum) 89 payload = str(patch)
103 # compare if there were changes between pre-merge and merge 90 if (self.lic_chksum_added.search_string(payload) or self.lic_chksum_removed.search_string(payload)):
104 for pn in self.modified:
105 pretest = PatchTestDataStore['pre%s-%s-%s' % (self.shortid(),self.metadata_chksum, pn)]
106 test = PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata_chksum, pn)]
107
108 # TODO: this is workaround to avoid false-positives when pretest metadata is empty (not reason found yet)
109 # For more info, check bug 12284
110 if not pretest:
111 return
112
113 if pretest != test:
114 # if any patch on the series contain reference on the metadata, fail 91 # if any patch on the series contain reference on the metadata, fail
115 for commit in self.commits: 92 for commit in self.commits:
116 if self.lictag_re.search_string(commit.commit_message): 93 if self.lictag_re.search_string(commit.commit_message):
117 break 94 break
118 else: 95 else:
119 self.fail('LIC_FILES_CHKSUM changed without "License-Update:" tag and description in commit message', 96 self.fail('LIC_FILES_CHKSUM changed without "License-Update:" tag and description in commit message')
120 data=[('Current checksum', pretest), ('New checksum', test)])
121 97
122 def test_max_line_length(self): 98 def test_max_line_length(self):
123 for patch in self.patchset: 99 for patch in self.patchset: