qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] tests/functional: expose sys.argv to unittest.main
@ 2025-07-25 14:41 Alex Bennée
  2025-07-25 14:49 ` Daniel P. Berrangé
  2025-07-28  9:45 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Bennée @ 2025-07-25 14:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Daniel P. Berrangé, Thomas Huth,
	Philippe Mathieu-Daudé

With this we can call the supported we can take advantage of the
argument the module supports:

  env PYTHONPATH=/home/alex/lsrc/qemu.git/python:/home/alex/lsrc/qemu.git/tests/functional ./pyvenv/bin/python /home/alex/lsrc/qemu.git/tests/functional/test_aarch64_kvm.py --help
  usage: test_aarch64_kvm.py [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [tests ...]

  positional arguments:
    tests                a list of any number of test modules, classes and test methods.

  options:
    -h, --help           show this help message and exit
    -v, --verbose        Verbose output
    -q, --quiet          Quiet output
    --locals             Show local variables in tracebacks
    --durations N        Show the N slowest test cases (N=0 for all)
    -f, --failfast       Stop on first fail or error
    -c, --catch          Catch Ctrl-C and display results so far
    -b, --buffer         Buffer stdout and stderr during tests
    -k TESTNAMEPATTERNS  Only run tests which match the given substring

  Examples:
    test_aarch64_kvm.py test_module               - run tests from test_module
    test_aarch64_kvm.py module.TestClass          - run tests from module.TestClass
    test_aarch64_kvm.py module.Class.test_method  - run specified test method
    test_aarch64_kvm.py path/to/test_file.py      - run tests from test_file.py

  usage: test_aarch64_kvm.py discover [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [-s START] [-p PATTERN] [-t TOP]

  options:
    -h, --help            show this help message and exit
    -v, --verbose         Verbose output
    -q, --quiet           Quiet output
    --locals              Show local variables in tracebacks
    --durations N         Show the N slowest test cases (N=0 for all)
    -f, --failfast        Stop on first fail or error
    -c, --catch           Catch Ctrl-C and display results so far
    -b, --buffer          Buffer stdout and stderr during tests
    -k TESTNAMEPATTERNS   Only run tests which match the given substring
    -s, --start-directory START
                          Directory to start discovery ('.' default)
    -p, --pattern PATTERN
                          Pattern to match tests ('test*.py' default)
    -t, --top-level-directory TOP
                          Top level directory of project (defaults to start directory)

  For test discovery all test modules must be importable from the top level directory of the project.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/functional/qemu_test/testcase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 2a78e735f16..5caf7b13fe3 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -249,7 +249,7 @@ def main():
         tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError,
                                    test_output_log = pycotap.LogMode.LogToError)
         res = unittest.main(module = None, testRunner = tr, exit = False,
-                            argv=["__dummy__", path])
+                            argv=[sys.argv[0], path] + sys.argv[1:])
         for (test, message) in res.result.errors + res.result.failures:
 
             if hasattr(test, "log_filename"):
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] tests/functional: expose sys.argv to unittest.main
  2025-07-25 14:41 [RFC PATCH] tests/functional: expose sys.argv to unittest.main Alex Bennée
@ 2025-07-25 14:49 ` Daniel P. Berrangé
  2025-07-28  9:45 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2025-07-25 14:49 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel, Thomas Huth, Philippe Mathieu-Daudé

On Fri, Jul 25, 2025 at 03:41:42PM +0100, Alex Bennée wrote:
> With this we can call the supported we can take advantage of the
> argument the module supports:
> 
>   env PYTHONPATH=/home/alex/lsrc/qemu.git/python:/home/alex/lsrc/qemu.git/tests/functional ./pyvenv/bin/python /home/alex/lsrc/qemu.git/tests/functional/test_aarch64_kvm.py --help
>   usage: test_aarch64_kvm.py [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [tests ...]
> 
>   positional arguments:
>     tests                a list of any number of test modules, classes and test methods.
> 
>   options:
>     -h, --help           show this help message and exit
>     -v, --verbose        Verbose output
>     -q, --quiet          Quiet output
>     --locals             Show local variables in tracebacks
>     --durations N        Show the N slowest test cases (N=0 for all)
>     -f, --failfast       Stop on first fail or error
>     -c, --catch          Catch Ctrl-C and display results so far
>     -b, --buffer         Buffer stdout and stderr during tests
>     -k TESTNAMEPATTERNS  Only run tests which match the given substring
> 
>   Examples:
>     test_aarch64_kvm.py test_module               - run tests from test_module
>     test_aarch64_kvm.py module.TestClass          - run tests from module.TestClass
>     test_aarch64_kvm.py module.Class.test_method  - run specified test method
>     test_aarch64_kvm.py path/to/test_file.py      - run tests from test_file.py
> 
>   usage: test_aarch64_kvm.py discover [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [-s START] [-p PATTERN] [-t TOP]
> 
>   options:
>     -h, --help            show this help message and exit
>     -v, --verbose         Verbose output
>     -q, --quiet           Quiet output
>     --locals              Show local variables in tracebacks
>     --durations N         Show the N slowest test cases (N=0 for all)
>     -f, --failfast        Stop on first fail or error
>     -c, --catch           Catch Ctrl-C and display results so far
>     -b, --buffer          Buffer stdout and stderr during tests
>     -k TESTNAMEPATTERNS   Only run tests which match the given substring
>     -s, --start-directory START
>                           Directory to start discovery ('.' default)
>     -p, --pattern PATTERN
>                           Pattern to match tests ('test*.py' default)
>     -t, --top-level-directory TOP
>                           Top level directory of project (defaults to start directory)
> 
>   For test discovery all test modules must be importable from the top level directory of the project.
> 
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/functional/qemu_test/testcase.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] tests/functional: expose sys.argv to unittest.main
  2025-07-25 14:41 [RFC PATCH] tests/functional: expose sys.argv to unittest.main Alex Bennée
  2025-07-25 14:49 ` Daniel P. Berrangé
@ 2025-07-28  9:45 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-28  9:45 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Daniel P. Berrangé, Thomas Huth

On 25/7/25 16:41, Alex Bennée wrote:
> With this we can call the supported we can take advantage of the

~~we can call the supported~~

> argument the module supports:
> 
>    env PYTHONPATH=/home/alex/lsrc/qemu.git/python:/home/alex/lsrc/qemu.git/tests/functional ./pyvenv/bin/python /home/alex/lsrc/qemu.git/tests/functional/test_aarch64_kvm.py --help
>    usage: test_aarch64_kvm.py [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [tests ...]
> 
>    positional arguments:
>      tests                a list of any number of test modules, classes and test methods.
> 
>    options:
>      -h, --help           show this help message and exit
>      -v, --verbose        Verbose output
>      -q, --quiet          Quiet output
>      --locals             Show local variables in tracebacks
>      --durations N        Show the N slowest test cases (N=0 for all)
>      -f, --failfast       Stop on first fail or error
>      -c, --catch          Catch Ctrl-C and display results so far
>      -b, --buffer         Buffer stdout and stderr during tests
>      -k TESTNAMEPATTERNS  Only run tests which match the given substring
> 
>    Examples:
>      test_aarch64_kvm.py test_module               - run tests from test_module
>      test_aarch64_kvm.py module.TestClass          - run tests from module.TestClass
>      test_aarch64_kvm.py module.Class.test_method  - run specified test method
>      test_aarch64_kvm.py path/to/test_file.py      - run tests from test_file.py
> 
>    usage: test_aarch64_kvm.py discover [-h] [-v] [-q] [--locals] [--durations N] [-f] [-c] [-b] [-k TESTNAMEPATTERNS] [-s START] [-p PATTERN] [-t TOP]
> 
>    options:
>      -h, --help            show this help message and exit
>      -v, --verbose         Verbose output
>      -q, --quiet           Quiet output
>      --locals              Show local variables in tracebacks
>      --durations N         Show the N slowest test cases (N=0 for all)
>      -f, --failfast        Stop on first fail or error
>      -c, --catch           Catch Ctrl-C and display results so far
>      -b, --buffer          Buffer stdout and stderr during tests
>      -k TESTNAMEPATTERNS   Only run tests which match the given substring
>      -s, --start-directory START
>                            Directory to start discovery ('.' default)
>      -p, --pattern PATTERN
>                            Pattern to match tests ('test*.py' default)
>      -t, --top-level-directory TOP
>                            Top level directory of project (defaults to start directory)
> 
>    For test discovery all test modules must be importable from the top level directory of the project.
> 
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/functional/qemu_test/testcase.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-28  9:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 14:41 [RFC PATCH] tests/functional: expose sys.argv to unittest.main Alex Bennée
2025-07-25 14:49 ` Daniel P. Berrangé
2025-07-28  9:45 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).