[KMTEST] Test what happens when CcSetFileSizes is called with data still mapped at the tail od the file

This commit is contained in:
Jérôme Gardou 2020-11-09 10:37:10 +01:00
parent 9e6866402b
commit 6929451500
2 changed files with 23 additions and 3 deletions

View file

@ -178,7 +178,7 @@ PerformTest(
Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; Fcb->Header.FileSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE;
Fcb->Header.ValidDataLength.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; Fcb->Header.ValidDataLength.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE;
if ((TestId > 1 && TestId < 4) || TestId == 5) if ((TestId > 1 && TestId < 4) || TestId >= 5)
{ {
Fcb->Header.AllocationSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE; Fcb->Header.AllocationSize.QuadPart = VACB_MAPPING_GRANULARITY - PAGE_SIZE;
} }
@ -315,6 +315,25 @@ PerformTest(
} }
} }
} }
else if (TestId == 6)
{
Offset.QuadPart = 0;
KmtStartSeh();
Ret = CcMapData(TestFileObject, &Offset, VACB_MAPPING_GRANULARITY - PAGE_SIZE, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
KmtEndSeh(STATUS_SUCCESS);
if (!skip(Ret == TRUE, "CcMapData failed\n"))
{
ok_eq_ulong(Buffer[(VACB_MAPPING_GRANULARITY - PAGE_SIZE - sizeof(ULONG)) / sizeof(ULONG)], 0xBABABABA);
}
KmtStartSeh();
CcSetFileSizes(TestFileObject, &NewFileSizes);
KmtEndSeh(STATUS_SUCCESS);
if (Ret == TRUE)
CcUnpinData(Bcb);
}
} }
} }
} }
@ -379,7 +398,7 @@ TestMessageHandler(
ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); ok_eq_ulong((ULONG)InLength, sizeof(ULONG));
PerformTest(*(PULONG)Buffer, DeviceObject); PerformTest(*(PULONG)Buffer, DeviceObject);
break; break;
case IOCTL_FINISH_TEST: case IOCTL_FINISH_TEST:
ok_eq_ulong((ULONG)InLength, sizeof(ULONG)); ok_eq_ulong((ULONG)InLength, sizeof(ULONG));
CleanupTest(*(PULONG)Buffer, DeviceObject); CleanupTest(*(PULONG)Buffer, DeviceObject);

View file

@ -24,8 +24,9 @@ START_TEST(CcSetFileSizes)
* 3: copy read - FS & AS * 3: copy read - FS & AS
* 4: dirty VACB - only FS * 4: dirty VACB - only FS
* 5: dirty VACB - FS & AS * 5: dirty VACB - FS & AS
* 6: CcSetFileSizes with mapped data at tail of file
*/ */
for (TestId = 0; TestId < 6; ++TestId) for (TestId = 0; TestId < 7; ++TestId)
{ {
Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId); Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret); ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);