Test that adding "S" to the fopen mode results in the underlying file handle having the sequential access hint set.
Signed-off-by: Luke Deller luke@deller.id.au --- dlls/msvcrt/tests/file.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index fb242d81282..d02087be46c 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -35,6 +35,7 @@ #include <process.h> #include <errno.h> #include <locale.h> +#include <winternl.h>
#define MSVCRT_FD_BLOCK_SIZE 32 typedef struct { @@ -2731,6 +2732,39 @@ static void test_lseek(void) DeleteFileA("_creat.tst"); }
+static void test_fopen_hints(void) +{ + char *tempf; + FILE *fp; + HANDLE handle; + FILE_MODE_INFORMATION mode_info; + IO_STATUS_BLOCK io; + NTSTATUS status; + + /* create a test file */ + tempf = _tempnam(".","wne"); + fp = fopen(tempf, "wb"); + ok(fp != NULL, "unable to create test file\n"); + fwrite("abc\n", 1, 4, fp); + fclose(fp); + + /* open test file with sequential access hint */ + fp = fopen(tempf, "rbS"); + ok(fp != NULL, "unable to open test file with sequential access hint\n"); + + /* check that sequential access hint is set on underlying file handle */ + handle = (HANDLE)_get_osfhandle(_fileno(fp)); + status = NtQueryInformationFile(handle, &io, &mode_info, sizeof(mode_info), + FileModeInformation); + ok(!status, "NtQueryInformationFile failed\n"); + ok(mode_info.Mode & FILE_SEQUENTIAL_ONLY, "handle missing hint\n"); + + /* clean up */ + fclose(fp); + unlink(tempf); + free(tempf); +} + START_TEST(file) { int arg_c; @@ -2803,6 +2837,7 @@ START_TEST(file) test_close(); test__creat(); test_lseek(); + test_fopen_hints();
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report * file contains lines in the correct order