All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-block@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: [PATCH 3/6] tests/qemu-iotests: Allow to run "./check -n" from the source directory, too
Date: Tue,  8 Feb 2022 11:13:08 +0100	[thread overview]
Message-ID: <20220208101311.1511083-4-thuth@redhat.com> (raw)
In-Reply-To: <20220208101311.1511083-1-thuth@redhat.com>

For better integration of the iotests into the meson build system, it
would be very helpful to get the list of the tests in the "auto" group
during the "configure" step already. However, "check -n -g auto"
currently only works if the binaries have already been built. Re-order
the code in the "check" a little bit so that we can use the -n option
without building the binaries first.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qemu-iotests/check | 52 ++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 75de1b4691..0fa75abf13 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -120,6 +120,30 @@ def make_argparser() -> argparse.ArgumentParser:
 if __name__ == '__main__':
     args = make_argparser().parse_args()
 
+    if os.path.islink(sys.argv[0]):
+        # called from the build tree
+        source_iotests = os.path.dirname(os.readlink(sys.argv[0]))
+    else:
+        source_iotests = os.getcwd()
+
+    testfinder = TestFinder(source_iotests)
+
+    groups = args.groups.split(',') if args.groups else None
+    x_groups = args.exclude_groups.split(',') if args.exclude_groups else None
+
+    try:
+        tests = testfinder.find_tests(groups=groups, exclude_groups=x_groups,
+                                      tests=args.tests,
+                                      start_from=args.start_from)
+        if not tests:
+            raise ValueError('No tests selected')
+    except ValueError as e:
+        sys.exit(e)
+
+    if args.dry_run:
+        print('\n'.join(tests))
+        sys.exit(0)
+
     env = TestEnv(imgfmt=args.imgfmt, imgproto=args.imgproto,
                   aiomode=args.aiomode, cachemode=args.cachemode,
                   imgopts=args.imgopts, misalign=args.misalign,
@@ -140,11 +164,6 @@ if __name__ == '__main__':
         os.chdir(exec_path.parent)
         os.execve(cmd[0], cmd, full_env)
 
-    testfinder = TestFinder(test_dir=env.source_iotests)
-
-    groups = args.groups.split(',') if args.groups else None
-    x_groups = args.exclude_groups.split(',') if args.exclude_groups else None
-
     group_local = os.path.join(env.source_iotests, 'group.local')
     if os.path.isfile(group_local):
         try:
@@ -152,21 +171,8 @@ if __name__ == '__main__':
         except ValueError as e:
             sys.exit(f"Failed to parse group file '{group_local}': {e}")
 
-    try:
-        tests = testfinder.find_tests(groups=groups, exclude_groups=x_groups,
-                                      tests=args.tests,
-                                      start_from=args.start_from)
-        if not tests:
-            raise ValueError('No tests selected')
-    except ValueError as e:
-        sys.exit(e)
-
-    if args.dry_run:
-        print('\n'.join(tests))
-    else:
-        with TestRunner(env, tap=args.tap,
-                        color=args.color) as tr:
-            paths = [os.path.join(env.source_iotests, t) for t in tests]
-            ok = tr.run_tests(paths, args.jobs)
-            if not ok:
-                sys.exit(1)
+    with TestRunner(env, tap=args.tap, color=args.color) as tr:
+        paths = [os.path.join(env.source_iotests, t) for t in tests]
+        ok = tr.run_tests(paths, args.jobs)
+        if not ok:
+            sys.exit(1)
-- 
2.27.0



  parent reply	other threads:[~2022-02-08 10:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 10:13 [PATCH 0/6] Improve integration of iotests in the meson test harness Thomas Huth
2022-02-08 10:13 ` [PATCH 1/6] tests/qemu-iotests: Improve the check for GNU sed Thomas Huth
2022-02-08 11:46   ` Hanna Reitz
2022-02-08 12:13     ` Thomas Huth
2022-02-08 12:28       ` Hanna Reitz
2022-02-08 12:38         ` Thomas Huth
2022-02-08 13:11           ` Philippe Mathieu-Daudé via
2022-02-08 14:52             ` Thomas Huth
2022-02-11 16:14               ` Eric Blake
2022-02-11 16:48                 ` Thomas Huth
2022-02-15 13:28                   ` Thomas Huth
2022-02-15 13:51                     ` Daniel P. Berrangé
2022-02-15 16:09                       ` Thomas Huth
2022-02-08 10:13 ` [PATCH 2/6] tests/qemu-iotests/meson.build: Improve the indentation Thomas Huth
2022-02-08 10:51   ` Philippe Mathieu-Daudé via
2022-02-08 12:00   ` Hanna Reitz
2022-02-08 10:13 ` Thomas Huth [this message]
2022-02-08 12:26   ` [PATCH 3/6] tests/qemu-iotests: Allow to run "./check -n" from the source directory, too Hanna Reitz
2022-02-08 10:13 ` [PATCH 4/6] tests/qemu-iotests/meson.build: Call the 'check' script directly Thomas Huth
2022-02-08 12:36   ` Paolo Bonzini
2022-02-08 15:10     ` Thomas Huth
2022-02-08 16:19       ` Paolo Bonzini
2022-02-08 13:12   ` Hanna Reitz
2022-02-08 15:46     ` Thomas Huth
2022-02-08 10:13 ` [PATCH 5/6] tests: Do not treat the iotests as separate meson test target anymore Thomas Huth
2022-02-08 10:26   ` Peter Maydell
2022-02-08 11:16     ` Thomas Huth
2022-02-08 11:33       ` Peter Maydell
2022-02-08 12:37       ` Paolo Bonzini
2022-02-08 10:13 ` [PATCH 6/6] tests: Remove check-block.sh Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220208101311.1511083-4-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.