summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-10-16 15:44:58 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-17 11:41:34 +0100
commit26e3d58e71e5a88ac2c2d34845f45c77635cd2d4 (patch)
treea5e2359080ee9efa58bfd2ebb2fc88751ce03232
parent6e53a778f10c77eab3c0172a0cbc4d63efc663e9 (diff)
downloadpoky-26e3d58e71e5a88ac2c2d34845f45c77635cd2d4.tar.gz
patchtest: set default repo and testdir targets
Since patchtest is in oe-core, the Python os module's methods can be used to retrieve the repository path and tests directory by default. This reduces the number of mandatory arguments for invocation of patchtest unless the user wants to use a custom test suite or test patches against a different repo. The REPO and TESTDIR arguments are likewise adjusted so that they are optional. Also, make it more obvious what the --startdir flag is meant for on the command line by renaming it to --testdir, and update the scripts/patchtest.README file to be consistent with the new usage. (From OE-Core rev: bae7421ece4806f5148f164293810b9fe75e0756) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/patchtest/data.py9
-rwxr-xr-xscripts/patchtest6
-rw-r--r--scripts/patchtest.README10
3 files changed, 17 insertions, 8 deletions
diff --git a/meta/lib/patchtest/data.py b/meta/lib/patchtest/data.py
index b661dd6479..12f36aa14d 100644
--- a/meta/lib/patchtest/data.py
+++ b/meta/lib/patchtest/data.py
@@ -35,6 +35,9 @@ import logging
35logger=logging.getLogger('patchtest') 35logger=logging.getLogger('patchtest')
36info=logger.info 36info=logger.info
37 37
38default_testdir = os.path.abspath(os.path.dirname(__file__) + "/tests")
39default_repodir = os.path.abspath(os.path.dirname(__file__) + "/../../..")
40
38# Data store commonly used to share values between pre and post-merge tests 41# Data store commonly used to share values between pre and post-merge tests
39PatchTestDataStore = collections.defaultdict(str) 42PatchTestDataStore = collections.defaultdict(str)
40 43
@@ -58,10 +61,12 @@ class PatchTestInput(object):
58 target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path', 61 target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path',
59 help='The directory containing patches to be tested') 62 help='The directory containing patches to be tested')
60 63
61 parser.add_argument('repodir', metavar='REPO', 64 parser.add_argument('--repodir', metavar='REPO',
65 default=default_repodir,
62 help="Name of the repository where patch is merged") 66 help="Name of the repository where patch is merged")
63 67
64 parser.add_argument('startdir', metavar='TESTDIR', 68 parser.add_argument('--testdir', metavar='TESTDIR',
69 default=default_testdir,
65 help="Directory where test cases are located") 70 help="Directory where test cases are located")
66 71
67 parser.add_argument('--top-level-directory', '-t', 72 parser.add_argument('--top-level-directory', '-t',
diff --git a/scripts/patchtest b/scripts/patchtest
index 9525a2be17..b25ef18321 100755
--- a/scripts/patchtest
+++ b/scripts/patchtest
@@ -142,7 +142,7 @@ def _runner(resultklass, prefix=None):
142 loader.testMethodPrefix = prefix 142 loader.testMethodPrefix = prefix
143 143
144 # create the suite with discovered tests and the corresponding runner 144 # create the suite with discovered tests and the corresponding runner
145 suite = loader.discover(start_dir=PatchTestInput.startdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir) 145 suite = loader.discover(start_dir=PatchTestInput.testdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir)
146 ntc = suite.countTestCases() 146 ntc = suite.countTestCases()
147 147
148 # if there are no test cases, just quit 148 # if there are no test cases, just quit
@@ -220,9 +220,9 @@ if __name__ == '__main__':
220 if PatchTestInput.debug: 220 if PatchTestInput.debug:
221 logger.setLevel(logging.DEBUG) 221 logger.setLevel(logging.DEBUG)
222 222
223 # if topdir not define, default it to startdir 223 # if topdir not define, default it to testdir
224 if not PatchTestInput.topdir: 224 if not PatchTestInput.topdir:
225 PatchTestInput.topdir = PatchTestInput.startdir 225 PatchTestInput.topdir = PatchTestInput.testdir
226 226
227 try: 227 try:
228 ret = main() 228 ret = main()
diff --git a/scripts/patchtest.README b/scripts/patchtest.README
index 689d513df5..ad46b02ad6 100644
--- a/scripts/patchtest.README
+++ b/scripts/patchtest.README
@@ -79,15 +79,19 @@ To run patchtest on the host, do the following:
79 or patchtest-get-series 79 or patchtest-get-series
803. Run patchtest on a patch file by doing the following: 803. Run patchtest on a patch file by doing the following:
81 81
82 patchtest --patch /path/to/patch/file /path/to/target/repo /path/to/tests/directory 82 patchtest --patch /path/to/patch/file
83 83
84 or, if you have stored the patch files in a directory, do: 84 or, if you have stored the patch files in a directory, do:
85 85
86 patchtest --directory /path/to/patch/directory /path/to/target/repo /path/to/tests/directory 86 patchtest --directory /path/to/patch/directory
87 87
88 For example, to test `master-gcc-Fix--fstack-protector-issue-on-aarch64.patch` against the oe-core test suite: 88 For example, to test `master-gcc-Fix--fstack-protector-issue-on-aarch64.patch` against the oe-core test suite:
89 89
90 patchtest --patch master-gcc-Fix--fstack-protector-issue-on-aarch64.patch /path/to/openembedded-core /path/to/openembedded-core/meta/lib/patchtest/tests 90 patchtest --patch master-gcc-Fix--fstack-protector-issue-on-aarch64.patch
91
92 If you want to use a different test suite or target repository, you can use the --testdir and --repodir flags:
93
94 patchtest --patch /path/to/patch/file --repodir /path/to/repo --testdir /path/to/test/dir
91 95
92### Guest Mode 96### Guest Mode
93 97