2 * Copyright 2018 Daniel Lehman
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
34 typedef void (*vtable_ptr
)(void);
37 const vtable_ptr
*vtable
;
44 static char* (CDECL
*p_setlocale
)(int category
, const char* locale
);
45 static size_t (CDECL
*p___strncnt
)(const char *str
, size_t count
);
47 static unsigned int (CDECL
*p_CurrentScheduler_GetNumberOfVirtualProcessors
)(void);
48 static unsigned int (CDECL
*p__CurrentScheduler__GetNumberOfVirtualProcessors
)(void);
49 static unsigned int (CDECL
*p_CurrentScheduler_Id
)(void);
50 static unsigned int (CDECL
*p__CurrentScheduler__Id
)(void);
52 static Context
* (__cdecl
*p_Context_CurrentContext
)(void);
53 static _Context
* (__cdecl
*p__Context__CurrentContext
)(_Context
*);
55 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(module,y)
56 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
58 static BOOL
init(void)
62 module
= LoadLibraryA("msvcr110.dll");
65 win_skip("msvcr110.dll not installed\n");
69 SET(p_setlocale
, "setlocale");
70 SET(p___strncnt
, "__strncnt");
71 SET(p_CurrentScheduler_GetNumberOfVirtualProcessors
, "?GetNumberOfVirtualProcessors@CurrentScheduler@Concurrency@@SAIXZ");
72 SET(p__CurrentScheduler__GetNumberOfVirtualProcessors
, "?_GetNumberOfVirtualProcessors@_CurrentScheduler@details@Concurrency@@SAIXZ");
73 SET(p_CurrentScheduler_Id
, "?Id@CurrentScheduler@Concurrency@@SAIXZ");
74 SET(p__CurrentScheduler__Id
, "?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ");
76 SET(p__Context__CurrentContext
, "?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ");
78 if(sizeof(void*) == 8)
80 SET(p_Context_CurrentContext
, "?CurrentContext@Context@Concurrency@@SAPEAV12@XZ");
84 SET(p_Context_CurrentContext
, "?CurrentContext@Context@Concurrency@@SAPAV12@XZ");
90 static void test_CurrentScheduler(void)
98 ncpus
= p_CurrentScheduler_GetNumberOfVirtualProcessors();
99 ok(ncpus
== expect
, "expected %x, got %x\n", expect
, ncpus
);
100 id
= p_CurrentScheduler_Id();
101 ok(id
== expect
, "expected %u, got %u\n", expect
, id
);
104 expect
= si
.dwNumberOfProcessors
;
105 /* these _CurrentScheduler calls trigger scheduler creation
106 if either is commented out, the following CurrentScheduler (no _) tests will still work */
107 ncpus
= p__CurrentScheduler__GetNumberOfVirtualProcessors();
108 id
= p__CurrentScheduler__Id();
109 ok(ncpus
== expect
, "expected %u, got %u\n", expect
, ncpus
);
110 ok(id
== 0, "expected 0, got %u\n", id
);
112 /* these CurrentScheduler tests assume scheduler is created */
113 ncpus
= p_CurrentScheduler_GetNumberOfVirtualProcessors();
114 ok(ncpus
== expect
, "expected %u, got %u\n", expect
, ncpus
);
115 id
= p_CurrentScheduler_Id();
116 ok(id
== 0, "expected 0, got %u\n", id
);
119 static void test_setlocale(void)
123 static const char *names
[] =
132 for(i
=0; i
<ARRAY_SIZE(names
); i
++) {
133 ret
= p_setlocale(LC_ALL
, names
[i
]);
134 ok(ret
!= NULL
, "expected success, but got NULL\n");
135 ok(!strcmp(ret
, names
[i
]), "expected %s, got %s\n", names
[i
], ret
);
138 ret
= p_setlocale(LC_ALL
, "en-us.1250");
139 ok(!ret
, "setlocale(en-us.1250) succeeded (%s)\n", ret
);
141 p_setlocale(LC_ALL
, "C");
144 static void test___strncnt(void)
164 ret
= p___strncnt(NULL
, 1);
166 for (i
= 0; i
< ARRAY_SIZE(strncnt_tests
); ++i
)
168 ret
= p___strncnt(strncnt_tests
[i
].str
, strncnt_tests
[i
].size
);
169 ok(ret
== strncnt_tests
[i
].ret
, "%u: unexpected return value %u.\n", i
, (int)ret
);
173 static void test_CurrentContext(void)
178 ctx
= p_Context_CurrentContext();
179 ok(!!ctx
, "got NULL\n");
181 memset(&_ctx
, 0xcc, sizeof(_ctx
));
182 ret
= p__Context__CurrentContext(&_ctx
);
183 ok(_ctx
.ctx
== ctx
, "expected %p, got %p\n", ctx
, _ctx
.ctx
);
184 ok(ret
== &_ctx
, "expected %p, got %p\n", &_ctx
, ret
);
190 test_CurrentScheduler(); /* MUST be first (at least among Concurrency tests) */
193 test_CurrentContext();