Author: tfaber
Date: Wed Aug 10 22:26:14 2011
New Revision: 53167
URL:
http://svn.reactos.org/svn/reactos?rev=53167&view=rev
Log:
[KMTESTS]
- Remove breakpoint on buffer overflow
- Use a compromise for ok_* macros for SIZE_T and [U]LONG_PTR values
Modified:
branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExResource.c
branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeSpinLock.c
branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c
Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/i…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] Wed Aug 10
22:26:14 2011
@@ -99,10 +99,6 @@
#endif /* defined KMT_USER_MODE */
extern PKMT_RESULTBUFFER ResultBuffer;
-
-#define MICROSECOND 10
-#define MILLISECOND (1000 * MICROSECOND)
-#define SECOND (1000 * MILLISECOND)
#ifdef __GNUC__
#define KMT_FORMAT(type, fmt, first) __attribute__((__format__(type, fmt, first)))
@@ -141,7 +137,15 @@
#define ok_eq_ulong(value, expected) ok_eq_print(value, expected,
"%lu")
#define ok_eq_longlong(value, expected) ok_eq_print(value, expected,
"%I64d")
#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected,
"%I64u")
-#define ok_eq_size(value, expected) ok_eq_ulonglong((ULONGLONG)(value),
(ULONGLONG)(expected))
+#ifndef _WIN64
+#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected),
"%lu")
+#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected),
"%ld")
+#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected),
"%lu")
+#elif defined _WIN64
+#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected),
"%I64u")
+#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected),
"%I64d")
+#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected),
"%I64u")
+#endif /* defined _WIN64 */
#define ok_eq_hex(value, expected) ok_eq_print(value, expected,
"0x%08lx")
#define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE,
expected TRUE\n")
#define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE,
expected FALSE\n")
@@ -156,6 +160,10 @@
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
+#define MICROSECOND 10
+#define MILLISECOND (1000 * MICROSECOND)
+#define SECOND (1000 * MILLISECOND)
+
#if defined KMT_DEFINE_TEST_FUNCTIONS
#if defined KMT_KERNEL_MODE
@@ -216,11 +224,7 @@
OldLength = Buffer->LogBufferLength;
NewLength = OldLength + Length;
if (NewLength > Buffer->LogBufferMaxLength)
- {
- /* TODO: indicate failure somehow */
- __debugbreak();
return;
- }
} while (InterlockedCompareExchange(&Buffer->LogBufferLength, NewLength,
OldLength) != OldLength);
memcpy(&Buffer->LogBuffer[OldLength], String, Length);
Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExResource.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExResource.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExResource.c [iso-8859-1] Wed Aug 10
22:26:14 2011
@@ -44,16 +44,16 @@
ok_eq_uint((Res)->Flag, 0);
\
if (!Reinit) ok_eq_pointer((Res)->SharedWaiters, NULL);
\
if (!Reinit) ok_eq_pointer((Res)->ExclusiveWaiters, NULL);
\
- ok_eq_pointer((PVOID)(Res)->OwnerThreads[0].OwnerThread, NULL);
\
+ ok_eq_ulongptr((Res)->OwnerThreads[0].OwnerThread, 0);
\
ok_eq_ulong((Res)->OwnerThreads[0].TableSize, 0LU);
\
- ok_eq_pointer((PVOID)(Res)->OwnerThreads[1].OwnerThread, NULL);
\
+ ok_eq_ulongptr((Res)->OwnerThreads[1].OwnerThread, 0);
\
ok_eq_ulong((Res)->OwnerThreads[1].TableSize, 0LU);
\
ok_eq_ulong((Res)->ContentionCount, 0LU);
\
ok_eq_uint((Res)->NumberOfSharedWaiters, 0);
\
ok_eq_uint((Res)->NumberOfExclusiveWaiters, 0);
\
/* ok_eq_pointer((Res)->Reserved2, NULL); */
\
ok_eq_pointer((Res)->Address, NULL);
\
- ok_eq_pointer((PVOID)(Res)->SpinLock, NULL);
\
+ ok_eq_ulongptr((Res)->SpinLock, 0);
\
} while (0)
#define CheckResourceStatus(Res, Exclusive, Shared, ExclusiveWaiters, SharedWaiters) do
\
Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeSpinLock.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeSpinLock.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeSpinLock.c [iso-8859-1] Wed Aug 10
22:26:14 2011
@@ -140,14 +140,14 @@
{ \
ok_eq_bool(Ret, (Value) == 0); \
if (SpinLock) \
- ok_eq_pointer((PVOID)*(SpinLock), \
- (Value) ? (PVOID)((ULONG_PTR)Thread | 1) : 0); \
+ ok_eq_ulongptr(*(SpinLock), \
+ (Value) ? (ULONG_PTR)Thread | 1 : 0); \
} \
else \
{ \
ok_bool_true(Ret, "KeTestSpinLock returned");
\
if (SpinLock) \
- ok_eq_pointer((PVOID)*(SpinLock), NULL); \
+ ok_eq_ulongptr(*(SpinLock), 0); \
} \
ok_eq_uint((CheckData)->Irql, (CheckData)->OriginalIrql);
\
} while (0)
@@ -165,7 +165,7 @@
{ \
ok_eq_bool(Ret, (Value) == 0); \
if (SpinLock) \
- ok_eq_pointer((PVOID)*(SpinLock), \
+ ok_eq_ulongptr(*(SpinLock), \
(Value) ? &(CheckData)->QueueHandle : 0);
\
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Next, NULL); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Lock, \
@@ -175,7 +175,7 @@
{ \
ok_bool_true(Ret, "KeTestSpinLock returned");
\
if (SpinLock) \
- ok_eq_pointer((PVOID)*(SpinLock), NULL); \
+ ok_eq_ulongptr(*(SpinLock), 0); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Next,
(CheckData)->UntouchedValue); \
ok_eq_pointer((CheckData)->QueueHandle.LockQueue.Lock,
(CheckData)->UntouchedValue); \
} \
@@ -219,7 +219,7 @@
ok_irql(CheckData->OriginalIrql);
if (SpinLock)
- ok_eq_pointer((PVOID)*SpinLock, NULL);
+ ok_eq_ulongptr(*SpinLock, 0);
CheckData->Acquire(SpinLock, CheckData);
CheckSpinLock(SpinLock, CheckData, 1);
CheckData->Release(SpinLock, CheckData);
@@ -312,7 +312,7 @@
/* KeInitializeSpinLock */
memset(&SpinLock, 0x55, sizeof SpinLock);
KeInitializeSpinLock(&SpinLock);
- ok_eq_pointer((PVOID)SpinLock, NULL);
+ ok_eq_ulongptr(SpinLock, 0);
/* KeTestSpinLock */
ok_bool_true(KeTestSpinLock(&SpinLock), "KeTestSpinLock returned");
Modified: branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/r…
==============================================================================
--- branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c [iso-8859-1] (original)
+++ branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c [iso-8859-1] Wed Aug 10
22:26:14 2011
@@ -156,11 +156,11 @@
{
NTSTATUS Status;
UCHAR Buffer[513];
- const INT Size = 512;
- const INT HalfSize = Size / 2;
+ const SIZE_T Size = 512;
+ const SIZE_T HalfSize = Size / 2;
SIZE_T RetSize;
KIRQL Irql;
- INT i;
+ ULONG i;
KeRaiseIrql(HIGH_LEVEL, &Irql);
/* zero everything behind 'Size'. Tests will check that this wasn't
changed.
@@ -308,7 +308,7 @@
RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, SIZE_MAX);
ok_eq_size(RetSize, HalfSize - 8 + 1);
RetSize = RtlCompareMemory(NULL, NULL, 0);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
Status = _SEH2_GetExceptionCode();
} _SEH2_END;
@@ -318,31 +318,31 @@
/* RtlCompareMemoryUlong */
MakeBuffer(Buffer, 8, 0x55, Size - 4, 0, 0);
RetSize = RtlCompareMemoryUlong(Buffer, sizeof(ULONG), 0x55555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
RetSize = RtlCompareMemoryUlong(Buffer + 1, sizeof(ULONG), 0x55555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
RetSize = RtlCompareMemoryUlong(Buffer + 2, sizeof(ULONG), 0x55555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
RetSize = RtlCompareMemoryUlong(Buffer + 3, sizeof(ULONG), 0x55555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x55555555LU);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x00555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
RetSize = RtlCompareMemoryUlong(Buffer, 1, 0x55555555LU);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
RetSize = RtlCompareMemoryUlong(Buffer, 2, 0x55555555LU);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
RetSize = RtlCompareMemoryUlong(Buffer, 3, 0x55555555LU);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
RetSize = RtlCompareMemoryUlong(Buffer, 5, 0x55555555LU);
- ok_eq_size(RetSize, 4LU);
+ ok_eq_size(RetSize, 4);
KeLowerIrql(Irql);
Status = STATUS_SUCCESS;
_SEH2_TRY {
RetSize = RtlCompareMemoryUlong(NULL, 0, 0x55555555LU);
- ok_eq_size(RetSize, 0LU);
+ ok_eq_size(RetSize, 0);
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
Status = _SEH2_GetExceptionCode();
} _SEH2_END;