Alexandre Julliard : kernel32/tests: Fix FormatMessage test failures on various Windows versions.

Alexandre Julliard julliard at winehq.org
Fri Oct 30 11:04:29 CDT 2009


Module: wine
Branch: master
Commit: 36e56ad1aa3214c148725a626b5df678981b13b1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=36e56ad1aa3214c148725a626b5df678981b13b1

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Oct 29 22:10:21 2009 +0100

kernel32/tests: Fix FormatMessage test failures on various Windows versions.

---

 dlls/kernel32/tests/format_msg.c |   81 ++++++++++++++++++++++---------------
 include/winerror.h               |    9 ++++
 2 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/dlls/kernel32/tests/format_msg.c b/dlls/kernel32/tests/format_msg.c
index 583cae8..dbd7fc7 100644
--- a/dlls/kernel32/tests/format_msg.c
+++ b/dlls/kernel32/tests/format_msg.c
@@ -121,6 +121,7 @@ static void test_message_from_string_wide(void)
     static const WCHAR s_sp001sp002[] = {' ',' ','0','0','1',',',' ',' ','0','0','0','2',0};
     static const WCHAR s_sp002sp001[] = {' ',' ','0','0','0','2',',',' ',' ','0','0','1',0};
     static const WCHAR s_sp002sp003[] = {' ',' ','0','0','0','2',',',' ','0','0','0','0','3',0};
+    static const WCHAR s_sp001004[]   = {' ',' ','0','0','1',',','0','0','0','0','0','4',0};
 
     WCHAR out[0x100] = {0};
     DWORD r, error;
@@ -337,7 +338,8 @@ static void test_message_from_string_wide(void)
     ok(r==11,"failed: r=%d\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, fmt_1oou3oou,
               0, 0, out, sizeof(out)/sizeof(WCHAR), 5, 3, 1, 6, 4, 2 );
-    ok(!lstrcmpW( s_sp001sp002, out),"failed out=[%s]\n", wine_dbgstr_w(out));
+    ok(!lstrcmpW( s_sp001sp002, out) || broken(!lstrcmpW(s_sp001004, out)),
+       "failed out=[%s]\n", wine_dbgstr_w(out));
     ok(r==12,"failed: r=%d\n",r);
     /* args are not counted the same way with an argument array */
     {
@@ -573,35 +575,42 @@ static void test_message_from_string(void)
     ok(r==3, "failed: r=%d\n",r);
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*s!",
              0, 0, out, sizeof(out), 4, "t");
-    ok(!strcmp( "   t", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
-    r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4.2u!",
-             0, 0, out, sizeof(out), 3 );
-    ok(!strcmp( "  03", out),"failed out=[%s]\n",out);
-    ok(r==4,"failed: r=%d\n",r);
-    r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!",
-             0, 0, out, sizeof(out), 5, 3, 1 );
-    ok(!strcmp( "  001", out),"failed out=[%s]\n",out);
-    ok(r==5,"failed: r=%d\n",r);
-    r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%1!*.*u!",
-             0, 0, out, sizeof(out), 5, 3, 1, 4, 2 );
-    ok(!strcmp( "  001, 0002", out),"failed out=[%s]\n",out);
-    ok(r==11,"failed: r=%d\n",r);
-    r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
-             0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
-    ok(!strcmp( "  001,  0002", out),"failed out=[%s]\n",out);
-    ok(r==12,"failed: r=%d\n",r);
-    /* args are not counted the same way with an argument array */
+    if (!strcmp("*s",out)) win_skip( "width/precision not supported\n" );
+    else
     {
-        ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 };
-        r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                           "%1!*.*u!,%1!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
-        ok(!strcmp("  0002, 00003", out),"failed out=[%s]\n",out);
-        ok(r==13,"failed: r=%d\n",r);
-        r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                           "%1!*.*u!,%4!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
-        ok(!strcmp("  0002,  001", out),"failed out=[%s]\n",out);
+        ok(!strcmp( "   t", out),"failed out=[%s]\n",out);
+        ok(r==4,"failed: r=%d\n",r);
+        r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!4.2u!",
+                 0, 0, out, sizeof(out), 3 );
+        ok(!strcmp( "  03", out),"failed out=[%s]\n",out);
+        ok(r==4,"failed: r=%d\n",r);
+        r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!",
+                 0, 0, out, sizeof(out), 5, 3, 1 );
+        ok(!strcmp( "  001", out),"failed out=[%s]\n",out);
+        ok(r==5,"failed: r=%d\n",r);
+        r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%1!*.*u!",
+                 0, 0, out, sizeof(out), 5, 3, 1, 4, 2 );
+        ok(!strcmp( "  001, 0002", out),"failed out=[%s]\n",out);
+        ok(r==11,"failed: r=%d\n",r);
+        r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
+                 0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
+        /* older Win versions marked as broken even though this is arguably the correct behavior */
+        /* but the new (brain-damaged) behavior is specified on MSDN */
+        ok(!strcmp( "  001,  0002", out) || broken(!strcmp("  001,000004", out)),
+           "failed out=[%s]\n",out);
         ok(r==12,"failed: r=%d\n",r);
