Commit 3b08a51b authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl/tests: Add some tests for device interfaces.

parent 0b8c1d69
......@@ -36,7 +36,10 @@
#define IOCTL_WINETEST_MISMATCHED_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80b, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_COMPLETION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80c, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_MAIN CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_MAIN CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_REGISTER_IFACE CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_ENABLE_IFACE CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_DISABLE_IFACE CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
static const char teststr[] = "Wine is not an emulator";
......
......@@ -33,7 +33,8 @@
#include "utils.h"
static const GUID control_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc0}};
static UNICODE_STRING control_symlink;
static const GUID bus_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc1}};
static UNICODE_STRING control_symlink, bus_symlink;
static DEVICE_OBJECT *bus_fdo, *bus_pdo;
......@@ -60,6 +61,7 @@ static NTSTATUS fdo_pnp(IRP *irp)
IoDetachDevice(bus_pdo);
IoDeleteDevice(bus_fdo);
RtlFreeUnicodeString(&control_symlink);
RtlFreeUnicodeString(&bus_symlink);
return ret;
}
......@@ -259,6 +261,17 @@ static NTSTATUS fdo_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG code)
test_bus_query();
return STATUS_SUCCESS;
case IOCTL_WINETEST_BUS_REGISTER_IFACE:
return IoRegisterDeviceInterface(bus_pdo, &bus_class, NULL, &bus_symlink);
case IOCTL_WINETEST_BUS_ENABLE_IFACE:
IoSetDeviceInterfaceState(&bus_symlink, TRUE);
return STATUS_SUCCESS;
case IOCTL_WINETEST_BUS_DISABLE_IFACE:
IoSetDeviceInterfaceState(&bus_symlink, FALSE);
return STATUS_SUCCESS;
default:
ok(0, "Unexpected ioctl %#x.\n", code);
return STATUS_NOT_IMPLEMENTED;
......
......@@ -987,6 +987,7 @@ static void add_file_to_catalog(HANDLE catalog, const WCHAR *file)
static void test_pnp_devices(void)
{
static const GUID control_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc0}};
static const GUID bus_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc1}};
char buffer[200];
SP_DEVICE_INTERFACE_DETAIL_DATA_A *iface_detail = (void *)buffer;
......@@ -1028,6 +1029,65 @@ static void test_pnp_devices(void)
ret = DeviceIoControl(bus, IOCTL_WINETEST_BUS_MAIN, NULL, 0, NULL, 0, &size, NULL);
ok(ret, "got error %u\n", GetLastError());
/* Test IoRegisterDeviceInterface() and IoSetDeviceInterfaceState(). */
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_NO_MORE_ITEMS, "got error %#x\n", GetLastError());
SetupDiDestroyDeviceInfoList(set);
ret = DeviceIoControl(bus, IOCTL_WINETEST_BUS_REGISTER_IFACE, NULL, 0, NULL, 0, &size, NULL);
ok(ret, "got error %u\n", GetLastError());
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(ret, "failed to get interface, error %#x\n", GetLastError());
ok(IsEqualGUID(&iface.InterfaceClassGuid, &bus_class),
"wrong class %s\n", debugstr_guid(&iface.InterfaceClassGuid));
ok(!iface.Flags, "got flags %#x\n", iface.Flags);
SetupDiDestroyDeviceInfoList(set);
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_NO_MORE_ITEMS, "got error %#x\n", GetLastError());
SetupDiDestroyDeviceInfoList(set);
ret = DeviceIoControl(bus, IOCTL_WINETEST_BUS_ENABLE_IFACE, NULL, 0, NULL, 0, &size, NULL);
ok(ret, "got error %u\n", GetLastError());
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(ret, "failed to get interface, error %#x\n", GetLastError());
ok(IsEqualGUID(&iface.InterfaceClassGuid, &bus_class),
"wrong class %s\n", debugstr_guid(&iface.InterfaceClassGuid));
ok(iface.Flags == SPINT_ACTIVE, "got flags %#x\n", iface.Flags);
SetupDiDestroyDeviceInfoList(set);
ret = DeviceIoControl(bus, IOCTL_WINETEST_BUS_DISABLE_IFACE, NULL, 0, NULL, 0, &size, NULL);
ok(ret, "got error %u\n", GetLastError());
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(ret, "failed to get interface, error %#x\n", GetLastError());
ok(IsEqualGUID(&iface.InterfaceClassGuid, &bus_class),
"wrong class %s\n", debugstr_guid(&iface.InterfaceClassGuid));
ok(!iface.Flags, "got flags %#x\n", iface.Flags);
SetupDiDestroyDeviceInfoList(set);
set = SetupDiGetClassDevsA(&bus_class, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
ret = SetupDiEnumDeviceInterfaces(set, NULL, &bus_class, 0, &iface);
ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_NO_MORE_ITEMS, "got error %#x\n", GetLastError());
SetupDiDestroyDeviceInfoList(set);
CloseHandle(bus);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment