Thomas Huth <[email protected]> writes:
> On 06/02/2023 16.04, Fabiano Rosas wrote:
>> Signed-off-by: Fabiano Rosas <[email protected]>
>> ---
>> tests/qtest/drive_del-test.c | 70 ++++++++++++++++++++++++++++++++++++
>> 1 file changed, 70 insertions(+)
>>
>> diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
>> index 9a750395a9..6fa96fa94a 100644
>> --- a/tests/qtest/drive_del-test.c
>> +++ b/tests/qtest/drive_del-test.c
>> @@ -16,6 +16,21 @@
>> #include "qapi/qmp/qdict.h"
>> #include "qapi/qmp/qlist.h"
>>
>> +static const char *qvirtio_get_dev_type(void);
>> +
>> +/*
>> + * This covers the possible absence of a device due to QEMU build
>> + * options.
>> + */
>> +static bool look_for_device_builtin(const char *prefix, const char *suffix)
>> +{
>> + gchar *device = g_strdup_printf("%s-%s", prefix, suffix);
>> + bool rc = qtest_has_device(device);
>> +
>> + g_free(device);
>> + return rc;
>> +}
>
> I think I'd rather merge the above code into the has_device_builtin()
> function below ... or is there a reason for keeping this separate?
No reason, I'll merge them.
>> static bool look_for_drive0(QTestState *qts, const char *command, const
>> char *key)
>> {
>> QDict *response;
>> @@ -40,6 +55,11 @@ static bool look_for_drive0(QTestState *qts, const char
>> *command, const char *ke
>> return found;
>> }
>>
>> +static bool has_device_builtin(const char *dev)
>> +{
>> + return look_for_device_builtin(dev, qvirtio_get_dev_type());
>> +}
>> +
>> static bool has_drive(QTestState *qts)
>> {
>> return look_for_drive0(qts, "query-block", "device");
>> @@ -208,6 +228,11 @@ static void test_drive_del_device_del(void)
>> {
>> QTestState *qts;
>>
>> + if (!has_device_builtin("virtio-scsi")) {
>> + g_test_skip(NULL);
>
> Having a short message for the skip would be nice.
ok.