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
6244f059
Commit
6244f059
authored
May 17, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
May 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi/tests: Add tests for SetupDiGetActualSectionToInstall().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c9e3307f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
182 additions
and
21 deletions
+182
-21
devinst.c
dlls/setupapi/tests/devinst.c
+182
-21
No files found.
dlls/setupapi/tests/devinst.c
View file @
6244f059
...
...
@@ -41,6 +41,19 @@ static GUID guid2 = {0x6a55b5a5, 0x3f65, 0x11db, {0xb7,0x04,0x00,0x11,0x95,0x5c,
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
);
static
void
create_file
(
const
char
*
name
,
const
char
*
data
)
{
HANDLE
file
;
DWORD
size
;
BOOL
ret
;
file
=
CreateFileA
(
name
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"Failed to create %s, error %u.
\n
"
,
name
,
GetLastError
());
ret
=
WriteFile
(
file
,
data
,
strlen
(
data
),
&
size
,
NULL
);
ok
(
ret
&&
size
==
strlen
(
data
),
"Failed to write %s, error %u.
\n
"
,
name
,
GetLastError
());
CloseHandle
(
file
);
}
static
void
test_create_device_list_ex
(
void
)
{
static
const
WCHAR
machine
[]
=
{
'd'
,
'u'
,
'm'
,
'm'
,
'y'
,
0
};
...
...
@@ -103,26 +116,6 @@ todo_wine
RegCloseKey
(
root_key
);
}
static
void
create_inf_file
(
LPCSTR
filename
)
{
DWORD
dwNumberOfBytesWritten
;
HANDLE
hf
=
CreateFileA
(
filename
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
static
const
char
data
[]
=
"[Version]
\n
"
"Signature=
\"
$Chicago$
\"\n
"
"Class=Bogus
\n
"
"ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}
\n
"
"[ClassInstall32]
\n
"
"AddReg=BogusClass.NT.AddReg
\n
"
"[BogusClass.NT.AddReg]
\n
"
"HKR,,,,
\"
Wine test devices
\"\n
"
;
WriteFile
(
hf
,
data
,
sizeof
(
data
)
-
1
,
&
dwNumberOfBytesWritten
,
NULL
);
CloseHandle
(
hf
);
}
static
void
get_temp_filename
(
LPSTR
path
)
{
static
char
curr
[
MAX_PATH
]
=
{
0
};
...
...
@@ -148,10 +141,20 @@ static void test_install_class(void)
char
tmpfile
[
MAX_PATH
];
BOOL
ret
;
static
const
char
inf_data
[]
=
"[Version]
\n
"
"Signature=
\"
$Chicago$
\"\n
"
"Class=Bogus
\n
"
"ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}
\n
"
"[ClassInstall32]
\n
"
"AddReg=BogusClass.NT.AddReg
\n
"
"[BogusClass.NT.AddReg]
\n
"
"HKR,,,,
\"
Wine test devices
\"\n
"
;
tmpfile
[
0
]
=
'.'
;
tmpfile
[
1
]
=
'\\'
;
get_temp_filename
(
tmpfile
+
2
);
create_
inf_file
(
tmpfile
+
2
);
create_
file
(
tmpfile
+
2
,
inf_data
);
ret
=
SetupDiInstallClassA
(
NULL
,
NULL
,
0
,
NULL
);
ok
(
!
ret
,
"Expected failure.
\n
"
);
...
...
@@ -1952,10 +1955,168 @@ static void test_device_install_params(void)
SetupDiDestroyDeviceInfoList
(
set
);
}
#ifdef __i386__
#define MYEXT "x86"
#define WOWEXT "AMD64"
#define WRONGEXT "ARM"
#elif defined(__x86_64__)
#define MYEXT "AMD64"
#define WOWEXT "x86"
#define WRONGEXT "ARM64"
#elif defined(__arm__)
#define MYEXT "ARM"
#define WOWEXT "ARM64"
#define WRONGEXT "x86"
#elif defined(__aarch64__)
#define MYEXT "ARM64"
#define WOWEXT "ARM"
#define WRONGEXT "AMD64"
#else
#define MYEXT
#define WOWEXT
#define WRONGEXT
#endif
static
void
test_get_actual_section
(
void
)
{
static
const
char
inf_data
[]
=
"[Version]
\n
"
"Signature=
\"
$Chicago$
\"\n
"
"[section1]
\n
"
"[section2]
\n
"
"[section2.nt]
\n
"
"[section3]
\n
"
"[section3.nt"
MYEXT
"]
\n
"
"[section4]
\n
"
"[section4.nt]
\n
"
"[section4.nt"
MYEXT
"]
\n
"
"[section5.nt]
\n
"
"[section6.nt"
MYEXT
"]
\n
"
"[section7]
\n
"
"[section7.nt"
WRONGEXT
"]
\n
"
"[section8.nt"
WRONGEXT
"]
\n
"
"[section9.nt"
MYEXT
"]
\n
"
"[section9.nt"
WOWEXT
"]
\n
"
"[section10.nt"
WOWEXT
"]
\n
"
;
char
inf_path
[
MAX_PATH
],
section
[
LINE_LEN
],
*
extptr
;
DWORD
size
;
HINF
hinf
;
BOOL
ret
;
GetTempPathA
(
sizeof
(
inf_path
),
inf_path
);
strcat
(
inf_path
,
"setupapi_test.inf"
);
create_file
(
inf_path
,
inf_data
);
hinf
=
SetupOpenInfFileA
(
inf_path
,
NULL
,
INF_STYLE_WIN4
,
NULL
);
ok
(
hinf
!=
INVALID_HANDLE_VALUE
,
"Failed to open INF file, error %#x.
\n
"
,
GetLastError
());
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section1"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
NULL
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcmp
(
section
,
"section1"
),
"Got unexpected section %s.
\n
"
,
section
);
size
=
0xdeadbeef
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section1"
,
NULL
,
5
,
&
size
,
NULL
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
size
==
9
,
"Got size %u.
\n
"
,
size
);
SetLastError
(
0xdeadbeef
);
size
=
0xdeadbeef
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section1"
,
section
,
5
,
&
size
,
NULL
);
ok
(
!
ret
,
"Expected failure.
\n
"
);
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"Got unexpected error %#x.
\n
"
,
GetLastError
());
ok
(
size
==
9
,
"Got size %u.
\n
"
,
size
);
SetLastError
(
0xdeadbeef
);
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section1"
,
section
,
ARRAY_SIZE
(
section
),
&
size
,
NULL
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section1"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
size
==
9
,
"Got size %u.
\n
"
,
size
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section1"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section1"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
!
extptr
||
!*
extptr
/* Windows 10 1809 */
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section2"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section2.NT"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section3"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section3.NT"
MYEXT
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section4"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section4.NT"
MYEXT
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section5"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section5.NT"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section6"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section6.NT"
MYEXT
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section7"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section7"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
!
extptr
||
!*
extptr
/* Windows 10 1809 */
,
"Got extension %s.
\n
"
,
extptr
);
todo_wine
{
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section8"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section8"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
!
extptr
||
!*
extptr
/* Windows 10 1809 */
,
"Got extension %s.
\n
"
,
extptr
);
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"nonexistent"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"nonexistent"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
!
extptr
||
!*
extptr
/* Windows 10 1809 */
,
"Got extension %s.
\n
"
,
extptr
);
}
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section9"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section9.NT"
MYEXT
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
extptr
==
section
+
8
,
"Got extension %s.
\n
"
,
extptr
);
todo_wine
{
if
(
0
)
{
/* For some reason, this call hangs on Windows 10 1809. */
extptr
=
section
;
ret
=
SetupDiGetActualSectionToInstallA
(
hinf
,
"section10"
,
section
,
ARRAY_SIZE
(
section
),
NULL
,
&
extptr
);
ok
(
ret
,
"Failed to get section, error %#x.
\n
"
,
GetLastError
());
ok
(
!
strcasecmp
(
section
,
"section10"
),
"Got unexpected section %s.
\n
"
,
section
);
ok
(
!
extptr
,
"Got extension %s.
\n
"
,
extptr
);
}
}
SetupCloseInfFile
(
hinf
);
ret
=
DeleteFileA
(
inf_path
);
ok
(
ret
,
"Failed to delete %s, error %u.
\n
"
,
inf_path
,
GetLastError
());
}
START_TEST
(
devinst
)
{
HKEY
hkey
;
test_get_actual_section
();
if
((
hkey
=
SetupDiOpenClassRegKey
(
NULL
,
KEY_ALL_ACCESS
))
==
INVALID_HANDLE_VALUE
)
{
skip
(
"needs admin rights
\n
"
);
...
...
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