diff mbox series

[1/4] microbit: add missing qtest_quit() call

Message ID 20230912184130.3056054-2-berrange@redhat.com
State New
Headers show
Series ci: fix hang of FreeBSD CI jobs | expand

Commit Message

Daniel P. Berrangé Sept. 12, 2023, 6:41 p.m. UTC
Without this call, the QEMU process is being left running which on
FreeBSD 13.2 at least, makes meson think the test is still running,
and thus execution of "make check" continues forever.

This fixes the regression introduced in:

  commit a9c9bbee855877293683012942d3485d50f286af
  Author: Chris Laplante <chris@laplante.io>
  Date:   Tue Aug 22 17:31:02 2023 +0100

    qtest: microbit-test: add tests for nRF51 DETECT

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1882
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/qtest/microbit-test.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Henderson Sept. 12, 2023, 7:10 p.m. UTC | #1
On 9/12/23 11:41, Daniel P. Berrangé wrote:
> Without this call, the QEMU process is being left running which on
> FreeBSD 13.2 at least, makes meson think the test is still running,
> and thus execution of "make check" continues forever.
> 
> This fixes the regression introduced in:
> 
>    commit a9c9bbee855877293683012942d3485d50f286af
>    Author: Chris Laplante<chris@laplante.io>
>    Date:   Tue Aug 22 17:31:02 2023 +0100
> 
>      qtest: microbit-test: add tests for nRF51 DETECT
> 
> Fixes:https://gitlab.com/qemu-project/qemu/-/issues/1882
> Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> ---
>   tests/qtest/microbit-test.c | 2 ++
>   1 file changed, 2 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

But I think that it's unfortunate that we have to remember this for each test.


r~
Daniel P. Berrangé Sept. 13, 2023, 8:06 a.m. UTC | #2
On Tue, Sep 12, 2023 at 12:10:19PM -0700, Richard Henderson wrote:
> On 9/12/23 11:41, Daniel P. Berrangé wrote:
> > Without this call, the QEMU process is being left running which on
> > FreeBSD 13.2 at least, makes meson think the test is still running,
> > and thus execution of "make check" continues forever.
> > 
> > This fixes the regression introduced in:
> > 
> >    commit a9c9bbee855877293683012942d3485d50f286af
> >    Author: Chris Laplante<chris@laplante.io>
> >    Date:   Tue Aug 22 17:31:02 2023 +0100
> > 
> >      qtest: microbit-test: add tests for nRF51 DETECT
> > 
> > Fixes:https://gitlab.com/qemu-project/qemu/-/issues/1882
> > Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> > ---
> >   tests/qtest/microbit-test.c | 2 ++
> >   1 file changed, 2 insertions(+)
> 
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> But I think that it's unfortunate that we have to remember this for each test.

We should use G_DEFINE_AUTOPTR_CLEANUP_FUNC for QTestState, and
then we can change tests to declare

   g_autoptr(QTestState) qts = qtest_init(....)

which will make it a bit more robust against forgotten cleanup.



We register an ABRT handler to kill off QEMU manually during
g_asserts().

The "death signal" code will give another layer of robustness
for exits too on Linux and now FreeBSD.

If we really wanted to we could add a 3rd layer of defence by
adding an atexit() handler, but I'm not sure this last one is
worth it for something we're not hitting frequently AFAIR.

With regards,
Daniel
diff mbox series

Patch

diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
index 2abcad8e31..72190d38f7 100644
--- a/tests/qtest/microbit-test.c
+++ b/tests/qtest/microbit-test.c
@@ -434,6 +434,8 @@  static void test_nrf51_gpio_detect(void)
     g_assert_true(qtest_get_irq(qts, 0));
     qtest_set_irq_in(qts, "/machine/nrf51", "unnamed-gpio-in", 3, 0);
     g_assert_true(qtest_get_irq(qts, 0));
+
+    qtest_quit(qts);
 }
 
 static void timer_task(QTestState *qts, hwaddr task)