Update memory regression test and split MDL tests into new file series
authorJason Filby <jason.filby@gmail.com>
Tue, 13 Apr 2004 20:30:58 +0000 (20:30 +0000)
committerJason Filby <jason.filby@gmail.com>
Tue, 13 Apr 2004 20:30:58 +0000 (20:30 +0000)
svn path=/trunk/; revision=9128

reactos/regtests/kmregtests/Makefile
reactos/regtests/kmregtests/tests/mdl-1.c [new file with mode: 0644]
reactos/regtests/kmregtests/tests/mm-1.c

index 17a1a7f..48bfe0c 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.3 2003/12/07 11:34:41 chorns Exp $
+# $Id: Makefile,v 1.4 2004/04/13 20:29:29 jfilby Exp $
 
 PATH_TO_TOP = ../..
 
@@ -11,6 +11,7 @@ TARGET_NAME = kmregtests
 TARGET_LIBS = $(SDK_PATH_LIB)/rtshared.a
 
 TARGET_CFLAGS = -I../shared -Werror -Wall
+TARGET_CFLAGS += -D__USE_W32API
 
 include Makefile.tests
 
diff --git a/reactos/regtests/kmregtests/tests/mdl-1.c b/reactos/regtests/kmregtests/tests/mdl-1.c
new file mode 100644 (file)
index 0000000..94f6d65
--- /dev/null
@@ -0,0 +1,68 @@
+#include <ddk/ntddk.h>
+#include <windows.h>
+
+#include "regtests.h"
+
+static int RunTest(char *Buffer)
+{
+  VOID *pmem1;
+  PHYSICAL_ADDRESS LowestAcceptableAddress, HighestAcceptableAddress, SkipBytes;
+  SIZE_T TotalBytes;
+  PMDL Mdl;
+
+  /* Allocate memory for use in testing */
+  pmem1 = ExAllocatePool(NonPagedPool,
+                         512);
+
+  /* MDL Testing */
+  Mdl = NULL;
+  Mdl = MmCreateMdl(NULL,
+                    pmem1,
+                    512);
+  if (Mdl == NULL)
+  {
+    strcpy(Buffer, "MmCreateMdl() failed for Mdl\n");
+    return TS_FAILED;
+  }
+  MmBuildMdlForNonPagedPool(Mdl);
+  MmProbeAndLockPages(Mdl,
+                      KernelMode,
+                      IoReadAccess);
+  MmUnlockPages(Mdl);
+  ExFreePool(Mdl);
+
+  SkipBytes.QuadPart = PAGE_SIZE * 4;
+  TotalBytes = 4096;
+  Mdl = NULL;
+  Mdl = MmAllocatePagesForMdl(LowestAcceptableAddress,
+                              HighestAcceptableAddress,
+                              SkipBytes,
+                              TotalBytes);
+  if (Mdl == NULL)
+  {
+    strcpy(Buffer, "MmAllocatePagesForMdl() failed for Mdl\n");
+    return TS_FAILED;
+  }
+  MmFreePagesFromMdl(Mdl);
+
+  /* Free memory used in test */
+  ExFreePool(pmem1);
+
+  return TS_OK;
+}
+
+int
+Mdl_1Test(int Command, char *Buffer)
+{
+  switch (Command)
+    {
+      case TESTCMD_RUN:
+        return RunTest(Buffer);
+      case TESTCMD_TESTNAME:
+        strcpy(Buffer, "Kernel Memory MDL API");
+        return TS_OK;
+      default:
+        break;
+    }
+  return TS_FAILED;
+}
index 046fa97..3d7e94d 100644 (file)
@@ -14,6 +14,7 @@ static int RunTest(char *Buffer)
   /* Various ways to allocate memory */
   HighestAcceptableAddress.QuadPart = 0x00000000FFFFFF; /* 16MB */
   AllocSize1 = 512;
+  pmem1 = 0;
   pmem1 = MmAllocateContiguousMemory(AllocSize1,
                                      HighestAcceptableAddress);
   if (pmem1 == 0)
@@ -26,6 +27,7 @@ static int RunTest(char *Buffer)
   HighestAcceptableAddress.QuadPart = 0x00000000FFFFFF; /* 16MB */
   BoundryAddressMultiple.QuadPart = 512;
   AllocSize2 = 512;
+  pmem2 = 0;
   pmem2 = MmAllocateContiguousMemorySpecifyCache(AllocSize2,
                                                  LowestAcceptableAddress,
                                                  HighestAcceptableAddress,
@@ -41,6 +43,7 @@ static int RunTest(char *Buffer)
   HighestAcceptableAddress.QuadPart = 0x0000000F000000; /* 250MB */
   BoundryAddressMultiple.QuadPart = 1024;
   AllocSize3 = 512;
+  pmem3 = 0;
   pmem3 = MmAllocateContiguousMemorySpecifyCache(AllocSize3,
                                                  LowestAcceptableAddress,
                                                  HighestAcceptableAddress,
@@ -57,6 +60,7 @@ static int RunTest(char *Buffer)
   HighestAcceptableAddress.QuadPart = 0x00000000FFFFFF; /* 16MB */
   BoundryAddressMultiple.QuadPart = 4096;
   AllocSize4 = 512;
+  pmem4 = 0;
   pmem4 = MmAllocateContiguousMemorySpecifyCache(AllocSize4,
                                                  LowestAcceptableAddress,
                                                  HighestAcceptableAddress,
@@ -69,6 +73,7 @@ static int RunTest(char *Buffer)
   }
 
   AllocSize5 = 1048576; /* 1MB */
+  pmem5 = 0;
   pmem5 = MmAllocateNonCachedMemory(AllocSize5);
   if (pmem5 == 0)
   {
@@ -77,6 +82,7 @@ static int RunTest(char *Buffer)
   }
 
   /* Memory checking functions */
+  PhysicalAddress.QuadPart = 0;
   PhysicalAddress = MmGetPhysicalAddress(pmem1);
   if (PhysicalAddress.QuadPart == 0)
   {
@@ -138,6 +144,7 @@ static int RunTest(char *Buffer)
 
   /* Misc functions */
   Server = MmIsThisAnNtAsSystem();
+  MemSize = 0;
   MemSize = MmQuerySystemSize();
   if (MemSize != MmSmallSystem &&
       MemSize != MmMediumSystem &&
@@ -147,10 +154,6 @@ static int RunTest(char *Buffer)
     return TS_FAILED;
   }
 
-  /* Page locking functions */
-
-  /* Mapping functions */
-
   /* Free allocated memory */
   MmFreeContiguousMemory(pmem1);
   MmFreeContiguousMemorySpecifyCache(pmem2,
@@ -165,8 +168,6 @@ static int RunTest(char *Buffer)
   MmFreeNonCachedMemory(pmem5,
                         AllocSize5);
 
-  /* MDL operations */
-
   return TS_OK;
 }
 
@@ -178,7 +179,7 @@ Mm_1Test(int Command, char *Buffer)
       case TESTCMD_RUN:
         return RunTest(Buffer);
       case TESTCMD_TESTNAME:
-        strcpy(Buffer, "Kernel Memory API");
+        strcpy(Buffer, "Kernel Core Memory API");
         return TS_OK;
       default:
         break;