kernel32/tests: Avoid failures when processes start during the process test.

On Windows processes sometimes start during test_services_exe() so that
the size returned by the first NtQuerySystemInformation() is no longer
sufficient for the second call.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54094
This commit is contained in:
Francois Gouget 2022-12-08 03:39:39 +01:00 committed by Alexandre Julliard
parent 926433faa3
commit 508b793ec9

View file

@ -4949,16 +4949,25 @@ static void test_job_list_attribute(HANDLE parent_job)
static void test_services_exe(void)
{
NTSTATUS status;
ULONG size, offset;
ULONG size, offset, try;
char *buf;
SYSTEM_PROCESS_INFORMATION *spi;
ULONG services_pid = 0, services_session_id = ~0;
status = NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &size);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got %#lx\n", status);
/* Check that passing a zero size returns a size suitable for the next call,
* taking into account that in rare cases processes may start between the
* two NtQuerySystemInformation() calls. So this may require a few tries.
*/
for (try = 0; try < 3; try++)
{
status = NtQuerySystemInformation(SystemProcessInformation, NULL, 0, &size);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got %#lx\n", status);
buf = malloc(size);
status = NtQuerySystemInformation(SystemProcessInformation, buf, size, &size);
buf = malloc(size);
status = NtQuerySystemInformation(SystemProcessInformation, buf, size, &size);
if (status != STATUS_INFO_LENGTH_MISMATCH) break;
free(buf);
}
ok(status == STATUS_SUCCESS, "got %#lx\n", status);
spi = (SYSTEM_PROCESS_INFORMATION *)buf;