mirror of
https://git.yoctoproject.org/poky
synced 2026-04-27 12:32:13 +02:00
patchtest: simplify, rename modules
- simplify base.py, data.py - move some leftover regex patterns to patterns.py - remove pyparsing path logic, since this is no longer needed - rename PatchTestInput class to PatchtestParser - data.py: rename to patchtest_parser.py - patterns.py: rename to patchtest_patterns.py - move PatchTestDataStore to test_metadata.py since that's the only place it's used - remove unused logger code (From OE-Core rev: 1e971b05b036b0b1eb0bdbd9b26b54d06e74294c) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
18a65c77c0
commit
4c378fc895
@@ -7,7 +7,7 @@
|
||||
|
||||
import base
|
||||
import os
|
||||
import patterns
|
||||
import patchtest_patterns
|
||||
import pyparsing
|
||||
|
||||
class TestPatch(base.Base):
|
||||
@@ -20,17 +20,17 @@ class TestPatch(base.Base):
|
||||
if patch.path.endswith('.patch') and patch.is_added_file:
|
||||
cls.newpatches.append(patch)
|
||||
|
||||
cls.mark = str(patterns.signed_off_by_prefix).strip('"')
|
||||
cls.mark = str(patchtest_patterns.signed_off_by_prefix).strip('"')
|
||||
|
||||
# match PatchSignedOffBy.mark with '+' preceding it
|
||||
cls.prog = patterns.patch_signed_off_by
|
||||
cls.prog = patchtest_patterns.patch_signed_off_by
|
||||
|
||||
def setUp(self):
|
||||
if self.unidiff_parse_error:
|
||||
self.skip('Parse error %s' % self.unidiff_parse_error)
|
||||
|
||||
self.valid_status = ', '.join(patterns.upstream_status_nonliteral_valid_status)
|
||||
self.standard_format = 'Upstream-Status: <Valid status>'
|
||||
self.valid_status = ", ".join(patchtest_patterns.upstream_status_nonliteral_valid_status)
|
||||
self.standard_format = "Upstream-Status: <Valid status>"
|
||||
|
||||
# we are just interested in series that introduce CVE patches, thus discard other
|
||||
# possibilities: modification to current CVEs, patch directly introduced into the
|
||||
@@ -45,31 +45,62 @@ class TestPatch(base.Base):
|
||||
|
||||
for newpatch in TestPatch.newpatches:
|
||||
payload = newpatch.__str__()
|
||||
if not patterns.upstream_status_regex.search_string(payload):
|
||||
self.fail('Added patch file is missing Upstream-Status: <Valid status> in the commit message',
|
||||
data=[('Standard format', self.standard_format), ('Valid status', self.valid_status)])
|
||||
if not patchtest_patterns.upstream_status_regex.search_string(payload):
|
||||
self.fail(
|
||||
"Added patch file is missing Upstream-Status: <Valid status> in the commit message",
|
||||
data=[
|
||||
("Standard format", self.standard_format),
|
||||
("Valid status", self.valid_status),
|
||||
],
|
||||
)
|
||||
for line in payload.splitlines():
|
||||
if self.patchmetadata_regex.match(line):
|
||||
if patchtest_patterns.patchmetadata_regex.match(line):
|
||||
continue
|
||||
if patterns.upstream_status_regex.search_string(line):
|
||||
if patterns.inappropriate.searchString(line):
|
||||
try:
|
||||
patterns.upstream_status_inappropriate_info.parseString(line.lstrip('+'))
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail('Upstream-Status is Inappropriate, but no reason was provided',
|
||||
data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Inappropriate [reason]')])
|
||||
elif patterns.submitted.searchString(line):
|
||||
try:
|
||||
patterns.upstream_status_submitted_info.parseString(line.lstrip('+'))
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail('Upstream-Status is Submitted, but it is not mentioned where',
|
||||
data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Submitted [where]')])
|
||||
else:
|
||||
try:
|
||||
patterns.upstream_status.parseString(line.lstrip('+'))
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail('Upstream-Status is in incorrect format',
|
||||
data=[('Current', pe.pstr), ('Standard format', self.standard_format), ('Valid status', self.valid_status)])
|
||||
if patchtest_patterns.upstream_status_regex.search_string(line):
|
||||
if patchtest_patterns.inappropriate.searchString(line):
|
||||
try:
|
||||
patchtest_patterns.upstream_status_inappropriate_info.parseString(
|
||||
line.lstrip("+")
|
||||
)
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail(
|
||||
"Upstream-Status is Inappropriate, but no reason was provided",
|
||||
data=[
|
||||
("Current", pe.pstr),
|
||||
(
|
||||
"Standard format",
|
||||
"Upstream-Status: Inappropriate [reason]",
|
||||
),
|
||||
],
|
||||
)
|
||||
elif patchtest_patterns.submitted.searchString(line):
|
||||
try:
|
||||
patchtest_patterns.upstream_status_submitted_info.parseString(
|
||||
line.lstrip("+")
|
||||
)
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail(
|
||||
"Upstream-Status is Submitted, but it is not mentioned where",
|
||||
data=[
|
||||
("Current", pe.pstr),
|
||||
(
|
||||
"Standard format",
|
||||
"Upstream-Status: Submitted [where]",
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
try:
|
||||
patchtest_patterns.upstream_status.parseString(line.lstrip("+"))
|
||||
except pyparsing.ParseException as pe:
|
||||
self.fail(
|
||||
"Upstream-Status is in incorrect format",
|
||||
data=[
|
||||
("Current", pe.pstr),
|
||||
("Standard format", self.standard_format),
|
||||
("Valid status", self.valid_status),
|
||||
],
|
||||
)
|
||||
|
||||
def test_signed_off_by_presence(self):
|
||||
if not TestPatch.newpatches:
|
||||
@@ -78,7 +109,7 @@ class TestPatch(base.Base):
|
||||
for newpatch in TestPatch.newpatches:
|
||||
payload = newpatch.__str__()
|
||||
for line in payload.splitlines():
|
||||
if self.patchmetadata_regex.match(line):
|
||||
if patchtest_patterns.patchmetadata_regex.match(line):
|
||||
continue
|
||||
if TestPatch.prog.search_string(payload):
|
||||
break
|
||||
@@ -87,10 +118,12 @@ class TestPatch(base.Base):
|
||||
|
||||
def test_cve_tag_format(self):
|
||||
for commit in TestPatch.commits:
|
||||
if patterns.cve.search_string(commit.shortlog) or patterns.cve.search_string(commit.commit_message):
|
||||
if patchtest_patterns.cve.search_string(
|
||||
commit.shortlog
|
||||
) or patchtest_patterns.cve.search_string(commit.commit_message):
|
||||
tag_found = False
|
||||
for line in commit.payload.splitlines():
|
||||
if patterns.cve_payload_tag.search_string(line):
|
||||
if patchtest_patterns.cve_payload_tag.search_string(line):
|
||||
tag_found = True
|
||||
break
|
||||
if not tag_found:
|
||||
|
||||
Reference in New Issue
Block a user