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
147be95a
Commit
147be95a
authored
Jun 14, 2014
by
Grazvydas Ignotas
Committed by
Alexandre Julliard
Jun 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt/tests: Add a test for fwrite flushing behavior.
parent
96142839
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
file.c
dlls/msvcrt/tests/file.c
+60
-0
No files found.
dlls/msvcrt/tests/file.c
View file @
147be95a
...
...
@@ -2219,6 +2219,65 @@ static void test__open_osfhandle(void)
CloseHandle
(
tmp
);
}
static
void
test_write_flush_size
(
FILE
*
file
,
size_t
bufsize
)
{
char
*
inbuffer
;
char
*
outbuffer
;
size_t
size
;
int
fd
;
fd
=
fileno
(
file
);
inbuffer
=
calloc
(
bufsize
+
1
,
1
);
outbuffer
=
calloc
(
bufsize
+
1
,
1
);
_snprintf
(
outbuffer
,
bufsize
+
1
,
"0,1,2,3,4,5,6,7,8,9"
);
for
(
size
=
bufsize
+
1
;
size
>=
bufsize
-
1
;
size
--
)
{
rewind
(
file
);
fwrite
(
outbuffer
,
1
,
size
,
file
);
/* lseek() below intentionally redirects the write in fflush() to detect
* if fwrite() has already flushed the whole buffer or not.
*/
lseek
(
fd
,
1
,
SEEK_SET
);
fflush
(
file
);
fseek
(
file
,
0
,
SEEK_SET
);
ok
(
fread
(
inbuffer
,
1
,
bufsize
,
file
)
==
bufsize
,
"read failed
\n
"
);
if
(
size
==
bufsize
)
todo_wine
ok
(
memcmp
(
outbuffer
,
inbuffer
,
bufsize
)
==
0
,
"missing flush by %d byte write
\n
"
,
size
);
else
ok
(
memcmp
(
outbuffer
,
inbuffer
,
bufsize
)
!=
0
,
"unexpected flush by %d byte write
\n
"
,
size
);
}
rewind
(
file
);
fwrite
(
outbuffer
,
1
,
bufsize
/
2
,
file
);
fwrite
(
outbuffer
+
bufsize
/
2
,
1
,
bufsize
/
2
,
file
);
lseek
(
fd
,
1
,
SEEK_SET
);
fflush
(
file
);
fseek
(
file
,
0
,
SEEK_SET
);
ok
(
fread
(
inbuffer
,
1
,
bufsize
,
file
)
==
bufsize
,
"read failed
\n
"
);
ok
(
memcmp
(
outbuffer
,
inbuffer
,
bufsize
)
!=
0
,
"unexpected flush by %d/2 byte double write
\n
"
,
bufsize
);
free
(
inbuffer
);
free
(
outbuffer
);
}
static
void
test_write_flush
(
void
)
{
char
iobuf
[
1024
];
char
*
tempf
;
FILE
*
file
;
tempf
=
_tempnam
(
"."
,
"wne"
);
file
=
fopen
(
tempf
,
"wb+"
);
ok
(
file
!=
NULL
,
"unable to create test file
\n
"
);
iobuf
[
0
]
=
0
;
fwrite
(
iobuf
,
1
,
1
,
file
);
/* needed for wine to init _bufsiz */
todo_wine
ok
(
file
->
_bufsiz
==
4096
,
"incorrect default buffer size: %d"
,
file
->
_bufsiz
);
test_write_flush_size
(
file
,
file
->
_bufsiz
);
setvbuf
(
file
,
iobuf
,
_IOFBF
,
sizeof
(
iobuf
));
test_write_flush_size
(
file
,
sizeof
(
iobuf
));
fclose
(
file
);
unlink
(
tempf
);
free
(
tempf
);
}
START_TEST
(
file
)
{
int
arg_c
;
...
...
@@ -2284,6 +2343,7 @@ START_TEST(file)
test_stdin
();
test_mktemp
();
test__open_osfhandle
();
test_write_flush
();
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
* file contains lines in the correct order
...
...
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