Author: pschweitzer
Date: Sat Jun 3 10:29:39 2017
New Revision: 74759
URL:
http://svn.reactos.org/svn/reactos?rev=74759&view=rev
Log:
[KMTESTS:MM]
Test various sizes with MmMapLockedPagesSpecifyCache() to show that behavior is strictly
identical.
This was designed/tested under W2K3.
CORE-8204
Modified:
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache.h
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c
trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_user.c
Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_mm/MmMapLock…
==============================================================================
--- trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache.h [iso-8859-1] (original)
+++ trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache.h [iso-8859-1] Sat Jun 3
10:29:39 2017
@@ -20,10 +20,12 @@
{
USHORT Length;
PVOID Buffer;
- USHORT Pattern;
+ ULONG Pattern;
} READ_BUFFER, *PREAD_BUFFER;
#define IOCTL_QUERY_BUFFER 1
#define IOCTL_READ_BUFFER 2
+#define WRITE_PATTERN 0xA4A5A6A7
+
#endif /* !defined _KMTEST_MMMAPLOCKEDPAGESSPECIFYCACHE_H_ */
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] Sat Jun
3 10:29:39 2017
@@ -122,7 +122,7 @@
Length = QueryBuffer->Length;
ok(Length > 0, "Null size!\n");
- CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length + 0x8,
'MLPC');
+ CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length,
'MLPC');
ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n");
CurrentUser = NULL;
if (!skip(CurrentBuffer != NULL, "ExAllocatePool failed!\n"))
@@ -195,14 +195,15 @@
if (ReadBuffer->Buffer != NULL)
{
USHORT i;
- PUSHORT KBuffer = MmGetSystemAddressForMdlSafe(CurrentMdl,
NormalPagePriority);
+ PULONG KBuffer = MmGetSystemAddressForMdlSafe(CurrentMdl,
NormalPagePriority);
ok(KBuffer != NULL, "Failed to get kmode ptr\n");
+ ok(ReadBuffer->Length % sizeof(ULONG) == 0, "Invalid
size: %d\n", ReadBuffer->Length);
if (!skip(Buffer != NULL, "Failed to get kmode
ptr\n"))
{
- for (i = 0; i < ReadBuffer->Length / sizeof(USHORT);
++i)
+ for (i = 0; i < ReadBuffer->Length / sizeof(ULONG);
++i)
{
- ok_eq_ulong((ULONG)KBuffer[i],
(ULONG)ReadBuffer->Pattern);
+ ok_eq_ulong(KBuffer[i], ReadBuffer->Pattern);
}
}
}
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] Sat
Jun 3 10:29:39 2017
@@ -9,44 +9,201 @@
#include "MmMapLockedPagesSpecifyCache.h"
+#define SET_BUFFER_LENGTH(Var, Length) \
+{ \
+ C_ASSERT(((Length) % sizeof(ULONG)) == 0); \
+ Var = (Length); \
+}
+
START_TEST(MmMapLockedPagesSpecifyCache)
{
QUERY_BUFFER QueryBuffer;
READ_BUFFER ReadBuffer;
DWORD Length;
USHORT i;
- PUSHORT Buffer;
+ PULONG Buffer;
+ USHORT BufferLength;
KmtLoadDriver(L"MmMapLockedPagesSpecifyCache", FALSE);
KmtOpenDriver();
- QueryBuffer.Length = 0x100;
- 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, 0x100);
- 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 = 0x100;
- 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, 0x100);
- ok(QueryBuffer.Buffer != NULL, "Buffer is NULL\n");
-
- ReadBuffer.Buffer = QueryBuffer.Buffer;
- if (!skip(QueryBuffer.Buffer != NULL, "Buffer is NULL\n"))
- {
- ReadBuffer.Pattern = 0xA7;
- ReadBuffer.Length = QueryBuffer.Length;
- Buffer = QueryBuffer.Buffer;
- for (i = 0; i < ReadBuffer.Length / sizeof(USHORT); ++i)
+ // Less than a page
+ SET_BUFFER_LENGTH(BufferLength, 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");
+
+ // 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;
}