Re: [PATCH 3/3] msvcrt100/tests: Add tests for concurrency::event
Hi, On 03/13/17 21:53, Daniel Lehman wrote:
+static void test_event(void) +{ + int i; + int ret; + int left; + int wait; + event evt; + event *evts[70]; + HANDLE thread; + HANDLE threads[NUMELMS(evts)]; + + call_func1(p_event_ctor, &evt); + + ret = call_func2(p_event_wait, &evt, 100); + ok(ret == -1, "expected -1, got %d\n", ret); + + call_func1(p_event_set, &evt); + ret = call_func2(p_event_wait, &evt, 100); + ok(!ret, "expected 0, got %d\n", ret); Could you please add following test here (to show that event is not reset after wait): ret = call_func2(p_event_wait, &evt, 100); ok(!ret, "expected 0, got %d\n", ret);
+ i = 0; + left = NUMELMS(evts); + while (left) { + wait = min(left, MAXIMUM_WAIT_OBJECTS); + WaitForMultipleObjects(wait, &threads[i], TRUE, 5000); + left -= wait; + i += wait; + } + + for (i = 0; i < NUMELMS(evts); i++) + CloseHandle(threads[i]); I think it's cleaner if you change the while and for loop to something like: for (i = 0; i < NUMELMS(threads); i++) { WaitForSingleObject(threads[i], INFINITE); CloseHandle(threads[i]); }
+ /* reset and test wait for multiple with any */ + for (i = 0; i < NUMELMS(evts); i++) + call_func1(p_event_reset, evts[i]); + + for (i = 0; i < NUMELMS(evts); i++) + threads[i] = CreateThread(NULL, 0, test_event_thread, (void*)evts[i], 0, NULL); + + ret = p_event_wait_for_multiple(evts, NUMELMS(evts), FALSE, 5000); + ok(ret != -1, "didn't expect -1\n"); Could you please start only one thread in this case and check exact return value from p_event_wait_for_multiple.
Could you please also add following test: static DWORD WINAPI multiple_events_thread(void *arg) { event **events = arg; Sleep(50); call_func1(p_event_set, events[0]); call_func1(p_event_reset, events[0]); call_func1(p_event_set, events[1]); call_func1(p_event_reset, events[1]); return 0; } call_func1(p_event_reset, evts[0]); call_func1(p_event_reset, evts[1]); thread = CreateThread(NULL, 0, multiple_events_thread, (void*)evts, 0, NULL); ret = p_event_wait_for_multiple(evts, 2, TRUE, 500); ok(ret == -1, "expect -1, got %d\n", ret); WaitForSingleObject(thread, INFINITE); CloseHandle(thread); Thanks, Piotr
participants (1)
-
Piotr Caban