From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 1 + dlls/cfgmgr32/tests/Makefile.in | 5 ++ dlls/cfgmgr32/tests/cfgmgr32.c | 124 ++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 dlls/cfgmgr32/tests/Makefile.in create mode 100644 dlls/cfgmgr32/tests/cfgmgr32.c
diff --git a/configure.ac b/configure.ac index 84fadd08853..f01b975e916 100644 --- a/configure.ac +++ b/configure.ac @@ -2382,6 +2382,7 @@ WINE_CONFIG_MAKEFILE(dlls/capi2032) WINE_CONFIG_MAKEFILE(dlls/cards) WINE_CONFIG_MAKEFILE(dlls/cdosys) WINE_CONFIG_MAKEFILE(dlls/cfgmgr32) +WINE_CONFIG_MAKEFILE(dlls/cfgmgr32/tests) WINE_CONFIG_MAKEFILE(dlls/clusapi) WINE_CONFIG_MAKEFILE(dlls/cng.sys) WINE_CONFIG_MAKEFILE(dlls/combase) diff --git a/dlls/cfgmgr32/tests/Makefile.in b/dlls/cfgmgr32/tests/Makefile.in new file mode 100644 index 00000000000..4e1f97b1c0c --- /dev/null +++ b/dlls/cfgmgr32/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = cfgmgr32.dll +IMPORTS = cfgmgr32 + +C_SRCS = \ + cfgmgr32.c diff --git a/dlls/cfgmgr32/tests/cfgmgr32.c b/dlls/cfgmgr32/tests/cfgmgr32.c new file mode 100644 index 00000000000..f188778b22b --- /dev/null +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 "cfgmgr32.h" + +static void test_CM_MapCrToWin32Err(void) +{ + const DWORD default_error = 0xdeadbeef; + DWORD ret, expected; + unsigned int i; + + static const struct + { + CONFIGRET code; + DWORD win32_error; + } + map_codes[] = + { + { CR_SUCCESS, ERROR_SUCCESS }, + { CR_OUT_OF_MEMORY, ERROR_NOT_ENOUGH_MEMORY }, + { CR_INVALID_POINTER, ERROR_INVALID_USER_BUFFER }, + { CR_INVALID_FLAG, ERROR_INVALID_FLAGS }, + { CR_INVALID_DEVNODE, ERROR_INVALID_DATA }, + { CR_INVALID_DEVINST, ERROR_INVALID_DATA }, + { CR_NO_SUCH_DEVNODE, ERROR_NOT_FOUND }, + { CR_NO_SUCH_DEVINST, ERROR_NOT_FOUND }, + { CR_ALREADY_SUCH_DEVNODE, ERROR_ALREADY_EXISTS }, + { CR_ALREADY_SUCH_DEVINST, ERROR_ALREADY_EXISTS }, + { CR_BUFFER_SMALL, ERROR_INSUFFICIENT_BUFFER }, + { CR_NO_REGISTRY_HANDLE, ERROR_INVALID_HANDLE }, + { CR_REGISTRY_ERROR, ERROR_REGISTRY_CORRUPT }, + { CR_INVALID_DEVICE_ID, ERROR_INVALID_DATA }, + { CR_NO_SUCH_VALUE, ERROR_NOT_FOUND }, + { CR_NO_SUCH_REGISTRY_KEY, ERROR_FILE_NOT_FOUND }, + { CR_INVALID_MACHINENAME, ERROR_INVALID_DATA }, + { CR_REMOTE_COMM_FAILURE, ERROR_SERVICE_NOT_ACTIVE }, + { CR_MACHINE_UNAVAILABLE, ERROR_SERVICE_NOT_ACTIVE }, + { CR_NO_CM_SERVICES, ERROR_SERVICE_NOT_ACTIVE }, + { CR_ACCESS_DENIED, ERROR_ACCESS_DENIED }, + { CR_CALL_NOT_IMPLEMENTED, ERROR_CALL_NOT_IMPLEMENTED }, + { CR_INVALID_PROPERTY, ERROR_INVALID_DATA }, + { CR_NO_SUCH_DEVICE_INTERFACE, ERROR_NOT_FOUND }, + { CR_INVALID_REFERENCE_STRING, ERROR_INVALID_DATA }, + { CR_DEFAULT, default_error }, + { CR_INVALID_RES_DES, default_error }, + { CR_INVALID_LOG_CONF, default_error }, + { CR_INVALID_ARBITRATOR, default_error }, + { CR_INVALID_NODELIST, default_error }, + { CR_DEVNODE_HAS_REQS, default_error }, + { CR_DEVINST_HAS_REQS, default_error }, + { CR_INVALID_RESOURCEID, default_error }, + { CR_DLVXD_NOT_FOUND, default_error }, + { CR_NO_MORE_LOG_CONF, default_error }, + { CR_NO_MORE_RES_DES, default_error }, + { CR_INVALID_RANGE_LIST, default_error }, + { CR_INVALID_RANGE, default_error }, + { CR_FAILURE, default_error }, + { CR_NO_SUCH_LOGICAL_DEV, default_error }, + { CR_CREATE_BLOCKED, default_error }, + { CR_NOT_SYSTEM_VM, default_error }, + { CR_REMOVE_VETOED, default_error }, + { CR_APM_VETOED, default_error }, + { CR_INVALID_LOAD_TYPE, default_error }, + { CR_NO_ARBITRATOR, default_error }, + { CR_INVALID_DATA, default_error }, + { CR_INVALID_API, default_error }, + { CR_DEVLOADER_NOT_READY, default_error }, + { CR_NEED_RESTART, default_error }, + { CR_NO_MORE_HW_PROFILES, default_error }, + { CR_DEVICE_NOT_THERE, default_error }, + { CR_WRONG_TYPE, default_error }, + { CR_INVALID_PRIORITY, default_error }, + { CR_NOT_DISABLEABLE, default_error }, + { CR_FREE_RESOURCES, default_error }, + { CR_QUERY_VETOED, default_error }, + { CR_CANT_SHARE_IRQ, default_error }, + { CR_NO_DEPENDENT, default_error }, + { CR_SAME_RESOURCES, default_error }, + { CR_DEVICE_INTERFACE_ACTIVE, default_error }, + { CR_INVALID_CONFLICT_LIST, default_error }, + { CR_INVALID_INDEX, default_error }, + { CR_INVALID_STRUCTURE_SIZE, default_error }, + { NUM_CR_RESULTS, default_error }, + }; + + SetLastError(0xdeadbeef); + ret = 0; + ret = CM_MapCrToWin32Err( 0xdeadbeef, default_error ); + ok( ret == default_error, "expected default error, got %ld.\n", ret ); + ok( GetLastError() == 0xdeadbeef, "unexpected error %ld.\n", GetLastError() ); + + for ( i = 0; i < sizeof(map_codes) / sizeof(map_codes[0]); i++ ) + { + ret = 0xdeadbeef; + ret = CM_MapCrToWin32Err( map_codes[i].code, default_error ); + expected = map_codes[i].win32_error; + + if (expected == default_error) + ok( ret == default_error, "expected default error, got %ld.\n", ret ); + else + ok( ret == expected, "expected %ld, got %ld.\n", expected, ret ); + } +} + +START_TEST(cfgmgr32) +{ + test_CM_MapCrToWin32Err(); +}