Author: pschweitzer
Date: Thu Jun 8 20:16:34 2017
New Revision: 74967
URL:
http://svn.reactos.org/svn/reactos?rev=74967&view=rev
Log:
[KMTESTS:MM]
When testing noncached mapping, use MmAllocateNonCachedMemory() as suggested by Thomas to
avoid later potential failures
Modified:
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c
Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_mm/MmMapLock…
==============================================================================
--- trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c [iso-8859-1]
(original)
+++ trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c [iso-8859-1] Thu Jun
8 20:16:34 2017
@@ -18,6 +18,7 @@
static PVOID CurrentBuffer;
static PMDL CurrentMdl;
static PVOID CurrentUser;
+static SIZE_T NonCachedLength;
NTSTATUS
TestEntry(
@@ -86,7 +87,14 @@
_SEH2_END;
ok_eq_hex(SehStatus, STATUS_SUCCESS);
IoFreeMdl(CurrentMdl);
- ExFreePoolWithTag(CurrentBuffer, 'MLPC');
+ if (NonCachedLength)
+ {
+ MmFreeNonCachedMemory(CurrentBuffer, NonCachedLength);
+ }
+ else
+ {
+ ExFreePoolWithTag(CurrentBuffer, 'MLPC');
+ }
CurrentMdl = NULL;
}
@@ -128,8 +136,22 @@
if (!skip(Length > 0, "Null size!\n"))
{
- CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length,
'MLPC');
- ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n");
+ if (QueryBuffer->Cached)
+ {
+ CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length,
'MLPC');
+ ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n");
+ NonCachedLength = 0;
+ }
+ else
+ {
+ CurrentBuffer = MmAllocateNonCachedMemory(Length);
+ ok(CurrentBuffer != NULL, "MmAllocateNonCachedMemory
failed!\n");
+ if (CurrentBuffer)
+ {
+ RtlZeroMemory(CurrentBuffer, Length);
+ NonCachedLength = Length;
+ }
+ }
if (!skip(CurrentBuffer != NULL, "ExAllocatePool
failed!\n"))
{
CurrentMdl = IoAllocateMdl(CurrentBuffer, Length, FALSE, FALSE,
NULL);
@@ -163,17 +185,8 @@
SehStatus = _SEH2_GetExceptionCode();
}
_SEH2_END;
-
- if (QueryBuffer->Cached)
- {
- ok_eq_hex(SehStatus, STATUS_SUCCESS);
- ok(CurrentUser != NULL,
"MmMapLockedPagesSpecifyCache failed!\n");
- }
- else
- {
- ok_eq_hex(SehStatus, STATUS_INVALID_ADDRESS);
- ok_eq_pointer(CurrentUser, NULL);
- }
+ ok_eq_hex(SehStatus, STATUS_SUCCESS);
+ ok(CurrentUser != NULL, "MmMapLockedPagesSpecifyCache
failed!\n");
}
else
{
Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_mm/MmMapLock…
==============================================================================
--- trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c [iso-8859-1]
(original)
+++ trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c [iso-8859-1] Thu
Jun 8 20:16:34 2017
@@ -15,13 +15,35 @@
Var = (Length); \
}
+#define FILL_QUERY_BUFFER(QueryBuffer, BufferLength, UseCache) \
+{ \
+ QueryBuffer.Length = BufferLength; \
+ QueryBuffer.Buffer = NULL; \
+ QueryBuffer.Cached = UseCache; \
+}
+
+#define FILL_READ_BUFFER(QueryBuffer, ReadBuffer) \
+{ \
+ PULONG Buffer; \
+ ReadBuffer.Buffer = QueryBuffer.Buffer; \
+ if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n")) \
+ { \
+ ReadBuffer.Pattern = WRITE_PATTERN; \
+ ReadBuffer.Length = QueryBuffer.Length; \
+ Buffer = QueryBuffer.Buffer; \
+ for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i) \
+ { \
+ Buffer[i] = ReadBuffer.Pattern; \
+ } \
+ } \
+}
+
START_TEST(MmMapLockedPagesSpecifyCache)
{
QUERY_BUFFER QueryBuffer;
READ_BUFFER ReadBuffer;
DWORD Length;
USHORT i;
- PULONG Buffer;
USHORT BufferLength;
KmtLoadDriver(L"MmMapLockedPagesSpecifyCache", FALSE);
@@ -29,16 +51,104 @@
// Less than a page
SET_BUFFER_LENGTH(BufferLength, 2048);
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, FALSE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ // 1 page
+ SET_BUFFER_LENGTH(BufferLength, 4096);
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, FALSE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ // more than 1 page
+ SET_BUFFER_LENGTH(BufferLength, 4096 + 2048);
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, FALSE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ // 2 pages
+ SET_BUFFER_LENGTH(BufferLength, 2 * 4096);
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, FALSE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ Length = sizeof(QUERY_BUFFER);
+ FILL_QUERY_BUFFER(QueryBuffer, BufferLength, TRUE);
+ ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+ ok_eq_int(QueryBuffer.Length, BufferLength);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
+
+ Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
+ ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
+
+ // more than 2 pages
+ SET_BUFFER_LENGTH(BufferLength, 2 * 4096 + 2048);
QueryBuffer.Length = BufferLength;
QueryBuffer.Buffer = NULL;
QueryBuffer.Cached = FALSE;
Length = sizeof(QUERY_BUFFER);
ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
ok_eq_int(QueryBuffer.Length, BufferLength);
- ok_eq_pointer(QueryBuffer.Buffer, NULL);
+ ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
- ReadBuffer.Buffer = QueryBuffer.Buffer;
Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
QueryBuffer.Length = BufferLength;
@@ -49,167 +159,8 @@
ok_eq_int(QueryBuffer.Length, BufferLength);
ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = WRITE_PATTERN;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i)
- {
- Buffer[i] = ReadBuffer.Pattern;
- }
- }
-
Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- // 1 page
- SET_BUFFER_LENGTH(BufferLength, 4096);
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = FALSE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok_eq_pointer(QueryBuffer.Buffer, NULL);
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = TRUE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = WRITE_PATTERN;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i)
- {
- Buffer[i] = ReadBuffer.Pattern;
- }
- }
-
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- // more than 1 page
- SET_BUFFER_LENGTH(BufferLength, 4096 + 2048);
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = FALSE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok_eq_pointer(QueryBuffer.Buffer, NULL);
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = TRUE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = WRITE_PATTERN;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i)
- {
- Buffer[i] = ReadBuffer.Pattern;
- }
- }
-
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- // 2 pages
- SET_BUFFER_LENGTH(BufferLength, 2 * 4096);
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = FALSE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok_eq_pointer(QueryBuffer.Buffer, NULL);
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = TRUE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = WRITE_PATTERN;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i)
- {
- Buffer[i] = ReadBuffer.Pattern;
- }
- }
-
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- // more than 2 pages
- SET_BUFFER_LENGTH(BufferLength, 2 * 4096 + 2048);
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = FALSE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok_eq_pointer(QueryBuffer.Buffer, NULL);
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- Length = 0;
- ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
-
- QueryBuffer.Length = BufferLength;
- QueryBuffer.Buffer = NULL;
- QueryBuffer.Cached = TRUE;
- Length = sizeof(QUERY_BUFFER);
- ok(KmtSendBufferToDriver(IOCTL_QUERY_BUFFER, &QueryBuffer, sizeof(QUERY_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
- ok_eq_int(QueryBuffer.Length, BufferLength);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = WRITE_PATTERN;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(ULONG); ++i)
- {
- Buffer[i] = ReadBuffer.Pattern;
- }
- }
-
- Length = 0;
+ FILL_READ_BUFFER(QueryBuffer, ReadBuffer);
ok(KmtSendBufferToDriver(IOCTL_READ_BUFFER, &ReadBuffer, sizeof(READ_BUFFER),
&Length) == ERROR_SUCCESS, "\n");
KmtCloseDriver();