mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[CRT_APITEST]
Add another test for strlen, that tests, whether the direction flag in ELFAGS has been modified. While clearing it is legitimate to do according to the ABI, the native implementation does not change it, so we don't want to do it either. svn path=/trunk/; revision=70429
This commit is contained in:
parent
6a513178c3
commit
2866514570
1 changed files with 21 additions and 0 deletions
|
@ -23,12 +23,18 @@ GCC_builtin_strlen(const char *str)
|
|||
}
|
||||
#endif
|
||||
|
||||
#define EFLAGS_DF 0x400L
|
||||
|
||||
typedef size_t (*PFN_STRLEN)(const char *);
|
||||
|
||||
void
|
||||
Test_strlen(PFN_STRLEN pstrlen)
|
||||
{
|
||||
size_t len;
|
||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||
volatile uintptr_t eflags;
|
||||
char *teststr = "a\0bcdefghijk";
|
||||
#endif
|
||||
|
||||
/* basic parameter tests */
|
||||
StartSeh()
|
||||
|
@ -37,6 +43,21 @@ Test_strlen(PFN_STRLEN pstrlen)
|
|||
(void)len;
|
||||
|
||||
ok_int((int)pstrlen("test"), 4);
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64)
|
||||
eflags = __readeflags();
|
||||
__writeeflags(eflags | EFLAGS_DF);
|
||||
len = pstrlen(teststr + 4);
|
||||
eflags = __readeflags();
|
||||
ok((eflags & EFLAGS_DF) != 0, "Direction flag in ELFAGS was changed.");
|
||||
|
||||
/* Only test this for the exported versions, intrinsics might do it
|
||||
differently. It's up to us to not do fishy stuff! */
|
||||
if (pstrlen == strlen)
|
||||
{
|
||||
ok(len == 8, "Should not have gone backwards (got len %i)", (int)len);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
START_TEST(strlen)
|
||||
|
|
Loading…
Reference in a new issue