Daniel Lehman : msvcr120/tests: Add _Context::_CurrentContext tests.

Alexandre Julliard julliard at winehq.org
Tue Nov 3 15:55:54 CST 2020


Module: wine
Branch: master
Commit: 782d4bc5357af0f917ec9dad91aea9e51ec339f2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=782d4bc5357af0f917ec9dad91aea9e51ec339f2

Author: Daniel Lehman <dlehman25 at gmail.com>
Date:   Mon Nov  2 20:12:09 2020 -0800

msvcr120/tests: Add _Context::_CurrentContext tests.

Signed-off-by: Daniel Lehman <dlehman25 at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcr120/tests/msvcr120.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c
index a055feeac91..52531ddad72 100644
--- a/dlls/msvcr120/tests/msvcr120.c
+++ b/dlls/msvcr120/tests/msvcr120.c
@@ -157,6 +157,16 @@ typedef struct
     double i;
 } _Dcomplex;
 
+typedef void (*vtable_ptr)(void);
+
+typedef struct {
+    const vtable_ptr *vtable;
+} Context;
+
+typedef struct {
+    Context *ctx;
+} _Context;
+
 static char* (CDECL *p_setlocale)(int category, const char* locale);
 static struct MSVCRT_lconv* (CDECL *p_localeconv)(void);
 static size_t (CDECL *p_wcstombs_s)(size_t *ret, char* dest, size_t sz, const wchar_t* src, size_t max);
@@ -208,6 +218,9 @@ static MSVCRT_bool (__thiscall *p__Condition_variable_wait_for)(_Condition_varia
 static void (__thiscall *p__Condition_variable_notify_one)(_Condition_variable*);
 static void (__thiscall *p__Condition_variable_notify_all)(_Condition_variable*);
 
+static Context* (__cdecl *p_Context_CurrentContext)(void);
+static _Context* (__cdecl *p__Context__CurrentContext)(_Context*);
+
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(module,y)
 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
 
@@ -250,6 +263,7 @@ static BOOL init(void)
     SET(p_nexttowardl, "nexttowardl");
     SET(p_wctrans, "wctrans");
     SET(p_towctrans, "towctrans");
+    SET(p__Context__CurrentContext, "?_CurrentContext at _Context@details at Concurrency@@SA?AV123 at XZ");
     if(sizeof(void*) == 8) { /* 64-bit initialization */
         SET(p_critical_section_ctor,
                 "??0critical_section at Concurrency@@QEAA at XZ");
@@ -281,6 +295,8 @@ static BOOL init(void)
                 "?notify_one at _Condition_variable@details at Concurrency@@QEAAXXZ");
         SET(p__Condition_variable_notify_all,
                 "?notify_all at _Condition_variable@details at Concurrency@@QEAAXXZ");
+        SET(p_Context_CurrentContext,
+                "?CurrentContext at Context@Concurrency@@SAPEAV12 at XZ");
     } else {
 #ifdef __arm__
         SET(p_critical_section_ctor,
@@ -345,6 +361,8 @@ static BOOL init(void)
         SET(p__Condition_variable_notify_all,
                 "?notify_all at _Condition_variable@details at Concurrency@@QAEXXZ");
 #endif
+        SET(p_Context_CurrentContext,
+                "?CurrentContext at Context@Concurrency@@SAPAV12 at XZ");
     }
 
     init_thiscall_thunk();
@@ -1065,6 +1083,20 @@ static void test_towctrans(void)
     ok(ret == 'T', "towctrans('T', 1) returned %c, expected T\n", ret);
 }
 
+static void test_CurrentContext(void)
+{
+    _Context _ctx, *ret;
+    Context *ctx;
+
+    ctx = p_Context_CurrentContext();
+    ok(!!ctx, "got NULL\n");
+
+    memset(&_ctx, 0xcc, sizeof(_ctx));
+    ret = p__Context__CurrentContext(&_ctx);
+    ok(_ctx.ctx == ctx, "expected %p, got %p\n", ctx, _ctx.ctx);
+    ok(ret == &_ctx, "expected %p, got %p\n", &_ctx, ret);
+}
+
 START_TEST(msvcr120)
 {
     if (!init()) return;
@@ -1086,4 +1118,5 @@ START_TEST(msvcr120)
     test__Cbuild();
     test_nexttoward();
     test_towctrans();
+    test_CurrentContext();
 }




More information about the wine-cvs mailing list