Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 55 ++++++++++--------------------------------- 1 file changed, 12 insertions(+), 43 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index c58e35f482..b24480ce1a 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -37,7 +37,6 @@ static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID); static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO); -static BOOL (WINAPI *pSetupDiGetINFClassA)(PCSTR, LPGUID, PSTR, DWORD, PDWORD); static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID);
/* This is a unique guid for testing purposes */ @@ -52,7 +51,6 @@ static void init_function_pointers(void) pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); - pSetupDiGetINFClassA = (void *)GetProcAddress(hSetupAPI, "SetupDiGetINFClassA"); }
static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey) @@ -1157,7 +1155,7 @@ todo_wine } }
-static void testSetupDiGetINFClassA(void) +static void test_get_inf_class(void) { static const char inffile[] = "winetest.inf"; static const char content[] = "[Version]\r\n\r\n"; @@ -1171,19 +1169,7 @@ static void testSetupDiGetINFClassA(void) HANDLE h; int i;
- if(!pSetupDiGetINFClassA) - { - win_skip("SetupDiGetINFClassA not present\n"); - return; - } - - count = GetTempPathA(MAX_PATH, filename); - if(!count) - { - win_skip("GetTempPathA failed\n"); - return; - } - + GetTempPathA(MAX_PATH, filename); strcat(filename, inffile); DeleteFileA(filename);
@@ -1191,11 +1177,6 @@ static void testSetupDiGetINFClassA(void) SetLastError(0xdeadbeef); retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count); ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); - if (ERROR_CALL_NOT_IMPLEMENTED == GetLastError()) - { - skip("SetupDiGetINFClassA is not implemented\n"); - return; - } ok(ERROR_FILE_NOT_FOUND == GetLastError(), "expected error ERROR_FILE_NOT_FOUND, got %u\n", GetLastError());
@@ -1227,12 +1208,8 @@ static void testSetupDiGetINFClassA(void) /* test file content */ h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if(h == INVALID_HANDLE_VALUE) - { - win_skip("failed to create file %s (error %u)\n", filename, GetLastError()); - return; - } - CloseHandle( h); + ok(h != INVALID_HANDLE_VALUE, "Failed to create file, error %#x.\n", GetLastError()); + CloseHandle(h);
retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count); ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); @@ -1242,13 +1219,9 @@ static void testSetupDiGetINFClassA(void) trace("testing signature %s\n", signatures[i]); h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if(h == INVALID_HANDLE_VALUE) - { - win_skip("failed to create file %s (error %u)\n", filename, GetLastError()); - return; - } - WriteFile( h, content, sizeof(content), &count, NULL); - CloseHandle( h); + ok(h != INVALID_HANDLE_VALUE, "Failed to create file, error %#x.\n", GetLastError()); + WriteFile(h, content, sizeof(content), &count, NULL); + CloseHandle(h);
retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count); ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); @@ -1300,10 +1273,8 @@ static void testSetupDiGetINFClassA(void) SetLastError(0xdeadbeef); retval = SetupDiGetINFClassA(filename, &guid, cn, 0, &count); ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); - ok(ERROR_INSUFFICIENT_BUFFER == GetLastError() || - ERROR_INVALID_PARAMETER == GetLastError(), - "expected error ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER, " - "got %u\n", GetLastError()); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER || GetLastError() == ERROR_INVALID_PARAMETER /* 2k3+ */, + "Got unexpected error %#x.\n", GetLastError());
DeleteFileA(filename);
@@ -1313,10 +1284,8 @@ static void testSetupDiGetINFClassA(void) SetLastError(0xdeadbeef); retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count); ok(!retval, "expected SetupDiGetINFClassA to fail!\n"); - ok(RPC_S_INVALID_STRING_UUID == GetLastError() || - ERROR_INVALID_PARAMETER == GetLastError(), - "expected error RPC_S_INVALID_STRING_UUID or ERROR_INVALID_PARAMETER, " - "got %u\n", GetLastError()); + ok(GetLastError() == RPC_S_INVALID_STRING_UUID || GetLastError() == ERROR_INVALID_PARAMETER /* 7+ */, + "Got unexpected error %#x.\n", GetLastError());
/* network adapter guid */ WritePrivateProfileStringA("Version", "ClassGUID", @@ -1440,7 +1409,7 @@ START_TEST(devinst) test_register_device_iface(); test_registry_property_a(); test_registry_property_w(); - testSetupDiGetINFClassA(); + test_get_inf_class(); test_devnode(); test_device_interface_key(); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v3: actually fix test failures
dlls/setupapi/tests/devinst.c | 70 ++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 48 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index b24480ce1a..dd036cdcd1 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -34,9 +34,7 @@ #include "wine/test.h"
/* function pointers */ -static HDEVINFO (WINAPI *pSetupDiCreateDeviceInfoListExW)(GUID*,HWND,PCWSTR,PVOID); static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); -static BOOL (WINAPI *pSetupDiDestroyDeviceInfoList)(HDEVINFO); static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID);
/* This is a unique guid for testing purposes */ @@ -47,8 +45,6 @@ static void init_function_pointers(void) { HMODULE hSetupAPI = GetModuleHandleA("setupapi.dll");
- pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW"); - pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList"); pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); } @@ -119,57 +115,38 @@ cleanup: return ret; }
-static void test_SetupDiCreateDeviceInfoListEx(void) +static void test_create_device_list_ex(void) { - HDEVINFO devlist; - BOOL ret; - DWORD error; - static CHAR notnull[] = "NotNull"; static const WCHAR machine[] = { 'd','u','m','m','y',0 }; static const WCHAR empty[] = { 0 }; + static char notnull[] = "NotNull"; + HDEVINFO set; + BOOL ret;
SetLastError(0xdeadbeef); - /* create empty DeviceInfoList, but set Reserved to a value, which is not NULL */ - devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, notnull); - - error = GetLastError(); - if (error == ERROR_CALL_NOT_IMPLEMENTED) - { - win_skip("SetupDiCreateDeviceInfoListExW is not implemented\n"); - return; - } - ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE); - ok(error == ERROR_INVALID_PARAMETER, "GetLastError returned wrong value : %d, (expected %d)\n", error, ERROR_INVALID_PARAMETER); + set = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, notnull); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError());
SetLastError(0xdeadbeef); - /* create empty DeviceInfoList, but set MachineName to something */ - devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, machine, NULL); + set = SetupDiCreateDeviceInfoListExW(NULL, NULL, machine, NULL); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_MACHINENAME + || GetLastError() == ERROR_MACHINE_UNAVAILABLE, + || GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, + "Got unexpected error %#x.\n", GetLastError());
- error = GetLastError(); - if (error == ERROR_CALL_NOT_IMPLEMENTED) - { - /* win10 reports ERROR_CALL_NOT_IMPLEMENTED at first here */ - win_skip("SetupDiCreateDeviceInfoListExW is not implemented\n"); - return; - } - ok(devlist == INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected %p)\n", devlist, error, INVALID_HANDLE_VALUE); - ok(error == ERROR_INVALID_MACHINENAME || error == ERROR_MACHINE_UNAVAILABLE, "GetLastError returned wrong value : %d, (expected %d or %d)\n", error, ERROR_INVALID_MACHINENAME, ERROR_MACHINE_UNAVAILABLE); + set = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL); + ok(set && set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.", GetLastError());
- /* create empty DeviceInfoList */ - devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL); - ok(devlist && devlist != INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected != %p)\n", devlist, error, INVALID_HANDLE_VALUE); - - /* destroy DeviceInfoList */ - ret = pSetupDiDestroyDeviceInfoList(devlist); - ok(ret, "SetupDiDestroyDeviceInfoList failed : %d\n", error); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError());
- /* create empty DeviceInfoList with empty machine name */ - devlist = pSetupDiCreateDeviceInfoListExW(NULL, NULL, empty, NULL); - ok(devlist && devlist != INVALID_HANDLE_VALUE, "SetupDiCreateDeviceInfoListExW failed : %p %d (expected != %p)\n", devlist, error, INVALID_HANDLE_VALUE); + set = SetupDiCreateDeviceInfoListExW(NULL, NULL, empty, NULL); + ok(set && set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.", GetLastError());
- /* destroy DeviceInfoList */ - ret = pSetupDiDestroyDeviceInfoList(devlist); - ok(ret, "SetupDiDestroyDeviceInfoList failed : %d\n", error); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); }
static void test_SetupDiOpenClassRegKeyExA(void) @@ -1389,10 +1366,7 @@ START_TEST(devinst) } RegCloseKey(hkey);
- if (pSetupDiCreateDeviceInfoListExW) - test_SetupDiCreateDeviceInfoListEx(); - else - win_skip("SetupDiCreateDeviceInfoListExW is not available\n"); + test_create_device_list_ex();
if (pSetupDiOpenClassRegKeyExA) test_SetupDiOpenClassRegKeyExA();
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=44995
Your paranoid android.
=== build (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:136:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:7500: recipe for target 'dlls/setupapi/tests' failed Task: The exe32 Wine crossbuild failed
=== debian9 (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:136:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:8635: recipe for target 'dlls/setupapi/tests' failed Task: The win32 build failed
=== debian9 (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:136:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:8360: recipe for target 'dlls/setupapi/tests' failed Task: The wow64 build failed
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 75 +++++++++++++------------------------------ 1 file changed, 23 insertions(+), 52 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index dd036cdcd1..edd80f159e 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -33,22 +33,10 @@ #include "wine/heap.h" #include "wine/test.h"
-/* function pointers */ -static BOOL (WINAPI *pSetupDiCallClassInstaller)(DI_FUNCTION, HDEVINFO, PSP_DEVINFO_DATA); -static HKEY (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PVOID); - /* This is a unique guid for testing purposes */ static GUID guid = {0x6a55b5a4, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}}; static GUID guid2 = {0x6a55b5a5, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}};
-static void init_function_pointers(void) -{ - HMODULE hSetupAPI = GetModuleHandleA("setupapi.dll"); - - pSetupDiCallClassInstaller = (void *)GetProcAddress(hSetupAPI, "SetupDiCallClassInstaller"); - pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA"); -} - static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey) { LONG ret; @@ -149,42 +137,32 @@ static void test_create_device_list_ex(void) ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); }
-static void test_SetupDiOpenClassRegKeyExA(void) +static void test_open_class_key(void) { - static const CHAR guidString[] = "{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; - HKEY hkey; + static const char guidstr[] = "{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; + HKEY root_key, class_key; + LONG res;
- /* Check return value for nonexistent key */ - hkey = pSetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS, - DIOCR_INSTALLER, NULL, NULL); - ok(hkey == INVALID_HANDLE_VALUE, - "returned %p (expected INVALID_HANDLE_VALUE)\n", hkey); + SetLastError(0xdeadbeef); + class_key = SetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS, DIOCR_INSTALLER, NULL, NULL); + ok(class_key == INVALID_HANDLE_VALUE, "Expected failure.\n"); +todo_wine + ok(GetLastError() == ERROR_INVALID_CLASS, "Got unexpected error %#x.\n", GetLastError());
- /* Test it for a key that exists */ - hkey = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS); - if (hkey != INVALID_HANDLE_VALUE) - { - HKEY classKey; - if (RegCreateKeyA(hkey, guidString, &classKey) == ERROR_SUCCESS) - { - RegCloseKey(classKey); - SetLastError(0xdeadbeef); - classKey = pSetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS, - DIOCR_INSTALLER, NULL, NULL); - ok(classKey != INVALID_HANDLE_VALUE, - "opening class registry key failed with error %d\n", - GetLastError()); - if (classKey != INVALID_HANDLE_VALUE) - RegCloseKey(classKey); - RegDeleteKeyA(hkey, guidString); - } - else - trace("failed to create registry key for test\n"); + root_key = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS); + ok(root_key != INVALID_HANDLE_VALUE, "Failed to open root key, error %#x.\n", GetLastError());
- RegCloseKey(hkey); - } - else - trace("failed to open classes key %u\n", GetLastError()); + res = RegCreateKeyA(root_key, guidstr, &class_key); + ok(!res, "Failed to create class key, error %#x.\n", GetLastError()); + RegCloseKey(class_key); + + SetLastError(0xdeadbeef); + class_key = SetupDiOpenClassRegKeyExA(&guid, KEY_ALL_ACCESS, DIOCR_INSTALLER, NULL, NULL); + ok(class_key != INVALID_HANDLE_VALUE, "Failed to open class key, error %#x.\n", GetLastError()); + RegCloseKey(class_key); + + RegDeleteKeyA(root_key, guidstr); + RegCloseKey(root_key); }
static void create_inf_file(LPCSTR filename) @@ -1357,8 +1335,6 @@ START_TEST(devinst) { HKEY hkey;
- init_function_pointers(); - if ((hkey = SetupDiOpenClassRegKey(NULL, KEY_ALL_ACCESS)) == INVALID_HANDLE_VALUE) { skip("needs admin rights\n"); @@ -1367,12 +1343,7 @@ START_TEST(devinst) RegCloseKey(hkey);
test_create_device_list_ex(); - - if (pSetupDiOpenClassRegKeyExA) - test_SetupDiOpenClassRegKeyExA(); - else - win_skip("SetupDiOpenClassRegKeyExA is not available\n"); - + test_open_class_key(); test_install_class(); test_device_info(); test_get_device_instance_id();
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=44996
Your paranoid android.
=== build (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:124:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:7500: recipe for target 'dlls/setupapi/tests' failed Task: The exe32 Wine crossbuild failed
=== debian9 (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:124:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:8635: recipe for target 'dlls/setupapi/tests' failed Task: The win32 build failed
=== debian9 (build log) ===
../../../../wine/dlls/setupapi/tests/devinst.c:124:13: error: expected expression before ‘||’ token Makefile:184: recipe for target 'devinst.o' failed Makefile:8360: recipe for target 'dlls/setupapi/tests' failed Task: The wow64 build failed