summaryrefslogtreecommitdiffstats
path: root/meta/lib/patchtest
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/patchtest')
-rw-r--r--meta/lib/patchtest/README.md20
-rw-r--r--meta/lib/patchtest/data.py86
-rw-r--r--meta/lib/patchtest/patch.py62
-rw-r--r--meta/lib/patchtest/repo.py120
-rw-r--r--meta/lib/patchtest/requirements.txt7
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.fail32
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.pass31
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.fail31
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.pass31
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail26
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.pass25
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.fail22
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.pass24
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.1.fail36
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.2.fail35
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.pass33
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.1.skip35
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.2.skip41
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.fail73
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.pass73
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.fail73
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.pass73
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.1.fail71
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.2.fail72
-rw-r--r--meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.pass72
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.fail30
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.pass31
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.fail37
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.pass39
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.fail53
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.pass54
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.fail35
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.pass51
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.fail46
-rw-r--r--meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.pass49
-rw-r--r--meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.fail73
-rw-r--r--meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.pass73
-rw-r--r--meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.fail71
-rw-r--r--meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.pass72
-rwxr-xr-xmeta/lib/patchtest/selftest/selftest94
-rw-r--r--meta/lib/patchtest/tests/__init__.py0
-rw-r--r--meta/lib/patchtest/tests/base.py239
-rw-r--r--meta/lib/patchtest/tests/pyparsing/common.py26
-rw-r--r--meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py18
-rw-r--r--meta/lib/patchtest/tests/pyparsing/parse_shortlog.py14
-rw-r--r--meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py22
-rw-r--r--meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py24
-rw-r--r--meta/lib/patchtest/tests/test_mbox.py159
-rw-r--r--meta/lib/patchtest/tests/test_metadata.py197
-rw-r--r--meta/lib/patchtest/tests/test_patch.py103
-rw-r--r--meta/lib/patchtest/tests/test_python_pylint.py65
-rw-r--r--meta/lib/patchtest/utils.py61
52 files changed, 2940 insertions, 0 deletions
diff --git a/meta/lib/patchtest/README.md b/meta/lib/patchtest/README.md
new file mode 100644
index 0000000000..f66613c0c1
--- /dev/null
+++ b/meta/lib/patchtest/README.md
@@ -0,0 +1,20 @@
1# patchtest selftests for openembedded-core
2
3This directory provides a test suite and selftest script for use with the
4patchtest repository: https://git.yoctoproject.org/patchtest/
5
6To setup for use:
7
81. Clone https://git.openembedded.org/openembedded-core (this repo) and https://git.openembedded.org/bitbake/
92. Clone https://git.yoctoproject.org/patchtest
103. Install the necessary Python modules: in meta/lib/patchtest or the patchtest
11 repo, do `pip install -r requirements.txt`
124. Add patchtest to PATH: `export PATH=/path/to/patchtest/repo:$PATH`
135. Initialize the environment: `source oe-init-build-env`
146. Add meta-selftest to bblayers.conf: `bitbake-layers add-layer
15 /path/to/meta-selftest/` (the selftests use this layer's recipes as test
16 targets)
177. Finally, run the selftest script: `./meta/lib/patchtest/selftest/selftest`
18
19For more information on using patchtest, see the patchtest repo at
20https://git.yoctoproject.org/patchtest/.
diff --git a/meta/lib/patchtest/data.py b/meta/lib/patchtest/data.py
new file mode 100644
index 0000000000..356259921d
--- /dev/null
+++ b/meta/lib/patchtest/data.py
@@ -0,0 +1,86 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# patchtestdata: module used to share command line arguments between
5# patchtest & test suite and a data store between test cases
6#
7# Copyright (C) 2016 Intel Corporation
8#
9# SPDX-License-Identifier: GPL-2.0-only
10#
11# NOTE: Strictly speaking, unit test should be isolated from outside,
12# but patchtest test suites uses command line input data and
13# pretest and test test cases may use the datastore defined
14# on this module
15
16import os
17import argparse
18import collections
19import logging
20
21logger=logging.getLogger('patchtest')
22info=logger.info
23
24default_testdir = os.path.abspath(os.path.dirname(__file__) + "/tests")
25default_repodir = os.path.abspath(os.path.dirname(__file__) + "/../../..")
26
27# Data store commonly used to share values between pre and post-merge tests
28PatchTestDataStore = collections.defaultdict(str)
29
30class PatchTestInput(object):
31 """Abstract the patchtest argument parser"""
32
33 @classmethod
34 def set_namespace(cls):
35 parser = cls.get_parser()
36 parser.parse_args(namespace=cls)
37
38 @classmethod
39 def get_parser(cls):
40 parser = argparse.ArgumentParser()
41
42 target_patch_group = parser.add_mutually_exclusive_group(required=True)
43
44 target_patch_group.add_argument('--patch', metavar='PATCH', dest='patch_path',
45 help='The patch to be tested')
46
47 target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path',
48 help='The directory containing patches to be tested')
49
50 parser.add_argument('--repodir', metavar='REPO',
51 default=default_repodir,
52 help="Name of the repository where patch is merged")
53
54 parser.add_argument('--testdir', metavar='TESTDIR',
55 default=default_testdir,
56 help="Directory where test cases are located")
57
58 parser.add_argument('--top-level-directory', '-t',
59 dest='topdir',
60 default=None,
61 help="Top level directory of project (defaults to start directory)")
62
63 parser.add_argument('--pattern', '-p',
64 dest='pattern',
65 default='test*.py',
66 help="Pattern to match test files")
67
68 parser.add_argument('--base-branch', '-b',
69 dest='basebranch',
70 help="Branch name used by patchtest to branch from. By default, it uses the current one.")
71
72 parser.add_argument('--base-commit', '-c',
73 dest='basecommit',
74 help="Commit ID used by patchtest to branch from. By default, it uses HEAD.")
75
76 parser.add_argument('--debug', '-d',
77 action='store_true',
78 help='Enable debug output')
79
80 parser.add_argument('--log-results',
81 action='store_true',
82 help='Enable logging to a file matching the target patch name with ".testresult" appended')
83
84
85 return parser
86
diff --git a/meta/lib/patchtest/patch.py b/meta/lib/patchtest/patch.py
new file mode 100644
index 0000000000..baf6283873
--- /dev/null
+++ b/meta/lib/patchtest/patch.py
@@ -0,0 +1,62 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# patchtestpatch: PatchTestPatch class which abstracts a patch file
5#
6# Copyright (C) 2016 Intel Corporation
7#
8# SPDX-License-Identifier: GPL-2.0-only
9#
10
11import logging
12import utils
13
14logger = logging.getLogger('patchtest')
15
16class PatchTestPatch(object):
17 MERGE_STATUS_INVALID = 'INVALID'
18 MERGE_STATUS_NOT_MERGED = 'NOTMERGED'
19 MERGE_STATUS_MERGED_SUCCESSFULL = 'PASS'
20 MERGE_STATUS_MERGED_FAIL = 'FAIL'
21 MERGE_STATUS = (MERGE_STATUS_INVALID,
22 MERGE_STATUS_NOT_MERGED,
23 MERGE_STATUS_MERGED_SUCCESSFULL,
24 MERGE_STATUS_MERGED_FAIL)
25
26 def __init__(self, path, forcereload=False):
27 self._path = path
28 self._forcereload = forcereload
29
30 self._contents = None
31 self._branch = None
32 self._merge_status = PatchTestPatch.MERGE_STATUS_NOT_MERGED
33
34 @property
35 def contents(self):
36 if self._forcereload or (not self._contents):
37 logger.debug('Reading %s contents' % self._path)
38 try:
39 with open(self._path, newline='') as _f:
40 self._contents = _f.read()
41 except IOError:
42 logger.warn("Reading the mbox %s failed" % self.resource)
43 return self._contents
44
45 @property
46 def path(self):
47 return self._path
48
49 @property
50 def branch(self):
51 if not self._branch:
52 self._branch = utils.get_branch(self._path)
53 return self._branch
54
55 def setmergestatus(self, status):
56 self._merge_status = status
57
58 def getmergestatus(self):
59 return self._merge_status
60
61 merge_status = property(getmergestatus, setmergestatus)
62
diff --git a/meta/lib/patchtest/repo.py b/meta/lib/patchtest/repo.py
new file mode 100644
index 0000000000..5f361ac500
--- /dev/null
+++ b/meta/lib/patchtest/repo.py
@@ -0,0 +1,120 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# patchtestrepo: PatchTestRepo class used mainly to control a git repo from patchtest
5#
6# Copyright (C) 2016 Intel Corporation
7#
8# SPDX-License-Identifier: GPL-2.0-only
9#
10
11import os
12import utils
13import logging
14import git
15from patch import PatchTestPatch
16
17logger = logging.getLogger('patchtest')
18info=logger.info
19
20class PatchTestRepo(object):
21
22 # prefixes used for temporal branches/stashes
23 prefix = 'patchtest'
24
25
26 def __init__(self, patch, repodir, commit=None, branch=None):
27 self._repodir = repodir
28 self._repo = git.Repo.init(repodir)
29 self._patch = PatchTestPatch(patch)
30 self._current_branch = self._repo.active_branch.name
31
32 # targeted branch defined on the patch may be invalid, so make sure there
33 # is a corresponding remote branch
34 valid_patch_branch = None
35 if self._patch.branch in self._repo.branches:
36 valid_patch_branch = self._patch.branch
37
38 # Target Branch
39 # Priority (top has highest priority):
40 # 1. branch given at cmd line
41 # 2. branch given at the patch
42 # 3. current branch
43 self._branch = branch or valid_patch_branch or self._current_branch
44
45 # Target Commit
46 # Priority (top has highest priority):
47 # 1. commit given at cmd line
48 # 2. branch given at cmd line
49 # 3. branch given at the patch
50 # 3. current HEAD
51 self._commit = self._get_commitid(commit) or \
52 self._get_commitid(branch) or \
53 self._get_commitid(valid_patch_branch) or \
54 self._get_commitid('HEAD')
55
56 self._workingbranch = "%s_%s" % (PatchTestRepo.prefix, os.getpid())
57
58 # create working branch. Use the '-B' flag so that we just
59 # check out the existing one if it's there
60 self._repo.git.execute(['git', 'checkout', '-B', self._workingbranch, self._commit])
61
62 self._patchmerged = False
63
64 # Check if patch can be merged using git-am
65 self._patchcanbemerged = True
66 try:
67 # Make sure to get the absolute path of the file
68 self._repo.git.execute(['git', 'apply', '--check', os.path.abspath(self._patch.path)], with_exceptions=True)
69 except git.exc.GitCommandError as ce:
70 self._patchcanbemerged = False
71
72 # for debugging purposes, print all repo parameters
73 logger.debug("Parameters")
74 logger.debug("\tRepository : %s" % self._repodir)
75 logger.debug("\tTarget Commit : %s" % self._commit)
76 logger.debug("\tTarget Branch : %s" % self._branch)
77 logger.debug("\tWorking branch : %s" % self._workingbranch)
78 logger.debug("\tPatch : %s" % self._patch)
79
80 @property
81 def patch(self):
82 return self._patch.path
83
84 @property
85 def branch(self):
86 return self._branch
87
88 @property
89 def commit(self):
90 return self._commit
91
92 @property
93 def ismerged(self):
94 return self._patchmerged
95
96 @property
97 def canbemerged(self):
98 return self._patchcanbemerged
99
100 def _get_commitid(self, commit):
101
102 if not commit:
103 return None
104
105 try:
106 return self._repo.rev_parse(commit).hexsha
107 except Exception as e:
108 print(f"Couldn't find commit {commit} in repo")
109
110 return None
111
112 def merge(self):
113 if self._patchcanbemerged:
114 self._repo.git.execute(['git', 'am', '--keep-cr', os.path.abspath(self._patch.path)])
115 self._patchmerged = True
116
117 def clean(self):
118 self._repo.git.execute(['git', 'checkout', self._current_branch])
119 self._repo.git.execute(['git', 'branch', '-D', self._workingbranch])
120 self._patchmerged = False
diff --git a/meta/lib/patchtest/requirements.txt b/meta/lib/patchtest/requirements.txt
new file mode 100644
index 0000000000..4247b91f09
--- /dev/null
+++ b/meta/lib/patchtest/requirements.txt
@@ -0,0 +1,7 @@
1boto3
2git-pw>=2.5.0
3GitPython
4jinja2
5pylint
6pyparsing>=3.0.9
7unidiff
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.fail
new file mode 100644
index 0000000000..0c40cdc1b6
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.fail
@@ -0,0 +1,32 @@
1From 1fbb446d1849b1208012cbdae5d85d228cdbe4a6 Mon Sep 17 00:00:00 2001
2From: First Last <first.last@example.com>
3Date: Tue, 29 Aug 2023 13:32:24 -0400
4Subject: [PATCH] selftest-hello: add a summary
5
6This patch should fail the selftests because the author address is from the
7invalid "example.com".
8
9Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
10---
11 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 3 ++-
12 1 file changed, 2 insertions(+), 1 deletion(-)
13
14diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
15index 547587bef4..491f0a3df7 100644
16--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
18@@ -1,3 +1,4 @@
19+SUMMARY = "A cool sample"
20 DESCRIPTION = "Simple helloworld application -- selftest variant"
21 SECTION = "examples"
22 LICENSE = "MIT"
23@@ -16,4 +17,4 @@ do_install() {
24 install -m 0755 helloworld ${D}${bindir}
25 }
26
27-BBCLASSEXTEND = "native nativesdk"
28\ No newline at end of file
29+BBCLASSEXTEND = "native nativesdk"
30--
312.41.0
32
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.pass
new file mode 100644
index 0000000000..cbb8ef2cef
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.1.pass
@@ -0,0 +1,31 @@
1From 1fbb446d1849b1208012cbdae5d85d228cdbe4a6 Mon Sep 17 00:00:00 2001
2From: First Last <first.last@address.com>
3Date: Tue, 29 Aug 2023 13:32:24 -0400
4Subject: [PATCH] selftest-hello: add a summary
5
6This patch should pass the selftests because the author address is in a valid format.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 3 ++-
11 1 file changed, 2 insertions(+), 1 deletion(-)
12
13diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
14index 547587bef4..491f0a3df7 100644
15--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
16+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17@@ -1,3 +1,4 @@
18+SUMMARY = "A cool sample"
19 DESCRIPTION = "Simple helloworld application -- selftest variant"
20 SECTION = "examples"
21 LICENSE = "MIT"
22@@ -16,4 +17,4 @@ do_install() {
23 install -m 0755 helloworld ${D}${bindir}
24 }
25
26-BBCLASSEXTEND = "native nativesdk"
27\ No newline at end of file
28+BBCLASSEXTEND = "native nativesdk"
29--
302.41.0
31
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.fail
new file mode 100644
index 0000000000..3e2b81bca1
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.fail
@@ -0,0 +1,31 @@
1From 1fbb446d1849b1208012cbdae5d85d228cdbe4a6 Mon Sep 17 00:00:00 2001
2From: Upgrade Helper <auh@auh.yoctoproject.org>
3Date: Tue, 29 Aug 2023 13:32:24 -0400
4Subject: [PATCH] selftest-hello: add a summary
5
6This patch should fail the selftests because AUH is an invalid sender.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 3 ++-
11 1 file changed, 2 insertions(+), 1 deletion(-)
12
13diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
14index 547587bef4..491f0a3df7 100644
15--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
16+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17@@ -1,3 +1,4 @@
18+SUMMARY = "A cool sample"
19 DESCRIPTION = "Simple helloworld application -- selftest variant"
20 SECTION = "examples"
21 LICENSE = "MIT"
22@@ -16,4 +17,4 @@ do_install() {
23 install -m 0755 helloworld ${D}${bindir}
24 }
25
26-BBCLASSEXTEND = "native nativesdk"
27\ No newline at end of file
28+BBCLASSEXTEND = "native nativesdk"
29--
302.41.0
31
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.pass
new file mode 100644
index 0000000000..f84e1265a7
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_author_valid.2.pass
@@ -0,0 +1,31 @@
1From 1fbb446d1849b1208012cbdae5d85d228cdbe4a6 Mon Sep 17 00:00:00 2001
2From: First Last <averylongemailaddressthatishardtoread.from@address.com>
3Date: Tue, 29 Aug 2023 13:32:24 -0400
4Subject: [PATCH] selftest-hello: add a summary
5
6This patch should pass the selftests because the author address is in a valid format.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 3 ++-
11 1 file changed, 2 insertions(+), 1 deletion(-)
12
13diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
14index 547587bef4..491f0a3df7 100644
15--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
16+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17@@ -1,3 +1,4 @@
18+SUMMARY = "A cool sample"
19 DESCRIPTION = "Simple helloworld application -- selftest variant"
20 SECTION = "examples"
21 LICENSE = "MIT"
22@@ -16,4 +17,4 @@ do_install() {
23 install -m 0755 helloworld ${D}${bindir}
24 }
25
26-BBCLASSEXTEND = "native nativesdk"
27\ No newline at end of file
28+BBCLASSEXTEND = "native nativesdk"
29--
302.41.0
31
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail
new file mode 100644
index 0000000000..854d7eb8c7
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail
@@ -0,0 +1,26 @@
1From f06e14633723c1e78bc7a4b0fd0d3b79d09f0c68 Mon Sep 17 00:00:00 2001
2From: name@somedomain.com <email@address.com>
3Date: Thu, 2 May 2024 10:21:45 -0400
4Subject: [PATCH] README.OE-Core.md: Add foo to header
5
6This test patch adds 'foo' to the header of README.OE-Core.md
7
8[YOCTO 1234]
9
10Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
11---
12 README.OE-Core.md | 1 +
13 1 file changed, 1 insertion(+)
14
15diff --git a/README.OE-Core.md b/README.OE-Core.md
16index 687c58e410c..9d863891134 100644
17--- a/README.OE-Core.md
18+++ b/README.OE-Core.md
19@@ -1,3 +1,4 @@
20+**** FOO ****
21 OpenEmbedded-Core
22 =================
23
24--
252.44.0
26
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.pass
new file mode 100644
index 0000000000..2648b03364
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.pass
@@ -0,0 +1,25 @@
1From fdfd605e565d874502522c4b70b786c8c5aa0bad Mon Sep 17 00:00:00 2001
2From: name@somedomain.com <email@address.com>
3Date: Fri, 17 Feb 2017 16:29:21 -0600
4Subject: [PATCH] README: adds 'foo' to the header
5
6This test patch adds 'foo' to the header
7
8[YOCTO #1234]
9
10Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com>
11---
12 README | 1 +
13 1 file changed, 1 insertion(+)
14
15diff --git a/README b/README
16index 521916cd4f..cdf29dcea3 100644
17--- a/README
18+++ b/README
19@@ -1,3 +1,4 @@
20+**** FOO ****
21 OpenEmbedded-Core
22 =================
23
24--
252.11.0
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.fail
new file mode 100644
index 0000000000..93ca0f9119
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.fail
@@ -0,0 +1,22 @@
1From 0a52a62c9430c05d22cb7f46380488f2280b69bb Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Fri, 1 Sep 2023 08:56:14 -0400
4Subject: [PATCH] README.OE-Core.md: add foo
5
6Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
7---
8 README.OE-Core.md | 1 +
9 1 file changed, 1 insertion(+)
10
11diff --git a/README.OE-Core.md b/README.OE-Core.md
12index 2f2127fb03..48464252c8 100644
13--- a/README.OE-Core.md
14+++ b/README.OE-Core.md
15@@ -1,3 +1,4 @@
16+** FOO **
17 OpenEmbedded-Core
18 =================
19
20--
212.41.0
22
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.pass
new file mode 100644
index 0000000000..5e3dcbd58b
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_commit_message_presence.pass
@@ -0,0 +1,24 @@
1From 0a52a62c9430c05d22cb7f46380488f2280b69bb Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Fri, 1 Sep 2023 08:56:14 -0400
4Subject: [PATCH] README.OE-Core.md: add foo
5
6This is a commit message
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 README.OE-Core.md | 1 +
11 1 file changed, 1 insertion(+)
12
13diff --git a/README.OE-Core.md b/README.OE-Core.md
14index 2f2127fb03..48464252c8 100644
15--- a/README.OE-Core.md
16+++ b/README.OE-Core.md
17@@ -1,3 +1,4 @@
18+** FOO **
19 OpenEmbedded-Core
20 =================
21
22--
232.41.0
24
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.1.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.1.fail
new file mode 100644
index 0000000000..9cc4aab38a
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.1.fail
@@ -0,0 +1,36 @@
1From d12db4cfa913b0e7a4b5bd858d3019acc53ce426 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 30 Aug 2023 12:15:00 -0400
4Subject: [PATCH] selftest-hello: upgrade 1.0 -> 1.1
5
6This test should fail the mbox formatting test and the merge on head
7test.
8
9Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
10---
11 .../{selftest-hello_1.0.bb => selftest-hello_1.1.bb} | 3 ++-
12 1 file changed, 2 insertions(+), 1 deletion(-)
13 rename meta-selftest/recipes-test/selftest-hello/{selftest-hello_1.0.bb => selftest-hello_1.1.bb} (88%)
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
16similarity index 88%
17rename from meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
18rename to meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
19index 547587bef4..acc388ec2c 100644
20--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
21+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
22@@ -1,3 +1,4 @@
23%+SUMMARY = "Hello!"
24 DESCRIPTION = "Simple helloworld application -- selftest variant"
25 SECTION = "examples"
26 LICENSE = "MIT"
27@@ -16,4 +17,4 @@ do_install() {
28 install -m 0755 helloworld ${D}${bindir}
29 }
30
31-BBCLASSEXTEND = "native nativesdk"
32\ No newline at end of file
33+BBCLASSEXTEND = "native nativesdk"
34--
352.41.0
36
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.2.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.2.fail
new file mode 100644
index 0000000000..eca1c60085
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.2.fail
@@ -0,0 +1,35 @@
1From d12db4cfa913b0e7a4b5bd858d3019acc53ce426 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 30 Aug 2023 12:15:00 -0400
4Subject: [PATCH] selftest-hello: upgrade 1.0 -> 1.1
5
6This test should fail the merge-on-head and mbox formatting tests.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../{selftest-hello_1.0.bb => selftest-hello_1.1.bb} | 3 ++-
11 1 file changed, 2 insertions(+), 1 deletion(-)
12 rename meta-selftest/recipes-test/selftest-hello/{selftest-hello_1.0.bb => selftest-hello_1.1.bb} (88%)
13
14diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
15similarity index 88%
16rename from meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17rename to meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
18index 547587bef4..acc388ec2c 100644
19--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
20+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
21@@ -1,3 +1,4 @@
22%+SUMMARY = "Hello!"
23 DESCRIPTION = "Simple helloworld application -- selftest variant"
24 SECTION = "examples"
25 LICENSE = "MIT"
26@@ -16,4 +17,4 @@ do_install() {
27 install -m 0755 helloworld ${D}${bindir}
28 }
29
30-BBCLASSEXTEND = "native nativesdk"
31\ No newline at end of file
32+BBCLASSEXTEND = "native nativesdk"
33--
342.41.0
35
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.pass
new file mode 100644
index 0000000000..33940adffc
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_mbox_format.pass
@@ -0,0 +1,33 @@
1From d12db4cfa913b0e7a4b5bd858d3019acc53ce426 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 30 Aug 2023 12:15:00 -0400
4Subject: [PATCH] selftest-hello: upgrade 1.0 -> 1.1
5
6Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
7---
8 .../{selftest-hello_1.0.bb => selftest-hello_1.1.bb} | 3 ++-
9 1 file changed, 2 insertions(+), 1 deletion(-)
10 rename meta-selftest/recipes-test/selftest-hello/{selftest-hello_1.0.bb => selftest-hello_1.1.bb} (88%)
11
12diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
13similarity index 88%
14rename from meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
15rename to meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
16index 547587bef4..acc388ec2c 100644
17--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
18+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
19@@ -1,3 +1,4 @@
20+SUMMARY = "Hello!"
21 DESCRIPTION = "Simple helloworld application -- selftest variant"
22 SECTION = "examples"
23 LICENSE = "MIT"
24@@ -16,4 +17,4 @@ do_install() {
25 install -m 0755 helloworld ${D}${bindir}
26 }
27
28-BBCLASSEXTEND = "native nativesdk"
29\ No newline at end of file
30+BBCLASSEXTEND = "native nativesdk"
31--
322.41.0
33
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.1.skip b/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.1.skip
new file mode 100644
index 0000000000..2a72457878
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.1.skip
@@ -0,0 +1,35 @@
1From d12db4cfa913b0e7a4b5bd858d3019acc53ce426 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 30 Aug 2023 12:15:00 -0400
4Subject: [PATCH] selftest-hello: upgrade 1.0 -> 1.1
5
6This file should pass the test_series_merge_on_head test.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../{selftest-hello_1.0.bb => selftest-hello_1.1.bb} | 3 ++-
11 1 file changed, 2 insertions(+), 1 deletion(-)
12 rename meta-selftest/recipes-test/selftest-hello/{selftest-hello_1.0.bb => selftest-hello_1.1.bb} (88%)
13
14diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
15similarity index 88%
16rename from meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17rename to meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
18index 547587bef4..acc388ec2c 100644
19--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
20+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.1.bb
21@@ -1,3 +1,4 @@
22+SUMMARY = "Hello!"
23 DESCRIPTION = "Simple helloworld application -- selftest variant"
24 SECTION = "examples"
25 LICENSE = "MIT"
26@@ -16,4 +17,4 @@ do_install() {
27 install -m 0755 helloworld ${D}${bindir}
28 }
29
30-BBCLASSEXTEND = "native nativesdk"
31\ No newline at end of file
32+BBCLASSEXTEND = "native nativesdk"
33--
342.41.0
35
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.2.skip b/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.2.skip
new file mode 100644
index 0000000000..49bd1f8ede
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_series_merge_on_head.2.skip
@@ -0,0 +1,41 @@
1From 55208224f492af0ad929555ffc9b95ff1d301c5f Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Thu, 17 Aug 2023 15:02:38 -0400
4Subject: [PATCH] python3-dtc: upgrade 1.6.1 -> 1.7.0
5
6Changelog: https://kernel.googlesource.com/pub/scm/utils/dtc/dtc/+log/039a99414e778332d8f9c04cbd3072e1dcc62798
7
8Remove custom PV from the recipe since the relevant functionality is in
91.7.0:
10
11[tgamblin@megalith dtc]$ git tag --contains c001fc01a43e7a06447c06ea3d50bd60641322b8
12v1.7.0
13
14Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
15Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
16---
17 .../python/{python3-dtc_1.6.1.bb => python3-dtc_1.7.0.bb} | 3 +--
18 1 file changed, 1 insertion(+), 2 deletions(-)
19 rename meta/recipes-devtools/python/{python3-dtc_1.6.1.bb => python3-dtc_1.7.0.bb} (92%)
20
21diff --git a/meta/recipes-devtools/python/python3-dtc_1.6.1.bb b/meta/recipes-devtools/python/python3-dtc_1.7.0.bb
22similarity index 92%
23rename from meta/recipes-devtools/python/python3-dtc_1.6.1.bb
24rename to meta/recipes-devtools/python/python3-dtc_1.7.0.bb
25index 95ab0be474..85e48d4694 100644
26--- a/meta/recipes-devtools/python/python3-dtc_1.6.1.bb
27+++ b/meta/recipes-devtools/python/python3-dtc_1.7.0.bb
28@@ -14,9 +14,8 @@ UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
29
30 LIC_FILES_CHKSUM = "file://pylibfdt/libfdt.i;beginline=1;endline=6;md5=afda088c974174a29108c8d80b5dce90"
31
32-SRCREV = "c001fc01a43e7a06447c06ea3d50bd60641322b8"
33+SRCREV = "039a99414e778332d8f9c04cbd3072e1dcc62798"
34
35-PV = "1.6.1+git"
36 S = "${WORKDIR}/git"
37
38 PYPA_WHEEL = "${S}/dist/libfdt-1.6.2*.whl"
39--
402.41.0
41
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.fail
new file mode 100644
index 0000000000..cdbbc61b61
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.fail
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello% fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.pass
new file mode 100644
index 0000000000..ef6017037c
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_format.pass
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.fail
new file mode 100644
index 0000000000..629e78540b
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.fail
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: this is a very long commit shortlog with way too many words included in it to pass the test
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://0001-Fix-CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.pass
new file mode 100644
index 0000000000..ef6017037c
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_shortlog_length.pass
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.1.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.1.fail
new file mode 100644
index 0000000000..35d92aeed7
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.1.fail
@@ -0,0 +1,71 @@
1From 14d72f6973270f78455a8628143f2cff90e8f41e Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8---
9 .../selftest-hello/files/CVE-1234-56789.patch | 27 +++++++++++++++++++
10 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
11 2 files changed, 31 insertions(+), 2 deletions(-)
12 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
13
14diff --git a/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
15new file mode 100644
16index 0000000000..869cfb6fe5
17--- /dev/null
18+++ b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
19@@ -0,0 +1,27 @@
20+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
21+From: Trevor Gamblin <tgamblin@baylibre.com>
22+Date: Tue, 29 Aug 2023 14:08:20 -0400
23+Subject: [PATCH] Fix CVE-NOT-REAL
24+
25+CVE: CVE-1234-56789
26+Upstream-Status: Backport(http://example.com/example)
27+
28+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
29+---
30+ strlen.c | 1 +
31+ 1 file changed, 1 insertion(+)
32+
33+diff --git a/strlen.c b/strlen.c
34+index 1788f38..83d7918 100644
35+--- a/strlen.c
36++++ b/strlen.c
37+@@ -8,6 +8,7 @@ int main() {
38+
39+ printf("%d\n", str_len(string1));
40+ printf("%d\n", str_len(string2));
41++ printf("CVE FIXED!!!\n");
42+
43+ return 0;
44+ }
45+--
46+2.41.0
47diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
48index 547587bef4..76975a6729 100644
49--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
51@@ -3,7 +3,9 @@ SECTION = "examples"
52 LICENSE = "MIT"
53 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
54
55-SRC_URI = "file://helloworld.c"
56+SRC_URI = "file://helloworld.c \
57+ file://CVE-1234-56789.patch \
58+ "
59
60 S = "${WORKDIR}"
61
62@@ -16,4 +18,4 @@ do_install() {
63 install -m 0755 helloworld ${D}${bindir}
64 }
65
66-BBCLASSEXTEND = "native nativesdk"
67\ No newline at end of file
68+BBCLASSEXTEND = "native nativesdk"
69--
702.41.0
71
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.2.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.2.fail
new file mode 100644
index 0000000000..68f38dee06
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.2.fail
@@ -0,0 +1,72 @@
1From 14d72f6973270f78455a8628143f2cff90e8f41e Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Approved: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../selftest-hello/files/CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..869cfb6fe5
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
49index 547587bef4..76975a6729 100644
50--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
51+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52@@ -3,7 +3,9 @@ SECTION = "examples"
53 LICENSE = "MIT"
54 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
55
56-SRC_URI = "file://helloworld.c"
57+SRC_URI = "file://helloworld.c \
58+ file://CVE-1234-56789.patch \
59+ "
60
61 S = "${WORKDIR}"
62
63@@ -16,4 +18,4 @@ do_install() {
64 install -m 0755 helloworld ${D}${bindir}
65 }
66
67-BBCLASSEXTEND = "native nativesdk"
68\ No newline at end of file
69+BBCLASSEXTEND = "native nativesdk"
70--
712.41.0
72
diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.pass b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.pass
new file mode 100644
index 0000000000..ea34c76f0d
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMbox.test_signed_off_by_presence.pass
@@ -0,0 +1,72 @@
1From 14d72f6973270f78455a8628143f2cff90e8f41e Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../selftest-hello/files/CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..869cfb6fe5
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
49index 547587bef4..76975a6729 100644
50--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
51+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52@@ -3,7 +3,9 @@ SECTION = "examples"
53 LICENSE = "MIT"
54 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
55
56-SRC_URI = "file://helloworld.c"
57+SRC_URI = "file://helloworld.c \
58+ file://CVE-1234-56789.patch \
59+ "
60
61 S = "${WORKDIR}"
62
63@@ -16,4 +18,4 @@ do_install() {
64 install -m 0755 helloworld ${D}${bindir}
65 }
66
67-BBCLASSEXTEND = "native nativesdk"
68\ No newline at end of file
69+BBCLASSEXTEND = "native nativesdk"
70--
712.41.0
72
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.fail b/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.fail
new file mode 100644
index 0000000000..3574463ade
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.fail
@@ -0,0 +1,30 @@
1From c4ca86b9cca3643097db0328e2f34dccffbba309 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Simone=20Wei=C3=9F?= <simone.p.weiss@posteo.com>
3Date: Sat, 10 Feb 2024 13:18:44 +0100
4Subject: [PATCH] selftest-hello: add CVE_CHECK_IGNORE
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This should fail the test_cve_tag_format selftest.
10
11Signed-off-by: Simone Weiß <simone.p.weiss@posteo.com>
12---
13 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 3 ++-
14 1 file changed, 2 insertions(+), 1 deletion(-)
15
16diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17index 547587bef4..3ef9b87c34 100644
18--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
19+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
20@@ -16,4 +16,5 @@ do_install() {
21 install -m 0755 helloworld ${D}${bindir}
22 }
23
24-BBCLASSEXTEND = "native nativesdk"
25\ No newline at end of file
26+CVE_CHECK_IGNORE = "CVE-2024-12345"
27+BBCLASSEXTEND = "native nativesdk"
28--
292.39.2
30
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.pass b/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.pass
new file mode 100644
index 0000000000..10f942a6eb
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_cve_check_ignore.pass
@@ -0,0 +1,31 @@
1From 7d4d3fee0c7111830ee9b2b049ae3ce265b26030 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Simone=20Wei=C3=9F?= <simone.p.weiss@posteo.com>
3Date: Sat, 10 Feb 2024 13:23:56 +0100
4Subject: [PATCH] selftest-hello: add CVE_STATUS
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This should pass the test_cve_tag_format selftest.
10
11Signed-off-by: Simone Weiß <simone.p.weiss@posteo.com>
12---
13 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 4 +++-
14 1 file changed, 3 insertions(+), 1 deletion(-)
15
16diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17index 547587bef4..9908b3b417 100644
18--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
19+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
20@@ -16,4 +16,6 @@ do_install() {
21 install -m 0755 helloworld ${D}${bindir}
22 }
23
24-BBCLASSEXTEND = "native nativesdk"
25\ No newline at end of file
26+CVE_STATUS[CVE-2024-12345] = "not-applicable-platform: Issue only applies on Windows"
27+
28+BBCLASSEXTEND = "native nativesdk"
29--
302.39.2
31
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.fail b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.fail
new file mode 100644
index 0000000000..ab6c52c374
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.fail
@@ -0,0 +1,37 @@
1From f89919ea86d38404dd621521680a0162367bb965 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 6 Sep 2023 09:09:27 -0400
4Subject: [PATCH] selftest-hello: update LIC_FILES_CHKSUM
5
6This test should fail the
7test_metadata_lic_files_chksum.LicFilesChkSum.test_lic_files_chksum_modified_not_mentioned
8test.
9
10Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
11---
12 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 4 ++--
13 1 file changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
16index 547587bef4..65dda40aba 100644
17--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
18+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
19@@ -1,7 +1,7 @@
20 DESCRIPTION = "Simple helloworld application -- selftest variant"
21 SECTION = "examples"
22 LICENSE = "MIT"
23-LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
24+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f303"
25
26 SRC_URI = "file://helloworld.c"
27
28@@ -16,4 +16,4 @@ do_install() {
29 install -m 0755 helloworld ${D}${bindir}
30 }
31
32-BBCLASSEXTEND = "native nativesdk"
33\ No newline at end of file
34+BBCLASSEXTEND = "native nativesdk"
35--
362.41.0
37
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.pass b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.pass
new file mode 100644
index 0000000000..99d9f144da
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_modified_not_mentioned.pass
@@ -0,0 +1,39 @@
1From f89919ea86d38404dd621521680a0162367bb965 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Wed, 6 Sep 2023 09:09:27 -0400
4Subject: [PATCH] selftest-hello: update LIC_FILES_CHKSUM
5
6License-Update: Fix checksum
7
8This test should pass the
9test_metadata_lic_files_chksum.LicFilesChkSum.test_lic_files_chksum_modified_not_mentioned
10test.
11
12Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
13---
14 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
18index 547587bef4..65dda40aba 100644
19--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
20+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
21@@ -1,7 +1,7 @@
22 DESCRIPTION = "Simple helloworld application -- selftest variant"
23 SECTION = "examples"
24 LICENSE = "MIT"
25-LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
26+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f303"
27
28 SRC_URI = "file://helloworld.c"
29
30@@ -16,4 +16,4 @@ do_install() {
31 install -m 0755 helloworld ${D}${bindir}
32 }
33
34-BBCLASSEXTEND = "native nativesdk"
35\ No newline at end of file
36+BBCLASSEXTEND = "native nativesdk"
37--
382.41.0
39
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.fail b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.fail
new file mode 100644
index 0000000000..e14d644bb2
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.fail
@@ -0,0 +1,53 @@
1From 66430e7c6fbd5187b66560909a510e136fed91c0 Mon Sep 17 00:00:00 2001
2From: Daniela Plascencia <daniela.plascencia@linux.intel.com>
3Date: Thu, 23 Feb 2017 10:34:27 -0600
4Subject: [PATCH] meta: adding hello-yocto recipe
5
6This is a sample recipe
7
8Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com>
9---
10 .../hello-world/hello-world/hello_world.c | 5 +++++
11 .../hello-world/hello-world_1.0.bb | 18 ++++++++++++++++++
12 2 files changed, 23 insertions(+)
13 create mode 100644 meta/recipes-devtools/hello-world/hello-world/hello_world.c
14 create mode 100644 meta/recipes-devtools/hello-world/hello-world_1.0.bb
15
16diff --git a/meta/recipes-devtools/hello-world/hello-world/hello_world.c b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
17new file mode 100644
18index 0000000000..0d59f57d4c
19--- /dev/null
20+++ b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
21@@ -0,0 +1,5 @@
22+#include <stdio.h>
23+
24+int main(){
25+ printf("Hello World\n");
26+}
27diff --git a/meta/recipes-devtools/hello-world/hello-world_1.0.bb b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
28new file mode 100644
29index 0000000000..3c990c108a
30--- /dev/null
31+++ b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
32@@ -0,0 +1,18 @@
33+SUMMARY = "This is a sample summary"
34+DESCRIPTION = "This is a sample description"
35+HOMEPAGE = "https://sample.com/this-is-a-sample"
36+LICENSE = "MIT"
37+
38+SRC_URI += "file://hello_world.c"
39+
40+SRC_URI[md5sum] = "4ee21e9dcc9b5b6012c23038734e1632"
41+SRC_URI[sha256sum] = "edef2bbde0fbf0d88232782a0eded323f483a0519d6fde9a3b1809056fd35f3e"
42+
43+do_compile(){
44+ ${CC} -o hello_world ../hello_world.c
45+}
46+
47+do_install(){
48+ install -d ${D}${bindir}
49+ install -m +x hello_world ${D}${bindir}/hello_world
50+}
51--
522.41.0
53
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.pass b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.pass
new file mode 100644
index 0000000000..b8da16dfe5
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_lic_files_chksum_presence.pass
@@ -0,0 +1,54 @@
1From 5144d2ba1aa763312c047dd5f8901368cff79da6 Mon Sep 17 00:00:00 2001
2From: Daniela Plascencia <daniela.plascencia@linux.intel.com>
3Date: Thu, 23 Feb 2017 10:34:27 -0600
4Subject: [PATCH] meta: adding hello-yocto recipe
5
6This is a sample recipe
7
8Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com>
9---
10 .../hello-world/hello-world/hello_world.c | 5 +++++
11 .../hello-world/hello-world_1.0.bb | 19 +++++++++++++++++++
12 2 files changed, 24 insertions(+)
13 create mode 100644 meta/recipes-devtools/hello-world/hello-world/hello_world.c
14 create mode 100644 meta/recipes-devtools/hello-world/hello-world_1.0.bb
15
16diff --git a/meta/recipes-devtools/hello-world/hello-world/hello_world.c b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
17new file mode 100644
18index 0000000000..0d59f57d4c
19--- /dev/null
20+++ b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
21@@ -0,0 +1,5 @@
22+#include <stdio.h>
23+
24+int main(){
25+ printf("Hello World\n");
26+}
27diff --git a/meta/recipes-devtools/hello-world/hello-world_1.0.bb b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
28new file mode 100644
29index 0000000000..44d888c82a
30--- /dev/null
31+++ b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
32@@ -0,0 +1,19 @@
33+SUMMARY = "This is a sample summary"
34+DESCRIPTION = "This is a sample description"
35+HOMEPAGE = "https://sample.com/this-is-a-sample"
36+LICENSE = "MIT"
37+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
38+
39+SRC_URI += "file://hello_world.c"
40+
41+SRC_URI[md5sum] = "4ee21e9dcc9b5b6012c23038734e1632"
42+SRC_URI[sha256sum] = "edef2bbde0fbf0d88232782a0eded323f483a0519d6fde9a3b1809056fd35f3e"
43+
44+do_compile(){
45+ ${CC} -o hello_world ../hello_world.c
46+}
47+
48+do_install(){
49+ install -d ${D}${bindir}
50+ install -m +x hello_world ${D}${bindir}/hello_world
51+}
52--
532.41.0
54
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.fail b/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.fail
new file mode 100644
index 0000000000..983b6e0c2b
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.fail
@@ -0,0 +1,35 @@
1From 4ab06b5f81455249cd5e89d2cce9863803b5ecb5 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Fri, 8 Sep 2023 14:41:00 -0400
4Subject: [PATCH] selftest-hello: remove helloworld.c
5
6This should fail the test_src_uri_left_files selftest.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 4 +---
11 1 file changed, 1 insertion(+), 3 deletions(-)
12
13diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
14index 547587bef4..f6817f05bc 100644
15--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
16+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
17@@ -3,8 +3,6 @@ SECTION = "examples"
18 LICENSE = "MIT"
19 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
20
21-SRC_URI = "file://helloworld.c"
22-
23 S = "${WORKDIR}"
24
25 do_compile() {
26@@ -16,4 +14,4 @@ do_install() {
27 install -m 0755 helloworld ${D}${bindir}
28 }
29
30-BBCLASSEXTEND = "native nativesdk"
31\ No newline at end of file
32+BBCLASSEXTEND = "native nativesdk"
33--
342.41.0
35
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.pass b/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.pass
new file mode 100644
index 0000000000..1f1a77e581
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_src_uri_left_files.pass
@@ -0,0 +1,51 @@
1From 6c7ac367a873bf827c19b81085c943eace917a99 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Fri, 8 Sep 2023 14:41:00 -0400
4Subject: [PATCH] selftest-hello: remove helloworld.c
5
6This should pass the test_src_uri_left_files selftest.
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../recipes-test/selftest-hello/files/helloworld.c | 8 --------
11 .../recipes-test/selftest-hello/selftest-hello_1.0.bb | 4 +---
12 2 files changed, 1 insertion(+), 11 deletions(-)
13 delete mode 100644 meta-selftest/recipes-test/selftest-hello/files/helloworld.c
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/helloworld.c b/meta-selftest/recipes-test/selftest-hello/files/helloworld.c
16deleted file mode 100644
17index fc7169b7b8..0000000000
18--- a/meta-selftest/recipes-test/selftest-hello/files/helloworld.c
19+++ /dev/null
20@@ -1,8 +0,0 @@
21-#include <stdio.h>
22-
23-int main(void)
24-{
25- printf("Hello world!\n");
26-
27- return 0;
28-}
29diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
30index 547587bef4..f6817f05bc 100644
31--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
32+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
33@@ -3,8 +3,6 @@ SECTION = "examples"
34 LICENSE = "MIT"
35 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
36
37-SRC_URI = "file://helloworld.c"
38-
39 S = "${WORKDIR}"
40
41 do_compile() {
42@@ -16,4 +14,4 @@ do_install() {
43 install -m 0755 helloworld ${D}${bindir}
44 }
45
46-BBCLASSEXTEND = "native nativesdk"
47\ No newline at end of file
48+BBCLASSEXTEND = "native nativesdk"
49--
502.41.0
51
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.fail b/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.fail
new file mode 100644
index 0000000000..2d2b4e683d
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.fail
@@ -0,0 +1,46 @@
1From e29da5faa74409be394caa09d9f3b7b60f8592b9 Mon Sep 17 00:00:00 2001
2From: Daniela Plascencia <daniela.plascencia@linux.intel.com>
3Date: Thu, 23 Feb 2017 10:34:27 -0600
4Subject: [PATCH] meta: adding hello-yocto recipe
5
6This is a sample recipe
7
8Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com>
9---
10 meta/recipes-devtools/hello-world/hello-world/hello_world.c | 5 +++++
11 meta/recipes-devtools/hello-world/hello-world_1.0.bb | 12 ++++++++++++
12 2 files changed, 17 insertions(+)
13 create mode 100644 meta/recipes-devtools/hello-world/hello-world/hello_world.c
14 create mode 100644 meta/recipes-devtools/hello-world/hello-world_1.0.bb
15
16diff --git a/meta/recipes-devtools/hello-world/hello-world/hello_world.c b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
17new file mode 100644
18index 0000000000..0d59f57d4c
19--- /dev/null
20+++ b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
21@@ -0,0 +1,5 @@
22+#include <stdio.h>
23+
24+int main(){
25+ printf("Hello World\n");
26+}
27diff --git a/meta/recipes-devtools/hello-world/hello-world_1.0.bb b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
28new file mode 100644
29index 0000000000..c4e1359217
30--- /dev/null
31+++ b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
32@@ -0,0 +1,12 @@
33+LICENSE = "CLOSED"
34+
35+SRC_URI += "file://hello_world.c"
36+
37+do_compile(){
38+ ${CC} -o hello_world ../hello_world.c
39+}
40+
41+do_install(){
42+ install -d ${D}${bindir}
43+ install -m +x hello_world ${D}${bindir}/hello_world
44+}
45--
462.11.0
diff --git a/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.pass b/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.pass
new file mode 100644
index 0000000000..55f0309b3f
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestMetadata.test_summary_presence.pass
@@ -0,0 +1,49 @@
1From 0cd2fed12ce4b7b071edde12aec4481ad7a6f107 Mon Sep 17 00:00:00 2001
2From: Daniela Plascencia <daniela.plascencia@linux.intel.com>
3Date: Thu, 23 Feb 2017 10:34:27 -0600
4Subject: [PATCH] meta: adding hello-yocto recipe
5
6This is a sample recipe
7
8Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com>
9---
10 .../hello-world/hello-world/hello_world.c | 5 +++++
11 meta/recipes-devtools/hello-world/hello-world_1.0.bb | 15 +++++++++++++++
12 2 files changed, 20 insertions(+)
13 create mode 100644 meta/recipes-devtools/hello-world/hello-world/hello_world.c
14 create mode 100644 meta/recipes-devtools/hello-world/hello-world_1.0.bb
15
16diff --git a/meta/recipes-devtools/hello-world/hello-world/hello_world.c b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
17new file mode 100644
18index 0000000000..0d59f57d4c
19--- /dev/null
20+++ b/meta/recipes-devtools/hello-world/hello-world/hello_world.c
21@@ -0,0 +1,5 @@
22+#include <stdio.h>
23+
24+int main(){
25+ printf("Hello World\n");
26+}
27diff --git a/meta/recipes-devtools/hello-world/hello-world_1.0.bb b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
28new file mode 100644
29index 0000000000..c54283eece
30--- /dev/null
31+++ b/meta/recipes-devtools/hello-world/hello-world_1.0.bb
32@@ -0,0 +1,15 @@
33+SUMMARY = "This is a sample summary"
34+DESCRIPTION = "This is a sample description"
35+HOMEPAGE = "https://sample.com/this-is-a-sample"
36+LICENSE = "CLOSED"
37+
38+SRC_URI += "file://hello_world.c"
39+
40+do_compile(){
41+ ${CC} -o hello_world ../hello_world.c
42+}
43+
44+do_install(){
45+ install -d ${D}${bindir}
46+ install -m +x hello_world ${D}${bindir}/hello_world
47+}
48--
492.11.0
diff --git a/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.fail b/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.fail
new file mode 100644
index 0000000000..c763a7506e
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.fail
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-BAD-FORMAT
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-BAD-FORMAT
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.pass b/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.pass
new file mode 100644
index 0000000000..ef6017037c
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestPatch.test_cve_tag_format.pass
@@ -0,0 +1,73 @@
1From 35ccee3cee96fb29514475279248078d88907231 Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../files/0001-Fix-CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..9219b8db62
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/0001-Fix-CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48+
49diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50index 547587bef4..76975a6729 100644
51--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
53@@ -3,7 +3,9 @@ SECTION = "examples"
54 LICENSE = "MIT"
55 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
56
57-SRC_URI = "file://helloworld.c"
58+SRC_URI = "file://helloworld.c \
59+ file://CVE-1234-56789.patch \
60+ "
61
62 S = "${WORKDIR}"
63
64@@ -16,4 +18,4 @@ do_install() {
65 install -m 0755 helloworld ${D}${bindir}
66 }
67
68-BBCLASSEXTEND = "native nativesdk"
69\ No newline at end of file
70+BBCLASSEXTEND = "native nativesdk"
71--
722.41.0
73
diff --git a/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.fail b/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.fail
new file mode 100644
index 0000000000..ce8bf7b7d1
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.fail
@@ -0,0 +1,71 @@
1From 5a2d0ac780a0f4c046fb1a3c3463d3e726f191cb Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../selftest-hello/files/CVE-1234-56789.patch | 26 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 30 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..92a5b65a53
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
20@@ -0,0 +1,26 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+---
30+ strlen.c | 1 +
31+ 1 file changed, 1 insertion(+)
32+
33+diff --git a/strlen.c b/strlen.c
34+index 1788f38..83d7918 100644
35+--- a/strlen.c
36++++ b/strlen.c
37+@@ -8,6 +8,7 @@ int main() {
38+
39+ printf("%d\n", str_len(string1));
40+ printf("%d\n", str_len(string2));
41++ printf("CVE FIXED!!!\n");
42+
43+ return 0;
44+ }
45+--
46+2.41.0
47diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
48index 547587bef4..76975a6729 100644
49--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
50+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
51@@ -3,7 +3,9 @@ SECTION = "examples"
52 LICENSE = "MIT"
53 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
54
55-SRC_URI = "file://helloworld.c"
56+SRC_URI = "file://helloworld.c \
57+ file://CVE-1234-56789.patch \
58+ "
59
60 S = "${WORKDIR}"
61
62@@ -16,4 +18,4 @@ do_install() {
63 install -m 0755 helloworld ${D}${bindir}
64 }
65
66-BBCLASSEXTEND = "native nativesdk"
67\ No newline at end of file
68+BBCLASSEXTEND = "native nativesdk"
69--
702.41.0
71
diff --git a/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.pass b/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.pass
new file mode 100644
index 0000000000..ea34c76f0d
--- /dev/null
+++ b/meta/lib/patchtest/selftest/files/TestPatch.test_signed_off_by_presence.pass
@@ -0,0 +1,72 @@
1From 14d72f6973270f78455a8628143f2cff90e8f41e Mon Sep 17 00:00:00 2001
2From: Trevor Gamblin <tgamblin@baylibre.com>
3Date: Tue, 29 Aug 2023 14:12:27 -0400
4Subject: [PATCH] selftest-hello: fix CVE-1234-56789
5
6CVE: CVE-1234-56789
7
8Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
9---
10 .../selftest-hello/files/CVE-1234-56789.patch | 27 +++++++++++++++++++
11 .../selftest-hello/selftest-hello_1.0.bb | 6 +++--
12 2 files changed, 31 insertions(+), 2 deletions(-)
13 create mode 100644 meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
14
15diff --git a/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
16new file mode 100644
17index 0000000000..869cfb6fe5
18--- /dev/null
19+++ b/meta-selftest/recipes-test/selftest-hello/files/CVE-1234-56789.patch
20@@ -0,0 +1,27 @@
21+From b26a31186e6ee2eb1f506d5f2f9394d327a0df2f Mon Sep 17 00:00:00 2001
22+From: Trevor Gamblin <tgamblin@baylibre.com>
23+Date: Tue, 29 Aug 2023 14:08:20 -0400
24+Subject: [PATCH] Fix CVE-NOT-REAL
25+
26+CVE: CVE-1234-56789
27+Upstream-Status: Backport(http://example.com/example)
28+
29+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
30+---
31+ strlen.c | 1 +
32+ 1 file changed, 1 insertion(+)
33+
34+diff --git a/strlen.c b/strlen.c
35+index 1788f38..83d7918 100644
36+--- a/strlen.c
37++++ b/strlen.c
38+@@ -8,6 +8,7 @@ int main() {
39+
40+ printf("%d\n", str_len(string1));
41+ printf("%d\n", str_len(string2));
42++ printf("CVE FIXED!!!\n");
43+
44+ return 0;
45+ }
46+--
47+2.41.0
48diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
49index 547587bef4..76975a6729 100644
50--- a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
51+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
52@@ -3,7 +3,9 @@ SECTION = "examples"
53 LICENSE = "MIT"
54 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
55
56-SRC_URI = "file://helloworld.c"
57+SRC_URI = "file://helloworld.c \
58+ file://CVE-1234-56789.patch \
59+ "
60
61 S = "${WORKDIR}"
62
63@@ -16,4 +18,4 @@ do_install() {
64 install -m 0755 helloworld ${D}${bindir}
65 }
66
67-BBCLASSEXTEND = "native nativesdk"
68\ No newline at end of file
69+BBCLASSEXTEND = "native nativesdk"
70--
712.41.0
72
diff --git a/meta/lib/patchtest/selftest/selftest b/meta/lib/patchtest/selftest/selftest
new file mode 100755
index 0000000000..6fad50ce61
--- /dev/null
+++ b/meta/lib/patchtest/selftest/selftest
@@ -0,0 +1,94 @@
1#!/usr/bin/env python3
2
3# Test every patch from files folder and output error on failure
4#
5# Copyright (C) 2016 Intel Corporation
6#
7# SPDX-License-Identifier: GPL-2.0-only
8
9import os
10import subprocess
11import sys
12
13currentdir = os.path.dirname(os.path.abspath(__file__))
14patchesdir = os.path.join(currentdir, 'files')
15topdir = os.path.dirname(currentdir)
16parentdir = os.path.dirname(topdir)
17
18# path to the repo root
19repodir = os.path.dirname(os.path.dirname(parentdir))
20
21def print_results(passcount, failcount, skipcount, xpasscount, xfailcount, xskipcount, errorcount):
22 total = passcount + skipcount + failcount + xpasscount + xfailcount + xskipcount + errorcount
23 print("============================================================================")
24 print("Testsuite summary for %s" % os.path.basename(topdir))
25 print("============================================================================")
26 print("# TOTAL: %s" % str(total))
27 print("# XPASS: %s" % str(xpasscount))
28 print("# XFAIL: %s" % str(xfailcount))
29 print("# XSKIP: %s" % str(xskipcount))
30 print("# PASS: %s" % str(passcount))
31 print("# FAIL: %s" % str(failcount))
32 print("# SKIP: %s" % str(skipcount))
33 print("# ERROR: %s" % str(errorcount))
34 print("============================================================================")
35
36# Once the tests are in oe-core, we can remove the testdir param and use os.path.dirname to get relative paths
37def test(root, patch):
38 res = True
39 patchpath = os.path.abspath(os.path.join(root, patch))
40
41 cmd = 'patchtest --repodir %s --testdir %s/tests --patch %s' % (repodir, topdir, patchpath)
42 results = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
43
44 return results
45
46if __name__ == '__main__':
47 passcount = 0
48 failcount = 0
49 skipcount = 0
50 xpasscount = 0
51 xfailcount = 0
52 xskipcount = 0
53 errorcount = 0
54
55 results = None
56
57 for root, dirs, patches in os.walk(patchesdir):
58 for patch in patches:
59 results = test(root, patch)
60
61 a = patch.split('.')
62 klass, testname = a[0], a[1]
63 expected_result = a[-1]
64 testid = ".%s.%s" % (klass,testname)
65
66 for resultline in results.splitlines():
67 if testid in resultline:
68 result, _ = resultline.split(':', 1)
69
70 if expected_result.upper() == "FAIL" and result.upper() == "FAIL":
71 xfailcount = xfailcount + 1
72 print("XFAIL: %s (file: %s)" % (testid.strip("."), os.path.basename(patch)))
73 elif expected_result.upper() == "PASS" and result.upper() == "PASS":
74 xpasscount = xpasscount + 1
75 print("XPASS: %s (file: %s)" % (testid.strip("."), os.path.basename(patch)))
76 elif expected_result.upper() == "SKIP" and result.upper() == "SKIP":
77 xskipcount = xskipcount + 1
78 print("XSKIP: %s (file: %s)" % (testid.strip("."), os.path.basename(patch)))
79 else:
80 print("%s: %s (%s)" % (result.upper(), testid.strip("."), os.path.basename(patch)))
81 if result.upper() == "PASS":
82 passcount = passcount + 1
83 elif result.upper() == "FAIL":
84 failcount = failcount + 1
85 elif result.upper() == "SKIP":
86 skipcount = skipcount + 1
87 else:
88 print("Bad result on test %s against %s" % (testid.strip("."), os.path.basename(patch)))
89 errorcount = errorcount + 1
90 break
91 else:
92 print ("No test for=%s" % patch)
93
94 print_results(passcount, failcount, skipcount, xpasscount, xfailcount, xskipcount, errorcount)
diff --git a/meta/lib/patchtest/tests/__init__.py b/meta/lib/patchtest/tests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/meta/lib/patchtest/tests/__init__.py
diff --git a/meta/lib/patchtest/tests/base.py b/meta/lib/patchtest/tests/base.py
new file mode 100644
index 0000000000..424e61b5be
--- /dev/null
+++ b/meta/lib/patchtest/tests/base.py
@@ -0,0 +1,239 @@
1# Base class to be used by all test cases defined in the suite
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import unittest
8import logging
9import json
10import unidiff
11from data import PatchTestInput
12import mailbox
13import collections
14import sys
15import os
16import re
17
18sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pyparsing'))
19
20logger = logging.getLogger('patchtest')
21debug=logger.debug
22info=logger.info
23warn=logger.warn
24error=logger.error
25
26Commit = collections.namedtuple('Commit', ['author', 'subject', 'commit_message', 'shortlog', 'payload'])
27
28class PatchtestOEError(Exception):
29 """Exception for handling patchtest-oe errors"""
30 def __init__(self, message, exitcode=1):
31 super().__init__(message)
32 self.exitcode = exitcode
33
34class Base(unittest.TestCase):
35 # if unit test fails, fail message will throw at least the following JSON: {"id": <testid>}
36
37 endcommit_messages_regex = re.compile(r'\(From \w+-\w+ rev:|(?<!\S)Signed-off-by|(?<!\S)---\n')
38 patchmetadata_regex = re.compile(r'-{3} \S+|\+{3} \S+|@{2} -\d+,\d+ \+\d+,\d+ @{2} \S+')
39
40
41 @staticmethod
42 def msg_to_commit(msg):
43 payload = msg.get_payload()
44 return Commit(subject=msg['subject'].replace('\n', ' ').replace(' ', ' '),
45 author=msg.get('From'),
46 shortlog=Base.shortlog(msg['subject']),
47 commit_message=Base.commit_message(payload),
48 payload=payload)
49
50 @staticmethod
51 def commit_message(payload):
52 commit_message = payload.__str__()
53 match = Base.endcommit_messages_regex.search(payload)
54 if match:
55 commit_message = payload[:match.start()]
56 return commit_message
57
58 @staticmethod
59 def shortlog(shlog):
60 # remove possible prefix (between brackets) before colon
61 start = shlog.find(']', 0, shlog.find(':'))
62 # remove also newlines and spaces at both sides
63 return shlog[start + 1:].replace('\n', '').strip()
64
65 @classmethod
66 def setUpClass(cls):
67
68 # General objects: mailbox.mbox and patchset
69 cls.mbox = mailbox.mbox(PatchTestInput.repo.patch)
70
71 # Patch may be malformed, so try parsing it
72 cls.unidiff_parse_error = ''
73 cls.patchset = None
74 try:
75 cls.patchset = unidiff.PatchSet.from_filename(PatchTestInput.repo.patch, encoding=u'UTF-8')
76 except unidiff.UnidiffParseError as upe:
77 cls.patchset = []
78 cls.unidiff_parse_error = str(upe)
79
80 # Easy to iterate list of commits
81 cls.commits = []
82 for msg in cls.mbox:
83 if msg['subject'] and msg.get_payload():
84 cls.commits.append(Base.msg_to_commit(msg))
85
86 cls.setUpClassLocal()
87
88 @classmethod
89 def tearDownClass(cls):
90 cls.tearDownClassLocal()
91
92 @classmethod
93 def setUpClassLocal(cls):
94 pass
95
96 @classmethod
97 def tearDownClassLocal(cls):
98 pass
99
100 def fail(self, issue, fix=None, commit=None, data=None):
101 """ Convert to a JSON string failure data"""
102 value = {'id': self.id(),
103 'issue': issue}
104
105 if fix:
106 value['fix'] = fix
107 if commit:
108 value['commit'] = {'subject': commit.subject,
109 'shortlog': commit.shortlog}
110
111 # extend return value with other useful info
112 if data:
113 value['data'] = data
114
115 return super(Base, self).fail(json.dumps(value))
116
117 def skip(self, issue, data=None):
118 """ Convert the skip string to JSON"""
119 value = {'id': self.id(),
120 'issue': issue}
121
122 # extend return value with other useful info
123 if data:
124 value['data'] = data
125
126 return super(Base, self).skipTest(json.dumps(value))
127
128 def shortid(self):
129 return self.id().split('.')[-1]
130
131 def __str__(self):
132 return json.dumps({'id': self.id()})
133
134class Metadata(Base):
135 @classmethod
136 def setUpClassLocal(cls):
137 cls.tinfoil = cls.setup_tinfoil()
138
139 # get info about added/modified/remove recipes
140 cls.added, cls.modified, cls.removed = cls.get_metadata_stats(cls.patchset)
141
142 @classmethod
143 def tearDownClassLocal(cls):
144 cls.tinfoil.shutdown()
145
146 @classmethod
147 def setup_tinfoil(cls, config_only=False):
148 """Initialize tinfoil api from bitbake"""
149
150 # import relevant libraries
151 try:
152 scripts_path = os.path.join(PatchTestInput.repodir, 'scripts', 'lib')
153 if scripts_path not in sys.path:
154 sys.path.insert(0, scripts_path)
155 import scriptpath
156 scriptpath.add_bitbake_lib_path()
157 import bb.tinfoil
158 except ImportError:
159 raise PatchtestOEError('Could not import tinfoil module')
160
161 orig_cwd = os.path.abspath(os.curdir)
162
163 # Load tinfoil
164 tinfoil = None
165 try:
166 builddir = os.environ.get('BUILDDIR')
167 if not builddir:
168 logger.warn('Bitbake environment not loaded?')
169 return tinfoil
170 os.chdir(builddir)
171 tinfoil = bb.tinfoil.Tinfoil()
172 tinfoil.prepare(config_only=config_only)
173 except bb.tinfoil.TinfoilUIException as te:
174 if tinfoil:
175 tinfoil.shutdown()
176 raise PatchtestOEError('Could not prepare properly tinfoil (TinfoilUIException)')
177 except Exception as e:
178 if tinfoil:
179 tinfoil.shutdown()
180 raise e
181 finally:
182 os.chdir(orig_cwd)
183
184 return tinfoil
185
186 @classmethod
187 def get_metadata_stats(cls, patchset):
188 """Get lists of added, modified and removed metadata files"""
189
190 def find_pn(data, path):
191 """Find the PN from data"""
192 pn = None
193 pn_native = None
194 for _path, _pn in data:
195 if path in _path:
196 if 'native' in _pn:
197 # store the native PN but look for the non-native one first
198 pn_native = _pn
199 else:
200 pn = _pn
201 break
202 else:
203 # sent the native PN if found previously
204 if pn_native:
205 return pn_native
206
207 # on renames (usually upgrades), we need to check (FILE) base names
208 # because the unidiff library does not provided the new filename, just the modified one
209 # and tinfoil datastore, once the patch is merged, will contain the new filename
210 path_basename = path.split('_')[0]
211 for _path, _pn in data:
212 _path_basename = _path.split('_')[0]
213 if path_basename == _path_basename:
214 pn = _pn
215 return pn
216
217 if not cls.tinfoil:
218 cls.tinfoil = cls.setup_tinfoil()
219
220 added_paths, modified_paths, removed_paths = [], [], []
221 added, modified, removed = [], [], []
222
223 # get metadata filename additions, modification and removals
224 for patch in patchset:
225 if patch.path.endswith('.bb') or patch.path.endswith('.bbappend') or patch.path.endswith('.inc'):
226 if patch.is_added_file:
227 added_paths.append(os.path.join(os.path.abspath(PatchTestInput.repodir), patch.path))
228 elif patch.is_modified_file:
229 modified_paths.append(os.path.join(os.path.abspath(PatchTestInput.repodir), patch.path))
230 elif patch.is_removed_file:
231 removed_paths.append(os.path.join(os.path.abspath(PatchTestInput.repodir), patch.path))
232
233 data = cls.tinfoil.cooker.recipecaches[''].pkg_fn.items()
234
235 added = [find_pn(data,path) for path in added_paths]
236 modified = [find_pn(data,path) for path in modified_paths]
237 removed = [find_pn(data,path) for path in removed_paths]
238
239 return [a for a in added if a], [m for m in modified if m], [r for r in removed if r]
diff --git a/meta/lib/patchtest/tests/pyparsing/common.py b/meta/lib/patchtest/tests/pyparsing/common.py
new file mode 100644
index 0000000000..cbce4c38bc
--- /dev/null
+++ b/meta/lib/patchtest/tests/pyparsing/common.py
@@ -0,0 +1,26 @@
1# common pyparsing variables
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import pyparsing
8
9# general
10colon = pyparsing.Literal(":")
11start = pyparsing.LineStart()
12end = pyparsing.LineEnd()
13at = pyparsing.Literal("@")
14lessthan = pyparsing.Literal("<")
15greaterthan = pyparsing.Literal(">")
16opensquare = pyparsing.Literal("[")
17closesquare = pyparsing.Literal("]")
18inappropriate = pyparsing.CaselessLiteral("Inappropriate")
19submitted = pyparsing.CaselessLiteral("Submitted")
20
21# word related
22nestexpr = pyparsing.nestedExpr(opener='[', closer=']')
23inappropriateinfo = pyparsing.Literal("Inappropriate") + nestexpr
24submittedinfo = pyparsing.Literal("Submitted") + nestexpr
25word = pyparsing.Word(pyparsing.alphas)
26worddot = pyparsing.Word(pyparsing.alphas+".")
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py b/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py
new file mode 100644
index 0000000000..f7fb82ec2b
--- /dev/null
+++ b/meta/lib/patchtest/tests/pyparsing/parse_cve_tags.py
@@ -0,0 +1,18 @@
1# signed-off-by pyparsing definition
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7
8import pyparsing
9import common
10
11name = pyparsing.Regex('\S+.*(?= <)')
12username = pyparsing.OneOrMore(common.worddot)
13domain = pyparsing.OneOrMore(common.worddot)
14cve = pyparsing.Regex('CVE\-\d{4}\-\d+')
15cve_mark = pyparsing.Literal("CVE:")
16
17cve_tag = pyparsing.AtLineStart(cve_mark + cve)
18patch_cve_tag = pyparsing.AtLineStart("+" + cve_mark + cve)
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py b/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py
new file mode 100644
index 0000000000..30d3ab35b3
--- /dev/null
+++ b/meta/lib/patchtest/tests/pyparsing/parse_shortlog.py
@@ -0,0 +1,14 @@
1# subject pyparsing definition
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7# NOTE:This is an oversimplified syntax of the mbox's summary
8
9import pyparsing
10import common
11
12target = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables.replace(':','')))
13summary = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables))
14shortlog = common.start + target + common.colon + summary + common.end
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py b/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py
new file mode 100644
index 0000000000..692ebec3ff
--- /dev/null
+++ b/meta/lib/patchtest/tests/pyparsing/parse_signed_off_by.py
@@ -0,0 +1,22 @@
1# signed-off-by pyparsing definition
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7
8import pyparsing
9import common
10
11name = pyparsing.Regex('\S+.*(?= <)')
12username = pyparsing.OneOrMore(common.worddot)
13domain = pyparsing.OneOrMore(common.worddot)
14
15# taken from https://pyparsing-public.wikispaces.com/Helpful+Expressions
16email = pyparsing.Regex(r"(?P<user>[A-Za-z0-9._%+-]+)@(?P<hostname>[A-Za-z0-9.-]+)\.(?P<domain>[A-Za-z]{2,})")
17
18email_enclosed = common.lessthan + email + common.greaterthan
19
20signed_off_by_mark = pyparsing.Literal("Signed-off-by:")
21signed_off_by = pyparsing.AtLineStart(signed_off_by_mark + name + email_enclosed)
22patch_signed_off_by = pyparsing.AtLineStart("+" + signed_off_by_mark + name + email_enclosed)
diff --git a/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py b/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py
new file mode 100644
index 0000000000..bc6c427c4c
--- /dev/null
+++ b/meta/lib/patchtest/tests/pyparsing/parse_upstream_status.py
@@ -0,0 +1,24 @@
1# upstream-status pyparsing definition
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7
8import common
9import pyparsing
10
11upstream_status_literal_valid_status = ["Pending", "Backport", "Denied", "Inappropriate", "Submitted"]
12upstream_status_nonliteral_valid_status = ["Pending", "Backport", "Denied", "Inappropriate [reason]", "Submitted [where]"]
13
14upstream_status_valid_status = pyparsing.Or(
15 [pyparsing.Literal(status) for status in upstream_status_literal_valid_status]
16)
17
18upstream_status_mark = pyparsing.Literal("Upstream-Status")
19inappropriate_status_mark = common.inappropriate
20submitted_status_mark = common.submitted
21
22upstream_status = common.start + upstream_status_mark + common.colon + upstream_status_valid_status
23upstream_status_inappropriate_info = common.start + upstream_status_mark + common.colon + common.inappropriateinfo
24upstream_status_submitted_info = common.start + upstream_status_mark + common.colon + common.submittedinfo
diff --git a/meta/lib/patchtest/tests/test_mbox.py b/meta/lib/patchtest/tests/test_mbox.py
new file mode 100644
index 0000000000..0b623b7d17
--- /dev/null
+++ b/meta/lib/patchtest/tests/test_mbox.py
@@ -0,0 +1,159 @@
1# Checks related to the patch's author
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import base
8import collections
9import parse_shortlog
10import parse_signed_off_by
11import pyparsing
12import subprocess
13from data import PatchTestInput
14
15def headlog():
16 output = subprocess.check_output(
17 "cd %s; git log --pretty='%%h#%%aN#%%cD:#%%s' -1" % PatchTestInput.repodir,
18 universal_newlines=True,
19 shell=True
20 )
21 return output.split('#')
22
23class TestMbox(base.Base):
24
25 auh_email = 'auh@auh.yoctoproject.org'
26
27 invalids = [pyparsing.Regex("^Upgrade Helper.+"),
28 pyparsing.Regex(auh_email),
29 pyparsing.Regex("uh@not\.set"),
30 pyparsing.Regex("\S+@example\.com")]
31
32 rexp_detect = pyparsing.Regex('\[\s?YOCTO.*\]')
33 rexp_validation = pyparsing.Regex('\[(\s?YOCTO\s?#\s?(\d+)\s?,?)+\]')
34 revert_shortlog_regex = pyparsing.Regex('Revert\s+".*"')
35 signoff_prog = parse_signed_off_by.signed_off_by
36 revert_shortlog_regex = pyparsing.Regex('Revert\s+".*"')
37 maxlength = 90
38
39 # base paths of main yocto project sub-projects
40 paths = {
41 'oe-core': ['meta-selftest', 'meta-skeleton', 'meta', 'scripts'],
42 'bitbake': ['bitbake'],
43 'documentation': ['documentation'],
44 'poky': ['meta-poky','meta-yocto-bsp'],
45 'oe': ['meta-gpe', 'meta-gnome', 'meta-efl', 'meta-networking', 'meta-multimedia','meta-initramfs', 'meta-ruby', 'contrib', 'meta-xfce', 'meta-filesystems', 'meta-perl', 'meta-webserver', 'meta-systemd', 'meta-oe', 'meta-python']
46 }
47
48 # scripts folder is a mix of oe-core and poky, most is oe-core code except:
49 poky_scripts = ['scripts/yocto-bsp', 'scripts/yocto-kernel', 'scripts/yocto-layer', 'scripts/lib/bsp']
50
51 Project = collections.namedtuple('Project', ['name', 'listemail', 'gitrepo', 'paths'])
52
53 bitbake = Project(name='Bitbake', listemail='bitbake-devel@lists.openembedded.org', gitrepo='http://git.openembedded.org/bitbake/', paths=paths['bitbake'])
54 doc = Project(name='Documentantion', listemail='yocto@yoctoproject.org', gitrepo='http://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/', paths=paths['documentation'])
55 poky = Project(name='Poky', listemail='poky@yoctoproject.org', gitrepo='http://git.yoctoproject.org/cgit/cgit.cgi/poky/', paths=paths['poky'])
56 oe = Project(name='oe', listemail='openembedded-devel@lists.openembedded.org', gitrepo='http://git.openembedded.org/meta-openembedded/', paths=paths['oe'])
57
58
59 def test_signed_off_by_presence(self):
60 for commit in TestMbox.commits:
61 # skip those patches that revert older commits, these do not required the tag presence
62 if self.revert_shortlog_regex.search_string(commit.shortlog):
63 continue
64 if not self.signoff_prog.search_string(commit.payload):
65 self.fail('Mbox is missing Signed-off-by. Add it manually or with "git commit --amend -s"',
66 commit=commit)
67
68 def test_shortlog_format(self):
69 for commit in TestMbox.commits:
70 shortlog = commit.shortlog
71 if not shortlog.strip():
72 self.skip('Empty shortlog, no reason to execute shortlog format test')
73 else:
74 # no reason to re-check on revert shortlogs
75 if shortlog.startswith('Revert "'):
76 continue
77 try:
78 parse_shortlog.shortlog.parseString(shortlog)
79 except pyparsing.ParseException as pe:
80 self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"',
81 commit=commit)
82
83 def test_shortlog_length(self):
84 for commit in TestMbox.commits:
85 # no reason to re-check on revert shortlogs
86 shortlog = commit.shortlog
87 if shortlog.startswith('Revert "'):
88 continue
89 l = len(shortlog)
90 if l > self.maxlength:
91 self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (self.maxlength, l),
92 commit=commit)
93
94 def test_series_merge_on_head(self):
95 self.skip("Merge test is disabled for now")
96 if PatchTestInput.repo.branch != "master":
97 self.skip("Skipping merge test since patch is not intended for master branch. Target detected is %s" % PatchTestInput.repo.branch)
98 if not PatchTestInput.repo.ismerged:
99 commithash, author, date, shortlog = headlog()
100 self.fail('Series does not apply on top of target branch %s' % PatchTestInput.repo.branch,
101 data=[('Targeted branch', '%s (currently at %s)' % (PatchTestInput.repo.branch, commithash))])
102
103 def test_target_mailing_list(self):
104 """In case of merge failure, check for other targeted projects"""
105 if PatchTestInput.repo.ismerged:
106 self.skip('Series merged, no reason to check other mailing lists')
107
108 # a meta project may be indicted in the message subject, if this is the case, just fail
109 # TODO: there may be other project with no-meta prefix, we also need to detect these
110 project_regex = pyparsing.Regex("\[(?P<project>meta-.+)\]")
111 for commit in TestMbox.commits:
112 match = project_regex.search_string(commit.subject)
113 if match:
114 self.fail('Series sent to the wrong mailing list or some patches from the series correspond to different mailing lists',
115 commit=commit)
116
117 for patch in self.patchset:
118 folders = patch.path.split('/')
119 base_path = folders[0]
120 for project in [self.bitbake, self.doc, self.oe, self.poky]:
121 if base_path in project.paths:
122 self.fail('Series sent to the wrong mailing list or some patches from the series correspond to different mailing lists',
123 data=[('Suggested ML', '%s [%s]' % (project.listemail, project.gitrepo)),
124 ('Patch\'s path:', patch.path)])
125
126 # check for poky's scripts code
127 if base_path.startswith('scripts'):
128 for poky_file in self.poky_scripts:
129 if patch.path.startswith(poky_file):
130 self.fail('Series sent to the wrong mailing list or some patches from the series correspond to different mailing lists',
131 data=[('Suggested ML', '%s [%s]' % (self.poky.listemail, self.poky.gitrepo)),('Patch\'s path:', patch.path)])
132
133 def test_mbox_format(self):
134 if self.unidiff_parse_error:
135 self.fail('Series has malformed diff lines. Create the series again using git-format-patch and ensure it applies using git am',
136 data=[('Diff line',self.unidiff_parse_error)])
137
138 def test_commit_message_presence(self):
139 for commit in TestMbox.commits:
140 if not commit.commit_message.strip():
141 self.fail('Please include a commit message on your patch explaining the change', commit=commit)
142
143 def test_bugzilla_entry_format(self):
144 for commit in TestMbox.commits:
145 if not self.rexp_detect.search_string(commit.commit_message):
146 self.skip("No bug ID found")
147 elif not self.rexp_validation.search_string(commit.commit_message):
148 self.fail('Bugzilla issue ID is not correctly formatted - specify it with format: "[YOCTO #<bugzilla ID>]"', commit=commit)
149
150 def test_author_valid(self):
151 for commit in self.commits:
152 for invalid in self.invalids:
153 if invalid.search_string(commit.author):
154 self.fail('Invalid author %s. Resend the series with a valid patch author' % commit.author, commit=commit)
155
156 def test_non_auh_upgrade(self):
157 for commit in self.commits:
158 if self.auh_email in commit.payload:
159 self.fail('Invalid author %s. Resend the series with a valid patch author' % self.auh_email, commit=commit)
diff --git a/meta/lib/patchtest/tests/test_metadata.py b/meta/lib/patchtest/tests/test_metadata.py
new file mode 100644
index 0000000000..f5dbcf01ed
--- /dev/null
+++ b/meta/lib/patchtest/tests/test_metadata.py
@@ -0,0 +1,197 @@
1# Checks related to the patch's LIC_FILES_CHKSUM metadata variable
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import base
8import os
9import pyparsing
10from data import PatchTestInput, PatchTestDataStore
11
12class TestMetadata(base.Metadata):
13 metadata_lic = 'LICENSE'
14 invalid_license = 'PATCHTESTINVALID'
15 metadata_chksum = 'LIC_FILES_CHKSUM'
16 license_var = 'LICENSE'
17 closed = 'CLOSED'
18 lictag_re = pyparsing.AtLineStart("License-Update:")
19 lic_chksum_added = pyparsing.AtLineStart("+" + metadata_chksum)
20 lic_chksum_removed = pyparsing.AtLineStart("-" + metadata_chksum)
21 add_mark = pyparsing.Regex('\\+ ')
22 max_length = 200
23 metadata_src_uri = 'SRC_URI'
24 md5sum = 'md5sum'
25 sha256sum = 'sha256sum'
26 git_regex = pyparsing.Regex('^git\\:\\/\\/.*')
27 metadata_summary = 'SUMMARY'
28 cve_check_ignore_var = 'CVE_CHECK_IGNORE'
29 cve_status_var = 'CVE_STATUS'
30
31 def test_license_presence(self):
32 if not self.added:
33 self.skip('No added recipes, skipping test')
34
35 # TODO: this is a workaround so we can parse the recipe not
36 # containing the LICENSE var: add some default license instead
37 # of INVALID into auto.conf, then remove this line at the end
38 auto_conf = os.path.join(os.environ.get('BUILDDIR'), 'conf', 'auto.conf')
39 open_flag = 'w'
40 if os.path.exists(auto_conf):
41 open_flag = 'a'
42 with open(auto_conf, open_flag) as fd:
43 for pn in self.added:
44 fd.write('LICENSE ??= "%s"\n' % self.invalid_license)
45
46 no_license = False
47 for pn in self.added:
48 rd = self.tinfoil.parse_recipe(pn)
49 license = rd.getVar(self.metadata_lic)
50 if license == self.invalid_license:
51 no_license = True
52 break
53
54 # remove auto.conf line or the file itself
55 if open_flag == 'w':
56 os.remove(auto_conf)
57 else:
58 fd = open(auto_conf, 'r')
59 lines = fd.readlines()
60 fd.close()
61 with open(auto_conf, 'w') as fd:
62 fd.write(''.join(lines[:-1]))
63
64 if no_license:
65 self.fail('Recipe does not have the LICENSE field set.')
66
67 def test_lic_files_chksum_presence(self):
68 if not self.added:
69 self.skip('No added recipes, skipping test')
70
71 for pn in self.added:
72 rd = self.tinfoil.parse_recipe(pn)
73 pathname = rd.getVar('FILE')
74 # we are not interested in images
75 if '/images/' in pathname:
76 continue
77 lic_files_chksum = rd.getVar(self.metadata_chksum)
78 if rd.getVar(self.license_var) == self.closed:
79 continue
80 if not lic_files_chksum:
81 self.fail('%s is missing in newly added recipe' % self.metadata_chksum)
82
83 def test_lic_files_chksum_modified_not_mentioned(self):
84 if not self.modified:
85 self.skip('No modified recipes, skipping test')
86
87 for patch in self.patchset:
88 # for the moment, we are just interested in metadata
89 if patch.path.endswith('.patch'):
90 continue
91 payload = str(patch)
92 if (self.lic_chksum_added.search_string(payload) or self.lic_chksum_removed.search_string(payload)):
93 # if any patch on the series contain reference on the metadata, fail
94 for commit in self.commits:
95 if self.lictag_re.search_string(commit.commit_message):
96 break
97 else:
98 self.fail('LIC_FILES_CHKSUM changed without "License-Update:" tag and description in commit message')
99
100 def test_max_line_length(self):
101 for patch in self.patchset:
102 # for the moment, we are just interested in metadata
103 if patch.path.endswith('.patch'):
104 continue
105 payload = str(patch)
106 for line in payload.splitlines():
107 if self.add_mark.search_string(line):
108 current_line_length = len(line[1:])
109 if current_line_length > self.max_length:
110 self.fail('Patch line too long (current length %s, maximum is %s)' % (current_line_length, self.max_length),
111 data=[('Patch', patch.path), ('Line', '%s ...' % line[0:80])])
112
113 def pretest_src_uri_left_files(self):
114 # these tests just make sense on patches that can be merged
115 if not PatchTestInput.repo.canbemerged:
116 self.skip('Patch cannot be merged')
117 if not self.modified:
118 self.skip('No modified recipes, skipping pretest')
119
120 # get the proper metadata values
121 for pn in self.modified:
122 # we are not interested in images
123 if 'core-image' in pn:
124 continue
125 rd = self.tinfoil.parse_recipe(pn)
126 PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata_src_uri, pn)] = rd.getVar(self.metadata_src_uri)
127
128 def test_src_uri_left_files(self):
129 # these tests just make sense on patches that can be merged
130 if not PatchTestInput.repo.canbemerged:
131 self.skip('Patch cannot be merged')
132 if not self.modified:
133 self.skip('No modified recipes, skipping pretest')
134
135 # get the proper metadata values
136 for pn in self.modified:
137 # we are not interested in images
138 if 'core-image' in pn:
139 continue
140 rd = self.tinfoil.parse_recipe(pn)
141 PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata_src_uri, pn)] = rd.getVar(self.metadata_src_uri)
142
143 for pn in self.modified:
144 pretest_src_uri = PatchTestDataStore['pre%s-%s-%s' % (self.shortid(), self.metadata_src_uri, pn)].split()
145 test_src_uri = PatchTestDataStore['%s-%s-%s' % (self.shortid(), self.metadata_src_uri, pn)].split()
146
147 pretest_files = set([os.path.basename(patch) for patch in pretest_src_uri if patch.startswith('file://')])
148 test_files = set([os.path.basename(patch) for patch in test_src_uri if patch.startswith('file://')])
149
150 # check if files were removed
151 if len(test_files) < len(pretest_files):
152
153 # get removals from patchset
154 filesremoved_from_patchset = set()
155 for patch in self.patchset:
156 if patch.is_removed_file:
157 filesremoved_from_patchset.add(os.path.basename(patch.path))
158
159 # get the deleted files from the SRC_URI
160 filesremoved_from_usr_uri = pretest_files - test_files
161
162 # finally, get those patches removed at SRC_URI and not removed from the patchset
163 # TODO: we are not taking into account renames, so test may raise false positives
164 not_removed = filesremoved_from_usr_uri - filesremoved_from_patchset
165 if not_removed:
166 self.fail('Patches not removed from tree. Remove them and amend the submitted mbox',
167 data=[('Patch', f) for f in not_removed])
168
169 def test_summary_presence(self):
170 if not self.added:
171 self.skip('No added recipes, skipping test')
172
173 for pn in self.added:
174 # we are not interested in images
175 if 'core-image' in pn:
176 continue
177 rd = self.tinfoil.parse_recipe(pn)
178 summary = rd.getVar(self.metadata_summary)
179
180 # "${PN} version ${PN}-${PR}" is the default, so fail if default
181 if summary.startswith('%s version' % pn):
182 self.fail('%s is missing in newly added recipe' % self.metadata_summary)
183
184 def test_cve_check_ignore(self):
185 # Skip if we neither modified a recipe or target branches are not
186 # Nanbield and newer. CVE_CHECK_IGNORE was first deprecated in Nanbield.
187 if not self.modified or PatchTestInput.repo.branch == "kirkstone" or PatchTestInput.repo.branch == "dunfell":
188 self.skip('No modified recipes or older target branch, skipping test')
189 for pn in self.modified:
190 # we are not interested in images
191 if 'core-image' in pn:
192 continue
193 rd = self.tinfoil.parse_recipe(pn)
194 cve_check_ignore = rd.getVar(self.cve_check_ignore_var)
195
196 if cve_check_ignore is not None:
197 self.fail('%s is deprecated and should be replaced by %s' % (self.cve_check_ignore_var, self.cve_status_var))
diff --git a/meta/lib/patchtest/tests/test_patch.py b/meta/lib/patchtest/tests/test_patch.py
new file mode 100644
index 0000000000..d7187a0cb1
--- /dev/null
+++ b/meta/lib/patchtest/tests/test_patch.py
@@ -0,0 +1,103 @@
1# Checks related to the patch's CVE lines
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6#
7
8import base
9import os
10import parse_signed_off_by
11import parse_upstream_status
12import pyparsing
13
14class TestPatch(base.Base):
15
16 re_cve_pattern = pyparsing.Regex("CVE\-\d{4}\-\d+")
17 re_cve_payload_tag = pyparsing.Regex("\+CVE:(\s+CVE\-\d{4}\-\d+)+")
18 upstream_status_regex = pyparsing.AtLineStart("+" + "Upstream-Status")
19
20 @classmethod
21 def setUpClassLocal(cls):
22 cls.newpatches = []
23 # get just those relevant patches: new software patches
24 for patch in cls.patchset:
25 if patch.path.endswith('.patch') and patch.is_added_file:
26 cls.newpatches.append(patch)
27
28 cls.mark = str(parse_signed_off_by.signed_off_by_mark).strip('"')
29
30 # match PatchSignedOffBy.mark with '+' preceding it
31 cls.prog = parse_signed_off_by.patch_signed_off_by
32
33 def setUp(self):
34 if self.unidiff_parse_error:
35 self.skip('Parse error %s' % self.unidiff_parse_error)
36
37 self.valid_status = ', '.join(parse_upstream_status.upstream_status_nonliteral_valid_status)
38 self.standard_format = 'Upstream-Status: <Valid status>'
39
40 # we are just interested in series that introduce CVE patches, thus discard other
41 # possibilities: modification to current CVEs, patch directly introduced into the
42 # recipe, upgrades already including the CVE, etc.
43 new_cves = [p for p in self.patchset if p.path.endswith('.patch') and p.is_added_file]
44 if not new_cves:
45 self.skip('No new CVE patches introduced')
46
47 def test_upstream_status_presence_format(self):
48 if not TestPatch.newpatches:
49 self.skip("There are no new software patches, no reason to test Upstream-Status presence/format")
50
51 for newpatch in TestPatch.newpatches:
52 payload = newpatch.__str__()
53 if not self.upstream_status_regex.search_string(payload):
54 self.fail('Added patch file is missing Upstream-Status: <Valid status> in the commit message',
55 data=[('Standard format', self.standard_format), ('Valid status', self.valid_status)])
56 for line in payload.splitlines():
57 if self.patchmetadata_regex.match(line):
58 continue
59 if self.upstream_status_regex.search_string(line):
60 if parse_upstream_status.inappropriate_status_mark.searchString(line):
61 try:
62 parse_upstream_status.upstream_status_inappropriate_info.parseString(line.lstrip('+'))
63 except pyparsing.ParseException as pe:
64 self.fail('Upstream-Status is Inappropriate, but no reason was provided',
65 data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Inappropriate [reason]')])
66 elif parse_upstream_status.submitted_status_mark.searchString(line):
67 try:
68 parse_upstream_status.upstream_status_submitted_info.parseString(line.lstrip('+'))
69 except pyparsing.ParseException as pe:
70 self.fail('Upstream-Status is Submitted, but it is not mentioned where',
71 data=[('Current', pe.pstr), ('Standard format', 'Upstream-Status: Submitted [where]')])
72 else:
73 try:
74 parse_upstream_status.upstream_status.parseString(line.lstrip('+'))
75 except pyparsing.ParseException as pe:
76 self.fail('Upstream-Status is in incorrect format',
77 data=[('Current', pe.pstr), ('Standard format', self.standard_format), ('Valid status', self.valid_status)])
78
79 def test_signed_off_by_presence(self):
80 if not TestPatch.newpatches:
81 self.skip("There are no new software patches, no reason to test %s presence" % PatchSignedOffBy.mark)
82
83 for newpatch in TestPatch.newpatches:
84 payload = newpatch.__str__()
85 for line in payload.splitlines():
86 if self.patchmetadata_regex.match(line):
87 continue
88 if TestPatch.prog.search_string(payload):
89 break
90 else:
91 self.fail('A patch file has been added without a Signed-off-by tag: \'%s\'' % os.path.basename(newpatch.path))
92
93 def test_cve_tag_format(self):
94 for commit in TestPatch.commits:
95 if self.re_cve_pattern.search_string(commit.shortlog) or self.re_cve_pattern.search_string(commit.commit_message):
96 tag_found = False
97 for line in commit.payload.splitlines():
98 if self.re_cve_payload_tag.search_string(line):
99 tag_found = True
100 break
101 if not tag_found:
102 self.fail('Missing or incorrectly formatted CVE tag in patch file. Correct or include the CVE tag in the patch with format: "CVE: CVE-YYYY-XXXX"',
103 commit=commit)
diff --git a/meta/lib/patchtest/tests/test_python_pylint.py b/meta/lib/patchtest/tests/test_python_pylint.py
new file mode 100644
index 0000000000..ef315e591c
--- /dev/null
+++ b/meta/lib/patchtest/tests/test_python_pylint.py
@@ -0,0 +1,65 @@
1# Checks related to the python code done with pylint
2#
3# Copyright (C) 2016 Intel Corporation
4#
5# SPDX-License-Identifier: GPL-2.0-only
6
7import base
8from io import StringIO
9from data import PatchTestInput
10from pylint.reporters.text import TextReporter
11import pylint.lint as lint
12
13
14class PyLint(base.Base):
15 pythonpatches = []
16 pylint_pretest = {}
17 pylint_test = {}
18 pylint_options = " -E --disable='E0611, E1101, F0401, E0602' --msg-template='L:{line} F:{module} I:{msg}'"
19
20 @classmethod
21 def setUpClassLocal(cls):
22 # get just those patches touching python files
23 cls.pythonpatches = []
24 for patch in cls.patchset:
25 if patch.path.endswith('.py'):
26 if not patch.is_removed_file:
27 cls.pythonpatches.append(patch)
28
29 def setUp(self):
30 if self.unidiff_parse_error:
31 self.skip('Python-unidiff parse error')
32 if not PyLint.pythonpatches:
33 self.skip('No python related patches, skipping test')
34
35 def pretest_pylint(self):
36 for pythonpatch in self.pythonpatches:
37 if pythonpatch.is_modified_file:
38 pylint_output = StringIO()
39 reporter = TextReporter(pylint_output)
40 lint.Run([self.pylint_options, pythonpatch.path], reporter=reporter, exit=False)
41 for line in pylint_output.readlines():
42 if not '*' in line:
43 if line.strip():
44 self.pylint_pretest[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1]
45
46 def test_pylint(self):
47 for pythonpatch in self.pythonpatches:
48 # a condition checking whether a file is renamed or not
49 # unidiff doesn't support this yet
50 if pythonpatch.target_file is not pythonpatch.path:
51 path = pythonpatch.target_file[2:]
52 else:
53 path = pythonpatch.path
54 pylint_output = StringIO()
55 reporter = TextReporter(pylint_output)
56 lint.Run([self.pylint_options, pythonpatch.path], reporter=reporter, exit=False)
57 for line in pylint_output.readlines():
58 if not '*' in line:
59 if line.strip():
60 self.pylint_test[line.strip().split(' ',1)[0]] = line.strip().split(' ',1)[1]
61
62 for issue in self.pylint_test:
63 if self.pylint_test[issue] not in self.pylint_pretest.values():
64 self.fail('Errors in your Python code were encountered. Please check your code with a linter and resubmit',
65 data=[('Output', 'Please, fix the listed issues:'), ('', issue + ' ' + self.pylint_test[issue])])
diff --git a/meta/lib/patchtest/utils.py b/meta/lib/patchtest/utils.py
new file mode 100644
index 0000000000..8eddf3e85f
--- /dev/null
+++ b/meta/lib/patchtest/utils.py
@@ -0,0 +1,61 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# utils: common methods used by the patchtest framework
5#
6# Copyright (C) 2016 Intel Corporation
7#
8# SPDX-License-Identifier: GPL-2.0-only
9#
10
11import os
12import subprocess
13import logging
14import re
15import mailbox
16
17def logger_create(name):
18 logger = logging.getLogger(name)
19 loggerhandler = logging.StreamHandler()
20 loggerhandler.setFormatter(logging.Formatter("%(message)s"))
21 logger.addHandler(loggerhandler)
22 logger.setLevel(logging.INFO)
23 return logger
24
25def valid_branch(branch):
26 """ Check if branch is valid name """
27 lbranch = branch.lower()
28
29 invalid = lbranch.startswith('patch') or \
30 lbranch.startswith('rfc') or \
31 lbranch.startswith('resend') or \
32 re.search(r'^v\d+', lbranch) or \
33 re.search(r'^\d+/\d+', lbranch)
34
35 return not invalid
36
37def get_branch(path):
38 """ Get the branch name from mbox """
39 fullprefix = ""
40 mbox = mailbox.mbox(path)
41
42 if len(mbox):
43 subject = mbox[0]['subject']
44 if subject:
45 pattern = re.compile(r"(\[.*\])", re.DOTALL)
46 match = pattern.search(subject)
47 if match:
48 fullprefix = match.group(1)
49
50 branch, branches, valid_branches = None, [], []
51
52 if fullprefix:
53 prefix = fullprefix.strip('[]')
54 branches = [ b.strip() for b in prefix.split(',')]
55 valid_branches = [b for b in branches if valid_branch(b)]
56
57 if len(valid_branches):
58 branch = valid_branches[0]
59
60 return branch
61