[PATCH 0/1] MR1734: kernel32/tests: Avoid failures when processes start during the process test.
From: Francois Gouget <fgouget(a)codeweavers.com> 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 --- test_dead_process() also loops the NtQuerySystemInformation() call but its purpose is not to test that the returned size is valid so I think test_services_exe() needs a different style of loop. --- dlls/kernel32/tests/process.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index a15f8dd1fa8..5ac6ed57bbe 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -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; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1734
participants (2)
-
Francois Gouget -
Francois Gouget (@fgouget)