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

Alex Bennée posted 22 patches 2 years, 7 months ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Helge Deller <deller@gmx.de>, Xiaojuan Yang <yangxiaojuan@loongson.cn>, Song Gao <gaosong@loongson.cn>, Yoshinori Sato <ysato@users.sourceforge.jp>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>, Max Filippov <jcmvbkbc@gmail.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Paolo Bonzini <pbonzini@redhat.com>, Cleber Rosa <crosa@redhat.com>, Laurent Vivier <lvivier@redhat.com>
[PATCH 22/22] tests/qtest: skip bcm2835-test if no raspi3b model
Posted by Alex Bennée 2 years, 7 months ago
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(-)

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();
 }
-- 
2.39.2


Re: [PATCH 22/22] tests/qtest: skip bcm2835-test if no raspi3b model
Posted by Thomas Huth 2 years, 7 months ago
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();
>   }


Re: [PATCH 22/22] tests/qtest: skip bcm2835-test if no raspi3b model
Posted by Alex Bennée 2 years, 7 months ago
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();
>>   }


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro