[PATCH 20/51] tests/qtest: i440fx-test: Skip running request_{bios, pflash} for win32

Bin Meng posted 51 patches 3 years, 5 months ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Thomas Huth <thuth@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Greg Kurz <groug@kaod.org>, Christian Schoenebeck <qemu_oss@crudebyte.com>, "Cédric Le Goater" <clg@kaod.org>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Gerd Hoffmann <kraxel@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Michael Roth <michael.roth@amd.com>, Konstantin Kostiuk <kkostiuk@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, John Snow <jsnow@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <ani@anisinha.ca>, Alexander Bulekov <alxndr@bu.edu>, Bandan Das <bsd@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Darren Kenny <darren.kenny@oracle.com>, Qiuhao Li <Qiuhao.Li@outlook.com>, Havard Skinnemoen <hskinnemoen@google.com>, Tyrone Ting <kfting@nuvoton.com>, Markus Armbruster <armbru@redhat.com>, Coiby Xu <Coiby.Xu@gmail.com>, Jason Wang <jasowang@redhat.com>, Fam Zheng <fam@euphon.net>
There is a newer version of this series
[PATCH 20/51] tests/qtest: i440fx-test: Skip running request_{bios, pflash} for win32
Posted by Bin Meng 3 years, 5 months ago
From: Bin Meng <bin.meng@windriver.com>

The request_{bios,pflash} test cases call mmap() which does not
exist on win32. Exclude them.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 tests/qtest/i440fx-test.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/qtest/i440fx-test.c b/tests/qtest/i440fx-test.c
index 6d7d4d8d8f..3890f1237c 100644
--- a/tests/qtest/i440fx-test.c
+++ b/tests/qtest/i440fx-test.c
@@ -278,6 +278,8 @@ static void test_i440fx_pam(gconstpointer opaque)
     qtest_end();
 }
 
+#ifndef _WIN32
+
 #define BLOB_SIZE ((size_t)65536)
 #define ISA_BIOS_MAXSZ ((size_t)(128 * 1024))
 
@@ -396,6 +398,8 @@ static void request_pflash(FirmwareTestFixture *fixture,
     fixture->is_bios = false;
 }
 
+#endif /* _WIN32 */
+
 int main(int argc, char **argv)
 {
     TestData data;
@@ -406,8 +410,10 @@ int main(int argc, char **argv)
 
     qtest_add_data_func("i440fx/defaults", &data, test_i440fx_defaults);
     qtest_add_data_func("i440fx/pam", &data, test_i440fx_pam);
+#ifndef _WIN32
     add_firmware_test("i440fx/firmware/bios", request_bios);
     add_firmware_test("i440fx/firmware/pflash", request_pflash);
+#endif
 
     return g_test_run();
 }
-- 
2.34.1
Re: [PATCH 20/51] tests/qtest: i440fx-test: Skip running request_{bios, pflash} for win32
Posted by Marc-André Lureau 3 years, 5 months ago
Hi

On Wed, Aug 24, 2022 at 2:15 PM Bin Meng <bmeng.cn@gmail.com> wrote:

> From: Bin Meng <bin.meng@windriver.com>
>
> The request_{bios,pflash} test cases call mmap() which does not
> exist on win32. Exclude them.
>
>
We can fairly easily rewrite the create_blob_file() function to be portable
though, something like:

