From 4230863f75120b4bc8f12152247448b1988a3903 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Mon, 1 Aug 2011 21:53:52 +0000 Subject: [PATCH] [KMTESTS] - add kmt_platform.h that includes user or kernel headers as appropriate and allows Rtl tests to run in user mode without modification - include kmt_platform.h from kmt_test.h, so that tests don't have to include separate headers. This also allows for a PCH svn path=/branches/GSoC_2011/KMTestSuite/; revision=53021 --- kmtests/example/Example.c | 1 - kmtests/example/Example_drv.c | 2 -- kmtests/example/Example_user.c | 3 -- kmtests/example/KernelType.c | 1 - kmtests/include/kmt_platform.h | 48 ++++++++++++++++++++++++++++ kmtests/include/kmt_test.h | 2 ++ kmtests/kmtest/kmtest.c | 15 +++------ kmtests/kmtest/service.c | 8 ++--- kmtests/kmtest/support.c | 11 ++----- kmtests/kmtest/testlist.c | 3 -- kmtests/ntos_ex/ExDoubleList.c | 1 - kmtests/ntos_ex/ExHardError.c | 5 --- kmtests/ntos_ex/ExInterlocked.c | 3 -- kmtests/ntos_ex/ExPools.c | 5 --- kmtests/ntos_ex/ExResource.c | 4 --- kmtests/ntos_ex/ExSingleList.c | 1 - kmtests/ntos_ex/ExTimer.c | 3 -- kmtests/ntos_fsrtl/FsRtlExpression.c | 1 - kmtests/ntos_io/IoDeviceInterface.c | 2 -- kmtests/ntos_io/IoIrp.c | 1 - kmtests/ntos_io/IoMdl.c | 1 - kmtests/ntos_ke/KeApc.c | 3 -- kmtests/ntos_ke/KeDpc.c | 4 --- kmtests/ntos_ke/KeIrql.c | 4 --- kmtests/ntos_ke/KeProcessor.c | 3 -- kmtests/ntos_ke/KeSpinLock.c | 4 --- kmtests/ntos_ob/ObCreate.c | 3 -- kmtests/rtl/RtlMemory.c | 11 +------ 28 files changed, 61 insertions(+), 92 deletions(-) create mode 100644 kmtests/include/kmt_platform.h diff --git a/kmtests/example/Example.c b/kmtests/example/Example.c index ef8fb0e49bb..1d2c39d9f97 100644 --- a/kmtests/example/Example.c +++ b/kmtests/example/Example.c @@ -5,7 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#include #include START_TEST(Example) diff --git a/kmtests/example/Example_drv.c b/kmtests/example/Example_drv.c index dd7504e01f3..5a2a62ed14c 100644 --- a/kmtests/example/Example_drv.c +++ b/kmtests/example/Example_drv.c @@ -5,8 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#include - #include //#define NDEBUG diff --git a/kmtests/example/Example_user.c b/kmtests/example/Example_user.c index 6f3d7bfe229..f462fc6253c 100644 --- a/kmtests/example/Example_user.c +++ b/kmtests/example/Example_user.c @@ -5,9 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#define UNICODE -#define WIN32_LEAN_AND_MEAN -#include #include #include "Example.h" diff --git a/kmtests/example/KernelType.c b/kmtests/example/KernelType.c index 1c4b9ba4e8d..1df835f2d3c 100644 --- a/kmtests/example/KernelType.c +++ b/kmtests/example/KernelType.c @@ -5,7 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#include #include START_TEST(KernelType) diff --git a/kmtests/include/kmt_platform.h b/kmtests/include/kmt_platform.h new file mode 100644 index 00000000000..adb00e86f81 --- /dev/null +++ b/kmtests/include/kmt_platform.h @@ -0,0 +1,48 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Kernel-Mode Test Suite platform declarations + * PROGRAMMER: Thomas Faber + */ + +#ifndef _KMTEST_PLATFORM_H_ +#define _KMTEST_PLATFORM_H_ + +#if defined KMT_KERNEL_MODE || defined KMT_STANDALONE_DRIVER +#include +#include +#include +#include + +#elif defined KMT_USER_MODE +#define WIN32_LEAN_AND_MEAN +#define WIN32_NO_STATUS +#define UNICODE +#include +#include +#include +#include + +#ifdef KMT_EMULATE_KERNEL +#define ok_irql(i) +#ifdef __GNUC__ +#define KIRQL __attribute__((__unused__)) int +#elif !defined __GNUC__ +#define KIRQL int +#endif /* !defined __GNUC__ */ + +#undef KeRaiseIrql +#define KeRaiseIrql(new, old) +#undef KeLowerIrql +#define KeLowerIrql(i) +#define ExAllocatePool(type, size) HeapAlloc(GetProcessHeap(), 0, size) +#define ExAllocatePoolWithTag(type, size, tag) HeapAlloc(GetProcessHeap(), 0, size) +#define ExFreePool(p) HeapFree(GetProcessHeap(), 0, p) +#define ExFreePoolWithTag(p, tag) HeapFree(GetProcessHeap(), 0, p) +#endif /* defined KMT_EMULATE_KERNEL */ + +#endif /* defined KMT_USER_MODE */ + +#include + +#endif /* !defined _KMTEST_PLATFORM_H_ */ diff --git a/kmtests/include/kmt_test.h b/kmtests/include/kmt_test.h index 134645a90b3..60e3242ce2c 100644 --- a/kmtests/include/kmt_test.h +++ b/kmtests/include/kmt_test.h @@ -13,6 +13,8 @@ #ifndef _KMTEST_TEST_H_ #define _KMTEST_TEST_H_ +#include + #include typedef VOID KMT_TESTFUNC(VOID); diff --git a/kmtests/kmtest/kmtest.c b/kmtests/kmtest/kmtest.c index 6ab770948ed..ab2bbc47be7 100644 --- a/kmtests/kmtest/kmtest.c +++ b/kmtests/kmtest/kmtest.c @@ -5,21 +5,16 @@ * PROGRAMMER: Thomas Faber */ -#define UNICODE -#define WIN32_LEAN_AND_MEAN -#include -#include -#include +#define KMT_DEFINE_TEST_FUNCTIONS +#include + +#include "kmtest.h" +#include #include #include #include -#include "kmtest.h" -#include -#define KMT_DEFINE_TEST_FUNCTIONS -#include - #define SERVICE_NAME L"Kmtest" #define SERVICE_PATH L"kmtest_drv.sys" #define SERVICE_DESCRIPTION L"ReactOS Kernel-Mode Test Suite Driver" diff --git a/kmtests/kmtest/service.c b/kmtests/kmtest/service.c index ace5d3bae59..9f326144000 100644 --- a/kmtests/kmtest/service.c +++ b/kmtests/kmtest/service.c @@ -5,15 +5,11 @@ * PROGRAMMER: Thomas Faber */ -#define UNICODE -#define WIN32_LEAN_AND_MEAN -#include -#include +#include +#include "kmtest.h" #include -#include "kmtest.h" - #define SERVICE_ACCESS (SERVICE_START | SERVICE_STOP | DELETE) static SC_HANDLE ScmHandle; diff --git a/kmtests/kmtest/support.c b/kmtests/kmtest/support.c index b9b5d31aed9..03c10af2cce 100644 --- a/kmtests/kmtest/support.c +++ b/kmtests/kmtest/support.c @@ -5,17 +5,12 @@ * PROGRAMMER: Thomas Faber */ -#define UNICODE -#define WIN32_LEAN_AND_MEAN -#include -#include -#include - -#include +#include #include "kmtest.h" #include -#include + +#include extern HANDLE KmtestHandle; diff --git a/kmtests/kmtest/testlist.c b/kmtests/kmtest/testlist.c index 745ed92e0ed..9f315d3b3d3 100644 --- a/kmtests/kmtest/testlist.c +++ b/kmtests/kmtest/testlist.c @@ -5,9 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#define WIN32_LEAN_AND_MEAN -#define UNICODE -#include #include KMT_TESTFUNC Test_Example; diff --git a/kmtests/ntos_ex/ExDoubleList.c b/kmtests/ntos_ex/ExDoubleList.c index f582257a4ac..fb9251badf4 100644 --- a/kmtests/ntos_ex/ExDoubleList.c +++ b/kmtests/ntos_ex/ExDoubleList.c @@ -10,7 +10,6 @@ struct _LIST_ENTRY *__stdcall ExInterlockedInsertHeadList(struct _LIST_ENTRY *, struct _LIST_ENTRY *__stdcall ExInterlockedInsertTailList(struct _LIST_ENTRY *, struct _LIST_ENTRY *, unsigned long *); struct _LIST_ENTRY *__stdcall ExInterlockedRemoveHeadList(struct _LIST_ENTRY *, unsigned long *); -#include #include LIST_ENTRY Entries[5]; diff --git a/kmtests/ntos_ex/ExHardError.c b/kmtests/ntos_ex/ExHardError.c index c07ab57a169..056c471ef45 100644 --- a/kmtests/ntos_ex/ExHardError.c +++ b/kmtests/ntos_ex/ExHardError.c @@ -5,11 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#include -#include -#include -#include - #include /* TODO: don't require user interaction, test Io* routines, diff --git a/kmtests/ntos_ex/ExInterlocked.c b/kmtests/ntos_ex/ExInterlocked.c index d8db0c7367e..ee266e2c765 100644 --- a/kmtests/ntos_ex/ExInterlocked.c +++ b/kmtests/ntos_ex/ExInterlocked.c @@ -25,9 +25,6 @@ __declspec(dllimport) int __stdcall ExInterlockedDecrementLong(l __declspec(dllimport) int __stdcall Exi386InterlockedIncrementLong(long *); __declspec(dllimport) int __stdcall Exi386InterlockedDecrementLong(long *); -#include -#include - #include /* TODO: There are quite some changes needed for other architectures! diff --git a/kmtests/ntos_ex/ExPools.c b/kmtests/ntos_ex/ExPools.c index 3b55d4a14dc..c6357200be4 100644 --- a/kmtests/ntos_ex/ExPools.c +++ b/kmtests/ntos_ex/ExPools.c @@ -7,11 +7,6 @@ /* TODO: PoolsCorruption tests fail because accessing invalid memory doesn't necessarily cause an access violation */ -#include -#include -#include -/* SEH support with PSEH */ -#include #include #define NDEBUG diff --git a/kmtests/ntos_ex/ExResource.c b/kmtests/ntos_ex/ExResource.c index 974e689f5d1..80bcfa98e85 100644 --- a/kmtests/ntos_ex/ExResource.c +++ b/kmtests/ntos_ex/ExResource.c @@ -5,11 +5,7 @@ * PROGRAMMER: Thomas Faber */ -#include -#include -#include #include -#include //#define NDEBUG #include diff --git a/kmtests/ntos_ex/ExSingleList.c b/kmtests/ntos_ex/ExSingleList.c index b4b4b3ef4ad..ebce09a9d15 100644 --- a/kmtests/ntos_ex/ExSingleList.c +++ b/kmtests/ntos_ex/ExSingleList.c @@ -9,7 +9,6 @@ struct _SINGLE_LIST_ENTRY; struct _SINGLE_LIST_ENTRY *__stdcall ExInterlockedPushEntryList(struct _SINGLE_LIST_ENTRY *, struct _SINGLE_LIST_ENTRY *, unsigned long *); struct _SINGLE_LIST_ENTRY *__stdcall ExInterlockedPopEntryList(struct _SINGLE_LIST_ENTRY *, unsigned long *); -#include #include SINGLE_LIST_ENTRY Entries[5]; diff --git a/kmtests/ntos_ex/ExTimer.c b/kmtests/ntos_ex/ExTimer.c index d4ad836ed67..566a7dc121b 100644 --- a/kmtests/ntos_ex/ExTimer.c +++ b/kmtests/ntos_ex/ExTimer.c @@ -5,9 +5,6 @@ * PROGRAMMER: Aleksey Bragin */ -#include -#include -#include #include #define NDEBUG diff --git a/kmtests/ntos_fsrtl/FsRtlExpression.c b/kmtests/ntos_fsrtl/FsRtlExpression.c index 3249deb9817..da5479a6cfb 100644 --- a/kmtests/ntos_fsrtl/FsRtlExpression.c +++ b/kmtests/ntos_fsrtl/FsRtlExpression.c @@ -7,7 +7,6 @@ /* TODO: most of these calls fail the Windows checked build's !islower assertion and others */ -#include #include #define NDEBUG diff --git a/kmtests/ntos_io/IoDeviceInterface.c b/kmtests/ntos_io/IoDeviceInterface.c index 34434ff7e78..98edc8f682e 100644 --- a/kmtests/ntos_io/IoDeviceInterface.c +++ b/kmtests/ntos_io/IoDeviceInterface.c @@ -7,8 +7,6 @@ /* TODO: what's with the prototypes at the top, what's with the if-ed out part? Doesn't process most results */ -#include -#include #include #define NDEBUG diff --git a/kmtests/ntos_io/IoIrp.c b/kmtests/ntos_io/IoIrp.c index b2478321c04..a96de5c62d5 100644 --- a/kmtests/ntos_io/IoIrp.c +++ b/kmtests/ntos_io/IoIrp.c @@ -6,7 +6,6 @@ */ /* Based on code Copyright 2008 Etersoft (Alexander Morozov) */ -#include #include #define NDEBUG diff --git a/kmtests/ntos_io/IoMdl.c b/kmtests/ntos_io/IoMdl.c index 46b27237fc2..898761cfac4 100644 --- a/kmtests/ntos_io/IoMdl.c +++ b/kmtests/ntos_io/IoMdl.c @@ -5,7 +5,6 @@ * PROGRAMMER: Aleksey Bragin */ -#include #include #define NDEBUG diff --git a/kmtests/ntos_ke/KeApc.c b/kmtests/ntos_ke/KeApc.c index e365d335fb7..e8048741b18 100644 --- a/kmtests/ntos_ke/KeApc.c +++ b/kmtests/ntos_ke/KeApc.c @@ -5,9 +5,6 @@ * PROGRAMMER: Thomas Faber */ -#include -#include -#include #include #define CheckApcs(KernelApcsDisabled, SpecialApcsDisabled, AllApcsDisabled, Irql) do \ diff --git a/kmtests/ntos_ke/KeDpc.c b/kmtests/ntos_ke/KeDpc.c index 5eacde6a834..b52c0dbe280 100644 --- a/kmtests/ntos_ke/KeDpc.c +++ b/kmtests/ntos_ke/KeDpc.c @@ -5,11 +5,7 @@ * PROGRAMMER: Thomas Faber */ -#include -#include -#include #include -#include //#define NDEBUG #include diff --git a/kmtests/ntos_ke/KeIrql.c b/kmtests/ntos_ke/KeIrql.c index 2dd614cc150..27c4d36daf3 100644 --- a/kmtests/ntos_ke/KeIrql.c +++ b/kmtests/ntos_ke/KeIrql.c @@ -8,11 +8,7 @@ __declspec(dllimport) void __stdcall KeRaiseIrql(unsigned char, unsigned char *); __declspec(dllimport) void __stdcall KeLowerIrql(unsigned char); -#include -#include -#include #include -#include #define NDEBUG #include diff --git a/kmtests/ntos_ke/KeProcessor.c b/kmtests/ntos_ke/KeProcessor.c index 64b27d5fd2c..fdf7e3bb555 100644 --- a/kmtests/ntos_ke/KeProcessor.c +++ b/kmtests/ntos_ke/KeProcessor.c @@ -7,9 +7,6 @@ /* TODO: this test doesn't process any test results; it also takes very long */ -#include -#include -#include #include #define NDEBUG diff --git a/kmtests/ntos_ke/KeSpinLock.c b/kmtests/ntos_ke/KeSpinLock.c index 35e5fb60119..542053f0ec0 100644 --- a/kmtests/ntos_ke/KeSpinLock.c +++ b/kmtests/ntos_ke/KeSpinLock.c @@ -14,11 +14,7 @@ __declspec(dllimport) void __stdcall KeReleaseSpinLockFromDpcLevel(unsigned long /* this define makes KeInitializeSpinLock not use the inlined version */ #define WIN9X_COMPAT_SPINLOCK -#include -#include -#include #include -#include #include //#define NDEBUG diff --git a/kmtests/ntos_ob/ObCreate.c b/kmtests/ntos_ob/ObCreate.c index 18bdba7bef3..84d88e859e2 100644 --- a/kmtests/ntos_ob/ObCreate.c +++ b/kmtests/ntos_ob/ObCreate.c @@ -7,9 +7,6 @@ /* TODO: this test terminates with an access violation in Windows */ -#include -#include -#include #include #define NDEBUG diff --git a/kmtests/rtl/RtlMemory.c b/kmtests/rtl/RtlMemory.c index a46409c92fd..c650a507b20 100644 --- a/kmtests/rtl/RtlMemory.c +++ b/kmtests/rtl/RtlMemory.c @@ -5,16 +5,7 @@ * PROGRAMMER: Thomas Faber */ -/* TODO: move this to some header */ -#ifdef KMT_USER_MODE -# include -# define ok_irql(i) -# define KIRQL int -# define KeRaiseIrql(new, old) -# define KeLowerIrql(i) -#elif KMT_KERNEL_MODE -# include -#endif +#define KMT_EMULATE_KERNEL #include START_TEST(RtlMemory) -- 2.17.1