From e80d84eb522d4b4f29d59985dd0abf1c05b0644b Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 25 Oct 2019 11:40:14 -0500 Subject: [PATCH] advapi32/tests: Clean up double NotifyServiceStatusChange() tests. Simplify different paths, explicitly test data2.was_called, and test that the correct notification is produced for Windows 8+ (previously an intermittent failure was observed due to this uninitialized field). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/advapi32/tests/service.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c index 75da3cd4831..aa9a69fed23 100644 --- a/dlls/advapi32/tests/service.c +++ b/dlls/advapi32/tests/service.c @@ -2434,16 +2434,23 @@ static void test_servicenotify(SC_HANDLE scm_handle, const char *servicename) data2.notify.dwVersion = SERVICE_NOTIFY_STATUS_CHANGE; data2.notify.pfnNotifyCallback = ¬ify_cb; data2.notify.pContext = &data2; + data2.phase = PHASE_RUNNING; + data2.was_called = FALSE; dr = pNotifyServiceStatusChangeW(svc, SERVICE_NOTIFY_STOPPED | SERVICE_NOTIFY_RUNNING, &data2.notify); - ok(dr == ERROR_SUCCESS || /* win8+ */ - dr == ERROR_ALREADY_REGISTERED, "NotifyServiceStatusChangeW gave wrong result: %u\n", dr); - - /* should receive no notification because status has not changed. - * on win8+, SleepEx quits early but the callback is still not invoked. */ - dr2 = SleepEx(100, TRUE); - ok((dr == ERROR_SUCCESS && dr2 == WAIT_IO_COMPLETION) || /* win8+ */ - (dr == ERROR_ALREADY_REGISTERED && dr2 == 0), "Got wrong SleepEx result: %u\n", dr); + ok(dr == ERROR_ALREADY_REGISTERED || !dr /* Win8+ */, "wrong error %u\n", dr); + if (!dr) + { + dr = SleepEx(100, TRUE); + ok(dr == WAIT_IO_COMPLETION, "got %u\n", dr); + ok(data2.was_called, "APC was not called\n"); + } + else + { + dr = SleepEx(100, TRUE); + ok(!dr, "got %u\n", dr); + ok(!data2.was_called, "APC should not have been called\n"); + } ok(data.was_called == FALSE, "APC should not have been called\n"); memset(&data2.notify, 0, sizeof(data2.notify));