diff mbox series

[5/6] qtest: irq_intercept_[out/in]: return FAIL if no intercepts are installed

Message ID 20230714232659.76434-6-chris@laplante.io
State New
Headers show
Series Add nRF51 DETECT signal with test | expand

Commit Message

Chris Laplante July 14, 2023, 11:27 p.m. UTC
This is much better than just silently failing with OK.

Signed-off-by: Chris Laplante <chris@laplante.io>
---
 softmmu/qtest.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Peter Maydell July 24, 2023, 4:19 p.m. UTC | #1
On Sat, 15 Jul 2023 at 00:27, Chris Laplante <chris@laplante.io> wrote:
>
> This is much better than just silently failing with OK.
>
> Signed-off-by: Chris Laplante <chris@laplante.io>

Makes sense. Did you do a 'make check' on an
all-targets-enabled build just to confirm we haven't
accidentally let any bogus uses of the command in while
it was returning OK for these cases?

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Chris Laplante July 25, 2023, 4:03 a.m. UTC | #2
> Makes sense. Did you do a 'make check' on an
> all-targets-enabled build just to confirm we haven't
> accidentally let any bogus uses of the command in while
> it was returning OK for these cases?
> 
> Reviewed-by: Peter Maydell peter.maydell@linaro.org

Yes, I just did a 'make check' and got:

Ok:                 737 
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            71  
Timeout:            0   

Thanks,
Chris
diff mbox series

Patch

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 051bbf4177..e888acb319 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -399,6 +399,7 @@  static void qtest_process_command(CharBackend *chr, gchar **words)
         NamedGPIOList *ngl;
         bool is_named;
         bool is_outbound;
+        bool interception_succeeded = false;
 
         g_assert(words[1]);
         is_named = words[2] != NULL;
@@ -431,6 +432,7 @@  static void qtest_process_command(CharBackend *chr, gchar **words)
                 if (is_named) {
                     if (ngl->name && strcmp(ngl->name, words[2]) == 0) {
                         qtest_install_gpio_out_intercepts(dev, ngl->name, 0);
+                        interception_succeeded = true;
                         break;
                     }
                 } else if (!ngl->name) {
@@ -438,15 +440,22 @@  static void qtest_process_command(CharBackend *chr, gchar **words)
                     for (i = 0; i < ngl->num_out; ++i) {
                         qtest_install_gpio_out_intercepts(dev, ngl->name, i);
                     }
+                    interception_succeeded = true;
                 }
             } else {
                 qemu_irq_intercept_in(ngl->in, qtest_irq_handler,
                                       ngl->num_in);
+                interception_succeeded = true;
             }
         }
-        irq_intercept_dev = dev;
+
         qtest_send_prefix(chr);
-        qtest_send(chr, "OK\n");
+        if (interception_succeeded) {
+            irq_intercept_dev = dev;
+            qtest_send(chr, "OK\n");
+        } else {
+            qtest_send(chr, "FAIL No intercepts installed\n");
+        }
     } else if (strcmp(words[0], "set_irq_in") == 0) {
         DeviceState *dev;
         qemu_irq irq;