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
9a4b596e
Commit
9a4b596e
authored
Apr 10, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt/tests: Add some function pointers to bypass gcc builtin functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
2e01a484
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
heap.c
dlls/msvcrt/tests/heap.c
+8
-4
scanf.c
dlls/msvcrt/tests/scanf.c
+0
-0
string.c
dlls/msvcrt/tests/string.c
+8
-4
No files found.
dlls/msvcrt/tests/heap.c
View file @
9a4b596e
...
...
@@ -458,22 +458,26 @@ static void test_sbheap(void)
static
void
test_calloc
(
void
)
{
/* use function pointer to bypass gcc builtin */
void
*
(
__cdecl
*
p_calloc
)(
size_t
,
size_t
);
void
*
ptr
;
ptr
=
calloc
(
1
,
0
);
p_calloc
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"msvcrt.dll"
),
"calloc"
);
ptr
=
p_calloc
(
1
,
0
);
ok
(
ptr
!=
NULL
,
"got %p
\n
"
,
ptr
);
free
(
ptr
);
ptr
=
calloc
(
0
,
0
);
ptr
=
p_
calloc
(
0
,
0
);
ok
(
ptr
!=
NULL
,
"got %p
\n
"
,
ptr
);
free
(
ptr
);
ptr
=
calloc
(
0
,
1
);
ptr
=
p_
calloc
(
0
,
1
);
ok
(
ptr
!=
NULL
,
"got %p
\n
"
,
ptr
);
free
(
ptr
);
errno
=
0
;
ptr
=
calloc
(
~
(
size_t
)
0
/
2
,
~
(
size_t
)
0
/
2
);
ptr
=
p_
calloc
(
~
(
size_t
)
0
/
2
,
~
(
size_t
)
0
/
2
);
ok
(
ptr
==
NULL
||
broken
(
ptr
!=
NULL
)
/* winxp sp0 */
,
"got %p
\n
"
,
ptr
);
ok
(
errno
==
ENOMEM
||
broken
(
errno
==
0
)
/* winxp, win2k3 */
,
"got errno %d
\n
"
,
errno
);
free
(
ptr
);
...
...
dlls/msvcrt/tests/scanf.c
View file @
9a4b596e
This diff is collapsed.
Click to expand it.
dlls/msvcrt/tests/string.c
View file @
9a4b596e
...
...
@@ -3098,29 +3098,33 @@ static void test_atof(void)
static
void
test_strncpy
(
void
)
{
#define TEST_STRNCPY_LEN 10
/* use function pointer to bypass gcc builtin */
char
*
(
__cdecl
*
p_strncpy
)(
char
*
,
const
char
*
,
size_t
);
char
*
ret
;
char
dst
[
TEST_STRNCPY_LEN
+
1
];
char
not_null_terminated
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'0'
};
p_strncpy
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"msvcrt.dll"
),
"strncpy"
);
/* strlen(src) > TEST_STRNCPY_LEN */
ret
=
strncpy
(
dst
,
"01234567890123456789"
,
TEST_STRNCPY_LEN
);
ret
=
p_
strncpy
(
dst
,
"01234567890123456789"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\n
"
);
/* without null-terminated */
ret
=
strncpy
(
dst
,
not_null_terminated
,
TEST_STRNCPY_LEN
);
ret
=
p_
strncpy
(
dst
,
not_null_terminated
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\n
"
);
/* strlen(src) < TEST_STRNCPY_LEN */
strcpy
(
dst
,
"0123456789"
);
ret
=
strncpy
(
dst
,
"012345"
,
TEST_STRNCPY_LEN
);
ret
=
p_
strncpy
(
dst
,
"012345"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strcmp
(
dst
,
"012345"
),
"dst != 012345
\n
"
);
ok
(
dst
[
TEST_STRNCPY_LEN
-
1
]
==
'\0'
,
"dst[TEST_STRNCPY_LEN - 1] != 0
\n
"
);
/* strlen(src) == TEST_STRNCPY_LEN */
ret
=
strncpy
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
);
ret
=
p_
strncpy
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
);
ok
(
ret
==
dst
,
"ret != dst
\n
"
);
ok
(
!
strncmp
(
dst
,
"0123456789"
,
TEST_STRNCPY_LEN
),
"dst != 0123456789
\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