From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 1 + dlls/cfgmgr32/tests/Makefile.in | 5 + dlls/cfgmgr32/tests/cfgmgr32.c | 370 ++++++++++++++++++++++++++++++++ 3 files changed, 376 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..8075a7b91b2 --- /dev/null +++ b/dlls/cfgmgr32/tests/cfgmgr32.c @@ -0,0 +1,370 @@ +/* + * 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) +{ + DWORD def = 0xdeadbeef, ret; + CONFIGRET code; + + ret = 0xdeadbeef; + code = CR_SUCCESS; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_OUT_OF_MEMORY; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_NOT_ENOUGH_MEMORY, "expected ERROR_NOT_ENOUGH_MEMORY, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_POINTER; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_USER_BUFFER, "expected ERROR_INVALID_USER_BUFFER, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_FLAG; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_FLAGS, "expected ERROR_INVALID_FLAGS, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_DEVNODE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_DEVINST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_DEVNODE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_NOT_FOUND, "expected ERROR_NOT_FOUND, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_DEVINST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_NOT_FOUND, "expected ERROR_NOT_FOUND, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_ALREADY_SUCH_DEVNODE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_ALREADY_SUCH_DEVINST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_BUFFER_SMALL; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_REGISTRY_HANDLE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_REGISTRY_ERROR; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_REGISTRY_CORRUPT, "expected ERROR_REGISTRY_CORRUPT, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_DEVICE_ID; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_VALUE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_NOT_FOUND, "expected ERROR_NOT_FOUND, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_REGISTRY_KEY; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_MACHINENAME; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_REMOTE_COMM_FAILURE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_SERVICE_NOT_ACTIVE, "expected ERROR_SERVICE_NOT_ACTIVE, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_MACHINE_UNAVAILABLE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_SERVICE_NOT_ACTIVE, "expected ERROR_SERVICE_NOT_ACTIVE, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_CM_SERVICES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_SERVICE_NOT_ACTIVE, "expected ERROR_SERVICE_NOT_ACTIVE, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_ACCESS_DENIED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_CALL_NOT_IMPLEMENTED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_CALL_NOT_IMPLEMENTED, "expected ERROR_CALL_NOT_IMPLEMENTED, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_PROPERTY; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_DEVICE_INTERFACE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_NOT_FOUND, "expected ERROR_NOT_FOUND, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_REFERENCE_STRING; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == ERROR_INVALID_DATA, "expected ERROR_INVALID_DATA, got %ld.\n", ret ); + + /* Default */ + + ret = 0xdeadbeef; + code = 0xdeadbeef; + SetLastError(0xdeadbeef); + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + ok( GetLastError() == 0xdeadbeef, "unexpected error %ld.\n", GetLastError() ); + + ret = 0xdeadbeef; + code = CR_DEFAULT; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_RES_DES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_LOG_CONF; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_ARBITRATOR; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_NODELIST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DEVNODE_HAS_REQS; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DEVINST_HAS_REQS; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_RESOURCEID; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DLVXD_NOT_FOUND; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_MORE_LOG_CONF; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_MORE_RES_DES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_RANGE_LIST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_RANGE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_FAILURE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_SUCH_LOGICAL_DEV; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_CREATE_BLOCKED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NOT_SYSTEM_VM; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_REMOVE_VETOED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_REMOVE_VETOED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_APM_VETOED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_LOAD_TYPE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_ARBITRATOR; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_DATA; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_API; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DEVLOADER_NOT_READY; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NEED_RESTART; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_MORE_HW_PROFILES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DEVICE_NOT_THERE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_WRONG_TYPE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_PRIORITY; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NOT_DISABLEABLE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_FREE_RESOURCES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_QUERY_VETOED; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_CANT_SHARE_IRQ; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_NO_DEPENDENT; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_SAME_RESOURCES; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_DEVICE_INTERFACE_ACTIVE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_CONFLICT_LIST; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_INDEX; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = CR_INVALID_STRUCTURE_SIZE; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); + + ret = 0xdeadbeef; + code = NUM_CR_RESULTS; + ret = CM_MapCrToWin32Err( code, def ); + ok( ret == def, "expected default, got %ld.\n", ret ); +} + +START_TEST(cfgmgr32) +{ + test_CM_MapCrToWin32Err(); +}