Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
301f66bf
Commit
301f66bf
authored
May 27, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi/tests: Add some tests for SetupDiGetClassDevs().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bf09cca8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
156 additions
and
0 deletions
+156
-0
devinst.c
dlls/setupapi/tests/devinst.c
+156
-0
No files found.
dlls/setupapi/tests/devinst.c
View file @
301f66bf
...
...
@@ -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
);
...
...
@@ -2691,6 +2692,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
*
);
...
...
@@ -2728,4 +2883,5 @@ START_TEST(devinst)
test_device_install_params
();
test_driver_list
();
test_call_class_installer
();
test_get_class_devs
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment