[PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado

Gustavo Romero posted 9 patches 2 days, 9 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250926051542.104432-1-gustavo.romero@linaro.org
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Zhao Liu <zhao1.liu@intel.com>
configure                                     |  21 +++
meson_options.txt                             |   2 +
pythondeps.toml                               |   1 +
scripts/meson-buildoptions.sh                 |   2 +
tests/Makefile.include                        |   2 +-
.../functional/aarch64/test_reverse_debug.py  |   9 +-
tests/functional/meson.build                  |   6 +
tests/functional/ppc64/test_reverse_debug.py  |  11 +-
tests/functional/qemu_test/__init__.py        |   4 +-
tests/functional/qemu_test/decorators.py      |  18 +++
tests/functional/qemu_test/gdb.py             |  85 +++++++++++
tests/functional/reverse_debugging.py         | 140 ++++++++----------
tests/functional/x86_64/test_reverse_debug.py |  13 +-
13 files changed, 216 insertions(+), 98 deletions(-)
create mode 100644 tests/functional/qemu_test/gdb.py
[PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Gustavo Romero 2 days, 9 hours ago
tests/functional: Adapt reverse_debugging to run w/o Avocado

The goal of this series is to remove Avocado as a dependency for running
the reverse_debugging functional test.

After several rounds of discussions about v1 and v2, and experiments
done by Daniel and Thomas (thanks for all the experiments and comments
so far), I've taken a new approach and moved away from using a runner
for GDB. The changes, I believe, are much simpler now.

This new series uses GDB's machine interface (MI) via the pygdbmi module
(thanks Manos and Peter for the inputs). pygdbmi provides a controller
to start GDB and communicate with it through MI, so there is no longer a
risk of version clashes between libpython in GDB and Python modules in
the pyvenv, as it could, in theory, happen when GDB executes the test
script via -x option.

Also, as Daniel pointed out, the overall test output is pretty bad and
currently does not allow one to easily follow the sequence of GDB
commands used in the test. I took this opportunity to improve the output
and it now prints the sequence in a format that can be copied and pasted
directly into GDB.

The TAP protocol is respected, and Meson correctly displays GDB's test
output in testlog-thorough.txt.

Because the pygdbmi "shim" is so thin, I had to write a trivial GDB
class around it to easily capture and print the payloads returned by its
write() method. The GDB class allows clean, single-line commands to be
used in the tests through method chaining, making them easier to follow,
for example:

pc = gdb.cli("print $pc").get_add()

The test is kept “skipped” for aarch64, ppc64, and x86_64, so it is
necessary to set QEMU_TEST_FLAKY_TESTS=1 in the test environment to
effectively run the test on these archs.

On aarch64, the test is flaky, but there is a fix that I’ve tested while
writing this series [0] that resolves it. On ppc64 and x86_64, the test
always fails: on ppc64, GDB gets a bogus PC, and on x86_64, the last
part of the test (reverse-continue) does not hit the last executed PC
(as it should happen) but instead jumps to the beginning of the code
(first PC in forward order).

Thus, to effectively run the reverse_debugging test on aarch64:

$ export QEMU_TEST_FLAKY_TESTS=1
$ make check-functional

or even, to run only the reverse_debug test after 'make check-functional':
$ ./pyvenv/bin/meson test --verbose --no-rebuild -t 1 --setup thorough --suite func-thorough func-aarch64-reverse_debug


Cheers,
Gustavo

v1:
https://patchew.org/QEMU/20250819143916.4138035-1-gustavo.romero@linaro.org/

v2:
https://patchew.org/QEMU/20250904154640.52687-1-gustavo.romero@linaro.org/

v3:
https://patchew.org/QEMU/20250922054351.14289-1-gustavo.romero@linaro.org/

v4:
- Installed pygdbmi only in check-functional step and using pip,
  so not from local wheels (thomas)
- Fixed GDB probe in configure by ensuring that the GDB passed to Meson
  supports all that arches in the target list
- Fixed error found by Alex when skipping the test, "name 'test' is not
  defined", by using the new decorator suggested by Daniel to skip the
  tests if QEMU_TEST_GDB env var is missing (alex, daniel)
- Moved GDB class into its own file under qemu_test, in gdb.py. (alex,
  daniel)
- Put subprocess and the drop of the data drainer changes in separate
  commits (used previous commits from Daniel for it) (alex, daniel)
- Put back /usr/bin/env python shebang into per arch test files (daniel)
- Added new method reverse_debugging_run() to separate test bootstrap
  from GDB test execution, also helping to get a better diff view
  (daniel)
- Made diffs better for reviewing by avoiding mixing text changes with
  changes in the code related to Avocado's removal (alex, daniel)


Daniel P. Berrangé (2):
  tests/functional: replace avocado process with subprocess
  tests/functional: drop datadrainer class in reverse debugging

Gustavo Romero (7):
  tests/functional: Re-activate the check-venv target
  python: Install pygdbmi in meson's venv
  tests/functional: Provide GDB to the functional tests
  tests/functional: Add GDB class
  tests/functional: Add decorator to skip test on missing env vars
  tests/functional: Adapt reverse_debugging to run w/o Avocado
  tests/functional: Adapt arches to reverse_debugging w/o Avocado

 configure                                     |  21 +++
 meson_options.txt                             |   2 +
 pythondeps.toml                               |   1 +
 scripts/meson-buildoptions.sh                 |   2 +
 tests/Makefile.include                        |   2 +-
 .../functional/aarch64/test_reverse_debug.py  |   9 +-
 tests/functional/meson.build                  |   6 +
 tests/functional/ppc64/test_reverse_debug.py  |  11 +-
 tests/functional/qemu_test/__init__.py        |   4 +-
 tests/functional/qemu_test/decorators.py      |  18 +++
 tests/functional/qemu_test/gdb.py             |  85 +++++++++++
 tests/functional/reverse_debugging.py         | 140 ++++++++----------
 tests/functional/x86_64/test_reverse_debug.py |  13 +-
 13 files changed, 216 insertions(+), 98 deletions(-)
 create mode 100644 tests/functional/qemu_test/gdb.py

-- 
2.34.1


Re: [PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Philippe Mathieu-Daudé 2 days, 8 hours ago
Hi Gustavo,

On 26/9/25 07:15, Gustavo Romero wrote:
> tests/functional: Adapt reverse_debugging to run w/o Avocado
> 
> The goal of this series is to remove Avocado as a dependency for running
> the reverse_debugging functional test.


> Daniel P. Berrangé (2):
>    tests/functional: replace avocado process with subprocess
>    tests/functional: drop datadrainer class in reverse debugging
> 
> Gustavo Romero (7):
>    tests/functional: Re-activate the check-venv target
>    python: Install pygdbmi in meson's venv
>    tests/functional: Provide GDB to the functional tests
>    tests/functional: Add GDB class
>    tests/functional: Add decorator to skip test on missing env vars
>    tests/functional: Adapt reverse_debugging to run w/o Avocado
>    tests/functional: Adapt arches to reverse_debugging w/o Avocado

Out of curiosity, do you plan to post the final patch removing Avocado
use / dependency?

Regards,

Phil.

Re: [PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Thomas Huth 2 days, 5 hours ago
On 26/09/2025 08.49, Philippe Mathieu-Daudé wrote:
> Hi Gustavo,
> 
> On 26/9/25 07:15, Gustavo Romero wrote:
>> tests/functional: Adapt reverse_debugging to run w/o Avocado
>>
>> The goal of this series is to remove Avocado as a dependency for running
>> the reverse_debugging functional test.
> 
> 
>> Daniel P. Berrangé (2):
>>    tests/functional: replace avocado process with subprocess
>>    tests/functional: drop datadrainer class in reverse debugging
>>
>> Gustavo Romero (7):
>>    tests/functional: Re-activate the check-venv target
>>    python: Install pygdbmi in meson's venv
>>    tests/functional: Provide GDB to the functional tests
>>    tests/functional: Add GDB class
>>    tests/functional: Add decorator to skip test on missing env vars
>>    tests/functional: Adapt reverse_debugging to run w/o Avocado
>>    tests/functional: Adapt arches to reverse_debugging w/o Avocado
> 
> Out of curiosity, do you plan to post the final patch removing Avocado
> use / dependency?

Which other uses of Avocado are you thinking about? AFAIK, this test here is 
the last one that used Avocado.

  Thomas


Re: [PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Philippe Mathieu-Daudé 2 days, 5 hours ago
On 26/9/25 11:14, Thomas Huth wrote:
> On 26/09/2025 08.49, Philippe Mathieu-Daudé wrote:
>> Hi Gustavo,
>>
>> On 26/9/25 07:15, Gustavo Romero wrote:
>>> tests/functional: Adapt reverse_debugging to run w/o Avocado
>>>
>>> The goal of this series is to remove Avocado as a dependency for running
>>> the reverse_debugging functional test.
>>
>>
>>> Daniel P. Berrangé (2):
>>>    tests/functional: replace avocado process with subprocess
>>>    tests/functional: drop datadrainer class in reverse debugging
>>>
>>> Gustavo Romero (7):
>>>    tests/functional: Re-activate the check-venv target
>>>    python: Install pygdbmi in meson's venv
>>>    tests/functional: Provide GDB to the functional tests
>>>    tests/functional: Add GDB class
>>>    tests/functional: Add decorator to skip test on missing env vars
>>>    tests/functional: Adapt reverse_debugging to run w/o Avocado
>>>    tests/functional: Adapt arches to reverse_debugging w/o Avocado
>>
>> Out of curiosity, do you plan to post the final patch removing Avocado
>> use / dependency?
> 
> Which other uses of Avocado are you thinking about? AFAIK, this test 
> here is the last one that used Avocado.

Maybe I was not clear. After these tests conversion, I don't see any
more use of avocado, so we can remove its dependency on QEMU, right?
Basically, in a final patch I'd remove anything related to:

   python/setup.cfg:37:    avocado-framework >= 90.0
   python/tests/minreqs.txt:35:avocado-framework==90.0


Re: [PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Thomas Huth 2 days, 5 hours ago
On 26/09/2025 11.32, Philippe Mathieu-Daudé wrote:
> On 26/9/25 11:14, Thomas Huth wrote:
>> On 26/09/2025 08.49, Philippe Mathieu-Daudé wrote:
>>> Hi Gustavo,
>>>
>>> On 26/9/25 07:15, Gustavo Romero wrote:
>>>> tests/functional: Adapt reverse_debugging to run w/o Avocado
>>>>
>>>> The goal of this series is to remove Avocado as a dependency for running
>>>> the reverse_debugging functional test.
>>>
>>>
>>>> Daniel P. Berrangé (2):
>>>>    tests/functional: replace avocado process with subprocess
>>>>    tests/functional: drop datadrainer class in reverse debugging
>>>>
>>>> Gustavo Romero (7):
>>>>    tests/functional: Re-activate the check-venv target
>>>>    python: Install pygdbmi in meson's venv
>>>>    tests/functional: Provide GDB to the functional tests
>>>>    tests/functional: Add GDB class
>>>>    tests/functional: Add decorator to skip test on missing env vars
>>>>    tests/functional: Adapt reverse_debugging to run w/o Avocado
>>>>    tests/functional: Adapt arches to reverse_debugging w/o Avocado
>>>
>>> Out of curiosity, do you plan to post the final patch removing Avocado
>>> use / dependency?
>>
>> Which other uses of Avocado are you thinking about? AFAIK, this test here 
>> is the last one that used Avocado.
> 
> Maybe I was not clear. After these tests conversion, I don't see any
> more use of avocado, so we can remove its dependency on QEMU, right?
> Basically, in a final patch I'd remove anything related to:
> 
>    python/setup.cfg:37:    avocado-framework >= 90.0
>    python/tests/minreqs.txt:35:avocado-framework==90.0

I think that's related to the qemu.qmp stuff coming from 
https://gitlab.com/qemu-project/python-qemu-qmp ... so maybe better sync 
with John Snow whether it's OK to remove that?

  Thomas


Re: [PATCH v4 0/9] tests/functional: Adapt reverse_debugging to run w/o Avocado
Posted by Daniel P. Berrangé 2 days, 5 hours ago
On Fri, Sep 26, 2025 at 11:32:58AM +0200, Philippe Mathieu-Daudé wrote:
> On 26/9/25 11:14, Thomas Huth wrote:
> > On 26/09/2025 08.49, Philippe Mathieu-Daudé wrote:
> > > Hi Gustavo,
> > > 
> > > On 26/9/25 07:15, Gustavo Romero wrote:
> > > > tests/functional: Adapt reverse_debugging to run w/o Avocado
> > > > 
> > > > The goal of this series is to remove Avocado as a dependency for running
> > > > the reverse_debugging functional test.
> > > 
> > > 
> > > > Daniel P. Berrangé (2):
> > > >    tests/functional: replace avocado process with subprocess
> > > >    tests/functional: drop datadrainer class in reverse debugging
> > > > 
> > > > Gustavo Romero (7):
> > > >    tests/functional: Re-activate the check-venv target
> > > >    python: Install pygdbmi in meson's venv
> > > >    tests/functional: Provide GDB to the functional tests
> > > >    tests/functional: Add GDB class
> > > >    tests/functional: Add decorator to skip test on missing env vars
> > > >    tests/functional: Adapt reverse_debugging to run w/o Avocado
> > > >    tests/functional: Adapt arches to reverse_debugging w/o Avocado
> > > 
> > > Out of curiosity, do you plan to post the final patch removing Avocado
> > > use / dependency?
> > 
> > Which other uses of Avocado are you thinking about? AFAIK, this test
> > here is the last one that used Avocado.
> 
> Maybe I was not clear. After these tests conversion, I don't see any
> more use of avocado, so we can remove its dependency on QEMU, right?
> Basically, in a final patch I'd remove anything related to:
> 
>   python/setup.cfg:37:    avocado-framework >= 90.0
>   python/tests/minreqs.txt:35:avocado-framework==90.0

The python code CI jobs all rely on avocado. In the python-qemu-qmp
repo John has a patch that drops avocado. That can be pulled over
into QEMU, but it is likely John will propose removing the python/
directory from QEMU instead and using a wheel.

Either way, this patch series doesn't need to touch python/ dir,
as work on that is in-progress separately.

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 :|