diff mbox series

[22/22] tests/qtest: skip bcm2835-test if no raspi3b model

Message ID 20230503091244.1450613-23-alex.bennee@linaro.org
State New
Headers show
Series testing/next: cirrus, docker, docs, ci, configs, gitlab | expand

Commit Message

Alex Bennée May 3, 2023, 9:12 a.m. UTC
We can't assume the machine exists and should gracefully skip the test
if we haven't built the model. This is ostensibly fixed by
db2237c459 (tests/qtest: Restrict bcm2835-dma-test to CONFIG_RASPI)
but I still hit it during my tests. Other qtests seem to use this
pattern to gracefully skip stuff.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/qtest/bcm2835-dma-test.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Thomas Huth May 3, 2023, 9:51 a.m. UTC | #1
On 03/05/2023 11.12, Alex Bennée wrote:
> We can't assume the machine exists and should gracefully skip the test
> if we haven't built the model. This is ostensibly fixed by
> db2237c459 (tests/qtest: Restrict bcm2835-dma-test to CONFIG_RASPI)
> but I still hit it during my tests.

The problem is likely that you build aarch64-softmmu with the minimal 
config, but still keep arm-softmmu around with the full config? Then 
CONFIG_RASPI will still be set at the meson.build level since it is taken 
from config-all-devices.mak here.

> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/qtest/bcm2835-dma-test.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/qtest/bcm2835-dma-test.c b/tests/qtest/bcm2835-dma-test.c
> index 8293d822b9..2e6245e9e2 100644
> --- a/tests/qtest/bcm2835-dma-test.c
> +++ b/tests/qtest/bcm2835-dma-test.c
> @@ -107,12 +107,11 @@ static void bcm2835_dma_test_interrupts(void)
>   
>   int main(int argc, char **argv)
>   {
> -    int ret;
>       g_test_init(&argc, &argv, NULL);
> -    qtest_add_func("/bcm2835/dma/test_interrupts",
> +    if (qtest_has_machine("raspi3b")) {
> +        qtest_add_func("/bcm2835/dma/test_interrupts",
>                      bcm2835_dma_test_interrupts);
> -    qtest_start("-machine raspi3b");
> -    ret = g_test_run();
> -    qtest_end();

Where did the qtest_end() go?

It's maybe cleaner if you move the qtest_start() and qtest_end() calls into 
the bcm2835_dma_test_interrupts() function instead.

  Thomas


> -    return ret;
> +        qtest_start("-machine raspi3b");
> +    }
> +    return g_test_run();
>   }
Alex Bennée May 3, 2023, 10:34 a.m. UTC | #2
Thomas Huth <thuth@redhat.com> writes:

> On 03/05/2023 11.12, Alex Bennée wrote:
>> We can't assume the machine exists and should gracefully skip the test
>> if we haven't built the model. This is ostensibly fixed by
>> db2237c459 (tests/qtest: Restrict bcm2835-dma-test to CONFIG_RASPI)
>> but I still hit it during my tests.
>
> The problem is likely that you build aarch64-softmmu with the minimal
> config, but still keep arm-softmmu around with the full config? Then
> CONFIG_RASPI will still be set at the meson.build level since it is
> taken from config-all-devices.mak here.
>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   tests/qtest/bcm2835-dma-test.c | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
>> diff --git a/tests/qtest/bcm2835-dma-test.c
>> b/tests/qtest/bcm2835-dma-test.c
>> index 8293d822b9..2e6245e9e2 100644
>> --- a/tests/qtest/bcm2835-dma-test.c
>> +++ b/tests/qtest/bcm2835-dma-test.c
>> @@ -107,12 +107,11 @@ static void bcm2835_dma_test_interrupts(void)
>>     int main(int argc, char **argv)
>>   {
>> -    int ret;
>>       g_test_init(&argc, &argv, NULL);
>> -    qtest_add_func("/bcm2835/dma/test_interrupts",
>> +    if (qtest_has_machine("raspi3b")) {
>> +        qtest_add_func("/bcm2835/dma/test_interrupts",
>>                      bcm2835_dma_test_interrupts);
>> -    qtest_start("-machine raspi3b");
>> -    ret = g_test_run();
>> -    qtest_end();
>
> Where did the qtest_end() go?

Yeah I dropped it because other tests seem to use the return
g_test_run() pattern. Maybe they are wrong?

>
> It's maybe cleaner if you move the qtest_start() and qtest_end() calls
> into the bcm2835_dma_test_interrupts() function instead.
>
>  Thomas
>
>
>> -    return ret;
>> +        qtest_start("-machine raspi3b");
>> +    }
>> +    return g_test_run();
>>   }
diff mbox series

Patch

diff --git a/tests/qtest/bcm2835-dma-test.c b/tests/qtest/bcm2835-dma-test.c
index 8293d822b9..2e6245e9e2 100644
--- a/tests/qtest/bcm2835-dma-test.c
+++ b/tests/qtest/bcm2835-dma-test.c
@@ -107,12 +107,11 @@  static void bcm2835_dma_test_interrupts(void)
 
 int main(int argc, char **argv)
 {
-    int ret;
     g_test_init(&argc, &argv, NULL);
-    qtest_add_func("/bcm2835/dma/test_interrupts",
+    if (qtest_has_machine("raspi3b")) {
+        qtest_add_func("/bcm2835/dma/test_interrupts",
                    bcm2835_dma_test_interrupts);
-    qtest_start("-machine raspi3b");
-    ret = g_test_run();
-    qtest_end();
-    return ret;
+        qtest_start("-machine raspi3b");
+    }
+    return g_test_run();
 }