From: Michael Müller michael@fds-team.de
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/Makefile.in | 1 + include/pathcch.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/pathcch.h
diff --git a/include/Makefile.in b/include/Makefile.in index f1bcba35ed..72304d6f91 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -494,6 +494,7 @@ SOURCES = \ opnrst.idl \ optary.idl \ patchapi.h \ + pathcch.h \ pdh.h \ pdhmsg.h \ perflib.h \ diff --git a/include/pathcch.h b/include/pathcch.h new file mode 100644 index 0000000000..8831c5238d --- /dev/null +++ b/include/pathcch.h @@ -0,0 +1,26 @@ +/* + * Copyright 2017 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 + */ + +#define PATHCCH_NONE 0x00 +#define PATHCCH_ALLOW_LONG_PATHS 0x01 +#define PATHCCH_FORCE_ENABLE_LONG_NAME_PROCESS 0x02 +#define PATHCCH_FORCE_DISABLE_LONG_NAME_PROCESS 0x04 +#define PATHCCH_DO_NOT_NORMALIZE_SEGMENTS 0x08 +#define PATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH 0x10 + +HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags);
From: Michael Müller michael@fds-team.de
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- configure.ac | 1 + dlls/kernelbase/tests/Makefile.in | 4 ++ dlls/kernelbase/tests/path.c | 123 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 dlls/kernelbase/tests/Makefile.in create mode 100644 dlls/kernelbase/tests/path.c
diff --git a/configure.ac b/configure.ac index 02937cab5d..b014ef7cf1 100644 --- a/configure.ac +++ b/configure.ac @@ -3308,6 +3308,7 @@ WINE_CONFIG_DLL(kerberos) WINE_CONFIG_DLL(kernel32) WINE_CONFIG_TEST(dlls/kernel32/tests) WINE_CONFIG_DLL(kernelbase) +WINE_CONFIG_TEST(dlls/kernelbase/tests) WINE_CONFIG_DLL(keyboard.drv16,enable_win16) WINE_CONFIG_DLL(krnl386.exe16,enable_win16) WINE_CONFIG_DLL(ksuser) diff --git a/dlls/kernelbase/tests/Makefile.in b/dlls/kernelbase/tests/Makefile.in new file mode 100644 index 0000000000..ac8e1fcaa6 --- /dev/null +++ b/dlls/kernelbase/tests/Makefile.in @@ -0,0 +1,4 @@ +TESTDLL = kernelbase.dll + +C_SRCS = \ + path.c diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c new file mode 100644 index 0000000000..fbe1d3be2f --- /dev/null +++ b/dlls/kernelbase/tests/path.c @@ -0,0 +1,123 @@ +/* + * Path tests for kernelbase.dll + * + * Copyright 2017 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 <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <stdlib.h> +#include <winerror.h> +#include <winnls.h> +#include <pathcch.h> +#include <strsafe.h> + +#include "wine/test.h" + +HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); + +static const struct +{ + const char *path1; + const char *path2; + const char *result; +} +combine_test[] = +{ + /* normal paths */ + {"C:\", "a", "C:\a" }, + {"C:\b", "..\a", "C:\a" }, + {"C:", "a", "C:\a" }, + {"C:\", ".", "C:\" }, + {"C:\", "..", "C:\" }, + {"\a", "b", "\a\b" }, + + /* normal UNC paths */ + {"\\192.168.1.1\test", "a", "\\192.168.1.1\test\a" }, + {"\\192.168.1.1\test", "..", "\\192.168.1.1" }, + + /* NT paths */ + {"\\?\C:\", "a", "C:\a" }, + {"\\?\C:\", "..", "C:\" }, + + /* NT UNC path */ + {"\\?\UNC\192.168.1.1\test", "a", "\\192.168.1.1\test\a" }, + {"\\?\UNC\192.168.1.1\test", "..", "\\192.168.1.1" }, +}; + +static void test_PathCchCombineEx(void) +{ + WCHAR expected[MAX_PATH] = {'C',':','\','a',0}; + WCHAR p1[MAX_PATH] = {'C',':','\',0}; + WCHAR p2[MAX_PATH] = {'a',0}; + WCHAR output[MAX_PATH]; + HRESULT hr; + int i; + + if (!pPathCchCombineEx) + { + skip("PathCchCombineEx() is not available.\n"); + return; + } + + hr = pPathCchCombineEx(NULL, 2, p1, p2, 0); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + + memset(output, 0xff, sizeof(output)); + hr = pPathCchCombineEx(output, 0, p1, p2, 0); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); + ok(output[0] == 0xffff, "Expected output buffer to be unchanged\n"); + + memset(output, 0xff, sizeof(output)); + hr = pPathCchCombineEx(output, 1, p1, p2, 0); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Expected STRSAFE_E_INSUFFICIENT_BUFFER, got %08x\n", hr); + ok(output[0] == 0, "Expected output buffer to contain NULL string\n"); + + memset(output, 0xff, sizeof(output)); + hr = pPathCchCombineEx(output, 4, p1, p2, 0); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Expected STRSAFE_E_INSUFFICIENT_BUFFER, got %08x\n", hr); + ok(output[0] == 0x0, "Expected output buffer to contain NULL string\n"); + + memset(output, 0xff, sizeof(output)); + hr = pPathCchCombineEx(output, 5, p1, p2, 0); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(!lstrcmpW(output, expected), + "Combination of %s + %s returned %s, expected %s\n", + wine_dbgstr_w(p1), wine_dbgstr_w(p2), wine_dbgstr_w(output), wine_dbgstr_w(expected)); + + for (i = 0; i < sizeof(combine_test)/sizeof(combine_test[0]); i++) + { + MultiByteToWideChar(CP_ACP, 0, combine_test[i].path1, -1, p1, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, combine_test[i].path2, -1, p2, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, combine_test[i].result, -1, expected, MAX_PATH); + + hr = pPathCchCombineEx(output, MAX_PATH, p1, p2, 0); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok(!lstrcmpW(output, expected), "Combining %s with %s returned %s, expected %s\n", + wine_dbgstr_w(p1), wine_dbgstr_w(p2), wine_dbgstr_w(output), wine_dbgstr_w(expected)); + } +} + +START_TEST(path) +{ + HMODULE hmod = LoadLibraryA("kernelbase.dll"); + + pPathCchCombineEx = (void *)GetProcAddress(hmod, "PathCchCombineEx"); + + test_PathCchCombineEx(); +}
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=36272
Your paranoid android.
=== build (build) === Recreation of tests/Makefile failed
Hi Nikolay,
On 02/28/2018 11:54 AM, Nikolay Sivov wrote:
+START_TEST(path) +{
- HMODULE hmod = LoadLibraryA("kernelbase.dll");
- pPathCchCombineEx = (void *)GetProcAddress(hmod, "PathCchCombineEx");
Is there a reason not to link to kernelbase.dll directly?
Jacek
On 2/28/2018 4:24 PM, Jacek Caban wrote:
Hi Nikolay,
On 02/28/2018 11:54 AM, Nikolay Sivov wrote:
+START_TEST(path) +{
- HMODULE hmod = LoadLibraryA("kernelbase.dll");
- pPathCchCombineEx = (void *)GetProcAddress(hmod, "PathCchCombineEx");
Is there a reason not to link to kernelbase.dll directly?
I only did that because we don't have an export yet. I was going to look first at what needs to be done for shlwapi implementation to make all tests pass, and we don't want to link to shlwapi of course.
With that done this should be switched to using import library of course.
Jacek