Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
58415214
Commit
58415214
authored
Aug 29, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add tests for SetSearchPathMode.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a8d291c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
0 deletions
+109
-0
path.c
dlls/kernel32/tests/path.c
+109
-0
No files found.
dlls/kernel32/tests/path.c
View file @
58415214
...
...
@@ -72,6 +72,7 @@ static BOOL (WINAPI *pNeedCurrentDirectoryForExePathW)(LPCWSTR);
static
DWORD
(
WINAPI
*
pSearchPathA
)(
LPCSTR
,
LPCSTR
,
LPCSTR
,
DWORD
,
LPSTR
,
LPSTR
*
);
static
DWORD
(
WINAPI
*
pSearchPathW
)(
LPCWSTR
,
LPCWSTR
,
LPCWSTR
,
DWORD
,
LPWSTR
,
LPWSTR
*
);
static
BOOL
(
WINAPI
*
pSetSearchPathMode
)(
DWORD
);
static
BOOL
(
WINAPI
*
pActivateActCtx
)(
HANDLE
,
ULONG_PTR
*
);
static
HANDLE
(
WINAPI
*
pCreateActCtxW
)(
PCACTCTXW
);
...
...
@@ -2119,6 +2120,7 @@ static void init_pointers(void)
MAKEFUNC
(
NeedCurrentDirectoryForExePathW
);
MAKEFUNC
(
SearchPathA
);
MAKEFUNC
(
SearchPathW
);
MAKEFUNC
(
SetSearchPathMode
);
MAKEFUNC
(
ActivateActCtx
);
MAKEFUNC
(
CreateActCtxW
);
MAKEFUNC
(
DeactivateActCtx
);
...
...
@@ -2276,6 +2278,112 @@ static void test_CheckNameLegalDOS8Dot3(void)
}
}
static
void
test_SetSearchPathMode
(
void
)
{
BOOL
ret
;
char
orig
[
MAX_PATH
],
buf
[
MAX_PATH
],
dir
[
MAX_PATH
],
expect
[
MAX_PATH
];
HANDLE
handle
;
if
(
!
pSetSearchPathMode
)
{
win_skip
(
"SetSearchPathMode isn't available
\n
"
);
return
;
}
GetCurrentDirectoryA
(
MAX_PATH
,
orig
);
GetTempPathA
(
MAX_PATH
,
buf
);
GetTempFileNameA
(
buf
,
"path"
,
0
,
dir
);
DeleteFileA
(
dir
);
CreateDirectoryA
(
dir
,
NULL
);
ret
=
SetCurrentDirectoryA
(
dir
);
ok
(
ret
,
"failed to switch to %s
\n
"
,
dir
);
if
(
!
ret
)
{
RemoveDirectoryA
(
dir
);
return
;
}
handle
=
CreateFileA
(
"kernel32.dll"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
CloseHandle
(
handle
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
0
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
0x80
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_PERMANENT
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
SearchPathA
(
NULL
,
"kernel32.dll"
,
NULL
,
MAX_PATH
,
buf
,
NULL
);
ok
(
ret
,
"SearchPathA failed err %u
\n
"
,
GetLastError
()
);
GetCurrentDirectoryA
(
MAX_PATH
,
expect
);
strcat
(
expect
,
"
\\
kernel32.dll"
);
ok
(
!
lstrcmpiA
(
buf
,
expect
),
"found %s expected %s
\n
"
,
buf
,
expect
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
);
ok
(
ret
,
"SetSearchPathMode failed err %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
SearchPathA
(
NULL
,
"kernel32.dll"
,
NULL
,
MAX_PATH
,
buf
,
NULL
);
ok
(
ret
,
"SearchPathA failed err %u
\n
"
,
GetLastError
()
);
GetSystemDirectoryA
(
expect
,
MAX_PATH
);
strcat
(
expect
,
"
\\
kernel32.dll"
);
ok
(
!
lstrcmpiA
(
buf
,
expect
),
"found %s expected %s
\n
"
,
buf
,
expect
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE
);
ok
(
ret
,
"SetSearchPathMode failed err %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
SearchPathA
(
NULL
,
"kernel32.dll"
,
NULL
,
MAX_PATH
,
buf
,
NULL
);
ok
(
ret
,
"SearchPathA failed err %u
\n
"
,
GetLastError
()
);
GetCurrentDirectoryA
(
MAX_PATH
,
expect
);
strcat
(
expect
,
"
\\
kernel32.dll"
);
ok
(
!
lstrcmpiA
(
buf
,
expect
),
"found %s expected %s
\n
"
,
buf
,
expect
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE
|
BASE_SEARCH_PATH_PERMANENT
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
|
BASE_SEARCH_PATH_PERMANENT
);
ok
(
ret
,
"SetSearchPathMode failed err %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
);
ok
(
!
ret
,
"SetSearchPathMode succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pSetSearchPathMode
(
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
|
BASE_SEARCH_PATH_PERMANENT
);
ok
(
ret
,
"SetSearchPathMode failed err %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
SearchPathA
(
NULL
,
"kernel32.dll"
,
NULL
,
MAX_PATH
,
buf
,
NULL
);
ok
(
ret
,
"SearchPathA failed err %u
\n
"
,
GetLastError
()
);
GetSystemDirectoryA
(
expect
,
MAX_PATH
);
strcat
(
expect
,
"
\\
kernel32.dll"
);
ok
(
!
lstrcmpiA
(
buf
,
expect
),
"found %s expected %s
\n
"
,
buf
,
expect
);
DeleteFileA
(
"kernel32.dll"
);
SetCurrentDirectoryA
(
orig
);
RemoveDirectoryA
(
dir
);
}
START_TEST
(
path
)
{
CHAR
origdir
[
MAX_PATH
],
curdir
[
MAX_PATH
],
curDrive
,
otherDrive
;
...
...
@@ -2309,4 +2417,5 @@ START_TEST(path)
test_GetFullPathNameA
();
test_GetFullPathNameW
();
test_CheckNameLegalDOS8Dot3
();
test_SetSearchPathMode
();
}
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