[KMTESTS:CC]
authorPierre Schweitzer <pierre@reactos.org>
Wed, 10 Aug 2016 07:39:20 +0000 (07:39 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 10 Aug 2016 07:39:20 +0000 (07:39 +0000)
New test case which is matching the MS FastFAT CcCopyRead (minus the offset) and shows clearly the issue in our Cc.
It also shows that my hack is utterly broken :-).

CORE-11003
CORE-11819

svn path=/trunk/; revision=72182

rostests/kmtests/ntos_cc/CcCopyRead_drv.c
rostests/kmtests/ntos_cc/CcCopyRead_user.c

index a94dfbf..98b4d87 100644 (file)
@@ -195,6 +195,13 @@ TestIrpHandler(
             Fcb->Header.FileSize.QuadPart = 1004;
             Fcb->Header.ValidDataLength.QuadPart = 1004;
         }
+        else if (IoStack->FileObject->FileName.Length >= 2 * sizeof(WCHAR) &&
+                 IoStack->FileObject->FileName.Buffer[1] == 'R')
+        {
+            Fcb->Header.AllocationSize.QuadPart = 62;
+            Fcb->Header.FileSize.QuadPart = 62;
+            Fcb->Header.ValidDataLength.QuadPart = 62;
+        }
         else
         {
             Fcb->Header.AllocationSize.QuadPart = 512;
@@ -262,7 +269,7 @@ TestIrpHandler(
         }
         else
         {
-            ok(Offset.QuadPart % PAGE_SIZE == 0, "Offset is not aligned: %I64i\n", Offset.QuadPart);
+            ok((Offset.QuadPart % PAGE_SIZE == 0 || Offset.QuadPart == 0), "Offset is not aligned: %I64i\n", Offset.QuadPart);
             ok(Length % PAGE_SIZE == 0, "Length is not aligned: %I64i\n", Length);
 
             ok(Irp->AssociatedIrp.SystemBuffer == NULL, "A SystemBuffer was allocated!\n");
index fbcbae5..1dbc08a 100644 (file)
@@ -17,6 +17,7 @@ START_TEST(CcCopyRead)
     PVOID Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, 1024);
     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");
     
     KmtLoadDriver(L"CcCopyRead", FALSE);
     KmtOpenDriver();
@@ -77,6 +78,17 @@ START_TEST(CcCopyRead)
 
     NtClose(Handle);
 
+    InitializeObjectAttributes(&ObjectAttributes, &ReallySmallAlignmentTest, 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 = 1;
+    Status = NtReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Buffer, 61, &ByteOffset, NULL);
+    ok_eq_hex(Status, STATUS_SUCCESS);
+    ok_eq_hex(((USHORT *)Buffer)[0], 0xBABA);
+
+    NtClose(Handle);
+
     RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
     KmtCloseDriver();
     KmtUnloadDriver();