mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
2004-02-22 Casper S. Hornstrup <chorns@users.sourceforge.net>
* config (REGRESSIONTESTS): Add. * rules.mak (REGTESTS_PATH_INC): Add. * drivers/net/tcpip/makefile: Support regression tests. * drivers/net/tcpip/tcpip/main.c: Prepare regression tests. * hal/halx86/Makefile: Rename TARGET_LIBPATH to TARGET_IMPLIBPATH. * regtests/kmregtests/driver.c (KMRegTestsRegister): Add. (KMRegTestsRun): Move call to InitializeTests() and RegisterTests() to DriverEntry(). (KMRegTestsDispatch): Support IOCTL_KMREGTESTS_REGISTER. * regtests/kmregtests/kmregtests.h (IOCTL_KMREGTESTS_REGISTER): Define. * tools/config.mk: Define REGTESTS if REGRESSIONTESTS = 1. * tools/helper.mk: Support module private regression tests. (TARGET_LIBPATH): Rename to TARGET_IMPLIBPATH. (TARGET_LIBPATH, TARGET_REGTESTS): Add. * tools/mkconfig.c: Support REGTESTS. * tools/regtests.c (umstubfile, kmstubfile): Add. (is_file_changed, write_file_if_changed): Add. (KMSTUB): Add. (HELP): Mention -u and -k switches. (main): Parse -u and -k switches. * drivers/net/tcpip/tests: New directory. * drivers/net/tcpip/tests/.cvsignore: New file. * drivers/net/tcpip/tests/Makefile: Makefile. * drivers/net/tcpip/tests/tests: New directory. * drivers/net/tcpip/tests/tests/.cvsignore: New file. svn path=/trunk/; revision=8298
This commit is contained in:
parent
a7b989769f
commit
cc3221be2c
15 changed files with 365 additions and 37 deletions
|
@ -1,3 +1,31 @@
|
|||
2004-02-22 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* config (REGRESSIONTESTS): Add.
|
||||
* rules.mak (REGTESTS_PATH_INC): Add.
|
||||
* drivers/net/tcpip/makefile: Support regression tests.
|
||||
* drivers/net/tcpip/tcpip/main.c: Prepare regression tests.
|
||||
* hal/halx86/Makefile: Rename TARGET_LIBPATH to TARGET_IMPLIBPATH.
|
||||
* regtests/kmregtests/driver.c (KMRegTestsRegister): Add.
|
||||
(KMRegTestsRun): Move call to InitializeTests() and RegisterTests() to
|
||||
DriverEntry().
|
||||
(KMRegTestsDispatch): Support IOCTL_KMREGTESTS_REGISTER.
|
||||
* regtests/kmregtests/kmregtests.h (IOCTL_KMREGTESTS_REGISTER): Define.
|
||||
* tools/config.mk: Define REGTESTS if REGRESSIONTESTS = 1.
|
||||
* tools/helper.mk: Support module private regression tests.
|
||||
(TARGET_LIBPATH): Rename to TARGET_IMPLIBPATH.
|
||||
(TARGET_LIBPATH, TARGET_REGTESTS): Add.
|
||||
* tools/mkconfig.c: Support REGTESTS.
|
||||
* tools/regtests.c (umstubfile, kmstubfile): Add.
|
||||
(is_file_changed, write_file_if_changed): Add.
|
||||
(KMSTUB): Add.
|
||||
(HELP): Mention -u and -k switches.
|
||||
(main): Parse -u and -k switches.
|
||||
* drivers/net/tcpip/tests: New directory.
|
||||
* drivers/net/tcpip/tests/.cvsignore: New file.
|
||||
* drivers/net/tcpip/tests/Makefile: Makefile.
|
||||
* drivers/net/tcpip/tests/tests: New directory.
|
||||
* drivers/net/tcpip/tests/tests/.cvsignore: New file.
|
||||
|
||||
2004-02-18 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* apistatus.lst: Correct path of videoprt.dll.
|
||||
|
|
|
@ -25,12 +25,16 @@ MP := 0
|
|||
#
|
||||
ACPI := 0
|
||||
|
||||
#
|
||||
# Whether to build regression tests
|
||||
#
|
||||
REGRESSIONTESTS := 0
|
||||
|
||||
#
|
||||
# Whether to use Structured Exception Handling
|
||||
#
|
||||
SEH := 0
|
||||
|
||||
|
||||
#
|
||||
# Which version of NDIS do we support up to?
|
||||
#
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# $Id: makefile,v 1.13 2003/08/04 19:31:06 royce Exp $
|
||||
# $Id: makefile,v 1.14 2004/02/22 09:59:17 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_REGTESTS = yes
|
||||
|
||||
TARGET_TYPE = export_driver
|
||||
|
||||
TARGET_NAME = tcpip
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* REVISIONS:
|
||||
* CSH 01/08-2000 Created
|
||||
*/
|
||||
#include <roscfg.h>
|
||||
#include <tcpip.h>
|
||||
#include <dispatch.h>
|
||||
#include <fileobjs.h>
|
||||
|
@ -840,6 +841,8 @@ DriverEntry(
|
|||
|
||||
DriverObject->DriverUnload = TiUnload;
|
||||
|
||||
PREPARE_TESTS
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
6
reactos/drivers/net/tcpip/tests/.cvsignore
Normal file
6
reactos/drivers/net/tcpip/tests/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
_regtests.c
|
||||
_rtstub.c
|
||||
Makefile.tests
|
||||
*.d
|
||||
*.o
|
||||
*.a
|
21
reactos/drivers/net/tcpip/tests/Makefile
Normal file
21
reactos/drivers/net/tcpip/tests/Makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
# $Id: Makefile,v 1.1 2004/02/22 09:59:17 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = library
|
||||
|
||||
TARGET_NAME = regtests
|
||||
|
||||
TARGET_LIBPATH = .
|
||||
|
||||
TARGET_CFLAGS = -I$(REGTESTS_PATH_INC)
|
||||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
_regtests.o \
|
||||
$(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
2
reactos/drivers/net/tcpip/tests/tests/.cvsignore
Normal file
2
reactos/drivers/net/tcpip/tests/tests/.cvsignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.d
|
||||
*.o
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.12 2003/11/05 22:37:42 gvg Exp $
|
||||
# $Id: Makefile,v 1.13 2004/02/22 09:59:17 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
|
@ -22,7 +22,7 @@ TARGET_BASENAME = hal
|
|||
|
||||
TARGET_DEFNAME = ../hal/hal
|
||||
|
||||
TARGET_LIBPATH = .
|
||||
TARGET_IMPLIBPATH = .
|
||||
|
||||
TARGET_ASFLAGS = -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/ntoskrnl/include -D__ASM__
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern void AddTest(TestRoutine Routine);
|
||||
|
||||
PVOID
|
||||
AllocateMemory(ULONG Size)
|
||||
{
|
||||
|
@ -36,14 +38,28 @@ ShutdownBochs()
|
|||
strlen("Shutdown"));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
KMRegTestsRegister(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
TestRoutine *pTestRoutine;
|
||||
|
||||
pTestRoutine = (TestRoutine*)Irp->AssociatedIrp.SystemBuffer;
|
||||
AddTest(*pTestRoutine);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
KMRegTestsRun(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
InitializeTests();
|
||||
RegisterTests();
|
||||
PerformTests();
|
||||
ShutdownBochs();
|
||||
|
||||
|
@ -77,6 +93,10 @@ KMRegTestsDispatch(
|
|||
Irp->IoStatus.Information = 0;
|
||||
|
||||
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
|
||||
case IOCTL_KMREGTESTS_REGISTER:
|
||||
Status = KMRegTestsRegister(Irp, IrpSp);
|
||||
break;
|
||||
|
||||
case IOCTL_KMREGTESTS_RUN:
|
||||
Status = KMRegTestsRun(Irp, IrpSp);
|
||||
break;
|
||||
|
@ -95,18 +115,21 @@ KMRegTestsDispatch(
|
|||
|
||||
DPRINT("Leaving. Status (0x%X).\n", Status);
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
KMRegTestsOpenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION piosStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
NTSTATUS nErrCode;
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
NTSTATUS Status;
|
||||
|
||||
nErrCode = STATUS_SUCCESS;
|
||||
DPRINT("Called. DeviceObject is at (0x%X), IRP is at (0x%X), IrpSp->FileObject (0x%X).\n",
|
||||
DeviceObject, Irp, IrpSp->FileObject);
|
||||
|
||||
switch(piosStack->MajorFunction)
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
switch (IrpSp->MajorFunction)
|
||||
{
|
||||
/* Opening and closing handles to the device */
|
||||
case IRP_MJ_CREATE:
|
||||
|
@ -123,18 +146,18 @@ KMRegTestsOpenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
|
|||
case IRP_MJ_READ:
|
||||
/* Ignore */
|
||||
Irp->IoStatus.Information = 0;
|
||||
nErrCode = STATUS_END_OF_FILE;
|
||||
Status = STATUS_END_OF_FILE;
|
||||
break;
|
||||
|
||||
/* Unsupported operations */
|
||||
default:
|
||||
nErrCode = STATUS_NOT_IMPLEMENTED;
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = nErrCode;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return nErrCode;
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
|
@ -177,5 +200,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
|
||||
DeviceObject->Flags |= DO_BUFFERED_IO;
|
||||
|
||||
InitializeTests();
|
||||
RegisterTests();
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,13 @@
|
|||
|
||||
/* KMREGTESTS IOCTL code definitions */
|
||||
|
||||
#define FSCTL_KMREGTESTS_BASE FILE_DEVICE_NAMED_PIPE // ???
|
||||
#define FSCTL_KMREGTESTS_BASE FILE_DEVICE_NAMED_PIPE
|
||||
|
||||
#define KMREGTESTS_CTL_CODE(Function, Method, Access) \
|
||||
CTL_CODE(FSCTL_KMREGTESTS_BASE, Function, Method, Access)
|
||||
|
||||
#define IOCTL_KMREGTESTS_RUN \
|
||||
#define IOCTL_KMREGTESTS_REGISTER \
|
||||
KMREGTESTS_CTL_CODE(0, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_KMREGTESTS_RUN \
|
||||
KMREGTESTS_CTL_CODE(1, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
|
|
@ -133,3 +133,4 @@ OS2_PATH_INC=$(OS2_PATH)/include
|
|||
|
||||
# Other systems integration
|
||||
ROOT_PATH=$(PATH_TO_TOP)/..
|
||||
REGTESTS_PATH_INC=$(PATH_TO_TOP)/regtests/shared
|
|
@ -25,11 +25,14 @@ ifeq ($(ACPI), 1)
|
|||
CONFIG += ACPI
|
||||
endif
|
||||
|
||||
ifeq ($(REGRESSIONTESTS), 1)
|
||||
CONFIG += REGTESTS
|
||||
endif
|
||||
|
||||
ifeq ($(SEH), 1)
|
||||
CONFIG += SEH
|
||||
endif
|
||||
|
||||
|
||||
$(PATH_TO_TOP)/tools/mkconfig$(EXE_POSTFIX): $(PATH_TO_TOP)/tools/mkconfig.c
|
||||
$(HOST_CC) -g -o $(PATH_TO_TOP)/tools/mkconfig$(EXE_POSTFIX) $(PATH_TO_TOP)/tools/mkconfig.c
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: helper.mk,v 1.53 2004/02/21 09:20:33 gvg Exp $
|
||||
# $Id: helper.mk,v 1.54 2004/02/22 09:59:17 chorns Exp $
|
||||
#
|
||||
# Helper makefile for ReactOS modules
|
||||
# Variables this makefile accepts:
|
||||
|
@ -18,7 +18,8 @@
|
|||
# subsystem = Kernel subsystem
|
||||
# kmdll = Kernel mode DLL
|
||||
# winedll = DLL imported from wine
|
||||
# $TARGET_APPTYPE = Application type (windows,native,console)
|
||||
# $TARGET_APPTYPE = Application type (windows,native,console).
|
||||
# Required only for TARGET_TYPEs program and proglib
|
||||
# $TARGET_NAME = Base name of output file and .rc, .def, and .edf files
|
||||
# $TARGET_OBJECTS = Object files that compose the module
|
||||
# $TARGET_CPPAPP = C++ application (no,yes) (optional)
|
||||
|
@ -42,11 +43,13 @@
|
|||
# $TARGET_ENTRY = Entry point (optional)
|
||||
# $TARGET_DEFONLY = Use .def instead of .edf extension (no,yes) (optional)
|
||||
# $TARGET_NORC = Do not include standard resource file (no,yes) (optional)
|
||||
# $TARGET_LIBPATH = Destination path for import libraries (optional)
|
||||
# $TARGET_LIBPATH = Destination path for static libraries (optional)
|
||||
# $TARGET_IMPLIBPATH = Destination path for import libraries (optional)
|
||||
# $TARGET_INSTALLDIR = Destination path when installed (optional)
|
||||
# $TARGET_PCH = Filename of header to use to generate a PCH if supported by the compiler (optional)
|
||||
# $TARGET_BOOTSTRAP = Whether this file is needed to bootstrap the installation (no,yes) (optional)
|
||||
# $TARGET_BOOTSTRAP_NAME = Name on the installation medium (optional)
|
||||
# $TARGET_REGTESTS = This module has regression tests (no,yes) (optional)
|
||||
# $WINE_MODE = Compile using WINE headers (no,yes) (optional)
|
||||
# $WINE_RC = Name of .rc file for WINE modules (optional)
|
||||
# $SUBDIRS = Subdirs in which to run make (optional)
|
||||
|
@ -483,9 +486,15 @@ endif
|
|||
|
||||
|
||||
ifeq ($(TARGET_LIBPATH),)
|
||||
MK_LIBPATH := $(SDK_PATH_LIB)
|
||||
else
|
||||
MK_LIBPATH := $(TARGET_LIBPATH)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_IMPLIBPATH),)
|
||||
MK_IMPLIBPATH := $(MK_IMPLIBDEFPATH)
|
||||
else
|
||||
MK_IMPLIBPATH := $(TARGET_LIBPATH)
|
||||
MK_IMPLIBPATH := $(TARGET_IMPLIBPATH)
|
||||
endif
|
||||
|
||||
|
||||
|
@ -583,8 +592,8 @@ TARGET_NFLAGS += $(MK_NFLAGS)
|
|||
|
||||
MK_GCCLIBS := $(addprefix -l, $(TARGET_GCCLIBS))
|
||||
|
||||
ifeq ($(TARGET_TYPE), library)
|
||||
MK_FULLNAME := $(SDK_PATH_LIB)/$(MK_BASENAME)$(MK_EXT)
|
||||
ifeq ($(MK_MODE),static)
|
||||
MK_FULLNAME := $(MK_LIBPATH)/$(MK_BASENAME)$(MK_EXT)
|
||||
else
|
||||
MK_FULLNAME := $(MK_BASENAME)$(MK_EXT)
|
||||
endif
|
||||
|
@ -608,13 +617,23 @@ else
|
|||
MK_STRIPPED_OBJECT := $(MK_BASENAME).stripped.o
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_REGTESTS),yes)
|
||||
MK_REGTESTS := gen_regtests
|
||||
MK_REGTESTS_CLEAN := clean_regtests
|
||||
MK_OBJECTS += tests/_rtstub.o tests/regtests.a
|
||||
TARGET_CFLAGS += -I$(REGTESTS_PATH_INC)
|
||||
else
|
||||
MK_REGTESTS :=
|
||||
MK_REGTESTS_CLEAN :=
|
||||
endif
|
||||
|
||||
ifeq ($(MK_IMPLIBONLY),yes)
|
||||
|
||||
TARGET_CLEAN += $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
|
||||
|
||||
all: $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
|
||||
all: $(MK_REGTESTS) $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME)
|
||||
|
||||
$(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(TARGET_OBJECTS) $(MK_DEFNAME)
|
||||
$(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(MK_OBJECTS) $(MK_DEFNAME)
|
||||
$(DLLTOOL) \
|
||||
--dllname $(MK_FULLNAME) \
|
||||
--def $(MK_DEFNAME) \
|
||||
|
@ -623,7 +642,7 @@ $(MK_IMPLIBPATH)/$(MK_IMPLIB_FULLNAME): $(TARGET_OBJECTS) $(MK_DEFNAME)
|
|||
|
||||
else # MK_IMPLIBONLY
|
||||
|
||||
all: $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(SUBDIRS:%=%_all)
|
||||
all: $(MK_REGTESTS) $(MK_FULLNAME) $(MK_NOSTRIPNAME) $(SUBDIRS:%=%_all)
|
||||
|
||||
|
||||
ifeq ($(MK_IMPLIB),yes)
|
||||
|
@ -644,7 +663,7 @@ else
|
|||
MK_EXTRACMD2 :=
|
||||
endif
|
||||
|
||||
$(MK_NOSTRIPNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS)
|
||||
$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS)
|
||||
ifeq ($(MK_EXETYPE),dll)
|
||||
$(LD_CC) -Wl,--base-file,base.tmp \
|
||||
-Wl,--entry,$(TARGET_ENTRY) \
|
||||
|
@ -736,7 +755,7 @@ else
|
|||
MK_EXTRADEP :=
|
||||
endif
|
||||
|
||||
$(MK_NOSTRIPNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS)
|
||||
$(MK_NOSTRIPNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS)
|
||||
$(LD_CC) -Wl,--base-file,base.tmp \
|
||||
-Wl,--entry,$(TARGET_ENTRY) \
|
||||
$(TARGET_LFLAGS) \
|
||||
|
@ -766,7 +785,7 @@ else
|
|||
$(NM) --numeric-sort $(MK_NOSTRIPNAME) > $(MK_BASENAME).map
|
||||
endif
|
||||
|
||||
$(MK_FULLNAME): $(MK_FULLRES) $(TARGET_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) $(MK_NOSTRIPNAME)
|
||||
$(MK_FULLNAME): $(MK_FULLRES) $(MK_OBJECTS) $(MK_EXTRADEP) $(MK_LIBS) $(MK_NOSTRIPNAME)
|
||||
-
|
||||
ifneq ($(TARGET_CPPAPP),yes)
|
||||
$(LD) -r -o $(MK_STRIPPED_OBJECT) $(MK_OBJECTS)
|
||||
|
@ -843,7 +862,7 @@ MK_CLEANFILES := $(filter %.o,$(MK_OBJECTS))
|
|||
MK_CLEANFILTERED := $(MK_OBJECTS:.o=.d)
|
||||
MK_CLEANDEPS := $(join $(dir $(MK_CLEANFILTERED)), $(addprefix ., $(notdir $(MK_CLEANFILTERED))))
|
||||
|
||||
clean: $(SUBDIRS:%=%_clean)
|
||||
clean: $(MK_REGTESTS_CLEAN) $(SUBDIRS:%=%_clean)
|
||||
- $(RM) *.o depend.d *.pch $(MK_BASENAME).sym $(MK_BASENAME).a $(MK_RESOURCE) \
|
||||
$(MK_FULLNAME) $(MK_NOSTRIPNAME) $(MK_CLEANFILES) $(MK_CLEANDEPS) $(MK_BASENAME).map \
|
||||
junk.tmp base.tmp temp.exp $(MK_RC_BINARIES) $(MK_SPECDEF) $(MK_GENERATED_MAKEFILE) \
|
||||
|
@ -921,7 +940,22 @@ $(MK_RC_BINARIES): $(TARGET_RC_BINSRC)
|
|||
$(MK_RESOURCE): $(MK_RC_BINARIES)
|
||||
endif
|
||||
|
||||
.PHONY: all depends implib clean install dist bootcd depends
|
||||
gen_regtests:
|
||||
ifeq ($(MK_MODE),user)
|
||||
$(REGTESTS) ./tests/tests ./tests/_regtests.c ./tests/Makefile.tests -u ./tests/_rtstub.c
|
||||
$(MAKE) -C tests TARGET_REGTESTS=no all
|
||||
else
|
||||
ifeq ($(MK_MODE),kernel)
|
||||
$(REGTESTS) ./tests/tests ./tests/_regtests.c ./tests/Makefile.tests -k ./tests/_rtstub.c
|
||||
$(MAKE) -C tests TARGET_REGTESTS=no all
|
||||
endif
|
||||
endif
|
||||
|
||||
clean_regtests:
|
||||
$(MAKE) -C tests TARGET_REGTESTS=no clean
|
||||
$(RM) ./tests/_rtstub.c ./tests/_regtests.c ./tests/Makefile.tests
|
||||
|
||||
.PHONY: all depends implib clean install dist bootcd depends gen_regtests clean_regtests
|
||||
|
||||
ifneq ($(SUBDIRS),)
|
||||
$(SUBDIRS:%=%_all): %_all:
|
||||
|
|
|
@ -72,6 +72,7 @@ write_if_change(char* outbuf, char* filename)
|
|||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int include_tests;
|
||||
unsigned int i;
|
||||
char* outbuf;
|
||||
char* s;
|
||||
|
@ -93,11 +94,16 @@ main(int argc, char* argv[])
|
|||
s = outbuf;
|
||||
s = s + sprintf(s, "/* Automatically generated, ");
|
||||
s = s + sprintf(s, "Edit the Makefile to change configuration */\n");
|
||||
s = s + sprintf(s, "#ifndef __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
|
||||
s = s + sprintf(s, "#define __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
|
||||
s = s + sprintf(s, "#ifndef __INCLUDE_CONFIG_H\n");
|
||||
s = s + sprintf(s, "#define __INCLUDE_CONFIG_H\n");
|
||||
strcpy(config, "");
|
||||
include_tests = 0;
|
||||
for (i = 2; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "REGTESTS") == 0)
|
||||
{
|
||||
include_tests = 1;
|
||||
}
|
||||
s = s + sprintf(s, "#define %s\n", argv[i]);
|
||||
strcat(config, argv[i]);
|
||||
if (i != (argc - 1))
|
||||
|
@ -105,8 +111,19 @@ main(int argc, char* argv[])
|
|||
strcat(config, " ");
|
||||
}
|
||||
}
|
||||
if (include_tests)
|
||||
{
|
||||
s = s + sprintf(s, "#ifndef __ASM__\n");
|
||||
s = s + sprintf(s, "extern void PrepareTests();\n");
|
||||
s = s + sprintf(s, "#define PREPARE_TESTS PrepareTests();\n");
|
||||
s = s + sprintf(s, "#endif /* __ASM__ */\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
s = s + sprintf(s, "#define PREPARE_TESTS\n");
|
||||
}
|
||||
s = s + sprintf(s, "#define CONFIG \"%s\"\n", config);
|
||||
s = s + sprintf(s, "#endif /* __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H */\n");
|
||||
s = s + sprintf(s, "#endif /* __INCLUDE_CONFIG_H */\n");
|
||||
|
||||
return(write_if_change(outbuf, argv[1]));
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ static FILE *out;
|
|||
static char *path;
|
||||
static char *file;
|
||||
static char *makefile;
|
||||
static char *umstubfile;
|
||||
static char *kmstubfile;
|
||||
|
||||
char* convert_path(char* origpath)
|
||||
{
|
||||
|
@ -324,16 +326,136 @@ make_file_list (int type)
|
|||
|
||||
#endif
|
||||
|
||||
static int
|
||||
is_file_changed(char *filename, char *content)
|
||||
{
|
||||
FILE *file;
|
||||
int size;
|
||||
int n;
|
||||
char *filecontent;
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
if (file == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
if (size <= 0)
|
||||
{
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
filecontent = malloc(size);
|
||||
if (filecontent == NULL)
|
||||
{
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = fread(filecontent, 1, size, file);
|
||||
|
||||
if (n != strlen(content))
|
||||
{
|
||||
free(filecontent);
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(content, filecontent) != 0)
|
||||
{
|
||||
free(filecontent);
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free(filecontent);
|
||||
|
||||
fclose(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
write_file_if_changed(char *filename, char *content)
|
||||
{
|
||||
FILE *file;
|
||||
int n;
|
||||
|
||||
if (is_file_changed(filename, content) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
file = fopen(filename, "wb");
|
||||
if (file == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = fwrite(content, 1, strlen(content), file);
|
||||
|
||||
fclose(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char KMSTUB[] =
|
||||
"/* This file is autogenerated. */\n"
|
||||
"\n"
|
||||
"#include <roskrnl.h>\n"
|
||||
"#include <../kmregtests/kmregtests.h>\n"
|
||||
"\n"
|
||||
"typedef int (*TestRoutine)(int Command, char *Buffer);\n"
|
||||
"\n"
|
||||
"extern void RegisterTests();\n"
|
||||
"\n"
|
||||
"static PDEVICE_OBJECT KMRegTestsDeviceObject = NULL;\n"
|
||||
"static PFILE_OBJECT KMRegTestsFileObject = NULL;\n"
|
||||
"\n"
|
||||
"void AddTest(TestRoutine Routine)\n"
|
||||
"{\n"
|
||||
" PDEVICE_OBJECT DeviceObject;\n"
|
||||
" UNICODE_STRING DriverName;\n"
|
||||
" IO_STATUS_BLOCK IoStatus;\n"
|
||||
" NTSTATUS Status;\n"
|
||||
" KEVENT Event;\n"
|
||||
" PIRP Irp;\n"
|
||||
"\n"
|
||||
" if (KMRegTestsDeviceObject == NULL)\n"
|
||||
" {\n"
|
||||
" RtlInitUnicodeString(&DriverName, L\"\\Device\\KMRegTests\");\n"
|
||||
" Status = IoGetDeviceObjectPointer(&DriverName, FILE_WRITE_ATTRIBUTES,\n"
|
||||
" &KMRegTestsFileObject, &KMRegTestsDeviceObject);\n"
|
||||
" if (!NT_SUCCESS(Status)) return;\n"
|
||||
" }\n"
|
||||
" KeInitializeEvent(&Event, NotificationEvent, FALSE);\n"
|
||||
" Irp = IoBuildDeviceIoControlRequest(IOCTL_KMREGTESTS_REGISTER,\n"
|
||||
" KMRegTestsDeviceObject, &Routine, sizeof(TestRoutine), NULL, 0, FALSE, &Event, &IoStatus);\n"
|
||||
" Status = IoCallDriver(KMRegTestsDeviceObject, Irp);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void PrepareTests()\n"
|
||||
"{\n"
|
||||
" RegisterTests();\n"
|
||||
"}\n";
|
||||
|
||||
static char HELP[] =
|
||||
"REGTESTS path file makefile\n"
|
||||
"REGTESTS path file makefile [-u umstubfile] [-k kmstubfile]\n"
|
||||
"\n"
|
||||
" path Path to files\n"
|
||||
" file Registration file to create\n"
|
||||
" makefile Makefile to create\n";
|
||||
" makefile Makefile to create\n"
|
||||
" umstubfile Optional stub for running tests internal to a user-mode module\n"
|
||||
" kmstubfile Optional stub for running tests internal to a kernel-mode module\n";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
int i;
|
||||
|
||||
if (argc < 4)
|
||||
{
|
||||
puts(HELP);
|
||||
|
@ -369,6 +491,38 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
umstubfile = NULL;
|
||||
kmstubfile = NULL;
|
||||
for (i = 4; i < argc; i++)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
{
|
||||
if (argv[i][1] == 'u')
|
||||
{
|
||||
umstubfile = convert_path(argv[++i]);
|
||||
if (umstubfile[0] == 0)
|
||||
{
|
||||
printf("Missing umstubfile\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (argv[i][1] == 'k')
|
||||
{
|
||||
kmstubfile = convert_path(argv[++i]);
|
||||
if (kmstubfile[0] == 0)
|
||||
{
|
||||
printf("Missing kmstubfile\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown switch\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Registration file */
|
||||
out = fopen(file, "wb");
|
||||
|
@ -416,6 +570,30 @@ int main(int argc, char **argv)
|
|||
|
||||
fclose(out);
|
||||
|
||||
/* User-mode stubfile */
|
||||
if (umstubfile != NULL)
|
||||
{
|
||||
#if 0
|
||||
if (write_file_if_changed(umstubfile, UMSTUB) != 0)
|
||||
{
|
||||
perror("Cannot create output user-mode stubfile");
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
perror("WATNING: Cannot create output user-mode stubfile");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Kernel-mode stubfile */
|
||||
if (kmstubfile != NULL)
|
||||
{
|
||||
if (write_file_if_changed(kmstubfile, KMSTUB) != 0)
|
||||
{
|
||||
perror("Cannot create output kernel-mode stubfile");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Successfully generated regression test registrations.\n");
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue