From c981072e0d41f6750fb49f6fe03115d527d43f82 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 26 Jun 2015 10:13:24 +0200 Subject: [PATCH] kernel32-GetNumaProcessorNode: Remove test failures on Windows XP and change order of patches. --- ...dd-tests-for-GetNumaProcessorNode.-v.patch | 91 +++++++++++++++ ...-Implement-GetNumaProcessorNode.-v2.patch} | 47 +++++--- ...s-Add-tests-for-GetNumaProcessorNode.patch | 109 ------------------ patches/patchinstall.sh | 11 +- 4 files changed, 124 insertions(+), 134 deletions(-) create mode 100644 patches/kernel32-GetNumaProcessorNode/0001-kernel32-tests-Add-tests-for-GetNumaProcessorNode.-v.patch rename patches/kernel32-GetNumaProcessorNode/{0001-kernel32-Implement-GetNumaProcessorNode.patch => 0002-kernel32-Implement-GetNumaProcessorNode.-v2.patch} (64%) delete mode 100644 patches/kernel32-GetNumaProcessorNode/0002-kernel32-tests-Add-tests-for-GetNumaProcessorNode.patch diff --git a/patches/kernel32-GetNumaProcessorNode/0001-kernel32-tests-Add-tests-for-GetNumaProcessorNode.-v.patch b/patches/kernel32-GetNumaProcessorNode/0001-kernel32-tests-Add-tests-for-GetNumaProcessorNode.-v.patch new file mode 100644 index 00000000..ef0d2dc1 --- /dev/null +++ b/patches/kernel32-GetNumaProcessorNode/0001-kernel32-tests-Add-tests-for-GetNumaProcessorNode.-v.patch @@ -0,0 +1,91 @@ +From 1683ee187a990a2c55cc6db9b5fac120ca1bbaca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Sat, 18 Oct 2014 06:00:48 +0200 +Subject: kernel32/tests: Add tests for GetNumaProcessorNode. (v2) + +Changes in v2: + * Remove separate dlls/kernel32/tests/cpu.c file. + * Fix test failure on WinXP. +--- + dlls/kernel32/tests/process.c | 37 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c +index 6660af4..b4a435b 100644 +--- a/dlls/kernel32/tests/process.c ++++ b/dlls/kernel32/tests/process.c +@@ -3,6 +3,7 @@ + * + * Copyright 2002 Eric Pouech + * Copyright 2006 Dmitry Timoshkov ++ * Copyright 2014 Michael Müller + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -74,6 +75,7 @@ static BOOL (WINAPI *pTerminateJobObject)(HANDLE job, UINT exit_code); + static BOOL (WINAPI *pQueryInformationJobObject)(HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info, DWORD len, LPDWORD ret_len); + static BOOL (WINAPI *pSetInformationJobObject)(HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info, DWORD len); + static HANDLE (WINAPI *pCreateIoCompletionPort)(HANDLE file, HANDLE existing_port, ULONG_PTR key, DWORD threads); ++static BOOL (WINAPI *pGetNumaProcessorNode)(UCHAR, PUCHAR); + + /* ############################### */ + static char base[MAX_PATH]; +@@ -227,6 +229,7 @@ static BOOL init(void) + pQueryInformationJobObject = (void *)GetProcAddress(hkernel32, "QueryInformationJobObject"); + pSetInformationJobObject = (void *)GetProcAddress(hkernel32, "SetInformationJobObject"); + pCreateIoCompletionPort = (void *)GetProcAddress(hkernel32, "CreateIoCompletionPort"); ++ pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode"); + return TRUE; + } + +@@ -2692,6 +2695,39 @@ static void test_StartupNoConsole(void) + #endif + } + ++static void test_GetNumaProcessorNode(void) ++{ ++ SYSTEM_INFO si; ++ UCHAR node; ++ BOOL ret; ++ int i; ++ ++ if (!pGetNumaProcessorNode) ++ { ++ skip("GetNumaProcessorNode is missing\n"); ++ return; ++ } ++ ++ GetSystemInfo(&si); ++ for (i = 0; i < 256; i++) ++ { ++ SetLastError(0xdeadbeef); ++ node = (i < si.dwNumberOfProcessors) ? 0xFF : 0xAA; ++ ret = pGetNumaProcessorNode(i, &node); ++ if (i < si.dwNumberOfProcessors) ++ { ++ ok(ret, "GetNumaProcessorNode returned FALSE for processor %d\n", i); ++ ok(node != 0xFF, "expected node != 0xFF, but got 0xFF\n"); ++ } ++ else ++ { ++ ok(!ret, "GetNumaProcessorNode returned TRUE for processor %d\n", i); ++ ok(node == 0xFF || broken(node == 0xAA) /* WinXP */, "expected node 0xFF, got %x\n", node); ++ ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); ++ } ++ } ++} ++ + START_TEST(process) + { + HANDLE job; +@@ -2741,6 +2777,7 @@ START_TEST(process) + test_RegistryQuota(); + test_DuplicateHandle(); + test_StartupNoConsole(); ++ test_GetNumaProcessorNode(); + /* things that can be tested: + * lookup: check the way program to be executed is searched + * handles: check the handle inheritance stuff (+sec options) +-- +2.4.3 + diff --git a/patches/kernel32-GetNumaProcessorNode/0001-kernel32-Implement-GetNumaProcessorNode.patch b/patches/kernel32-GetNumaProcessorNode/0002-kernel32-Implement-GetNumaProcessorNode.-v2.patch similarity index 64% rename from patches/kernel32-GetNumaProcessorNode/0001-kernel32-Implement-GetNumaProcessorNode.patch rename to patches/kernel32-GetNumaProcessorNode/0002-kernel32-Implement-GetNumaProcessorNode.-v2.patch index b0e854a6..2d2aefea 100644 --- a/patches/kernel32-GetNumaProcessorNode/0001-kernel32-Implement-GetNumaProcessorNode.patch +++ b/patches/kernel32-GetNumaProcessorNode/0002-kernel32-Implement-GetNumaProcessorNode.-v2.patch @@ -1,19 +1,22 @@ -From 055d712c6ebe86e06c2792d2c33cf5b9c5960cf8 Mon Sep 17 00:00:00 2001 +From a228108e82fd231729cc6656c443af35b4249b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 18 Oct 2014 05:57:32 +0200 -Subject: kernel32: Implement GetNumaProcessorNode. +Subject: kernel32: Implement GetNumaProcessorNode. (v2) +Changes in v2: + * Remove NULL-pointer check, it also crashes on Windows. --- - dlls/kernel32/cpu.c | 28 ++++++++++++++++++++++++++++ - dlls/kernel32/kernel32.spec | 2 +- - include/winbase.h | 1 + - 3 files changed, 30 insertions(+), 1 deletion(-) + dlls/kernel32/cpu.c | 21 +++++++++++++++++++++ + dlls/kernel32/kernel32.spec | 2 +- + dlls/kernel32/tests/process.c | 2 +- + include/winbase.h | 1 + + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c -index f48fcf0..886e415 100644 +index f48fcf0..dc61763 100644 --- a/dlls/kernel32/cpu.c +++ b/dlls/kernel32/cpu.c -@@ -291,3 +291,31 @@ err: +@@ -291,3 +291,24 @@ err: } return TRUE; } @@ -27,14 +30,7 @@ index f48fcf0..886e415 100644 + + TRACE( "(%d, %p)\n", processor, node ); + -+ if (!node) -+ { -+ SetLastError(ERROR_INVALID_PARAMETER); -+ return FALSE; -+ } -+ + GetSystemInfo(&si); -+ + if (processor < si.dwNumberOfProcessors) + { + *node = 0; @@ -46,7 +42,7 @@ index f48fcf0..886e415 100644 + return FALSE; +} diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec -index a272535..da05859 100644 +index f9a0770..7703f2c 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -746,7 +746,7 @@ @@ -58,11 +54,24 @@ index a272535..da05859 100644 # @ stub GetNumaProcessorNodeEx # @ stub GetNumaProximityNode # @ stub GetNumaProximityNodeEx +diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c +index b4a435b..4145dce 100644 +--- a/dlls/kernel32/tests/process.c ++++ b/dlls/kernel32/tests/process.c +@@ -2704,7 +2704,7 @@ static void test_GetNumaProcessorNode(void) + + if (!pGetNumaProcessorNode) + { +- skip("GetNumaProcessorNode is missing\n"); ++ win_skip("GetNumaProcessorNode is missing\n"); + return; + } + diff --git a/include/winbase.h b/include/winbase.h -index 0d8cede..28fb5ea 100644 +index cc1081e..f3249a7 100644 --- a/include/winbase.h +++ b/include/winbase.h -@@ -1953,6 +1953,7 @@ WINBASEAPI BOOL WINAPI GetNamedPipeHandleStateW(HANDLE,LPDWORD,LPDWORD,LP +@@ -2052,6 +2052,7 @@ WINBASEAPI BOOL WINAPI GetNamedPipeHandleStateW(HANDLE,LPDWORD,LPDWORD,LP #define GetNamedPipeHandleState WINELIB_NAME_AW(GetNamedPipeHandleState) WINBASEAPI BOOL WINAPI GetNamedPipeInfo(HANDLE,LPDWORD,LPDWORD,LPDWORD,LPDWORD); WINBASEAPI VOID WINAPI GetNativeSystemInfo(LPSYSTEM_INFO); @@ -71,5 +80,5 @@ index 0d8cede..28fb5ea 100644 WINADVAPI BOOL WINAPI GetOldestEventLogRecord(HANDLE,PDWORD); WINBASEAPI BOOL WINAPI GetOverlappedResult(HANDLE,LPOVERLAPPED,LPDWORD,BOOL); -- -2.2.1 +2.4.3 diff --git a/patches/kernel32-GetNumaProcessorNode/0002-kernel32-tests-Add-tests-for-GetNumaProcessorNode.patch b/patches/kernel32-GetNumaProcessorNode/0002-kernel32-tests-Add-tests-for-GetNumaProcessorNode.patch deleted file mode 100644 index 728ab2d7..00000000 --- a/patches/kernel32-GetNumaProcessorNode/0002-kernel32-tests-Add-tests-for-GetNumaProcessorNode.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 24212987a7f995c9219be5807c6d70bd5d0f6f2d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michael=20M=C3=BCller?= -Date: Sat, 18 Oct 2014 06:00:48 +0200 -Subject: kernel32/tests: Add tests for GetNumaProcessorNode. - ---- - dlls/kernel32/tests/Makefile.in | 1 + - dlls/kernel32/tests/cpu.c | 77 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 78 insertions(+) - create mode 100644 dlls/kernel32/tests/cpu.c - -diff --git a/dlls/kernel32/tests/Makefile.in b/dlls/kernel32/tests/Makefile.in -index 2f2ac5f..50b0d8d 100644 ---- a/dlls/kernel32/tests/Makefile.in -+++ b/dlls/kernel32/tests/Makefile.in -@@ -8,6 +8,7 @@ C_SRCS = \ - codepage.c \ - comm.c \ - console.c \ -+ cpu.c \ - debugger.c \ - directory.c \ - drive.c \ -diff --git a/dlls/kernel32/tests/cpu.c b/dlls/kernel32/tests/cpu.c -new file mode 100644 -index 0000000..405d990 ---- /dev/null -+++ b/dlls/kernel32/tests/cpu.c -@@ -0,0 +1,77 @@ -+/* -+ * Unit test suite for cpu functions -+ * -+ * Copyright 2014 Michael Müller -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -+ */ -+ -+#include "wine/test.h" -+#include "winbase.h" -+#include "winnls.h" -+ -+static BOOL (WINAPI *pGetNumaProcessorNode)(UCHAR, PUCHAR); -+ -+static void InitFunctionPointers(void) -+{ -+ HMODULE hkernel32 = GetModuleHandleA("kernel32"); -+ -+ pGetNumaProcessorNode = (void *)GetProcAddress(hkernel32, "GetNumaProcessorNode"); -+} -+ -+static void test_GetNumaProcessorNode(void) -+{ -+ SYSTEM_INFO si; -+ UCHAR node; -+ BOOL ret; -+ int i; -+ -+ if (!pGetNumaProcessorNode) -+ { -+ win_skip("GetNumaProcessorNode() is missing\n"); -+ return; -+ } -+ -+ GetSystemInfo(&si); -+ -+ for (i = 0; i < 256; i++) -+ { -+ ret = pGetNumaProcessorNode(i, &node); -+ if (i < si.dwNumberOfProcessors) -+ { -+ ok(ret, "expected TRUE, got FALSE for processor %d\n", i); -+ ok(node != 0xFF, "expected node != 0xFF, but got 0xFF\n"); -+ } -+ else -+ { -+ ok(!ret, "expected FALSE, got TRUE for processor %d\n", i); -+ ok(node == 0xFF, "expected node == 0xFF, but got %x\n", node); -+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); -+ } -+ } -+ -+ /* crashes on windows */ -+ if (0) -+ { -+ ok(!pGetNumaProcessorNode(0, NULL), "expected return value FALSE, got TRUE\n"); -+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); -+ } -+} -+ -+START_TEST(cpu) -+{ -+ InitFunctionPointers(); -+ test_GetNumaProcessorNode(); -+} --- -1.9.1 - diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index bf9f391d..1b38f7f5 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -3002,15 +3002,14 @@ fi # | * [#38660] Add implementation for kernel32.GetNumaProcessorNode # | # | Modified files: -# | * dlls/kernel32/cpu.c, dlls/kernel32/kernel32.spec, dlls/kernel32/tests/Makefile.in, dlls/kernel32/tests/cpu.c, -# | include/winbase.h +# | * dlls/kernel32/cpu.c, dlls/kernel32/kernel32.spec, dlls/kernel32/tests/process.c, include/winbase.h # | if test "$enable_kernel32_GetNumaProcessorNode" -eq 1; then - patch_apply kernel32-GetNumaProcessorNode/0001-kernel32-Implement-GetNumaProcessorNode.patch - patch_apply kernel32-GetNumaProcessorNode/0002-kernel32-tests-Add-tests-for-GetNumaProcessorNode.patch + patch_apply kernel32-GetNumaProcessorNode/0001-kernel32-tests-Add-tests-for-GetNumaProcessorNode.-v.patch + patch_apply kernel32-GetNumaProcessorNode/0002-kernel32-Implement-GetNumaProcessorNode.-v2.patch ( - echo '+ { "Michael Müller", "kernel32: Implement GetNumaProcessorNode.", 1 },'; - echo '+ { "Michael Müller", "kernel32/tests: Add tests for GetNumaProcessorNode.", 1 },'; + echo '+ { "Michael Müller", "kernel32/tests: Add tests for GetNumaProcessorNode.", 2 },'; + echo '+ { "Michael Müller", "kernel32: Implement GetNumaProcessorNode.", 2 },'; ) >> "$patchlist" fi