From f82cad712a3626a7f635d069f4b464d447d4541c Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sat, 26 Nov 2016 20:50:35 -0800 Subject: [PATCH] tst: fsbench: rdwr test --- tst/fsbench/fsbench.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tst/fsbench/fsbench.c b/tst/fsbench/fsbench.c index 02ae480b..84dea4b0 100644 --- a/tst/fsbench/fsbench.c +++ b/tst/fsbench/fsbench.c @@ -19,9 +19,9 @@ #include #include -ULONG OptFileCount = 1000; -ULONG OptListCount = 100; -ULONG OptRdwrCount = 10000; +static ULONG OptFileCount = 1000; +static ULONG OptListCount = 100; +static ULONG OptRdwrCount = 100; static void file_create_dotest(ULONG CreateDisposition) { @@ -130,6 +130,8 @@ static void rdwr_dotest(ULONG CreateDisposition, ULONG CreateFlags) BOOL Success; DWORD BytesTransferred; WCHAR FileName[MAX_PATH]; + ULONG Iterations = 1000; + GetSystemInfo(&SystemInfo); Buffer = _aligned_malloc(SystemInfo.dwPageSize, SystemInfo.dwPageSize); @@ -145,14 +147,26 @@ static void rdwr_dotest(ULONG CreateDisposition, ULONG CreateFlags) 0); ASSERT(INVALID_HANDLE_VALUE != Handle); + if (CREATE_NEW == CreateDisposition) + { + BytesTransferred = SetFilePointer(Handle, Iterations * SystemInfo.dwPageSize, 0, FILE_BEGIN); + ASSERT(Iterations * SystemInfo.dwPageSize == BytesTransferred); + SetEndOfFile(Handle); + } + for (ULONG Index = 0; OptRdwrCount > Index; Index++) { - if (CREATE_NEW == CreateDisposition) - Success = WriteFile(Handle, Buffer, SystemInfo.dwPageSize, &BytesTransferred, 0); - else - Success = ReadFile(Handle, Buffer, SystemInfo.dwPageSize, &BytesTransferred, 0); - ASSERT(Success); - ASSERT(SystemInfo.dwPageSize == BytesTransferred); + BytesTransferred = SetFilePointer(Handle, 0, 0, FILE_BEGIN); + ASSERT(0 == BytesTransferred); + for (ULONG I = 0; Iterations > I; I++) + { + if (CREATE_NEW == CreateDisposition) + Success = WriteFile(Handle, Buffer, SystemInfo.dwPageSize, &BytesTransferred, 0); + else + Success = ReadFile(Handle, Buffer, SystemInfo.dwPageSize, &BytesTransferred, 0); + ASSERT(Success); + ASSERT(SystemInfo.dwPageSize == BytesTransferred); + } } Success = CloseHandle(Handle);