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
8b50afed
Commit
8b50afed
authored
Nov 10, 2023
by
Eric Pouech
Committed by
Alexandre Julliard
Nov 10, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt/tests: Add tests about allocation of environment entries.
Signed-off-by:
Eric Pouech
<
epouech@codeweavers.com
>
parent
b6d4be61
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
environ.c
dlls/msvcrt/tests/environ.c
+44
-0
No files found.
dlls/msvcrt/tests/environ.c
View file @
8b50afed
...
...
@@ -83,6 +83,15 @@ static void test_system(void)
ok
(
ret
==
0
,
"Expected system to return 0, got %d
\n
"
,
ret
);
}
static
unsigned
env_get_entry_countA
(
char
**
env
)
{
unsigned
count
;
if
(
!
env
)
return
0
;
for
(
count
=
0
;
env
[
count
]
!=
NULL
;
count
++
)
{}
return
count
;
}
static
wchar_t
*
env_get_valueW
(
wchar_t
**
envp
,
const
wchar_t
*
var
)
{
unsigned
i
;
...
...
@@ -255,6 +264,9 @@ static void test_environment_manipulation(void)
char
buf
[
256
];
errno_t
ret
;
size_t
len
;
unsigned
count
;
char
*
first
;
char
*
second
;
ok
(
_putenv
(
"cat="
)
==
0
,
"_putenv failed on deletion of nonexistent environment variable
\n
"
);
ok
(
_putenv
(
"cat=dog"
)
==
0
,
"failed setting cat=dog
\n
"
);
...
...
@@ -322,6 +334,38 @@ static void test_environment_manipulation(void)
ok
(
!
buf
[
0
],
"buf = %s
\n
"
,
buf
);
ok
(
errno
==
0xdeadbeef
,
"errno = %d
\n
"
,
errno
);
}
/* test stability of _environ[] pointers */
ok
(
_putenv
(
"__winetest_cat="
)
==
0
,
"Couldn't reset env var
\n
"
);
ok
(
_putenv
(
"__winetest_dog="
)
==
0
,
"Couldn't reset env var
\n
"
);
count
=
env_get_entry_countA
(
*
p_environ
);
ok
(
_putenv
(
"__winetest_cat=mew"
)
==
0
,
"Couldn't set env var
\n
"
);
ok
(
!
strcmp
(
(
*
p_environ
)[
count
],
"__winetest_cat=mew"
),
"Unexpected env var value
\n
"
);
first
=
(
*
p_environ
)[
count
];
ok
(
getenv
(
"__winetest_cat"
)
==
strchr
(
(
*
p_environ
)[
count
],
'='
)
+
1
,
"Expected getenv() to return pointer inside _environ[] entry
\n
"
);
ok
(
_putenv
(
"__winetest_dog=bark"
)
==
0
,
"Couldn't set env var
\n
"
);
ok
(
!
strcmp
(
(
*
p_environ
)[
count
+
1
],
"__winetest_dog=bark"
),
"Unexpected env var value
\n
"
);
ok
(
getenv
(
"__winetest_dog"
)
==
strchr
(
(
*
p_environ
)[
count
+
1
],
'='
)
+
1
,
"Expected getenv() to return pointer inside _environ[] entry
\n
"
);
todo_wine
ok
(
first
==
(
*
p_environ
)[
count
],
"Expected stability of _environ[count] pointer
\n
"
);
second
=
(
*
p_environ
)[
count
+
1
];
ok
(
count
+
2
==
env_get_entry_countA
(
*
p_environ
),
"Unexpected count
\n
"
);
ok
(
_putenv
(
"__winetest_cat=purr"
)
==
0
,
"Couldn't set env var
\n
"
);
ok
(
!
strcmp
(
(
*
p_environ
)[
count
],
"__winetest_cat=purr"
),
"Unexpected env var value
\n
"
);
ok
(
getenv
(
"__winetest_cat"
)
==
strchr
(
(
*
p_environ
)[
count
],
'='
)
+
1
,
"Expected getenv() to return pointer inside _environ[] entry
\n
"
);
todo_wine
ok
(
second
==
(
*
p_environ
)[
count
+
1
],
"Expected stability of _environ[count] pointer
\n
"
);
ok
(
!
strcmp
(
(
*
p_environ
)[
count
+
1
],
"__winetest_dog=bark"
),
"Couldn't get env var value
\n
"
);
ok
(
getenv
(
"__winetest_dog"
)
==
strchr
(
(
*
p_environ
)[
count
+
1
],
'='
)
+
1
,
"Expected getenv() to return pointer inside _environ[] entry
\n
"
);
ok
(
count
+
2
==
env_get_entry_countA
(
*
p_environ
),
"Unexpected count
\n
"
);
ok
(
_putenv
(
"__winetest_cat="
)
==
0
,
"Couldn't reset env vat
\n
"
);
todo_wine
ok
(
second
==
(
*
p_environ
)[
count
],
"Expected _environ[count] to be second
\n
"
);
ok
(
!
strcmp
(
(
*
p_environ
)[
count
],
"__winetest_dog=bark"
),
"Unexpected env var value
\n
"
);
ok
(
count
+
1
==
env_get_entry_countA
(
*
p_environ
),
"Unexpected count
\n
"
);
ok
(
_putenv
(
"__winetest_dog="
)
==
0
,
"Couldn't reset env var
\n
"
);
ok
(
count
==
env_get_entry_countA
(
*
p_environ
),
"Unexpected count
\n
"
);
}
START_TEST
(
environ
)
...
...
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