diff mbox series

[04/12] tests/qtest: Skip virtio-serial-console tests if device not present

Message ID 20230206150416.4604-5-farosas@suse.de (mailing list archive)
State New, archived
Headers show
Series qtests vs. default devices | expand

Commit Message

Fabiano Rosas Feb. 6, 2023, 3:04 p.m. UTC
The virtconsole device might not be present in the QEMU build that is
being tested. Skip the test if that's the case.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/virtio-serial-test.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Thomas Huth Feb. 7, 2023, 1:25 p.m. UTC | #1
On 06/02/2023 16.04, Fabiano Rosas wrote:
> The virtconsole device might not be present in the QEMU build that is
> being tested. Skip the test if that's the case.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/qtest/virtio-serial-test.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tests/qtest/virtio-serial-test.c b/tests/qtest/virtio-serial-test.c
> index 2541034822..f4e05e8fdd 100644
> --- a/tests/qtest/virtio-serial-test.c
> +++ b/tests/qtest/virtio-serial-test.c
> @@ -28,6 +28,10 @@ static void register_virtio_serial_test(void)
>   {
>       QOSGraphTestOptions opts = { };
>   
> +    if (!qtest_has_device("virtconsole")) {
> +        return;
> +    }
> +
>       opts.edge.before_cmd_line = "-device virtconsole,bus=vser0.0";
>       qos_add_test("console-nop", "virtio-serial", virtio_serial_nop, &opts);
>   

virtio-serial-test.c is a qos test - and this should detect automatically 
already whether a device is available and pluggable or not, I think.

There must be something else wrong here ... Laurent, Paolo, any ideas?

  Thomas
Thomas Huth Feb. 7, 2023, 1:37 p.m. UTC | #2
On 06/02/2023 16.04, Fabiano Rosas wrote:
> The virtconsole device might not be present in the QEMU build that is
> being tested. Skip the test if that's the case.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/qtest/virtio-serial-test.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tests/qtest/virtio-serial-test.c b/tests/qtest/virtio-serial-test.c
> index 2541034822..f4e05e8fdd 100644
> --- a/tests/qtest/virtio-serial-test.c
> +++ b/tests/qtest/virtio-serial-test.c
> @@ -28,6 +28,10 @@ static void register_virtio_serial_test(void)
>   {
>       QOSGraphTestOptions opts = { };
>   
> +    if (!qtest_has_device("virtconsole")) {
> +        return;
> +    }

Maybe it makes more sense to check for CONFIG_VIRTIO_SERIAL in the 
meson.build file first?

  Thomas
Laurent Vivier Feb. 7, 2023, 3:35 p.m. UTC | #3
On 2/7/23 14:25, Thomas Huth wrote:
> On 06/02/2023 16.04, Fabiano Rosas wrote:
>> The virtconsole device might not be present in the QEMU build that is
>> being tested. Skip the test if that's the case.
>>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>>   tests/qtest/virtio-serial-test.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/qtest/virtio-serial-test.c b/tests/qtest/virtio-serial-test.c
>> index 2541034822..f4e05e8fdd 100644
>> --- a/tests/qtest/virtio-serial-test.c
>> +++ b/tests/qtest/virtio-serial-test.c
>> @@ -28,6 +28,10 @@ static void register_virtio_serial_test(void)
>>   {
>>       QOSGraphTestOptions opts = { };
>> +    if (!qtest_has_device("virtconsole")) {
>> +        return;
>> +    }
>> +
>>       opts.edge.before_cmd_line = "-device virtconsole,bus=vser0.0";
>>       qos_add_test("console-nop", "virtio-serial", virtio_serial_nop, &opts);
> 
> virtio-serial-test.c is a qos test - and this should detect automatically already whether 
> a device is available and pluggable or not, I think.
> 
> There must be something else wrong here ... Laurent, Paolo, any ideas?

I think the checking of the device should be added where the device is added to the qos 
tree, in libqos/virtio-serial.c

If you don't add the device then the test is not started.

If I remember correctly, there was no autodetection of the devices, all are added statically.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/tests/qtest/virtio-serial-test.c b/tests/qtest/virtio-serial-test.c
index 2541034822..f4e05e8fdd 100644
--- a/tests/qtest/virtio-serial-test.c
+++ b/tests/qtest/virtio-serial-test.c
@@ -28,6 +28,10 @@  static void register_virtio_serial_test(void)
 {
     QOSGraphTestOptions opts = { };
 
+    if (!qtest_has_device("virtconsole")) {
+        return;
+    }
+
     opts.edge.before_cmd_line = "-device virtconsole,bus=vser0.0";
     qos_add_test("console-nop", "virtio-serial", virtio_serial_nop, &opts);