From c07a24b350c69ee6fa06e9234777092213b01895 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 8 Jun 2006 21:39:51 +0000 Subject: [PATCH] - Added DPRINT logic in all files (to be used as "TRACE" to aid in debugging of tests) - Added initial part of Ob tests which uses ObCreateObjectType, NtCreateDirectoryObject, ObCreateObject exported APIs. svn path=/trunk/; revision=22289 --- reactos/drivers/test/kmtest/deviface.c | 3 + reactos/drivers/test/kmtest/deviface_test.c | 3 + reactos/drivers/test/kmtest/kmtest.c | 4 +- reactos/drivers/test/kmtest/kmtest.h | 6 - reactos/drivers/test/kmtest/kmtest.rbuild | 1 + reactos/drivers/test/kmtest/ntos_io.c | 3 + reactos/drivers/test/kmtest/ntos_ob.c | 231 ++++++++++++++++++++ 7 files changed, 244 insertions(+), 7 deletions(-) create mode 100644 reactos/drivers/test/kmtest/ntos_ob.c diff --git a/reactos/drivers/test/kmtest/deviface.c b/reactos/drivers/test/kmtest/deviface.c index 7282c1a3939..3f6ed127c36 100644 --- a/reactos/drivers/test/kmtest/deviface.c +++ b/reactos/drivers/test/kmtest/deviface.c @@ -26,6 +26,9 @@ #include #include "kmtest.h" +//#define NDEBUG +#include "debug.h" + /* PUBLIC FUNCTIONS ***********************************************************/ /* diff --git a/reactos/drivers/test/kmtest/deviface_test.c b/reactos/drivers/test/kmtest/deviface_test.c index 35616845d5d..727fb74a5aa 100644 --- a/reactos/drivers/test/kmtest/deviface_test.c +++ b/reactos/drivers/test/kmtest/deviface_test.c @@ -25,6 +25,9 @@ #include #include "kmtest.h" +//#define NDEBUG +#include "debug.h" + /* PRIVATE FUNCTIONS **********************************************************/ NTSTATUS STDCALL diff --git a/reactos/drivers/test/kmtest/kmtest.c b/reactos/drivers/test/kmtest/kmtest.c index f72911b0d6a..d3f1a8ebe9e 100644 --- a/reactos/drivers/test/kmtest/kmtest.c +++ b/reactos/drivers/test/kmtest/kmtest.c @@ -105,6 +105,7 @@ int kmtest_ok(int condition, const char *msg, ... ) */ VOID FASTCALL DeviceInterfaceTest(); VOID FASTCALL NtoskrnlIoMdlTest(); +VOID FASTCALL NtoskrnlObTest(); /* * DriverEntry @@ -114,9 +115,10 @@ NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { - DbgPrint("Kernel Mode Regression Test driver starting...\n"); + DbgPrint("\n===============================================\nKernel Mode Regression Test driver starting...\n"); //DeviceInterfaceTest(); NtoskrnlIoMdlTest(); + NtoskrnlObTest(); return STATUS_UNSUCCESSFUL; } diff --git a/reactos/drivers/test/kmtest/kmtest.h b/reactos/drivers/test/kmtest/kmtest.h index 556f10bbc36..c242c5f32f9 100644 --- a/reactos/drivers/test/kmtest/kmtest.h +++ b/reactos/drivers/test/kmtest/kmtest.h @@ -10,12 +10,6 @@ Everything else is done by Aleksey Bragin based on PnPTest by Filip Navara */ -#if 0 -#define DPRINT DbgPrint("%s:%d ", __FILE__, __LINE__), DbgPrint -#else -#define DPRINT DbgPrint -#endif - extern ULONG successes; /* number of successful tests */ extern ULONG failures; /* number of failures */ //static ULONG todo_successes; /* number of successful tests inside todo block */ diff --git a/reactos/drivers/test/kmtest/kmtest.rbuild b/reactos/drivers/test/kmtest/kmtest.rbuild index 913644b92a4..36cbb6b37b3 100644 --- a/reactos/drivers/test/kmtest/kmtest.rbuild +++ b/reactos/drivers/test/kmtest/kmtest.rbuild @@ -8,5 +8,6 @@ deviface.c deviface_test.c ntos_io.c + ntos_ob.c kmtest.rc diff --git a/reactos/drivers/test/kmtest/ntos_io.c b/reactos/drivers/test/kmtest/ntos_io.c index 6e0abfce9a2..c17af873f05 100644 --- a/reactos/drivers/test/kmtest/ntos_io.c +++ b/reactos/drivers/test/kmtest/ntos_io.c @@ -25,6 +25,9 @@ #include #include "kmtest.h" +#define NDEBUG +#include "debug.h" + /* PUBLIC FUNCTIONS ***********************************************************/ VOID FASTCALL NtoskrnlIoMdlTest() diff --git a/reactos/drivers/test/kmtest/ntos_ob.c b/reactos/drivers/test/kmtest/ntos_ob.c new file mode 100644 index 00000000000..0cb2787fad1 --- /dev/null +++ b/reactos/drivers/test/kmtest/ntos_ob.c @@ -0,0 +1,231 @@ +/* + * NTOSKRNL Ob Regressions KM-Test + * ReactOS Kernel Mode Regression Testing framework + * + * Copyright 2006 Aleksey Bragin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; see the file COPYING.LIB. + * If not, write to the Free Software Foundation, + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* INCLUDES *******************************************************************/ + +#include +#include "kmtest.h" + +//#define NDEBUG +#include "debug.h" + +#include "ndk/obtypes.h" +#include "ndk/obfuncs.h" + +#include "ndk/ifssupp.h" +#include "ndk/setypes.h" +#include "ndk/sefuncs.h" + +// I ment to make this test scalable, but for now +// we work with two object types only +#define NUM_OBTYPES 2 + +typedef struct _MY_OBJECT1 +{ + ULONG Something1; +} MY_OBJECT1, *PMY_OBJECT1; + +typedef struct _MY_OBJECT2 +{ + ULONG Something1; + ULONG SomeLong[10]; +} MY_OBJECT2, *PMY_OBJECT2; + +POBJECT_TYPE ObTypes[NUM_OBTYPES]; +UNICODE_STRING ObTypeName[NUM_OBTYPES]; +UNICODE_STRING ObName[NUM_OBTYPES]; +OBJECT_TYPE_INITIALIZER ObTypeInitializer[NUM_OBTYPES]; +UNICODE_STRING ObDirectoryName; +OBJECT_ATTRIBUTES ObDirectoryAttributes; +OBJECT_ATTRIBUTES ObAttributes[NUM_OBTYPES]; +PVOID ObBody[NUM_OBTYPES]; +PMY_OBJECT1 ObObject1; +PMY_OBJECT2 ObObject2; + +/* PRIVATE FUNCTIONS **********************************************************/ + +VOID +DumpProc(IN PVOID Object, + IN POB_DUMP_CONTROL DumpControl) +{ + DbgPrint("DumpProc() called\n"); +} + +VOID +OpenProc(IN OB_OPEN_REASON OpenReason, + IN PEPROCESS Process, + IN PVOID Object, + IN ACCESS_MASK GrantedAccess, + IN ULONG HandleCount) +{ + DbgPrint("OpenProc() called\n"); +} + +VOID +CloseProc(IN PEPROCESS Process, + IN PVOID Object, + IN ACCESS_MASK GrantedAccess, + IN ULONG ProcessHandleCount, + IN ULONG SystemHandleCount) +{ + DbgPrint("CloseProc() called\n"); +} + +VOID +DeleteProc(IN PVOID Object) +{ + DbgPrint("DeleteProc()called\n"); +} + +NTSTATUS +ParseProc(IN PVOID ParseObject, + IN PVOID ObjectType, + IN OUT PACCESS_STATE AccessState, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Attributes, + IN OUT PUNICODE_STRING CompleteName, + IN OUT PUNICODE_STRING RemainingName, + IN OUT PVOID Context OPTIONAL, + IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, + OUT PVOID *Object) +{ + DbgPrint("ParseProc() called\n"); + return STATUS_SUCCESS; +} + +VOID +ObtCreateObjectTypes() +{ + UCHAR i; + NTSTATUS Status; + + for (i=0; i