Author: tfaber Date: Sun Jun 19 18:27:14 2011 New Revision: 52371
URL: http://svn.reactos.org/svn/reactos?rev=52371&view=rev Log: [KMTESTS] - add START_TEST macro in case test functions ever have to be passed an argument - add a few ok_* convenience macros - remove unnecessary C library function renaming macros
Modified: branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h
Modified: branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/ex... ============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/example/Example.c [iso-8859-1] Sun Jun 19 18:27:14 2011 @@ -8,7 +8,7 @@ #include <ntddk.h> #include <kmt_test.h>
-VOID Test_Example(VOID) +START_TEST(Example) { KIRQL Irql;
@@ -17,5 +17,18 @@ trace("Message from kernel, low-irql. %s. %ls.\n", "Format strings work", L"Even with Unicode"); KeRaiseIrql(HIGH_LEVEL, &Irql); trace("Message from kernel, high-irql. %s. %ls.\n", "Format strings work", L"Even with Unicode"); + + ok_irql(DISPATCH_LEVEL); + ok_eq_int(5, 6); + ok_eq_uint(6U, 7U); + ok_eq_long(1L, 2L); + ok_eq_ulong(3LU, 4LU); + ok_eq_pointer((PVOID)8, (PVOID)9); + ok_eq_hex(0x1234LU, 0x5678LU); + ok_bool_true(FALSE, "foo"); + ok_bool_false(TRUE, "bar"); + ok_eq_print(1, 2, "%i"); + ok_eq_str("Hello", "world"); + ok_eq_wstr(L"ABC", L"DEF"); KeLowerIrql(Irql); }
Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/in... ============================================================================== --- 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] Sun Jun 19 18:27:14 2011 @@ -37,6 +37,8 @@
extern PKMT_RESULTBUFFER ResultBuffer;
+#define START_TEST(name) VOID Test_##name(VOID) + #define KMT_STRINGIZE(x) #x #define ok(test, ...) ok_(test, __FILE__, __LINE__, __VA_ARGS__) #define trace(...) trace_( __FILE__, __LINE__, __VA_ARGS__) @@ -49,6 +51,21 @@ VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments); VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...);
+#ifdef KMT_KERNEL_MODE +#define ok_irql(irql) ok(KeGetCurrentIrql() == irql, "IRQL is %d, expected %d\n", KeGetCurrentIrql(), irql) +#endif /* defined KMT_KERNEL_MODE */ +#define ok_eq_print(value, expected, spec) ok(value == expected, #value " = " spec ", expected " spec "\n", value, expected) +#define ok_eq_pointer(value, expected) ok_eq_print(value, expected, "%p") +#define ok_eq_int(value, expected) ok_eq_print(value, expected, "%d") +#define ok_eq_uint(value, expected) ok_eq_print(value, expected, "%u") +#define ok_eq_long(value, expected) ok_eq_print(value, expected, "%ld") +#define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu") +#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") +#define ok_eq_str(value, expected) ok(!strcmp(value, expected), #value " = "%s", expected "%s"\n", value, expected) +#define ok_eq_wstr(value, expected) ok(!wcscmp(value, expected), #value " = "%ls", expected "%ls"\n", value, expected) + #if defined KMT_DEFINE_TEST_FUNCTIONS PKMT_RESULTBUFFER ResultBuffer = NULL;
@@ -70,10 +87,6 @@ HeapFree(GetProcessHeap(), 0, Buffer); } #endif /* defined KMT_USER_MODE */ - -#define KmtMemCpy memcpy -#define KmtStrLen strlen -#define KmtAssert assert
static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Length) { @@ -92,7 +105,7 @@ } } while (InterlockedCompareExchange(&Buffer->LogBufferLength, NewLength, OldLength) != OldLength);
- KmtMemCpy(&Buffer->LogBuffer[OldLength], String, Length); + memcpy(&Buffer->LogBuffer[OldLength], String, Length); }
#ifdef KMT_KERNEL_MODE @@ -108,16 +121,16 @@
if (Prepend1) { - SIZE_T Length = min(BufferMaxLength, KmtStrLen(Prepend1)); - KmtMemCpy(Buffer, Prepend1, Length); + SIZE_T Length = min(BufferMaxLength, strlen(Prepend1)); + memcpy(Buffer, Prepend1, Length); Buffer += Length; BufferLength += Length; BufferMaxLength -= Length; } if (Prepend2) { - SIZE_T Length = min(BufferMaxLength, KmtStrLen(Prepend2)); - KmtMemCpy(Buffer, Prepend2, Length); + SIZE_T Length = min(BufferMaxLength, strlen(Prepend2)); + memcpy(Buffer, Prepend2, Length); Buffer += Length; BufferLength += Length; BufferMaxLength -= Length;