[KMTESTS:CC] Duplicate tests for CcPinRead
authorPierre Schweitzer <pierre@reactos.org>
Sat, 1 Sep 2018 10:20:17 +0000 (12:20 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 1 Sep 2018 10:41:01 +0000 (12:41 +0200)
To be extended.

modules/rostests/kmtests/CMakeLists.txt
modules/rostests/kmtests/kmtest/testlist.c
modules/rostests/kmtests/ntos_cc/CMakeLists.txt
modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c

index 8c84453..5140795 100644 (file)
@@ -137,6 +137,7 @@ list(APPEND KMTEST_SOURCE
     kernel32/FindFile_user.c
     ntos_cc/CcCopyRead_user.c
     ntos_cc/CcMapData_user.c
+    ntos_cc/CcPinRead_user.c
     ntos_io/IoCreateFile_user.c
     ntos_io/IoDeviceObject_user.c
     ntos_io/IoReadWrite_user.c
index 99f5009..7b4930f 100644 (file)
@@ -8,6 +8,7 @@
 
 KMT_TESTFUNC Test_CcCopyRead;
 KMT_TESTFUNC Test_CcMapData;
+KMT_TESTFUNC Test_CcPinRead;
 KMT_TESTFUNC Test_Example;
 KMT_TESTFUNC Test_FileAttributes;
 KMT_TESTFUNC Test_FindFile;
@@ -37,6 +38,7 @@ const KMT_TEST TestList[] =
 {
     { "CcCopyRead",                   Test_CcCopyRead },
     { "CcMapData",                    Test_CcMapData },
+    { "CcPinRead",                    Test_CcPinRead },
     { "-Example",                     Test_Example },
     { "FileAttributes",               Test_FileAttributes },
     { "FindFile",                     Test_FindFile },
index f4e4fe0..83d2317 100644 (file)
@@ -30,3 +30,18 @@ add_importlibs(ccmapdata_drv ntoskrnl hal)
 add_target_compile_definitions(ccmapdata_drv KMT_STANDALONE_DRIVER)
 #add_pch(ccmapdata_drv ../include/kmt_test.h)
 add_rostests_file(TARGET ccmapdata_drv)
+
+#
+# CcPinRead
+#
+list(APPEND CCPINREAD_DRV_SOURCE
+    ../kmtest_drv/kmtest_standalone.c
+    CcPinRead_drv.c)
+
+add_library(ccpinread_drv SHARED ${CCPINREAD_DRV_SOURCE})
+set_module_type(ccpinread_drv kernelmodedriver)
+target_link_libraries(ccpinread_drv kmtest_printf ${PSEH_LIB})
+add_importlibs(ccpinread_drv ntoskrnl hal)
+add_target_compile_definitions(ccpinread_drv KMT_STANDALONE_DRIVER)
+#add_pch(ccmapdata_drv ../include/kmt_test.h)
+add_rostests_file(TARGET ccpinread_drv)
index 0d63e48..b2aac2f 100644 (file)
@@ -27,7 +27,6 @@ typedef struct _TEST_CONTEXT
     ULONG Length;
 } TEST_CONTEXT, *PTEST_CONTEXT;
 
-static BOOLEAN TestMap = FALSE;
 static ULONG TestTestId = -1;
 static PFILE_OBJECT TestFileObject;
 static PDEVICE_OBJECT TestDeviceObject;
@@ -47,7 +46,7 @@ TestEntry(
 
     UNREFERENCED_PARAMETER(RegistryPath);
 
-    *DeviceName = L"CcMapData";
+    *DeviceName = L"CcPinRead";
     *Flags = TESTENTRY_NO_EXCLUSIVE_DEVICE |
              TESTENTRY_BUFFERED_IO_DEVICE |
              TESTENTRY_NO_READONLY_DEVICE;
@@ -148,7 +147,7 @@ MapAndLockUserBuffer(
 static
 VOID
 NTAPI
-MapInAnotherThread(IN PVOID Context)
+PinInAnotherThread(IN PVOID Context)
 {
     BOOLEAN Ret;
     PULONG Buffer;
@@ -168,12 +167,10 @@ MapInAnotherThread(IN PVOID Context)
     Ret = FALSE;
     Offset.QuadPart = 0x1000;
     KmtStartSeh();
-    TestMap = TRUE;
-    Ret = CcMapData(TestFileObject, &Offset, TestContext->Length, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
-    TestMap = FALSE;
+    Ret = CcPinRead(TestFileObject, &Offset, TestContext->Length, PIN_WAIT, &Bcb, (PVOID *)&Buffer);
     KmtEndSeh(STATUS_SUCCESS);
 
-    if (!skip(Ret == TRUE, "CcMapData failed\n"))
+    if (!skip(Ret == TRUE, "CcPinRead failed\n"))
     {
         ok_eq_pointer(Bcb, TestContext->Bcb);
         ok_eq_pointer(Buffer, TestContext->Buffer);
@@ -216,7 +213,7 @@ PerformTest(
             TestFileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
 
             KmtStartSeh();
-            CcInitializeCacheMap(TestFileObject, &FileSizes, FALSE, &Callbacks, NULL);
+            CcInitializeCacheMap(TestFileObject, &FileSizes, TRUE, &Callbacks, NULL);
             KmtEndSeh(STATUS_SUCCESS);
 
             if (!skip(CcIsFileCached(TestFileObject) == TRUE, "CcInitializeCacheMap failed\n"))
@@ -226,10 +223,10 @@ PerformTest(
                     Ret = FALSE;
                     Offset.QuadPart = TestId * 0x1000;
                     KmtStartSeh();
-                    Ret = CcMapData(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, MAP_WAIT, &Bcb, (PVOID *)&Buffer);
+                    Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &Bcb, (PVOID *)&Buffer);
                     KmtEndSeh(STATUS_SUCCESS);
 
-                    if (!skip(Ret == TRUE, "CcMapData failed\n"))
+                    if (!skip(Ret == TRUE, "CcPinRead failed\n"))
                     {
                         ok_eq_ulong(Buffer[(0x3000 - TestId * 0x1000) / sizeof(ULONG)], 0xDEADBABE);
 
@@ -246,12 +243,10 @@ PerformTest(
                         Ret = FALSE;
                         Offset.QuadPart = 0x1000;
                         KmtStartSeh();
-                        TestMap = TRUE;
-                        Ret = CcMapData(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, MAP_WAIT, &TestContext->Bcb, &TestContext->Buffer);
-                        TestMap = FALSE;
+                        Ret = CcPinRead(TestFileObject, &Offset, FileSizes.FileSize.QuadPart - Offset.QuadPart, PIN_WAIT, &TestContext->Bcb, &TestContext->Buffer);
                         KmtEndSeh(STATUS_SUCCESS);
 
-                        if (!skip(Ret == TRUE, "CcMapData failed\n"))
+                        if (!skip(Ret == TRUE, "CcPinRead failed\n"))
                         {
                             PKTHREAD ThreadHandle;
 
@@ -269,11 +264,11 @@ PerformTest(
 #endif
 
                             TestContext->Length = FileSizes.FileSize.QuadPart - Offset.QuadPart;
-                            ThreadHandle = KmtStartThread(MapInAnotherThread, TestContext);
+                            ThreadHandle = KmtStartThread(PinInAnotherThread, TestContext);
                             KmtFinishThread(ThreadHandle, NULL);
 
                             TestContext->Length = FileSizes.FileSize.QuadPart - 2 * Offset.QuadPart;
-                            ThreadHandle = KmtStartThread(MapInAnotherThread, TestContext);
+                            ThreadHandle = KmtStartThread(PinInAnotherThread, TestContext);
                             KmtFinishThread(ThreadHandle, NULL);
 
                             CcUnpinData(TestContext->Bcb);
@@ -336,6 +331,8 @@ TestMessageHandler(
 {
     NTSTATUS Status = STATUS_SUCCESS;
 
+    FsRtlEnterFileSystem();
+
     switch (ControlCode)
     {
         case IOCTL_START_TEST:
@@ -353,6 +350,8 @@ TestMessageHandler(
             break;
     }
 
+    FsRtlExitFileSystem();
+
     return Status;
 }
 
@@ -370,6 +369,8 @@ TestIrpHandler(
     DPRINT("IRP %x/%x\n", IoStack->MajorFunction, IoStack->MinorFunction);
     ASSERT(IoStack->MajorFunction == IRP_MJ_READ);
 
+    FsRtlEnterFileSystem();
+
     Status = STATUS_NOT_SUPPORTED;
     Irp->IoStatus.Information = 0;
 
@@ -425,5 +426,7 @@ TestIrpHandler(
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
     }
 
+    FsRtlExitFileSystem();
+
     return Status;
 }