static char *create_blob_file(void)
{
    g_autofree uint8_t *buf = g_malloc(BLOB_SIZE);
    GError *error = NULL;
    char *pathname;
    int fd;
    size_t i;

    fd = g_file_open_tmp("blob_XXXXXX", &pathname, &error);
    g_assert_no_error(error);

    for (i = 0; i < BLOB_SIZE; ++i) {
        buf[i] = i;
    }

    g_file_set_contents(pathname, (char *)buf, BLOB_SIZE, &error);
    g_assert_no_error(error);
    close(fd);

    return pathname;
}

Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
>
>  tests/qtest/i440fx-test.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tests/qtest/i440fx-test.c b/tests/qtest/i440fx-test.c
> index 6d7d4d8d8f..3890f1237c 100644
> --- a/tests/qtest/i440fx-test.c
> +++ b/tests/qtest/i440fx-test.c
> @@ -278,6 +278,8 @@ static void test_i440fx_pam(gconstpointer opaque)
>      qtest_end();
>  }
>
> +#ifndef _WIN32
> +
>  #define BLOB_SIZE ((size_t)65536)
>  #define ISA_BIOS_MAXSZ ((size_t)(128 * 1024))
>
> @@ -396,6 +398,8 @@ static void request_pflash(FirmwareTestFixture
> *fixture,
>      fixture->is_bios = false;
>  }
>
> +#endif /* _WIN32 */
> +
>  int main(int argc, char **argv)
>  {
>      TestData data;
> @@ -406,8 +410,10 @@ int main(int argc, char **argv)
>
>      qtest_add_data_func("i440fx/defaults", &data, test_i440fx_defaults);
>      qtest_add_data_func("i440fx/pam", &data, test_i440fx_pam);
> +#ifndef _WIN32
>      add_firmware_test("i440fx/firmware/bios", request_bios);
>      add_firmware_test("i440fx/firmware/pflash", request_pflash);
> +#endif
>
>      return g_test_run();
>  }
> --
> 2.34.1
>
>
>

-- 
Marc-André Lureau
Re: [PATCH 20/51] tests/qtest: i440fx-test: Skip running request_{bios, pflash} for win32
Posted by Bin Meng 3 years, 5 months ago
On Wed, Aug 31, 2022 at 9:40 PM Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
>
> Hi
>
> On Wed, Aug 24, 2022 at 2:15 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>>
>> From: Bin Meng <bin.meng@windriver.com>
>>
>> The request_{bios,pflash} test cases call mmap() which does not
>> exist on win32. Exclude them.
>>
>
> We can fairly easily rewrite the create_blob_file() function to be portable though, something like:

Thanks for the suggestion!

Will spin a patch in v2.

>
> static char *create_blob_file(void)
> {
>     g_autofree uint8_t *buf = g_malloc(BLOB_SIZE);
>     GError *error = NULL;
>     char *pathname;
>     int fd;
>     size_t i;
>
>     fd = g_file_open_tmp("blob_XXXXXX", &pathname, &error);
>     g_assert_no_error(error);
>
>     for (i = 0; i < BLOB_SIZE; ++i) {
>         buf[i] = i;
>     }
>
>     g_file_set_contents(pathname, (char *)buf, BLOB_SIZE, &error);
>     g_assert_no_error(error);
>     close(fd);
>
>     return pathname;
> }
>
>> Signed-off-by: Bin Meng <bin.meng@windriver.com>
>> ---
>>
>>  tests/qtest/i440fx-test.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>

Regards,
Bin
Re: [PATCH 20/51] tests/qtest: i440fx-test: Skip running request_{bios,pflash} for win32
Posted by Thomas Huth 3 years, 5 months ago
On 24/08/2022 11.39, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> The request_{bios,pflash} test cases call mmap() which does not
> exist on win32. Exclude them.
> 
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
> 
>   tests/qtest/i440fx-test.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/tests/qtest/i440fx-test.c b/tests/qtest/i440fx-test.c
> index 6d7d4d8d8f..3890f1237c 100644
> --- a/tests/qtest/i440fx-test.c
> +++ b/tests/qtest/i440fx-test.c
> @@ -278,6 +278,8 @@ static void test_i440fx_pam(gconstpointer opaque)
>       qtest_end();
>   }
>   
> +#ifndef _WIN32
> +
>   #define BLOB_SIZE ((size_t)65536)
>   #define ISA_BIOS_MAXSZ ((size_t)(128 * 1024))
>   
> @@ -396,6 +398,8 @@ static void request_pflash(FirmwareTestFixture *fixture,
>       fixture->is_bios = false;
>   }
>   
> +#endif /* _WIN32 */
> +
>   int main(int argc, char **argv)
>   {
>       TestData data;
> @@ -406,8 +410,10 @@ int main(int argc, char **argv)
>   
>       qtest_add_data_func("i440fx/defaults", &data, test_i440fx_defaults);
>       qtest_add_data_func("i440fx/pam", &data, test_i440fx_pam);
> +#ifndef _WIN32
>       add_firmware_test("i440fx/firmware/bios", request_bios);
>       add_firmware_test("i440fx/firmware/pflash", request_pflash);
> +#endif
>   
>       return g_test_run();
>   }

Reviewed-by: Thomas Huth <thuth@redhat.com>