In the tests modified the buffer to show is expected to contain strings separated by \0. So that passing the buffer to the ok macro will only print the first string. Showing the whole returned buffer gives more information when the test fails.
Signed-off-by: Carlos Rivera carlos@superkaos.org --- dlls/kernel32/tests/profile.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 2fba26542f..c077f8b35b 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -591,8 +591,10 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, MAX_PATH, filename); ok(ret == 18, "Expected 18, got %d\n", ret); len = lstrlenA("section1") + sizeof(CHAR) + lstrlenA("section2") + 2 * sizeof(CHAR); - ok(!memcmp(buf, "section1\0section2\0\0", len), - "Expected "section1\0section2\0\0", got "%s"\n", buf); + + ok(!memcmp(buf, "section1\0section2\0", len), + "Expected "section1\x00section2\x00\x00", got %s\n", + debugstr_an(buf, (ret + 2 >= MAX_PATH ? MAX_PATH : ret + 1)));
/* lpAppName is empty */ memset(buf, 0xc, sizeof(buf)); @@ -667,7 +669,8 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, MAX_PATH, filename); ok(ret == 18, "Expected 18, got %d\n", ret); ok(!memcmp(buf, "name1\0name2\0name4\0", ret + 1), - "Expected "name1\0name2\0name4\0", got "%s"\n", buf); + "Expected "name1\x00name2\x00name4\x00\x00", got %s\n", + debugstr_an(buf, (ret + 2 >= MAX_PATH ? MAX_PATH : ret + 1)));
/* lpKeyName is empty */ memset(buf, 0xc,sizeof(buf)); @@ -794,8 +797,9 @@ static void test_GetPrivateProfileString(const char *content, const char *descri ok(ret == 14, "Expected 14, got %d\n", ret); len = lstrlenA("section1") + 2 * sizeof(CHAR); todo_wine - ok(!memcmp(buf, "section1\0secti\0\0", ret + 2), - "Expected "section1\0secti\0\0", got "%s"\n", buf); + ok(!memcmp(buf, "section1\0secti\0", ret + 2), + "Expected "section1\x00secti\x00\x00", got %s\n", + debugstr_an(buf, (ret + 2 >= 16 ? 16 : ret + 1)));
/* lpKeyName is NULL, not enough room for final key name */ memset(buf, 0xc,sizeof(buf)); @@ -804,8 +808,9 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, 16, filename); ok(ret == 14, "Expected 14, got %d\n", ret); todo_wine - ok(!memcmp(buf, "name1\0name2\0na\0\0", ret + 2), - "Expected "name1\0name2\0na\0\0", got "%s"\n", buf); + ok(!memcmp(buf, "name1\0name2\0na\0", ret + 2), + "Expected "name1\x00name2\x00na\x00\x00", got %s\n", + debugstr_an(buf, (ret + 2 >= 16 ? 16 : ret + 1)));
/* key value has quotation marks which are stripped */ memset(buf, 0xc,sizeof(buf));
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=77780
Your paranoid android.
=== debiant (32 bit report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit French report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit Japanese:Japan report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit Chinese:China report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (32 bit WoW report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
=== debiant (64 bit WoW report) ===
kernel32: profile.c:222: Test succeeded inside todo block: expected ERROR_FILE_NOT_FOUND, got 2
Hello Carlos, thanks for the patch! I just have one comment inlined:
On 8/31/20 4:37 AM, Carlos Rivera wrote:
In the tests modified the buffer to show is expected to contain strings separated by \0. So that passing the buffer to the ok macro will only print the first string. Showing the whole returned buffer gives more information when the test fails.
Signed-off-by: Carlos Rivera carlos@superkaos.org
dlls/kernel32/tests/profile.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/tests/profile.c b/dlls/kernel32/tests/profile.c index 2fba26542f..c077f8b35b 100644 --- a/dlls/kernel32/tests/profile.c +++ b/dlls/kernel32/tests/profile.c @@ -591,8 +591,10 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, MAX_PATH, filename); ok(ret == 18, "Expected 18, got %d\n", ret); len = lstrlenA("section1") + sizeof(CHAR) + lstrlenA("section2") + 2 * sizeof(CHAR);
- ok(!memcmp(buf, "section1\0section2\0\0", len),
"Expected \"section1\\0section2\\0\\0\", got \"%s\"\n", buf);
- ok(!memcmp(buf, "section1\0section2\0", len),
"Expected \"section1\\x00section2\\x00\\x00\", got %s\n",
debugstr_an(buf, (ret + 2 >= MAX_PATH ? MAX_PATH : ret + 1)));
Checking for sanity like this strikes me as overkill; we can probably expect the result from GetPrivateProfileString() to be sane.
Note also that if you do, encouraging use of sizeof(buf) seems like a good idea, and you could also the min() macro to simplify the expression.
/* lpAppName is empty */ memset(buf, 0xc, sizeof(buf));
@@ -667,7 +669,8 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, MAX_PATH, filename); ok(ret == 18, "Expected 18, got %d\n", ret); ok(!memcmp(buf, "name1\0name2\0name4\0", ret + 1),
"Expected \"name1\\0name2\\0name4\\0\", got \"%s\"\n", buf);
"Expected \"name1\\x00name2\\x00name4\\x00\\x00\", got %s\n",
debugstr_an(buf, (ret + 2 >= MAX_PATH ? MAX_PATH : ret + 1)));
/* lpKeyName is empty */ memset(buf, 0xc,sizeof(buf));
@@ -794,8 +797,9 @@ static void test_GetPrivateProfileString(const char *content, const char *descri ok(ret == 14, "Expected 14, got %d\n", ret); len = lstrlenA("section1") + 2 * sizeof(CHAR); todo_wine
- ok(!memcmp(buf, "section1\0secti\0\0", ret + 2),
"Expected \"section1\\0secti\\0\\0\", got \"%s\"\n", buf);
ok(!memcmp(buf, "section1\0secti\0", ret + 2),
"Expected \"section1\\x00secti\\x00\\x00\", got %s\n",
debugstr_an(buf, (ret + 2 >= 16 ? 16 : ret + 1)));
/* lpKeyName is NULL, not enough room for final key name */ memset(buf, 0xc,sizeof(buf));
@@ -804,8 +808,9 @@ static void test_GetPrivateProfileString(const char *content, const char *descri buf, 16, filename); ok(ret == 14, "Expected 14, got %d\n", ret); todo_wine
- ok(!memcmp(buf, "name1\0name2\0na\0\0", ret + 2),
"Expected \"name1\\0name2\\0na\\0\\0\", got \"%s\"\n", buf);
ok(!memcmp(buf, "name1\0name2\0na\0", ret + 2),
"Expected \"name1\\x00name2\\x00na\\x00\\x00\", got %s\n",
debugstr_an(buf, (ret + 2 >= 16 ? 16 : ret + 1)));
/* key value has quotation marks which are stripped */ memset(buf, 0xc,sizeof(buf));