405d990a06952ef4ea6499bc24a779ee8f33a41a
[reactos.git] / modules / rostests / winetests / kernel32 / cpu.c
1 /*
2 * Unit test suite for cpu functions
3 *
4 * Copyright 2014 Michael Müller
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "wine/test.h"
22 #include "winbase.h"
23 #include "winnls.h"
24
25 static BOOL (WINAPI *pGetNumaProcessorNode)(UCHAR, PUCHAR);
26
27 static void InitFunctionPointers(void)
28 {
29 HMODULE hkernel32 = GetModuleHandleA("kernel32");
30
31 pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode");
32 }
33
34 static void test_GetNumaProcessorNode(void)
35 {
36 SYSTEM_INFO si;
37 UCHAR node;
38 BOOL ret;
39 int i;
40
41 if (!pGetNumaProcessorNode)
42 {
43 win_skip("GetNumaProcessorNode() is missing\n");
44 return;
45 }
46
47 GetSystemInfo(&si);
48
49 for (i = 0; i < 256; i++)
50 {
51 ret = pGetNumaProcessorNode(i, &node);
52 if (i < si.dwNumberOfProcessors)
53 {
54 ok(ret, "expected TRUE, got FALSE for processor %d\n", i);
55 ok(node != 0xFF, "expected node != 0xFF, but got 0xFF\n");
56 }
57 else
58 {
59 ok(!ret, "expected FALSE, got TRUE for processor %d\n", i);
60 ok(node == 0xFF, "expected node == 0xFF, but got %x\n", node);
61 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
62 }
63 }
64
65 /* crashes on windows */
66 if (0)
67 {
68 ok(!pGetNumaProcessorNode(0, NULL), "expected return value FALSE, got TRUE\n");
69 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
70 }
71 }
72
73 START_TEST(cpu)
74 {
75 InitFunctionPointers();
76 test_GetNumaProcessorNode();
77 }