Piotr Caban : msvcrt/tests: Add Context::Id tests.
Alexandre Julliard
julliard at winehq.org
Thu Mar 23 15:34:54 CDT 2017
Module: wine
Branch: master
Commit: ccdd3673e7a6d5369620670fe5be49e099ea8941
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ccdd3673e7a6d5369620670fe5be49e099ea8941
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Mar 23 11:41:17 2017 +0100
msvcrt/tests: Add Context::Id tests.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcr100/tests/msvcr100.c | 53 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/dlls/msvcr100/tests/msvcr100.c b/dlls/msvcr100/tests/msvcr100.c
index ac167fc..295e287 100644
--- a/dlls/msvcr100/tests/msvcr100.c
+++ b/dlls/msvcr100/tests/msvcr100.c
@@ -142,6 +142,10 @@ typedef struct {
char pad[64];
} event;
+typedef struct {
+ void *vtable;
+} Context;
+
static int* (__cdecl *p_errno)(void);
static int (__cdecl *p_wmemcpy_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count);
static int (__cdecl *p_wmemmove_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count);
@@ -189,6 +193,9 @@ static void (__thiscall *p_event_set)(event*);
static size_t (__thiscall *p_event_wait)(event*, unsigned int);
static int (__cdecl *p_event_wait_for_multiple)(event**, size_t, MSVCRT_bool, unsigned int);
+static Context* (__cdecl *p_Context_CurrentContext)(void);
+unsigned int (__cdecl *p_Context_Id)(void);
+
/* make sure we use the correct errno */
#undef errno
#define errno (*p_errno())
@@ -221,6 +228,8 @@ static BOOL init(void)
SET(p__aligned_msize, "_aligned_msize");
SET(p_atoi, "atoi");
+ SET(p_Context_Id, "?Id at Context@Concurrency@@SAIXZ");
+
if(sizeof(void*) == 8) { /* 64-bit initialization */
SET(pSpinWait_ctor_yield, "??0?$_SpinWait@$00 at details@Concurrency@@QEAA at P6AXXZ@Z");
SET(pSpinWait_dtor, "??_F?$_SpinWait@$00 at details@Concurrency@@QEAAXXZ");
@@ -255,6 +264,8 @@ static BOOL init(void)
SET(p_event_set, "?set at event@Concurrency@@QEAAXXZ");
SET(p_event_wait, "?wait at event@Concurrency@@QEAA_KI at Z");
SET(p_event_wait_for_multiple, "?wait_for_multiple at event@Concurrency@@SA_KPEAPEAV12 at _K_NI@Z");
+
+ SET(p_Context_CurrentContext, "?CurrentContext at Context@Concurrency@@SAPEAV12 at XZ");
} else {
SET(pSpinWait_ctor_yield, "??0?$_SpinWait@$00 at details@Concurrency@@QAE at P6AXXZ@Z");
SET(pSpinWait_dtor, "??_F?$_SpinWait@$00 at details@Concurrency@@QAEXXZ");
@@ -289,6 +300,8 @@ static BOOL init(void)
SET(p_event_set, "?set at event@Concurrency@@QAEXXZ");
SET(p_event_wait, "?wait at event@Concurrency@@QAEII at Z");
SET(p_event_wait_for_multiple, "?wait_for_multiple at event@Concurrency@@SAIPAPAV12 at I_NI@Z");
+
+ SET(p_Context_CurrentContext, "?CurrentContext at Context@Concurrency@@SAPAV12 at XZ");
}
init_thiscall_thunk();
@@ -836,11 +849,51 @@ static void test_event(void)
call_func1(p_event_dtor, &evt);
}
+static DWORD WINAPI external_context_thread(void *arg)
+{
+ unsigned int id;
+ Context *ctx;
+
+ id = p_Context_Id();
+ ok(id == -1, "Context::Id() = %u\n", id);
+
+ ctx = p_Context_CurrentContext();
+ ok(ctx != NULL, "Context::CurrentContext() = NULL\n");
+ id = p_Context_Id();
+ ok(id == 1, "Context::Id() = %u\n", id);
+ return 0;
+}
+
+static void test_ExternalContextBase(void)
+{
+ unsigned int id;
+ Context *ctx;
+ HANDLE thread;
+
+ id = p_Context_Id();
+ ok(id == -1, "Context::Id() = %u\n", id);
+
+ ctx = p_Context_CurrentContext();
+ ok(ctx != NULL, "Context::CurrentContext() = NULL\n");
+ id = p_Context_Id();
+ ok(id == 0, "Context::Id() = %u\n", id);
+
+ ctx = p_Context_CurrentContext();
+ ok(ctx != NULL, "Context::CurrentContext() = NULL\n");
+ id = p_Context_Id();
+ ok(id == 0, "Context::Id() = %u\n", id);
+
+ thread = CreateThread(NULL, 0, external_context_thread, NULL, 0, NULL);
+ ok(thread != NULL, "CreateThread failed: %d\n", GetLastError());
+ WaitForSingleObject(thread, INFINITE);
+}
+
START_TEST(msvcr100)
{
if (!init())
return;
+ test_ExternalContextBase();
test_wmemcpy_s();
test_wmemmove_s();
test_fread_s();
More information about the wine-cvs
mailing list