https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6937fa8f41d9ffc807e33…
commit 6937fa8f41d9ffc807e33ee64663b4d33cde7907
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Sep 1 12:20:17 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Sep 1 12:41:01 2018 +0200
[KMTESTS:CC] Duplicate tests for CcPinRead
To be extended.
---
modules/rostests/kmtests/CMakeLists.txt | 1 +
modules/rostests/kmtests/kmtest/testlist.c | 2 ++
modules/rostests/kmtests/ntos_cc/CMakeLists.txt | 15 ++++++++++
modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c | 35 +++++++++++++-----------
4 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/modules/rostests/kmtests/CMakeLists.txt
b/modules/rostests/kmtests/CMakeLists.txt
index 8c844534dd..51407959c4 100644
--- a/modules/rostests/kmtests/CMakeLists.txt
+++ b/modules/rostests/kmtests/CMakeLists.txt
@@ -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
diff --git a/modules/rostests/kmtests/kmtest/testlist.c
b/modules/rostests/kmtests/kmtest/testlist.c
index 99f500994f..7b4930f659 100644
--- a/modules/rostests/kmtests/kmtest/testlist.c
+++ b/modules/rostests/kmtests/kmtest/testlist.c
@@ -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 },
diff --git a/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
b/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
index f4e4fe01de..83d2317a75 100644
--- a/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
+++ b/modules/rostests/kmtests/ntos_cc/CMakeLists.txt
@@ -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)
diff --git a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
index 0d63e48572..b2aac2fdf7 100644
--- a/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
+++ b/modules/rostests/kmtests/ntos_cc/CcPinRead_drv.c
@@ -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;
}