summaryrefslogtreecommitdiffstats
path: root/meta/lib/patchtest/tests/test_patch_cve.py
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-10-12 09:24:59 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-13 11:53:06 +0100
commitfd06e4f2664b69a2776cdc8188dba6e6e958d86a (patch)
tree2b26efe798c2169eeeea6e9c24ae5ac72d9fa9df /meta/lib/patchtest/tests/test_patch_cve.py
parent2fdabc368a52a9bf60f76f33e92b94de843688a8 (diff)
downloadpoky-fd06e4f2664b69a2776cdc8188dba6e6e958d86a.tar.gz
patchtest: clean up test suite
Various tweaks to make the test suite cleaner and more efficient: - Replace use of "re" module with "pyparsing" in tests (but not base.py) - Make test_mbox_cve only check for CVE tags in the commit if the added patch has them - Make test_mbox_cve SKIP instead of PASS if there's no CVE tag - Simplify the bugzilla tag checking test now that pyparsing is used - Modify the selftest script to correctly parse the new result output (From OE-Core rev: 7a187c2475aa762e2bc830950f608143f2535a72) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/patchtest/tests/test_patch_cve.py')
-rw-r--r--meta/lib/patchtest/tests/test_patch_cve.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/meta/lib/patchtest/tests/test_patch_cve.py b/meta/lib/patchtest/tests/test_patch_cve.py
index 144e130707..0ae85adcf9 100644
--- a/meta/lib/patchtest/tests/test_patch_cve.py
+++ b/meta/lib/patchtest/tests/test_patch_cve.py
@@ -19,12 +19,12 @@
19 19
20import base 20import base
21import os 21import os
22import re 22import pyparsing
23 23
24class CVE(base.Base): 24class CVE(base.Base):
25 25
26 re_cve_pattern = re.compile("CVE\-\d{4}\-\d+", re.IGNORECASE) 26 re_cve_pattern = pyparsing.Regex("CVE\-\d{4}\-\d+")
27 re_cve_payload_tag = re.compile("\+CVE:(\s+CVE\-\d{4}\-\d+)+") 27 re_cve_payload_tag = pyparsing.Regex("\+CVE:(\s+CVE\-\d{4}\-\d+)+")
28 28
29 def setUp(self): 29 def setUp(self):
30 if self.unidiff_parse_error: 30 if self.unidiff_parse_error:
@@ -39,10 +39,10 @@ class CVE(base.Base):
39 39
40 def test_cve_tag_format(self): 40 def test_cve_tag_format(self):
41 for commit in CVE.commits: 41 for commit in CVE.commits:
42 if self.re_cve_pattern.search(commit.shortlog) or self.re_cve_pattern.search(commit.commit_message): 42 if self.re_cve_pattern.search_string(commit.shortlog) or self.re_cve_pattern.search_string(commit.commit_message):
43 tag_found = False 43 tag_found = False
44 for line in commit.payload.splitlines(): 44 for line in commit.payload.splitlines():
45 if self.re_cve_payload_tag.match(line): 45 if self.re_cve_payload_tag.search_string(line):
46 tag_found = True 46 tag_found = True
47 break 47 break
48 if not tag_found: 48 if not tag_found: