From: Robert Gerigk <Robert-Gerigk@online.de> Move the CM_Get_Parent positive-path assertion into test_pnp_devices, where the child device has DEVPKEY_Device_Parent reliably populated by the bus driver. With the property in place, the result is always CR_SUCCESS and the returned parent maps back to the bus instance ID "ROOT\\WINETEST\\0". The setupapi-side test is reduced to the parameter-validation check (CR_INVALID_POINTER for a NULL output pointer), which does not depend on PnP state. Signed-off-by: Jan Robert Gerigk <Robert-Gerigk@online.de> --- dlls/ntoskrnl.exe/tests/ntoskrnl.c | 15 +++++++++++++++ dlls/setupapi/tests/devinst.c | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 524b038df88..e5b62fa5e6b 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -2295,6 +2295,21 @@ static void test_pnp_devices(void) ok(size == sizeof(WCHAR), "got size %lu, expected %Iu\n", size, sizeof(WCHAR)); ok(buffer_w[0] == 0, "got non-empty siblings %s\n", debugstr_w(buffer_w)); + /* CM_Get_Parent on the PnP-managed child returns the bus parent. */ + { + char parent_id[MAX_DEVICE_ID_LEN]; + DEVINST cm_parent = 0; + CONFIGRET cm_ret; + + cm_ret = CM_Get_Parent(&cm_parent, device.DevInst, 0); + ok(cm_ret == CR_SUCCESS, "CM_Get_Parent: got %#lx\n", cm_ret); + ok(cm_parent != 0, "got null parent devnode\n"); + + cm_ret = CM_Get_Device_IDA(cm_parent, parent_id, sizeof(parent_id), 0); + ok(cm_ret == CR_SUCCESS, "CM_Get_Device_IDA: got %#lx\n", cm_ret); + ok(!strcmp(parent_id, "ROOT\\WINETEST\\0"), "got parent ID %s\n", parent_id); + } + ret = SetupDiEnumDeviceInterfaces(set, NULL, &child_class, 0, &iface); ok(ret, "failed to get interface, error %#lx\n", GetLastError()); ok(IsEqualGUID(&iface.InterfaceClassGuid, &child_class), diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 605b0257667..98cec632219 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -2853,6 +2853,12 @@ static void test_devnode(void) ok(!ret, "got %#lx\n", ret); ok(!strcmp(buffer, "ROOT\\LEGACY_BOGUS\\0000"), "got %s\n", buffer); + /* CM_Get_Parent parameter validation. The CR_SUCCESS path requires a + * PnP-managed device with DEVPKEY_Device_Parent populated by the bus + * driver, which is exercised in ntoskrnl/tests/ntoskrnl.c::test_pnp_devices. */ + ret = CM_Get_Parent(NULL, device.DevInst, 0); + ok(ret == CR_INVALID_POINTER, "got %#lx\n", ret); + SetupDiDestroyDeviceInfoList(set); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10604