[KMTESTS:CC] Add a test for pinning without access
authorPierre Schweitzer <pierre@reactos.org>
Sat, 1 Sep 2018 10:40:24 +0000 (12:40 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 1 Sep 2018 10:41:02 +0000 (12:41 +0200)
modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
modules/rostests/kmtests/ntos_cc/CcPinRead_user.c

index 34ceb13..9b1d214 100644 (file)
@@ -217,6 +217,8 @@ PerformTest(
         Fcb = ExAllocatePool(NonPagedPool, sizeof(TEST_FCB));
         if (!skip(Fcb != NULL, "ExAllocatePool failed\n"))
         {
+            BOOLEAN PinAccess = (TestId != 4);
+
             RtlZeroMemory(Fcb, sizeof(TEST_FCB));
             ExInitializeFastMutex(&Fcb->HeaderMutex);
             FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
@@ -225,7 +227,7 @@ PerformTest(
             TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
 
             KmtStartSeh();
-            CcInitializeCacheMap(TestFileObject, &FileSizes, TRUE, &Callbacks, NULL);
+            CcInitializeCacheMap(TestFileObject, &FileSizes, PinAccess, &Callbacks, NULL);
             KmtEndSeh(STATUS_SUCCESS);
 
             if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap failed\n"))
@@ -300,6 +302,21 @@ PerformTest(
                         ExFreePool(TestContext);
                     }
                 }
+                else if (TestId == 4)
+                {
+                    Ret = FALSE;
+                    Offset.QuadPart = 0x1000;
+                    KmtStartSeh();
+                    Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &Bcb, (PVOID *)&Buffer);
+                    KmtEndSeh(STATUS_SUCCESS);
+
+                    if (!skip(Ret == TRUE, "CcPinRead failed\n"))
+                    {
+                        ok_eq_ulong(Buffer[0x2000 / sizeof(ULONG)], 0);
+
+                        CcUnpinData(Bcb);
+                    }
+                }
             }
         }
     }
index c7a93a5..7881816 100644 (file)
@@ -20,8 +20,9 @@ START_TEST(CcPinRead)
 
     /* 3 tests for offset
      * 1 test for BCB
+     * 1 test for pinning access
      */
-    for (TestId = 0; TestId < 4; ++TestId)
+    for (TestId = 0; TestId < 5; ++TestId)
     {
         Ret = KmtSendUlongToDriver(IOCTL_START_TEST, TestId);
         ok(Ret == ERROR_SUCCESS, "KmtSendUlongToDriver failed: %lx\n", Ret);