Sebastian Lackner : vcomp/tests: Add tests for _vcomp_master_begin and _vcomp_master_end.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Aug 7 10:57:42 CDT 2015
Module: wine
Branch: master
Commit: 0ff9a68af3fb1971253dc0c0af9508d82d5f5c90
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ff9a68af3fb1971253dc0c0af9508d82d5f5c90
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Fri Aug 7 08:21:09 2015 +0200
vcomp/tests: Add tests for _vcomp_master_begin and _vcomp_master_end.
---
dlls/vcomp/tests/vcomp.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/dlls/vcomp/tests/vcomp.c b/dlls/vcomp/tests/vcomp.c
index 5dbe166..99c98ef 100644
--- a/dlls/vcomp/tests/vcomp.c
+++ b/dlls/vcomp/tests/vcomp.c
@@ -60,6 +60,8 @@ static void (CDECL *p_vcomp_for_static_init)(int first, int last, int step, i
static void (CDECL *p_vcomp_for_static_simple_init)(unsigned int first, unsigned int last, int step,
BOOL increment, unsigned int *begin, unsigned int *end);
static void (WINAPIV *p_vcomp_fork)(BOOL ifval, int nargs, void *wrapper, ...);
+static int (CDECL *p_vcomp_master_begin)(void);
+static void (CDECL *p_vcomp_master_end)(void);
static void (CDECL *p_vcomp_sections_init)(int n);
static int (CDECL *p_vcomp_sections_next)(void);
static void (CDECL *p_vcomp_set_num_threads)(int num_threads);
@@ -228,6 +230,8 @@ static BOOL init_vcomp(void)
VCOMP_GET_PROC(_vcomp_for_static_init);
VCOMP_GET_PROC(_vcomp_for_static_simple_init);
VCOMP_GET_PROC(_vcomp_fork);
+ VCOMP_GET_PROC(_vcomp_master_begin);
+ VCOMP_GET_PROC(_vcomp_master_end);
VCOMP_GET_PROC(_vcomp_sections_init);
VCOMP_GET_PROC(_vcomp_sections_next);
VCOMP_GET_PROC(_vcomp_set_num_threads);
@@ -1122,6 +1126,48 @@ static void test_vcomp_for_dynamic_init(void)
pomp_set_num_threads(max_threads);
}
+static void CDECL master_cb(HANDLE semaphore)
+{
+ int num_threads = pomp_get_num_threads();
+ int thread_num = pomp_get_thread_num();
+
+ if (p_vcomp_master_begin())
+ {
+ ok(thread_num == 0, "expected thread_num == 0, got %d\n", thread_num);
+ if (num_threads >= 2)
+ {
+ DWORD result = WaitForSingleObject(semaphore, 1000);
+ ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+ }
+ p_vcomp_master_end();
+ }
+
+ if (thread_num == 1)
+ ReleaseSemaphore(semaphore, 1, NULL);
+}
+
+static void test_vcomp_master_begin(void)
+{
+ int max_threads = pomp_get_max_threads();
+ HANDLE semaphore;
+ int i;
+
+ semaphore = CreateSemaphoreA(NULL, 0, 1, NULL);
+ ok(semaphore != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
+
+ master_cb(semaphore);
+
+ for (i = 1; i <= 4; i++)
+ {
+ pomp_set_num_threads(i);
+ p_vcomp_fork(TRUE, 1, master_cb, semaphore);
+ p_vcomp_fork(FALSE, 1, master_cb, semaphore);
+ }
+
+ CloseHandle(semaphore);
+ pomp_set_num_threads(max_threads);
+}
+
static void test_atomic_integer32(void)
{
struct
@@ -1238,6 +1284,7 @@ START_TEST(vcomp)
test_vcomp_for_static_simple_init();
test_vcomp_for_static_init();
test_vcomp_for_dynamic_init();
+ test_vcomp_master_begin();
test_atomic_integer32();
test_atomic_float();
test_atomic_double();
More information about the wine-cvs
mailing list