mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:53:09 +00:00
[KMTESTS:CC] Add tests for CcCopyRead that reproduce CORE-15067
CORE-15067
This commit is contained in:
parent
15a3ca08b0
commit
351ae6b2b4
2 changed files with 29 additions and 2 deletions
|
@ -15,6 +15,7 @@ typedef struct _TEST_FCB
|
|||
FSRTL_ADVANCED_FCB_HEADER Header;
|
||||
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
||||
FAST_MUTEX HeaderMutex;
|
||||
BOOLEAN BigFile;
|
||||
} TEST_FCB, *PTEST_FCB;
|
||||
|
||||
static PFILE_OBJECT TestFileObject;
|
||||
|
@ -184,6 +185,7 @@ TestIrpHandler(
|
|||
RtlZeroMemory(Fcb, sizeof(*Fcb));
|
||||
ExInitializeFastMutex(&Fcb->HeaderMutex);
|
||||
FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
|
||||
Fcb->BigFile = FALSE;
|
||||
if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
|
||||
IoStack->FileObject->FileName.Buffer[1] == 'B')
|
||||
{
|
||||
|
@ -205,6 +207,14 @@ TestIrpHandler(
|
|||
Fcb->Header.FileSize.QuadPart = 62;
|
||||
Fcb->Header.ValidDataLength.QuadPart = 62;
|
||||
}
|
||||
else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
|
||||
IoStack->FileObject->FileName.Buffer[1] == 'F')
|
||||
{
|
||||
Fcb->Header.AllocationSize.QuadPart = 4294967296;
|
||||
Fcb->Header.FileSize.QuadPart = 4294967296;
|
||||
Fcb->Header.ValidDataLength.QuadPart = 4294967296;
|
||||
Fcb->BigFile = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Fcb->Header.AllocationSize.QuadPart = 512;
|
||||
|
@ -239,8 +249,13 @@ TestIrpHandler(
|
|||
if (!FlagOn(Irp->Flags, IRP_NOCACHE))
|
||||
{
|
||||
ok_irql(PASSIVE_LEVEL);
|
||||
ok(Offset.QuadPart % PAGE_SIZE != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
|
||||
ok(Length % PAGE_SIZE != 0, "Length is aligned: %I64i\n", Length);
|
||||
|
||||
/* We don't want to test alignement for big files (not the purpose of the test) */
|
||||
if (!Fcb->BigFile)
|
||||
{
|
||||
ok(Offset.QuadPart % PAGE_SIZE != 0, "Offset is aligned: %I64i\n", Offset.QuadPart);
|
||||
ok(Length % PAGE_SIZE != 0, "Length is aligned: %I64i\n", Length);
|
||||
}
|
||||
|
||||
Buffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
ok(Buffer != NULL, "Null pointer!\n");
|
||||
|
|
|
@ -18,6 +18,7 @@ START_TEST(CcCopyRead)
|
|||
UNICODE_STRING BigAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\BigAlignmentTest");
|
||||
UNICODE_STRING SmallAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\SmallAlignmentTest");
|
||||
UNICODE_STRING ReallySmallAlignmentTest = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\ReallySmallAlignmentTest");
|
||||
UNICODE_STRING FileBig = RTL_CONSTANT_STRING(L"\\Device\\Kmtest-CcCopyRead\\FileBig");
|
||||
|
||||
KmtLoadDriver(L"CcCopyRead", FALSE);
|
||||
KmtOpenDriver();
|
||||
|
@ -89,6 +90,17 @@ START_TEST(CcCopyRead)
|
|||
|
||||
NtClose(Handle);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes, &FileBig, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
Status = NtOpenFile(&Handle, FILE_ALL_ACCESS, &ObjectAttributes, &IoStatusBlock, 0, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
|
||||
ByteOffset.QuadPart = 0;
|
||||
Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 1024, &ByteOffset, NULL);
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
|
||||
|
||||
NtClose(Handle);
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||
KmtCloseDriver();
|
||||
KmtUnloadDriver();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue