[3/4] kernel32/tests: Add timer change/delete tests for timer queues.
Dan Hipschman
dsh at linux.ucla.edu
Wed Jul 16 19:44:27 CDT 2008
---
dlls/kernel32/tests/sync.c | 77 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index b01498b..22763c5 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -542,10 +542,54 @@ static void CALLBACK timer_queue_cb1(PVOID p, BOOLEAN timedOut)
++*pn;
}
+struct timer_queue_data1
+{
+ int num_calls;
+ int max_calls;
+ HANDLE q, t;
+};
+
+static void CALLBACK timer_queue_cb2(PVOID p, BOOLEAN timedOut)
+{
+ struct timer_queue_data1 *d = (struct timer_queue_data1 *) p;
+ ok(timedOut, "Timer callbacks should always time out\n");
+ /* Wait until our own timer handle is set to avoid a pretty much
+ impossible race condition (better safe than sorry). */
+ if (d->t)
+ if (++d->num_calls == d->max_calls)
+ {
+ BOOL ret;
+ SetLastError(0xdeadbeef);
+ /* Note, XP SP2 does *not* do any deadlock checking, so passing
+ INVALID_HANDLE_VALUE here will just hang. */
+ ret = DeleteTimerQueueTimer(d->q, d->t, NULL);
+ ok(!ret, "DeleteTimerQueueTimer\n");
+ todo_wine
+ ok(GetLastError() == ERROR_IO_PENDING, "DeleteTimerQueueTimer\n");
+ }
+}
+
+static void CALLBACK timer_queue_cb3(PVOID p, BOOLEAN timedOut)
+{
+ struct timer_queue_data1 *d = (struct timer_queue_data1 *) p;
+ ok(timedOut, "Timer callbacks should always time out\n");
+ /* Wait until our own timer handle is set to avoid a pretty much
+ impossible race condition (better safe than sorry). */
+ if (d->t)
+ if (++d->num_calls == d->max_calls)
+ {
+ /* Basically kill the timer since it won't have time to run
+ again. */
+ BOOL ret = ChangeTimerQueueTimer(d->q, d->t, 10000, 0);
+ ok(ret, "ChangeTimerQueueTimer\n");
+ }
+}
+
static void test_timer_queue(void)
{
HANDLE q, t1, t2, t3, t4, t5;
int n1, n2, n3, n4, n5;
+ struct timer_queue_data1 d2, d3;
HANDLE e;
BOOL ret;
@@ -636,6 +680,39 @@ static void test_timer_queue(void)
"Timer destruction event not triggered\n");
}
CloseHandle(e);
+
+ /* Test deleting/changing a timer in execution. */
+ q = CreateTimerQueue();
+ todo_wine
+ ok(q != NULL, "CreateTimerQueue\n");
+
+ d2.t = t2 = NULL;
+ d2.num_calls = 0;
+ d2.max_calls = 3;
+ d2.q = q;
+ ret = CreateTimerQueueTimer(&t2, q, timer_queue_cb2, &d2, 10,
+ 10, 0);
+ d2.t = t2;
+ ok(ret, "CreateTimerQueueTimer\n");
+
+ d3.t = t3 = NULL;
+ d3.num_calls = 0;
+ d3.max_calls = 4;
+ d3.q = q;
+ ret = CreateTimerQueueTimer(&t3, q, timer_queue_cb3, &d3, 10,
+ 10, 0);
+ d3.t = t3;
+ ok(ret, "CreateTimerQueueTimer\n");
+
+ Sleep(200);
+
+ ret = DeleteTimerQueueEx(q, INVALID_HANDLE_VALUE);
+ todo_wine
+ {
+ ok(ret, "DeleteTimerQueueEx\n");
+ ok(d2.num_calls == d2.max_calls, "DeleteTimerQueueTimer\n");
+ ok(d3.num_calls == d3.max_calls, "ChangeTimerQueueTimer\n");
+ }
}
START_TEST(sync)
More information about the wine-patches
mailing list