]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
patchtest: set default repo and testdir targets
authorTrevor Gamblin <tgamblin@baylibre.com>
Mon, 16 Oct 2023 19:44:58 +0000 (15:44 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 17 Oct 2023 10:06:15 +0000 (11:06 +0100)
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.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/patchtest/data.py
scripts/patchtest
scripts/patchtest.README

index b661dd64796b14b8aea3ec505d7aa213be50c569..12f36aa14d9b0db54234008b082bdfcf1f893fbb 100644 (file)
@@ -35,6 +35,9 @@ import logging
 logger=logging.getLogger('patchtest')
 info=logger.info
 
+default_testdir = os.path.abspath(os.path.dirname(__file__) + "/tests")
+default_repodir = os.path.abspath(os.path.dirname(__file__) + "/../../..")
+
 # Data store commonly used to share values between pre and post-merge tests
 PatchTestDataStore = collections.defaultdict(str)
 
@@ -58,10 +61,12 @@ class PatchTestInput(object):
         target_patch_group.add_argument('--directory', metavar='DIRECTORY', dest='patch_path',
                             help='The directory containing patches to be tested')
 
-        parser.add_argument('repodir', metavar='REPO',
+        parser.add_argument('--repodir', metavar='REPO',
+                            default=default_repodir,
                             help="Name of the repository where patch is merged")
 
-        parser.add_argument('startdir', metavar='TESTDIR',
+        parser.add_argument('--testdir', metavar='TESTDIR',
+                            default=default_testdir,
                             help="Directory where test cases are located")
 
         parser.add_argument('--top-level-directory', '-t',
index 9525a2be17d001bbcca0edda186741b4dc7ba75a..b25ef183216551763b5c0f2149c5319e78d4fabc 100755 (executable)
@@ -142,7 +142,7 @@ def _runner(resultklass, prefix=None):
         loader.testMethodPrefix = prefix
 
     # create the suite with discovered tests and the corresponding runner
-    suite = loader.discover(start_dir=PatchTestInput.startdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir)
+    suite = loader.discover(start_dir=PatchTestInput.testdir, pattern=PatchTestInput.pattern, top_level_dir=PatchTestInput.topdir)
     ntc = suite.countTestCases()
 
     # if there are no test cases, just quit
@@ -220,9 +220,9 @@ if __name__ == '__main__':
     if PatchTestInput.debug:
         logger.setLevel(logging.DEBUG)
 
-    # if topdir not define, default it to startdir
+    # if topdir not define, default it to testdir
     if not PatchTestInput.topdir:
-        PatchTestInput.topdir = PatchTestInput.startdir
+        PatchTestInput.topdir = PatchTestInput.testdir
 
     try:
         ret = main()
index 689d513df51cc75720a1bfd834224cee6c8bbced..ad46b02ad6e476d49f5cb0a9244ed3781e55d7d9 100644 (file)
@@ -79,15 +79,19 @@ To run patchtest on the host, do the following:
    or patchtest-get-series
 3. Run patchtest on a patch file by doing the following:
 
-        patchtest --patch /path/to/patch/file /path/to/target/repo /path/to/tests/directory 
+        patchtest --patch /path/to/patch/file
 
     or, if you have stored the patch files in a directory, do:
 
-        patchtest --directory /path/to/patch/directory /path/to/target/repo /path/to/tests/directory 
+        patchtest --directory /path/to/patch/directory
 
     For example, to test `master-gcc-Fix--fstack-protector-issue-on-aarch64.patch` against the oe-core test suite:
         
-        patchtest --patch master-gcc-Fix--fstack-protector-issue-on-aarch64.patch /path/to/openembedded-core /path/to/openembedded-core/meta/lib/patchtest/tests 
+        patchtest --patch master-gcc-Fix--fstack-protector-issue-on-aarch64.patch
+
+    If you want to use a different test suite or target repository, you can use the --testdir and --repodir flags:
+    
+        patchtest --patch /path/to/patch/file --repodir /path/to/repo --testdir /path/to/test/dir
 
 ### Guest Mode