Skip to content

Commit 2b1e733

Browse files
committed
[CRT_APITEST] Fix strlen test on x86
The code called winetest_setlocation, which calls strrchr, which clears the direction flag, so the test was succeeding on x86, even though strlen never changes it. On Windows it somehow depends on whether you compile the test on the command line or inside VS. This change fixes the test by explicitly reading eflags before using winetest_ok and placing a MemoryBarrier in between.
1 parent 30ef8f3 commit 2b1e733

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

modules/rostests/apitests/crt/strlen.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Test_strlen(PFN_STRLEN pstrlen)
3232
{
3333
size_t len;
3434
#if defined(_M_IX86) || defined(_M_AMD64)
35-
volatile uintptr_t eflags;
35+
volatile uintptr_t eflags, eflags2;
3636
char *teststr = "a\0bcdefghijk";
3737
#endif
3838

@@ -48,12 +48,9 @@ Test_strlen(PFN_STRLEN pstrlen)
4848
eflags = __readeflags();
4949
__writeeflags(eflags | EFLAGS_DF);
5050
len = pstrlen(teststr + 4);
51-
52-
#ifdef _M_AMD64
53-
ok((__readeflags() & EFLAGS_DF) != 0, "Direction flag in ELFAGS was changed.\n");
54-
#else
55-
ok((__readeflags() & EFLAGS_DF) == 0, "Direction flag in ELFAGS was not changed.\n");
56-
#endif
51+
eflags2 = __readeflags();
52+
MemoryBarrier();
53+
ok((eflags2 & EFLAGS_DF) != 0, "Direction flag in ELFAGS was changed: 0x%Ix -> 0x%Ix.\n", eflags | EFLAGS_DF, eflags2);
5754
__writeeflags(eflags);
5855

5956
/* Only test this for the exported versions, intrinsics might do it

0 commit comments

Comments
 (0)