On Tue, 3 Dec 2024, Pali Rohár wrote:

On Tuesday 19 November 2024 13:42:19 Pali Rohár wrote:
---
 mingw-w64-crt/Makefile.am           |  1 +
 mingw-w64-crt/testcases/t_vsscanf.c | 33 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 mingw-w64-crt/testcases/t_vsscanf.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index ae3b04c1e8a4..5330145ebe10 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -4236,6 +4236,7 @@ testcase_progs = \
   testcases/t_tls1 \
   testcases/t_trycatch \
   testcases/t_stat_slash \
+  testcases/t_vsscanf \
   testcases/t_wreaddir \
   testcases/t_fseeko64

diff --git a/mingw-w64-crt/testcases/t_vsscanf.c 
b/mingw-w64-crt/testcases/t_vsscanf.c
new file mode 100644
index 000000000000..743bfcf2f5d5
--- /dev/null
+++ b/mingw-w64-crt/testcases/t_vsscanf.c
@@ -0,0 +1,33 @@
+#define __USE_MINGW_ANSI_STDIO 0
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+__attribute__((__format__(scanf, 2, 3)))
+static int call_vsscanf(const char *str, const char *format, ...)
+{
+  int ret;
+  va_list ap;
+  va_start(ap, format);
+  ret = vsscanf(str, format, ap);
+  va_end(ap);
+  return ret;
+}
+
+int main()
+{
+  char b[51];
+  call_vsscanf(
+    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY",
+    "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c"
+    "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
+    &b[0],&b[1],&b[2],&b[3],&b[4],&b[5],&b[6],&b[7],&b[8],&b[9],&b[10],
+    &b[11],&b[12],&b[13],&b[14],&b[15],&b[16],&b[17],&b[18],&b[19],&b[20],
+    &b[21],&b[22],&b[23],&b[24],&b[25],&b[26],&b[27],&b[28],&b[29],&b[30],
+    &b[31],&b[32],&b[33],&b[34],&b[35],&b[36],&b[37],&b[38],&b[39],&b[40],
+    &b[41],&b[42],&b[43],&b[44],&b[45],&b[46],&b[47],&b[48],&b[49],&b[50]
+  );
+  printf("b=%.51s\n", b);
+  return memcmp(b, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY", 51) 
== 0;
+}
--
2.20.1


I took this test from my older email:
https://sourceforge.net/p/mingw-w64/mailman/message/37605353/

I thought that it is a good idea to have it in existing mingw-w64
test suite, as I figured out that mingw-w64 has its own test suite.

And now after retesting it with make check and wine (as described in
other email) I figured out that it has wrong return value.

The test for make check must return zero on success, but
"memcmp(...) == 0" expression return true (1) on success.

So the "== 0" at the end should be removed. So just as:

 return memcmp(b, "abcd...", 51);

Hmm, I already pushed this test - can you send an incremental patch for it?

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to