+        /* args are not counted the same way with an argument array */
+        {
+            ULONG_PTR args[] = { 6, 4, 2, 5, 3, 1 };
+            r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
+                               "%1!*.*u!,%1!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
+            ok(!strcmp("  0002, 00003", out),"failed out=[%s]\n",out);
+            ok(r==13,"failed: r=%d\n",r);
+            r = FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
+                               "%1!*.*u!,%4!*.*u!", 0, 0, out, sizeof(out), (__ms_va_list *)args );
+            ok(!strcmp("  0002,  001", out),"failed out=[%s]\n",out);
+            ok(r==12,"failed: r=%d\n",r);
+        }
     }
 
     /* change of pace... test the low byte of dwflags */
@@ -677,35 +686,41 @@ static void test_message_from_hmodule(void)
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL);
     error = GetLastError();
     ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
-    ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error);
+    ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_FOUND, "last error %u\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL);
     error = GetLastError();
     ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
-    ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error);
+    ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL);
     error = GetLastError();
     ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
-    ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error);
+    ok(error == ERROR_MR_MID_NOT_FOUND || error == ERROR_MUI_FILE_NOT_LOADED, "last error %u\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), out, sizeof(out)/sizeof(CHAR), NULL);
     error = GetLastError();
     ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
-    ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error);
+    ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
+       error == ERROR_MR_MID_NOT_FOUND ||
+       error == ERROR_MUI_FILE_NOT_LOADED,
+       "last error %u\n", error);
 
     SetLastError(0xdeadbeef);
     ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044,
                          MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), out, sizeof(out)/sizeof(CHAR), NULL);
     error = GetLastError();
     ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
-    ok(error == ERROR_RESOURCE_LANG_NOT_FOUND, "last error %u\n", error);
+    ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
+       error == ERROR_MR_MID_NOT_FOUND ||
+       error == ERROR_MUI_FILE_NOT_FOUND,
+       "last error %u\n", error);
 }
 
 START_TEST(format_msg)
diff --git a/include/winerror.h b/include/winerror.h
index a1fa985..5d02c06 100644
--- a/include/winerror.h
+++ b/include/winerror.h
@@ -1559,6 +1559,15 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
 #define ERROR_SXS_THREAD_QUERIES_DISABLED                  14010
 #define ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET              14011
 #define ERROR_SXS_CORRUPTION                               14083
+#define ERROR_MUI_FILE_NOT_FOUND                           15100
+#define ERROR_MUI_INVALID_FILE                             15101
+#define ERROR_MUI_INVALID_RC_CONFIG                        15102
+#define ERROR_MUI_INVALID_LOCALE_NAME                      15103
+#define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME            15104
+#define ERROR_MUI_FILE_NOT_LOADED                          15105
+#define ERROR_RESOURCE_ENUM_USER_STOP                      15106
+#define ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED        15107
+#define ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME         15108
 
 /* HRESULT values for OLE, SHELL and other Interface stuff */
 /* the codes 4000-40ff are reserved for OLE */




More information about the wine-cvs mailing list