mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTDLL_APITEST] Add tests for alignment for NtWriteFile
This mimics the usage of WriteFile which is done in rosautotest. CORE-15973
This commit is contained in:
parent
9d00413754
commit
64b6327dd7
1 changed files with 84 additions and 0 deletions
|
@ -211,4 +211,88 @@ START_TEST(NtWriteFile)
|
|||
&BufferSize,
|
||||
MEM_RELEASE);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
/* Now, testing aligned/non aligned writes */
|
||||
BufferSize = 4096; /* We assume max sector size */
|
||||
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
||||
&Buffer,
|
||||
0,
|
||||
&BufferSize,
|
||||
MEM_RESERVE | MEM_COMMIT,
|
||||
PAGE_READONLY);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
skip("Failed to allocate memory, status %lx\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = NtCreateFile(&FileHandle,
|
||||
FILE_WRITE_DATA | DELETE | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
&IoStatus,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
FILE_SUPERSEDE,
|
||||
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT |
|
||||
FILE_NO_INTERMEDIATE_BUFFERING |
|
||||
FILE_WRITE_THROUGH,
|
||||
NULL,
|
||||
0);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
/* non-cached, broken length -- fails with invalid parameter */
|
||||
ByteOffset.QuadPart = 0;
|
||||
Status = NtWriteFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
4,
|
||||
&ByteOffset,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INVALID_PARAMETER);
|
||||
|
||||
/* non-cached, broken offset -- fails with invalid parameter */
|
||||
ByteOffset.QuadPart = 4;
|
||||
Status = NtWriteFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
BufferSize,
|
||||
&ByteOffset,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_INVALID_PARAMETER);
|
||||
|
||||
/* non-cached, good length and offset -- succeeds */
|
||||
ByteOffset.QuadPart = 0;
|
||||
Status = NtWriteFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
BufferSize,
|
||||
&ByteOffset,
|
||||
NULL);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
DispositionInfo.DeleteFile = TRUE;
|
||||
Status = NtSetInformationFile(FileHandle,
|
||||
&IoStatus,
|
||||
&DispositionInfo,
|
||||
sizeof(DispositionInfo),
|
||||
FileDispositionInformation);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
Status = NtClose(FileHandle);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||
&Buffer,
|
||||
&BufferSize,
|
||||
MEM_RELEASE);
|
||||
ok_hex(Status, STATUS_SUCCESS);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue