[KMTESTS]
authorThomas Faber <thomas.faber@reactos.org>
Thu, 15 Sep 2011 16:49:22 +0000 (16:49 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 15 Sep 2011 16:49:22 +0000 (16:49 +0000)
- MmSection: properly clean up on failure
- Some more x64 build fixing

svn path=/trunk/; revision=53712

rostests/kmtests/ntos_ke/KeSpinLock.c
rostests/kmtests/ntos_mm/MmSection.c

index 79e799b..a2ed4a1 100644 (file)
@@ -88,8 +88,13 @@ static VOID LocalName(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData)  \
 
 DEFINE_ACQUIRE(AcquireNormal,         TRUE,  KeAcquireSpinLock(SpinLock, &CheckData->Irql))
 DEFINE_RELEASE(ReleaseNormal,         TRUE,  KeReleaseSpinLock(SpinLock, CheckData->Irql))
 
 DEFINE_ACQUIRE(AcquireNormal,         TRUE,  KeAcquireSpinLock(SpinLock, &CheckData->Irql))
 DEFINE_RELEASE(ReleaseNormal,         TRUE,  KeReleaseSpinLock(SpinLock, CheckData->Irql))
+#ifdef _X86_
 DEFINE_ACQUIRE(AcquireExp,            TRUE,  (KeAcquireSpinLock)(SpinLock, &CheckData->Irql))
 DEFINE_RELEASE(ReleaseExp,            TRUE,  (KeReleaseSpinLock)(SpinLock, CheckData->Irql))
 DEFINE_ACQUIRE(AcquireExp,            TRUE,  (KeAcquireSpinLock)(SpinLock, &CheckData->Irql))
 DEFINE_RELEASE(ReleaseExp,            TRUE,  (KeReleaseSpinLock)(SpinLock, CheckData->Irql))
+#else
+DEFINE_ACQUIRE(AcquireExp,            TRUE,  KeAcquireSpinLock(SpinLock, &CheckData->Irql))
+DEFINE_RELEASE(ReleaseExp,            TRUE,  KeReleaseSpinLock(SpinLock, CheckData->Irql))
+#endif
 DEFINE_ACQUIRE(AcquireSynch,          TRUE,  CheckData->Irql = KeAcquireSpinLockRaiseToSynch(SpinLock))
 
 DEFINE_ACQUIRE(AcquireInStackQueued,  TRUE,  KeAcquireInStackQueuedSpinLock(SpinLock, &CheckData->QueueHandle))
 DEFINE_ACQUIRE(AcquireSynch,          TRUE,  CheckData->Irql = KeAcquireSpinLockRaiseToSynch(SpinLock))
 
 DEFINE_ACQUIRE(AcquireInStackQueued,  TRUE,  KeAcquireInStackQueuedSpinLock(SpinLock, &CheckData->QueueHandle))
index 96246b2..ea7121c 100644 (file)
@@ -14,7 +14,7 @@ START_TEST(MmSection)
 {
     NTSTATUS Status = STATUS_SUCCESS;
     NTSTATUS ExceptionStatus;
 {
     NTSTATUS Status = STATUS_SUCCESS;
     NTSTATUS ExceptionStatus;
-    const PVOID InvalidPointer = (PVOID)0x5555555555555555LLU;
+    const PVOID InvalidPointer = (PVOID)0x5555555555555555ULL;
     PVOID SectionObject;
     LARGE_INTEGER MaximumSize;
 
     PVOID SectionObject;
     LARGE_INTEGER MaximumSize;
 
@@ -42,6 +42,9 @@ START_TEST(MmSection)
     ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
     ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, NULL, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
     EndSeh(STATUS_ACCESS_VIOLATION);
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, NULL, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
     EndSeh(STATUS_ACCESS_VIOLATION);
@@ -52,6 +55,21 @@ START_TEST(MmSection)
     EndSeh(STATUS_ACCESS_VIOLATION);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
     EndSeh(STATUS_ACCESS_VIOLATION);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
+    SectionObject = InvalidPointer;
+    MaximumSize.QuadPart = 0;
+    StartSeh()
+        Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, NULL);
+    EndSeh(STATUS_SUCCESS);
+    ok_eq_hex(Status, STATUS_INVALID_FILE_FOR_SECTION);
+    ok_eq_longlong(MaximumSize.QuadPart, 0LL);
+    ok_eq_pointer(SectionObject, InvalidPointer);
+
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
     MaximumSize.QuadPart = 0;
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
     MaximumSize.QuadPart = 0;
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
@@ -59,12 +77,18 @@ START_TEST(MmSection)
     ok_eq_hex(Status, STATUS_INVALID_PARAMETER_4);
     ok_eq_longlong(MaximumSize.QuadPart, 0LL);
 
     ok_eq_hex(Status, STATUS_INVALID_PARAMETER_4);
     ok_eq_longlong(MaximumSize.QuadPart, 0LL);
 
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
     MaximumSize.QuadPart = 1;
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
     EndSeh(STATUS_ACCESS_VIOLATION);
     ok_eq_longlong(MaximumSize.QuadPart, 1LL);
 
     MaximumSize.QuadPart = 1;
     StartSeh()
         Status = MmCreateSection(NULL, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, NULL);
     EndSeh(STATUS_ACCESS_VIOLATION);
     ok_eq_longlong(MaximumSize.QuadPart, 1LL);
 
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
     SectionObject = InvalidPointer;
     MaximumSize.QuadPart = 0;
     StartSeh()
     SectionObject = InvalidPointer;
     MaximumSize.QuadPart = 0;
     StartSeh()
@@ -74,6 +98,9 @@ START_TEST(MmSection)
     ok_eq_longlong(MaximumSize.QuadPart, 0LL);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
     ok_eq_longlong(MaximumSize.QuadPart, 0LL);
     ok_eq_pointer(SectionObject, InvalidPointer);
 
+    if (SectionObject && SectionObject != InvalidPointer)
+        ObDereferenceObject(SectionObject);
+
     SectionObject = InvalidPointer;
     MaximumSize.QuadPart = 1;
     StartSeh()
     SectionObject = InvalidPointer;
     MaximumSize.QuadPart = 1;
     StartSeh()
@@ -86,13 +113,4 @@ START_TEST(MmSection)
 
     if (SectionObject && SectionObject != InvalidPointer)
         ObDereferenceObject(SectionObject);
 
     if (SectionObject && SectionObject != InvalidPointer)
         ObDereferenceObject(SectionObject);
-
-    SectionObject = InvalidPointer;
-    MaximumSize.QuadPart = 1;
-    StartSeh()
-        Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, NULL);
-    EndSeh(STATUS_SUCCESS);
-    ok_eq_hex(Status, STATUS_INVALID_FILE_FOR_SECTION);
-    ok_eq_longlong(MaximumSize.QuadPart, 1LL);
-    ok_eq_pointer(SectionObject, InvalidPointer);
 }
 }