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
d98b87a3
Commit
d98b87a3
authored
May 06, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
May 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for RtlSetCurrentEnvironment().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
14b70350
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
env.c
dlls/ntdll/tests/env.c
+67
-0
No files found.
dlls/ntdll/tests/env.c
View file @
d98b87a3
...
...
@@ -515,6 +515,72 @@ static void test_process_params(void)
}
}
static
NTSTATUS
set_env_var
(
WCHAR
**
env
,
const
WCHAR
*
var
,
const
WCHAR
*
value
)
{
UNICODE_STRING
var_string
,
value_string
;
RtlInitUnicodeString
(
&
var_string
,
var
);
RtlInitUnicodeString
(
&
value_string
,
value
);
return
RtlSetEnvironmentVariable
(
env
,
&
var_string
,
&
value_string
);
}
static
void
check_env_var_
(
int
line
,
const
char
*
var
,
const
char
*
value
)
{
char
buffer
[
20
];
DWORD
size
=
GetEnvironmentVariableA
(
var
,
buffer
,
sizeof
(
buffer
));
if
(
value
)
{
ok_
(
__FILE__
,
line
)(
size
==
strlen
(
value
),
"wrong size %u
\n
"
,
size
);
ok_
(
__FILE__
,
line
)(
!
strcmp
(
buffer
,
value
),
"wrong value %s
\n
"
,
debugstr_a
(
buffer
));
}
else
{
ok_
(
__FILE__
,
line
)(
!
size
,
"wrong size %u
\n
"
,
size
);
ok_
(
__FILE__
,
line
)(
GetLastError
()
==
ERROR_ENVVAR_NOT_FOUND
,
"got error %u
\n
"
,
GetLastError
());
}
}
#define check_env_var(a, b) check_env_var_(__LINE__, a, b)
static
void
test_RtlSetCurrentEnvironment
(
void
)
{
NTSTATUS
status
;
WCHAR
*
old_env
,
*
env
,
*
prev
;
BOOL
ret
;
status
=
RtlCreateEnvironment
(
FALSE
,
&
env
);
ok
(
!
status
,
"got %#x
\n
"
,
status
);
ret
=
SetEnvironmentVariableA
(
"testenv1"
,
"heis"
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
ret
=
SetEnvironmentVariableA
(
"testenv2"
,
"dyo"
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
status
=
set_env_var
(
&
env
,
L"testenv1"
,
L"unus"
);
ok
(
!
status
,
"got %#x
\n
"
,
status
);
status
=
set_env_var
(
&
env
,
L"testenv3"
,
L"tres"
);
ok
(
!
status
,
"got %#x
\n
"
,
status
);
old_env
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
;
RtlSetCurrentEnvironment
(
env
,
&
prev
);
ok
(
prev
==
old_env
,
"got wrong previous env %p
\n
"
,
prev
);
ok
(
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
==
env
,
"got wrong current env
\n
"
);
check_env_var
(
"testenv1"
,
"unus"
);
check_env_var
(
"testenv2"
,
NULL
);
check_env_var
(
"testenv3"
,
"tres"
);
check_env_var
(
"PATH"
,
NULL
);
RtlSetCurrentEnvironment
(
old_env
,
NULL
);
ok
(
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
==
old_env
,
"got wrong current env
\n
"
);
check_env_var
(
"testenv1"
,
"heis"
);
check_env_var
(
"testenv2"
,
"dyo"
);
check_env_var
(
"testenv3"
,
NULL
);
SetEnvironmentVariableA
(
"testenv1"
,
NULL
);
SetEnvironmentVariableA
(
"testenv2"
,
NULL
);
}
START_TEST
(
env
)
{
HMODULE
mod
=
GetModuleHandleA
(
"ntdll.dll"
);
...
...
@@ -535,4 +601,5 @@ START_TEST(env)
testSet
();
testExpand
();
test_process_params
();
test_RtlSetCurrentEnvironment
();
}
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