Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index abf6fe9ed8d..728c4a3627d 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -1055,8 +1055,8 @@ static void test_device_iface(void) { char buffer[200]; SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_A *)buffer; + SP_DEVINFO_DATA device = {0}, device2 = {sizeof(device2)}; SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; - SP_DEVINFO_DATA device = {0}; BOOL ret; HDEVINFO set;
@@ -1154,6 +1154,16 @@ static void test_device_iface(void) check_device_iface(set, &device, &guid, 1, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\test"); check_device_iface(set, &device, &guid, 2, 0, NULL);
+ ret = SetupDiCreateDeviceInfoA(set, "ROOT\LEGACY_BOGUS\0001", &guid, NULL, NULL, 0, &device2); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device2, &guid, NULL, 0, NULL); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + + check_device_iface(set, NULL, &guid, 0, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\Oogah"); + check_device_iface(set, NULL, &guid, 1, 0, "\\?\ROOT#LEGACY_BOGUS#0000#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}\test"); + check_device_iface(set, NULL, &guid, 2, 0, "\\?\ROOT#LEGACY_BOGUS#0001#{6A55B5A4-3F65-11DB-B704-0011955C2BDB}"); + check_device_iface(set, NULL, &guid, 3, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 156 ++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 728c4a3627d..38d0bb162c9 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -37,6 +37,7 @@ /* 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 GUID iface_guid = {0xdeadbeef, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}};
BOOL (WINAPI *pSetupDiSetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE, const BYTE *, DWORD, DWORD); BOOL (WINAPI *pSetupDiGetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE *, BYTE *, DWORD, DWORD *, DWORD); @@ -2699,6 +2700,160 @@ static void test_call_class_installer(void) ok(ret, "Failed to delete file, error %u.\n", GetLastError()); }
+static void check_all_devices_enumerated_(int line, HDEVINFO set) +{ + SP_DEVINFO_DATA device = {sizeof(device)}; + BOOL ret, found_dev1 = 0, found_dev2 = 0, found_dev3 = 0; + char id[50]; + DWORD i; + + for (i = 0; SetupDiEnumDeviceInfo(set, i, &device); ++i) + { + ret = SetupDiGetDeviceInstanceIdA(set, &device, id, sizeof(id), NULL); + if (!ret) continue; + + if (!strcasecmp(id, "Root\LEGACY_BOGUS\foo")) + { + found_dev1 = 1; + ok_(__FILE__, line)(IsEqualGUID(&device.ClassGuid, &guid), + "Got unexpected class %s.\n", wine_dbgstr_guid(&device.ClassGuid)); + } + else if (!strcasecmp(id, "Root\LEGACY_BOGUS\qux")) + { + found_dev2 = 1; + ok_(__FILE__, line)(IsEqualGUID(&device.ClassGuid, &guid), + "Got unexpected class %s.\n", wine_dbgstr_guid(&device.ClassGuid)); + } + else if (!strcasecmp(id, "Root\LEGACY_BOGUS\bar")) + { + found_dev3 = 1; + ok_(__FILE__, line)(IsEqualGUID(&device.ClassGuid, &guid2), + "Got unexpected class %s.\n", wine_dbgstr_guid(&device.ClassGuid)); + } + } + ok_(__FILE__, line)(found_dev1, "Expected device 1 to be enumerated.\n"); + ok_(__FILE__, line)(found_dev2, "Expected device 2 to be enumerated.\n"); + ok_(__FILE__, line)(found_dev3, "Expected device 2 to be enumerated.\n"); +} +#define check_all_devices_enumerated(a) check_all_devices_enumerated_(__LINE__,a) + +static void test_get_class_devs(void) +{ + SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; + SP_DEVINFO_DATA device = {sizeof(device)}; + HDEVINFO set; + BOOL ret; + + set = SetupDiCreateDeviceInfoList(NULL, NULL); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\foo", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &iface_guid, NULL, 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\qux", &guid, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + + ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\bar", &guid2, NULL, NULL, 0, &device); + ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); + ok(ret, "Failed to register device, error %#x.\n", GetLastError()); + + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, NULL, NULL, 0); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_all_devices_enumerated(set); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); + check_device_info(set, 2, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, NULL, NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_all_devices_enumerated(set); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, 0); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_all_devices_enumerated(set); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS", NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); +todo_wine { + check_device_info(set, 0, &guid2, "ROOT\LEGACY_BOGUS\BAR"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 2, &guid, "ROOT\LEGACY_BOGUS\QUX"); +} + check_device_info(set, 3, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, "ROOT\LEGACY_BOGUS", NULL, 0); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); +todo_wine { + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); +} + check_device_info(set, 2, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, "ROOT\LEGACY_BOGUS", NULL, DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); +todo_wine { + check_device_info(set, 0, &guid2, "ROOT\LEGACY_BOGUS\BAR"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 2, &guid, "ROOT\LEGACY_BOGUS\QUX"); +} + check_device_info(set, 3, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); + SetupDiEnumDeviceInfo(set, 0, &device); + SetupDiRemoveDevice(set, &device); + SetupDiEnumDeviceInfo(set, 1, &device); + SetupDiRemoveDevice(set, &device); + SetupDiDestroyDeviceInfoList(set); + set = SetupDiGetClassDevsA(&guid2, NULL, NULL, 0); + SetupDiEnumDeviceInfo(set, 0, &device); + SetupDiRemoveDevice(set, &device); + SetupDiDestroyDeviceInfoList(set); +} + START_TEST(devinst) { static BOOL (WINAPI *pIsWow64Process)(HANDLE, BOOL *); @@ -2736,4 +2891,5 @@ START_TEST(devinst) test_device_install_params(); test_driver_list(); test_call_class_installer(); + test_get_class_devs(); }
Hi,
While running your changed tests, 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=52898
Your paranoid android.
=== w1064v1809 (32 bit report) ===
setupapi: devinst: Timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 877286e2aae..2f490f0978f 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -2448,6 +2448,9 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR enumstr, HWND p SetLastError(ERROR_INVALID_PARAMETER); return INVALID_HANDLE_VALUE; } + if (flags & DIGCF_ALLCLASSES) + class = NULL; + if (flags & unsupportedFlags) WARN("unsupported flags %08x\n", flags & unsupportedFlags); if (deviceset)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 142 ++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 6 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 38d0bb162c9..2d442bf968f 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -38,6 +38,7 @@ 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 GUID iface_guid = {0xdeadbeef, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}}; +static GUID iface_guid2 = {0xdeadf00d, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,0x2b,0xdb}};
BOOL (WINAPI *pSetupDiSetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE, const BYTE *, DWORD, DWORD); BOOL (WINAPI *pSetupDiGetDevicePropertyW)(HDEVINFO, PSP_DEVINFO_DATA, const DEVPROPKEY *, DEVPROPTYPE *, BYTE *, DWORD, DWORD *, DWORD); @@ -2700,7 +2701,7 @@ static void test_call_class_installer(void) ok(ret, "Failed to delete file, error %u.\n", GetLastError()); }
-static void check_all_devices_enumerated_(int line, HDEVINFO set) +static void check_all_devices_enumerated_(int line, HDEVINFO set, BOOL expect_dev3) { SP_DEVINFO_DATA device = {sizeof(device)}; BOOL ret, found_dev1 = 0, found_dev2 = 0, found_dev3 = 0; @@ -2733,9 +2734,10 @@ static void check_all_devices_enumerated_(int line, HDEVINFO set) } ok_(__FILE__, line)(found_dev1, "Expected device 1 to be enumerated.\n"); ok_(__FILE__, line)(found_dev2, "Expected device 2 to be enumerated.\n"); - ok_(__FILE__, line)(found_dev3, "Expected device 2 to be enumerated.\n"); + ok_(__FILE__, line)(found_dev3 == expect_dev3, "Expected device 2 %sto be enumerated.\n", + expect_dev3 ? "" : "not "); } -#define check_all_devices_enumerated(a) check_all_devices_enumerated_(__LINE__,a) +#define check_all_devices_enumerated(a,b) check_all_devices_enumerated_(__LINE__,a,b)
static void test_get_class_devs(void) { @@ -2751,11 +2753,15 @@ static void test_get_class_devs(void) ok(ret, "Failed to create device, error %#x.\n", GetLastError()); ret = SetupDiCreateDeviceInterfaceA(set, &device, &iface_guid, NULL, 0, &iface); ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &iface_guid2, NULL, 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); ok(ret, "Failed to register device, error %#x.\n", GetLastError());
ret = SetupDiCreateDeviceInfoA(set, "Root\LEGACY_BOGUS\qux", &guid, NULL, NULL, 0, &device); ok(ret, "Failed to create device, error %#x.\n", GetLastError()); + ret = SetupDiCreateDeviceInterfaceA(set, &device, &iface_guid, NULL, 0, &iface); + ok(ret, "Failed to create interface, error %#x.\n", GetLastError()); ret = SetupDiRegisterDeviceInfo(set, &device, 0, NULL, NULL, NULL); ok(ret, "Failed to register device, error %#x.\n", GetLastError());
@@ -2774,7 +2780,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); - check_all_devices_enumerated(set); + check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); @@ -2790,7 +2796,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(&guid, NULL, NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); - check_all_devices_enumerated(set); + check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); @@ -2802,7 +2808,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); - check_all_devices_enumerated(set); + check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); @@ -2842,6 +2848,130 @@ todo_wine { ret = SetupDiDestroyDeviceInfoList(set); ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError());
+ /* test DIGCF_DEVICE_INTERFACE */ + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_DEVICEINTERFACE); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_all_devices_enumerated(set, FALSE); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, "\\?\root#legacy_bogus#qux#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 2, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, "\\?\root#legacy_bogus#foo#{deadf00d-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid2, 1, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&guid, NULL, NULL, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&iface_guid, NULL, NULL, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); + check_device_info(set, 2, &guid, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, "\\?\root#legacy_bogus#qux#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 2, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&iface_guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_all_devices_enumerated(set, FALSE); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, "\\?\root#legacy_bogus#qux#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 2, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, "\\?\root#legacy_bogus#foo#{deadf00d-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid2, 1, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, DIGCF_DEVICEINTERFACE); + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Got unexpected error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); +todo_wine { + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); +todo_wine { + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); +todo_wine + check_device_info(set, 1, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, "\\?\root#legacy_bogus#foo#{deadf00d-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid2, 1, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS\bar", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS", NULL, DIGCF_DEVICEINTERFACE); +todo_wine { + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + SetLastError(0xdeadbeef); + set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); +todo_wine { + ok(set == INVALID_HANDLE_VALUE, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got unexpected error %#x.\n", GetLastError()); +} + + set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); + check_device_info(set, 1, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + + set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); + ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); +todo_wine + check_device_info(set, 1, NULL, NULL); + check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid, 1, 0, NULL); + check_device_iface(set, NULL, &iface_guid2, 0, 0, "\\?\root#legacy_bogus#foo#{deadf00d-3f65-11db-b704-0011955c2bdb}"); + check_device_iface(set, NULL, &iface_guid2, 1, 0, NULL); + ret = SetupDiDestroyDeviceInfoList(set); + ok(ret, "Failed to destroy device list, error %#x.\n", GetLastError()); + set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); SetupDiEnumDeviceInfo(set, 0, &device); SetupDiRemoveDevice(set, &device);
Hi,
While running your changed tests, 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=52900
Your paranoid android.
=== w1064v1809 (32 bit report) ===
setupapi: devinst: Timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 2f490f0978f..4b576e2db56 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -2456,7 +2456,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR enumstr, HWND p if (deviceset) set = deviceset; else - set = SetupDiCreateDeviceInfoListExW(class, parent, machine, reserved); + set = SetupDiCreateDeviceInfoListExW((flags & DIGCF_DEVICEINTERFACE) ? NULL : class, parent, machine, reserved); if (set != INVALID_HANDLE_VALUE) { if (machine && *machine)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/devinst.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 2d442bf968f..d7aa43fce2b 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2739,6 +2739,16 @@ static void check_all_devices_enumerated_(int line, HDEVINFO set, BOOL expect_de } #define check_all_devices_enumerated(a,b) check_all_devices_enumerated_(__LINE__,a,b)
+static void check_device_list_(int line, HDEVINFO set, const GUID *expect) +{ + SP_DEVINFO_LIST_DETAIL_DATA_A detail = {sizeof(detail)}; + BOOL ret = SetupDiGetDeviceInfoListDetailA(set, &detail); + ok_(__FILE__, line)(ret, "Failed to get list detail, error %#x.\n", GetLastError()); + ok_(__FILE__, line)(IsEqualGUID(&detail.ClassGuid, expect), "Expected class %s, got %s\n", + wine_dbgstr_guid(expect), wine_dbgstr_guid(&detail.ClassGuid)); +} +#define check_device_list(a,b) check_device_list_(__LINE__,a,b) + static void test_get_class_devs(void) { SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; @@ -2780,6 +2790,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); @@ -2787,6 +2798,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(&guid, NULL, NULL, 0); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &guid); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); check_device_info(set, 2, NULL, NULL); @@ -2796,6 +2808,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(&guid, NULL, NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); @@ -2808,6 +2821,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(NULL, "ROOT", NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_all_devices_enumerated(set, TRUE); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); ret = SetupDiDestroyDeviceInfoList(set); @@ -2815,6 +2829,7 @@ static void test_get_class_devs(void)
set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS", NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); todo_wine { check_device_info(set, 0, &guid2, "ROOT\LEGACY_BOGUS\BAR"); check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\FOO"); @@ -2827,6 +2842,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&guid, "ROOT\LEGACY_BOGUS", NULL, 0); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &guid); todo_wine { check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); @@ -2838,6 +2854,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&guid, "ROOT\LEGACY_BOGUS", NULL, DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); todo_wine { check_device_info(set, 0, &guid2, "ROOT\LEGACY_BOGUS\BAR"); check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\FOO"); @@ -2857,6 +2874,7 @@ todo_wine {
set = SetupDiGetClassDevsA(NULL, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_all_devices_enumerated(set, FALSE); check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); check_device_iface(set, NULL, &iface_guid, 1, 0, "\\?\root#legacy_bogus#qux#{deadbeef-3f65-11db-b704-0011955c2bdb}"); @@ -2868,6 +2886,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&guid, NULL, NULL, DIGCF_DEVICEINTERFACE); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, NULL, NULL); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); @@ -2876,6 +2895,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&iface_guid, NULL, NULL, DIGCF_DEVICEINTERFACE); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); check_device_info(set, 1, &guid, "ROOT\LEGACY_BOGUS\QUX"); check_device_info(set, 2, &guid, NULL); @@ -2888,6 +2908,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&iface_guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_all_devices_enumerated(set, FALSE); check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); check_device_iface(set, NULL, &iface_guid, 1, 0, "\\?\root#legacy_bogus#qux#{deadbeef-3f65-11db-b704-0011955c2bdb}"); @@ -2918,6 +2939,7 @@ todo_wine {
set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); todo_wine check_device_info(set, 1, NULL, NULL); @@ -2930,6 +2952,7 @@ todo_wine
set = SetupDiGetClassDevsA(NULL, "ROOT\LEGACY_BOGUS\bar", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, NULL, NULL); check_device_iface(set, NULL, &iface_guid, 0, 0, NULL); check_device_iface(set, NULL, &iface_guid2, 0, 0, NULL); @@ -2952,6 +2975,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); check_device_info(set, 1, NULL, NULL); check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); @@ -2962,6 +2986,7 @@ todo_wine {
set = SetupDiGetClassDevsA(&iface_guid, "ROOT\LEGACY_BOGUS\foo", NULL, DIGCF_DEVICEINTERFACE | DIGCF_ALLCLASSES); ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); + check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); todo_wine check_device_info(set, 1, NULL, NULL);
Hi,
While running your changed tests, 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=52902
Your paranoid android.
=== w1064v1809 (32 bit report) ===
setupapi: devinst: Timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/devinst.c | 35 ++++++++++++++++++----------------- dlls/setupapi/tests/devinst.c | 2 -- 2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 4b576e2db56..b7625644bec 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -748,7 +748,8 @@ static void delete_device(struct device *device) heap_free(device); }
-static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set, +/* Create a new device, or return a device already in the set. */ +static struct device *create_device(struct DeviceInfoSet *set, const GUID *class, const WCHAR *instanceid, BOOL phantom) { const DWORD one = 1; @@ -758,6 +759,15 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set, TRACE("%p, %s, %s, %d\n", set, debugstr_guid(class), debugstr_w(instanceid), phantom);
+ LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry) + { + if (!strcmpiW(instanceid, device->instanceId)) + { + TRACE("Found device %p already in set.\n", device); + return device; + } + } + if (!(device = heap_alloc_zero(sizeof(*device)))) { SetLastError(ERROR_OUTOFMEMORY); @@ -788,6 +798,8 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set, SETUPDI_GuidToString(class, guidstr); SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_CLASSGUID, (const BYTE *)guidstr, sizeof(guidstr)); + + TRACE("Created new device %p.\n", device); return device; }
@@ -1620,7 +1632,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const } }
- if (!(device = SETUPDI_CreateDeviceInfo(set, class, id, TRUE))) + if (!(device = create_device(set, class, id, TRUE))) return FALSE;
if (description) @@ -2196,8 +2208,7 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet, deviceClassStr[37] = 0; UuidFromStringW(&deviceClassStr[1], &deviceClass); - if ((device = SETUPDI_CreateDeviceInfo(set, - &deviceClass, deviceInst, FALSE))) + if ((device = create_device(set, &deviceClass, deviceInst, FALSE))) SETUPDI_AddDeviceInterfaces(device, subKey, guid, flags); } RegCloseKey(deviceKey); @@ -2318,7 +2329,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set, if (snprintfW(id, ARRAY_SIZE(id), fmt, enumerator, deviceName, deviceInstance) != -1) { - SETUPDI_CreateDeviceInfo(set, &deviceClass, id, FALSE); + create_device(set, &deviceClass, id, FALSE); } } } @@ -3439,7 +3450,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw PSP_DEVINFO_DATA device_data) { struct DeviceInfoSet *set; - struct device *device = NULL, *enum_device; + struct device *device; WCHAR classW[40]; GUID guid; HKEY enumKey = NULL; @@ -3489,17 +3500,7 @@ BOOL WINAPI SetupDiOpenDeviceInfoW(HDEVINFO devinfo, PCWSTR instance_id, HWND hw goto done; }
- /* If current set already contains a same instance, don't create new ones */ - LIST_FOR_EACH_ENTRY(enum_device, &set->devices, struct device, entry) - { - if (!strcmpiW(instance_id, enum_device->instanceId)) - { - device = enum_device; - break; - } - } - - if (!device && !(device = SETUPDI_CreateDeviceInfo(set, &guid, instance_id, FALSE))) + if (!(device = create_device(set, &guid, instance_id, FALSE))) goto done;
if (!device_data || device_data->cbSize == sizeof(SP_DEVINFO_DATA)) diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index d7aa43fce2b..7a3a53d5f1e 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2941,7 +2941,6 @@ todo_wine { ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); -todo_wine check_device_info(set, 1, NULL, NULL); check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); check_device_iface(set, NULL, &iface_guid, 1, 0, NULL); @@ -2988,7 +2987,6 @@ todo_wine { ok(set != INVALID_HANDLE_VALUE, "Failed to create device list, error %#x.\n", GetLastError()); check_device_list(set, &GUID_NULL); check_device_info(set, 0, &guid, "ROOT\LEGACY_BOGUS\FOO"); -todo_wine check_device_info(set, 1, NULL, NULL); check_device_iface(set, NULL, &iface_guid, 0, 0, "\\?\root#legacy_bogus#foo#{deadbeef-3f65-11db-b704-0011955c2bdb}"); check_device_iface(set, NULL, &iface_guid, 1, 0, NULL);
Hi,
While running your changed tests, 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=52903
Your paranoid android.
=== w1064v1809 (32 bit report) ===
setupapi: devinst: Timeout
Hi,
While running your changed tests, 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=52897
Your paranoid android.
=== w1064v1809 (32 bit report) ===
setupapi: devinst: Timeout