[PATCH v2] tests/qtest: Fix pxe-test build failure on Win32 due to missing memmem()

Zhuoying Cai posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261008195158.289711-1-zycai@linux.ibm.com
Maintainers: Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/pxe-test.c | 11 +++++++++++
1 file changed, 11 insertions(+)
[PATCH v2] tests/qtest: Fix pxe-test build failure on Win32 due to missing memmem()
Posted by Zhuoying Cai 1 month, 2 weeks ago
The s390x PXE tests use memmem() to probe the s390-ccw.img firmware
for device support strings before running each test. MinGW-w64 does
not provide memmem(), breaking the MSYS2/GCC build.

On Win32, skip the bios scan and return true; if the feature is absent
the test will time out rather than skip.

Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
Reported-by: Bernhard Beschow <shentey@gmail.com>
---
 tests/qtest/pxe-test.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
index 61c92a2df4..03e4054c5e 100644
--- a/tests/qtest/pxe-test.c
+++ b/tests/qtest/pxe-test.c
@@ -59,6 +59,7 @@ static testdef_t ppc64_tests_slow[] = {
     { NULL },
 };
 
+#ifndef _WIN32
 static const char *s390_bios_load(gsize *len)
 {
     static char *cached_contents;
@@ -106,9 +107,18 @@ out:
     *len = cached_len;
     return cached_contents;
 }
+#endif
 
 static bool s390_bios_has_string(const char *needle)
 {
+#ifdef _WIN32
+    /*
+     * memmem() is not available on win32; assume the string is present.
+     * If it is not, the test will timeout instead of detecting missing support.
+     */
+    g_test_message("\"%s\" assumed in bios", needle);
+    return true;
+#else
     const char *contents;
     gsize len;
     bool found;
@@ -118,6 +128,7 @@ static bool s390_bios_has_string(const char *needle)
 
     g_test_message("\"%s\" %s in bios", needle, found ? "found" : "not found");
     return found;
+#endif
 }
 
 static bool s390_bios_has_net_ccw(void)
-- 
2.56.0
Re: [PATCH v2] tests/qtest: Fix pxe-test build failure on Win32 due to missing memmem()
Posted by Eric Farman 1 month, 2 weeks ago

On 10/8/26 3:51 PM, Zhuoying Cai wrote:
> The s390x PXE tests use memmem() to probe the s390-ccw.img firmware
> for device support strings before running each test. MinGW-w64 does
> not provide memmem(), breaking the MSYS2/GCC build.
> 
> On Win32, skip the bios scan and return true; if the feature is absent
> the test will time out rather than skip.
> 
> Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
> Reported-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   tests/qtest/pxe-test.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)

Either this or Yonggang Luo's series works for me...

Tested-by: Eric Farman <farman@linux.ibm.com>

> 
> diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
> index 61c92a2df4..03e4054c5e 100644
> --- a/tests/qtest/pxe-test.c
> +++ b/tests/qtest/pxe-test.c
> @@ -59,6 +59,7 @@ static testdef_t ppc64_tests_slow[] = {
>       { NULL },
>   };
>   
> +#ifndef _WIN32
>   static const char *s390_bios_load(gsize *len)
>   {
>       static char *cached_contents;
> @@ -106,9 +107,18 @@ out:
>       *len = cached_len;
>       return cached_contents;
>   }
> +#endif
>   
>   static bool s390_bios_has_string(const char *needle)
>   {
> +#ifdef _WIN32
> +    /*
> +     * memmem() is not available on win32; assume the string is present.
> +     * If it is not, the test will timeout instead of detecting missing support.
> +     */
> +    g_test_message("\"%s\" assumed in bios", needle);
> +    return true;
> +#else
>       const char *contents;
>       gsize len;
>       bool found;
> @@ -118,6 +128,7 @@ static bool s390_bios_has_string(const char *needle)
>   
>       g_test_message("\"%s\" %s in bios", needle, found ? "found" : "not found");
>       return found;
> +#endif
>   }
>   
>   static bool s390_bios_has_net_ccw(void)
Re: [PATCH v2] tests/qtest: Fix pxe-test build failure on Win32 due to missing memmem()
Posted by Pierrick Bouvier 1 month, 2 weeks ago
Hi Eric,

On 10/8/2026 1:28 PM, Eric Farman wrote:
> 
> 
> On 10/8/26 3:51 PM, Zhuoying Cai wrote:
>> The s390x PXE tests use memmem() to probe the s390-ccw.img firmware
>> for device support strings before running each test. MinGW-w64 does
>> not provide memmem(), breaking the MSYS2/GCC build.
>>
>> On Win32, skip the bios scan and return true; if the feature is absent
>> the test will time out rather than skip.
>>
>> Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com>
>> Reported-by: Bernhard Beschow <shentey@gmail.com>
>> ---
>>   tests/qtest/pxe-test.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
> 
> Either this or Yonggang Luo's series works for me...
> 
> Tested-by: Eric Farman <farman@linux.ibm.com>
>

I'm pulling Yonggang implementation, which keeps the same behavior on
all OS.

Regards,
Pierrick