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 static char* (CDECL
*p_setlocale
)(int category
, const char* locale
);
35 static size_t (CDECL
*p___strncnt
)(const char *str
, size_t count
);
37 static unsigned int (CDECL
*p_CurrentScheduler_GetNumberOfVirtualProcessors
)(void);
38 static unsigned int (CDECL
*p__CurrentScheduler__GetNumberOfVirtualProcessors
)(void);
39 static unsigned int (CDECL
*p_CurrentScheduler_Id
)(void);
40 static unsigned int (CDECL
*p__CurrentScheduler__Id
)(void);
42 static BOOL
init(void)
46 module
= LoadLibraryA("msvcr110.dll");
49 win_skip("msvcr110.dll not installed\n");
53 p_setlocale
= (void*)GetProcAddress(module
, "setlocale");
54 p___strncnt
= (void*)GetProcAddress(module
, "__strncnt");
55 p_CurrentScheduler_GetNumberOfVirtualProcessors
= (void*)GetProcAddress(module
, "?GetNumberOfVirtualProcessors@CurrentScheduler@Concurrency@@SAIXZ");
56 p__CurrentScheduler__GetNumberOfVirtualProcessors
= (void*)GetProcAddress(module
, "?_GetNumberOfVirtualProcessors@_CurrentScheduler@details@Concurrency@@SAIXZ");
57 p_CurrentScheduler_Id
= (void*)GetProcAddress(module
, "?Id@CurrentScheduler@Concurrency@@SAIXZ");
58 p__CurrentScheduler__Id
= (void*)GetProcAddress(module
, "?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ");
63 static void test_CurrentScheduler(void)
71 ncpus
= p_CurrentScheduler_GetNumberOfVirtualProcessors();
72 ok(ncpus
== expect
, "expected %x, got %x\n", expect
, ncpus
);
73 id
= p_CurrentScheduler_Id();
74 ok(id
== expect
, "expected %u, got %u\n", expect
, id
);
77 expect
= si
.dwNumberOfProcessors
;
78 /* these _CurrentScheduler calls trigger scheduler creation
79 if either is commented out, the following CurrentScheduler (no _) tests will still work */
80 ncpus
= p__CurrentScheduler__GetNumberOfVirtualProcessors();
81 id
= p__CurrentScheduler__Id();
82 ok(ncpus
== expect
, "expected %u, got %u\n", expect
, ncpus
);
83 ok(id
== 0, "expected 0, got %u\n", id
);
85 /* these CurrentScheduler tests assume scheduler is created */
86 ncpus
= p_CurrentScheduler_GetNumberOfVirtualProcessors();
87 ok(ncpus
== expect
, "expected %u, got %u\n", expect
, ncpus
);
88 id
= p_CurrentScheduler_Id();
89 ok(id
== 0, "expected 0, got %u\n", id
);
92 static void test_setlocale(void)
96 static const char *names
[] =
105 for(i
=0; i
<ARRAY_SIZE(names
); i
++) {
106 ret
= p_setlocale(LC_ALL
, names
[i
]);
107 ok(ret
!= NULL
, "expected success, but got NULL\n");
108 ok(!strcmp(ret
, names
[i
]), "expected %s, got %s\n", names
[i
], ret
);
111 ret
= p_setlocale(LC_ALL
, "en-us.1250");
112 ok(!ret
, "setlocale(en-us.1250) succeeded (%s)\n", ret
);
114 p_setlocale(LC_ALL
, "C");
117 static void test___strncnt(void)
137 ret
= p___strncnt(NULL
, 1);
139 for (i
= 0; i
< ARRAY_SIZE(strncnt_tests
); ++i
)
141 ret
= p___strncnt(strncnt_tests
[i
].str
, strncnt_tests
[i
].size
);
142 ok(ret
== strncnt_tests
[i
].ret
, "%u: unexpected return value %u.\n", i
, (int)ret
);
149 test_CurrentScheduler(); /* MUST be first (at least among Concurrency tests) */