advapi32/tests: Avoid failure when GetServiceKeyName() gets a smart quote.

For non-English languages the Spooler display name may contain non-ASCII
characters, typically a smart quote. On Windows 7 GetServiceKeyName()
fails when it gets such characters.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2020-01-27 14:22:51 +01:00 committed by Alexandre Julliard
parent e9ec889dbf
commit 82aa066fcc
1 changed files with 19 additions and 0 deletions

View File

@ -720,6 +720,17 @@ static void test_get_displayname(void)
CloseServiceHandle(scm_handle); CloseServiceHandle(scm_handle);
} }
static int is_printable_ascii_str(const char *s)
{
while (*s)
{
if (*s < 32 || *s >= 127)
return 0;
s++;
}
return 1;
}
static void test_get_servicekeyname(void) static void test_get_servicekeyname(void)
{ {
SC_HANDLE scm_handle, svc_handle; SC_HANDLE scm_handle, svc_handle;
@ -861,6 +872,14 @@ static void test_get_servicekeyname(void)
servicesize = 0; servicesize = 0;
ret = GetServiceKeyNameA(scm_handle, displayname, NULL, &servicesize); ret = GetServiceKeyNameA(scm_handle, displayname, NULL, &servicesize);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
if (!is_printable_ascii_str(displayname) &&
GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
{
win_skip("GetServiceKeyName() does not support non-ASCII display names: %s\n", displayname); /* Windows 7 */
CloseServiceHandle(scm_handle);
return; /* All the tests that follow will fail too */
}
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());