[PATCH 1/2] kernel32/tests: Use debugstr_an to show contents of buffer.

Zebediah Figura z.figura12 at gmail.com
Mon Aug 31 09:59:05 CDT 2020


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 at 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));
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200831/d80a5b01/attachment.sig>


More information about the wine-devel mailing list