From 6003c5cb0689d30c2c08625eb8d38dcc2ba34e40 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sun, 24 Oct 2004 12:39:54 +0000 Subject: [PATCH] 2004-10-24 Casper S. Hornstrup * config (REGRESSIONTESTS): Remove. * tools/config.mk: Update. * lib/kernel32/misc/dllmain.c: Update. * drivers/net/tcpip/tests/Makefile (TARGET_OBJECTS): Add setup.o. * lib/gdiplus/tests/Makefile (TARGET_OBJECTS): Ditto. * lib/kernel32/tests/Makefile (TARGET_OBJECTS): Ditto. * lib/ws2_32/tests/Makefile (TARGET_OBJECTS): Ditto. * subsys/win32k/tests/makefile (TARGET_OBJECTS): Ditto. * regtests/shared/regtests.h (SetupOnce, _SetupOnce): Declare. (DISPATCHER): Rename to _Dispatcher. * lib/gdiplus/tests/tests/test-1.c: Update. * lib/kernel32/tests/tests/CreateFile.c: Ditto. * lib/ws2_32/tests/tests/WinsockEvent.c: Ditto. * subsys/win32k/tests/tests/eng-mem-1.c: Ditto. * tools/helper.mk: Be quiet when building tests. * tools/regtests.c: Remove unused code. * drivers/net/tcpip/tests/setup.c: New file. * lib/gdiplus/tests/setup.c: Ditto. * lib/kernel32/tests/setup.c: Ditto. * lib/ws2_32/tests/setup.c: Ditto. * subsys/win32k/tests/setup.c: Ditto. svn path=/trunk/; revision=11414 --- reactos/ChangeLog | 24 +++ reactos/config | 5 - reactos/drivers/net/tcpip/tests/Makefile | 4 +- reactos/drivers/net/tcpip/tests/setup.c | 5 + reactos/lib/gdiplus/tests/Makefile | 4 +- reactos/lib/gdiplus/tests/setup.c | 12 ++ reactos/lib/gdiplus/tests/tests/test-1.c | 2 +- reactos/lib/kernel32/misc/dllmain.c | 14 +- reactos/lib/kernel32/tests/Makefile | 6 +- reactos/lib/kernel32/tests/setup.c | 5 + reactos/lib/kernel32/tests/tests/CreateFile.c | 2 +- reactos/lib/ws2_32/tests/Makefile | 4 +- reactos/lib/ws2_32/tests/setup.c | 12 ++ reactos/lib/ws2_32/tests/tests/WinsockEvent.c | 9 +- reactos/regtests/shared/regtests.h | 7 +- reactos/subsys/win32k/tests/makefile | 4 +- reactos/subsys/win32k/tests/setup.c | 5 + reactos/subsys/win32k/tests/tests/eng-mem-1.c | 2 +- reactos/tools/config.mk | 4 - reactos/tools/helper.mk | 12 +- reactos/tools/regtests.c | 159 ++---------------- 21 files changed, 114 insertions(+), 187 deletions(-) create mode 100644 reactos/drivers/net/tcpip/tests/setup.c create mode 100644 reactos/lib/gdiplus/tests/setup.c create mode 100644 reactos/lib/kernel32/tests/setup.c create mode 100644 reactos/lib/ws2_32/tests/setup.c create mode 100644 reactos/subsys/win32k/tests/setup.c diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 1ee404a47cb..6d209efac3c 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,27 @@ +2004-10-24 Casper S. Hornstrup + + * config (REGRESSIONTESTS): Remove. + * tools/config.mk: Update. + * lib/kernel32/misc/dllmain.c: Update. + * drivers/net/tcpip/tests/Makefile (TARGET_OBJECTS): Add setup.o. + * lib/gdiplus/tests/Makefile (TARGET_OBJECTS): Ditto. + * lib/kernel32/tests/Makefile (TARGET_OBJECTS): Ditto. + * lib/ws2_32/tests/Makefile (TARGET_OBJECTS): Ditto. + * subsys/win32k/tests/makefile (TARGET_OBJECTS): Ditto. + * regtests/shared/regtests.h (SetupOnce, _SetupOnce): Declare. + (DISPATCHER): Rename to _Dispatcher. + * lib/gdiplus/tests/tests/test-1.c: Update. + * lib/kernel32/tests/tests/CreateFile.c: Ditto. + * lib/ws2_32/tests/tests/WinsockEvent.c: Ditto. + * subsys/win32k/tests/tests/eng-mem-1.c: Ditto. + * tools/helper.mk: Be quiet when building tests. + * tools/regtests.c: Remove unused code. + * drivers/net/tcpip/tests/setup.c: New file. + * lib/gdiplus/tests/setup.c: Ditto. + * lib/kernel32/tests/setup.c: Ditto. + * lib/ws2_32/tests/setup.c: Ditto. + * subsys/win32k/tests/setup.c: Ditto. + 2004-10-23 Casper S. Hornstrup * Makefile: Support regtests_implib. diff --git a/reactos/config b/reactos/config index 88a2b79948f..037b1f39f22 100644 --- a/reactos/config +++ b/reactos/config @@ -47,11 +47,6 @@ ACPI := 0 # 3GB := 1 -# -# Whether to build regression tests -# -REGRESSIONTESTS := 0 - # # Whether to use Structured Exception Handling # diff --git a/reactos/drivers/net/tcpip/tests/Makefile b/reactos/drivers/net/tcpip/tests/Makefile index 6d0c3c43747..333acdca461 100644 --- a/reactos/drivers/net/tcpip/tests/Makefile +++ b/reactos/drivers/net/tcpip/tests/Makefile @@ -12,7 +12,9 @@ TARGET_CFLAGS = -I$(REGTESTS_PATH_INC) -include Makefile.tests -TARGET_OBJECTS = $(addprefix tests/, $(TESTS)) +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/drivers/net/tcpip/tests/setup.c b/reactos/drivers/net/tcpip/tests/setup.c new file mode 100644 index 00000000000..86ae3e62d0e --- /dev/null +++ b/reactos/drivers/net/tcpip/tests/setup.c @@ -0,0 +1,5 @@ +#include "regtests.h" + +_SetupOnce() +{ +} diff --git a/reactos/lib/gdiplus/tests/Makefile b/reactos/lib/gdiplus/tests/Makefile index 073121955da..ef116bc495b 100644 --- a/reactos/lib/gdiplus/tests/Makefile +++ b/reactos/lib/gdiplus/tests/Makefile @@ -21,7 +21,9 @@ TARGET_LIBS = ../gdiplus.a -include Makefile.tests -TARGET_OBJECTS = $(addprefix tests/, $(TESTS)) +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/lib/gdiplus/tests/setup.c b/reactos/lib/gdiplus/tests/setup.c new file mode 100644 index 00000000000..b3793c31de2 --- /dev/null +++ b/reactos/lib/gdiplus/tests/setup.c @@ -0,0 +1,12 @@ +#include "regtests.h" + +extern BOOL +STDCALL +DllMain(HANDLE hInstDll, + ULONG dwReason, + LPVOID lpReserved); + +_SetupOnce() +{ + DllMain(NULL, DLL_PROCESS_ATTACH, NULL); +} diff --git a/reactos/lib/gdiplus/tests/tests/test-1.c b/reactos/lib/gdiplus/tests/tests/test-1.c index 8ddacb8e335..59be5307c2c 100644 --- a/reactos/lib/gdiplus/tests/tests/test-1.c +++ b/reactos/lib/gdiplus/tests/tests/test-1.c @@ -8,4 +8,4 @@ RunTest() { } -DISPATCHER(Test_1Test, "Test 1") +_Dispatcher(Test_1Test, "Test 1") diff --git a/reactos/lib/kernel32/misc/dllmain.c b/reactos/lib/kernel32/misc/dllmain.c index f8e9d4c588f..e487c7d55ce 100644 --- a/reactos/lib/kernel32/misc/dllmain.c +++ b/reactos/lib/kernel32/misc/dllmain.c @@ -1,4 +1,4 @@ -/* $Id: dllmain.c,v 1.36 2004/08/24 17:21:11 navaraf Exp $ +/* $Id: dllmain.c,v 1.37 2004/10/24 12:39:53 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -11,7 +11,6 @@ /* INCLUDES ******************************************************************/ -#include #include #define NDEBUG @@ -95,18 +94,7 @@ DllMain(HANDLE hDll, case DLL_PROCESS_ATTACH: DPRINT("DLL_PROCESS_ATTACH\n"); -#if !defined(REGTESTS) - /* - * When running regression tests, this module need to receive - * thread attach/detach notifications. This is needed because - * the module is already loaded when the regression test suite - * driver would load this module using LoadLibrary() so a - * DLL_PROCESS_ATTACH notification is not sent. The regression - * test suite driver sends thread notifications instead in this - * case. - */ LdrDisableThreadCalloutsForDll ((PVOID)hDll); -#endif /* * Connect to the csrss server diff --git a/reactos/lib/kernel32/tests/Makefile b/reactos/lib/kernel32/tests/Makefile index 71bc670a8ff..1e99edc8961 100644 --- a/reactos/lib/kernel32/tests/Makefile +++ b/reactos/lib/kernel32/tests/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.4 2004/10/23 21:05:11 chorns Exp $ +# $Id: Makefile,v 1.5 2004/10/24 12:39:53 chorns Exp $ PATH_TO_TOP = ../../.. @@ -14,7 +14,9 @@ TARGET_LIBS = ../kernel32.a -include Makefile.tests -TARGET_OBJECTS = $(addprefix tests/, $(TESTS)) +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/lib/kernel32/tests/setup.c b/reactos/lib/kernel32/tests/setup.c new file mode 100644 index 00000000000..86ae3e62d0e --- /dev/null +++ b/reactos/lib/kernel32/tests/setup.c @@ -0,0 +1,5 @@ +#include "regtests.h" + +_SetupOnce() +{ +} diff --git a/reactos/lib/kernel32/tests/tests/CreateFile.c b/reactos/lib/kernel32/tests/tests/CreateFile.c index e9ed3c769e7..96b7426d7ca 100644 --- a/reactos/lib/kernel32/tests/tests/CreateFile.c +++ b/reactos/lib/kernel32/tests/tests/CreateFile.c @@ -123,4 +123,4 @@ static void RunTest() TestFile(); } -DISPATCHER(CreatefileTest, "CreateFileW") +_Dispatcher(CreatefileTest, "CreateFileW") diff --git a/reactos/lib/ws2_32/tests/Makefile b/reactos/lib/ws2_32/tests/Makefile index ddbb6033295..e132c531337 100644 --- a/reactos/lib/ws2_32/tests/Makefile +++ b/reactos/lib/ws2_32/tests/Makefile @@ -12,7 +12,9 @@ TARGET_LIBS = ../ws2_32.a -include Makefile.tests -TARGET_OBJECTS = $(addprefix tests/, $(TESTS)) +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/lib/ws2_32/tests/setup.c b/reactos/lib/ws2_32/tests/setup.c new file mode 100644 index 00000000000..b3793c31de2 --- /dev/null +++ b/reactos/lib/ws2_32/tests/setup.c @@ -0,0 +1,12 @@ +#include "regtests.h" + +extern BOOL +STDCALL +DllMain(HANDLE hInstDll, + ULONG dwReason, + LPVOID lpReserved); + +_SetupOnce() +{ + DllMain(NULL, DLL_PROCESS_ATTACH, NULL); +} diff --git a/reactos/lib/ws2_32/tests/tests/WinsockEvent.c b/reactos/lib/ws2_32/tests/tests/WinsockEvent.c index 14a60eb526e..3bb20f3bacd 100644 --- a/reactos/lib/ws2_32/tests/tests/WinsockEvent.c +++ b/reactos/lib/ws2_32/tests/tests/WinsockEvent.c @@ -70,21 +70,14 @@ TestWSACloseEvent() TestWSACloseEventFailure(); } -extern BOOL -STDCALL -DllMain(HANDLE hInstDll, - ULONG dwReason, - LPVOID lpReserved); - static void RunTest() { WSADATA WSAData; - DllMain(NULL, DLL_PROCESS_ATTACH, NULL); WSAStartup(MAKEWORD(2, 0), &WSAData); TestWSACloseEvent(); WSACleanup(); } -DISPATCHER(WinsockeventTest, "Winsock 2 event") +_Dispatcher(WinsockeventTest, "Winsock 2 event") diff --git a/reactos/regtests/shared/regtests.h b/reactos/regtests/shared/regtests.h index 8ec5c89119f..9e63c0f5545 100755 --- a/reactos/regtests/shared/regtests.h +++ b/reactos/regtests/shared/regtests.h @@ -10,6 +10,11 @@ #include #include +extern void SetupOnce(); + +#define _SetupOnce() \ +void SetupOnce() + /* Valid values for Command parameter of TestRoutine */ #define TESTCMD_RUN 0 /* Buffer contains information about what failed */ #define TESTCMD_TESTNAME 1 /* Buffer contains description of test */ @@ -23,7 +28,7 @@ extern int _Result; extern char *_Buffer; /* Macros to simplify tests */ -#define DISPATCHER(FunctionName, TestName) \ +#define _Dispatcher(FunctionName, TestName) \ void \ FunctionName(int Command) \ { \ diff --git a/reactos/subsys/win32k/tests/makefile b/reactos/subsys/win32k/tests/makefile index c4b27a5744c..3f800471496 100644 --- a/reactos/subsys/win32k/tests/makefile +++ b/reactos/subsys/win32k/tests/makefile @@ -14,7 +14,9 @@ TARGET_LIBS = ../win32k.a -include Makefile.tests -TARGET_OBJECTS = $(addprefix tests/, $(TESTS)) +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/subsys/win32k/tests/setup.c b/reactos/subsys/win32k/tests/setup.c new file mode 100644 index 00000000000..86ae3e62d0e --- /dev/null +++ b/reactos/subsys/win32k/tests/setup.c @@ -0,0 +1,5 @@ +#include "regtests.h" + +_SetupOnce() +{ +} diff --git a/reactos/subsys/win32k/tests/tests/eng-mem-1.c b/reactos/subsys/win32k/tests/tests/eng-mem-1.c index 9e45aefc1ba..5067c5922a7 100644 --- a/reactos/subsys/win32k/tests/tests/eng-mem-1.c +++ b/reactos/subsys/win32k/tests/tests/eng-mem-1.c @@ -45,4 +45,4 @@ static void RunTest() #endif } -DISPATCHER(Eng_mem_1Test, "Win32k Engine Memory API") +_Dispatcher(Eng_mem_1Test, "Win32k Engine Memory API") diff --git a/reactos/tools/config.mk b/reactos/tools/config.mk index 33abd7ccad2..3e6a9b321a4 100644 --- a/reactos/tools/config.mk +++ b/reactos/tools/config.mk @@ -25,10 +25,6 @@ ifeq ($(ACPI), 1) CONFIG += ACPI endif -ifeq ($(REGRESSIONTESTS), 1) -CONFIG += REGTESTS -endif - ifeq ($(SEH), 1) CONFIG += SEH endif diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index 0df41295dc2..dac1990e136 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -1,4 +1,4 @@ -# $Id: helper.mk,v 1.91 2004/10/23 21:05:12 chorns Exp $ +# $Id: helper.mk,v 1.92 2004/10/24 12:39:54 chorns Exp $ # # Helper makefile for ReactOS modules # Variables this makefile accepts: @@ -722,7 +722,7 @@ else endif $(MK_BASENAME).a: $(MK_OBJECTS) - $(AR) -r $(MK_BASENAME).a $(MK_OBJECTS) + $(AR) -rc $(MK_BASENAME).a $(MK_OBJECTS) $(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS) ifeq ($(MK_EXETYPE),dll) @@ -815,7 +815,7 @@ else endif $(MK_BASENAME).a: $(MK_OBJECTS) - $(AR) -r $(MK_BASENAME).a $(MK_OBJECTS) + $(AR) -rc $(MK_BASENAME).a $(MK_OBJECTS) $(MK_NOSTRIPNAME): $(MK_EXTRADEP) $(MK_FULLRES) $(MK_BASENAME).a $(MK_LIBS) $(LD_CC) -Wl,--base-file,base.tmp \ @@ -882,8 +882,10 @@ endif # MK_MODE ifeq ($(MK_MODE),static) $(MK_FULLNAME): $(MK_EXTRADEP) $(MK_OBJECTS) - $(AR) -r $(MK_FULLNAME) $(MK_OBJECTS) - @echo $(MK_BASENAME)$(MK_EXT) was successfully built. + $(AR) -rc $(MK_FULLNAME) $(MK_OBJECTS) +ifneq ($(TARGET_TYPE),test) + @echo $(MK_FULLNAME) was successfully built. +endif # Static libraries dont have a nostrip version $(MK_NOSTRIPNAME): diff --git a/reactos/tools/regtests.c b/reactos/tools/regtests.c index 4f7869b8ed1..500bb351a26 100755 --- a/reactos/tools/regtests.c +++ b/reactos/tools/regtests.c @@ -36,8 +36,6 @@ static FILE *out; static char *path; static char *file; static char *makefile; -static char *umstubfile; -static char *kmstubfile; static char *exestubfile; static char* @@ -430,88 +428,6 @@ write_file_if_changed(char *filename, return 0; } -static char KMSTUB[] = - "/* This file is autogenerated. */\n" - "\n" - "#include \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" - " 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 UMSTUB[] = - "/* This file is autogenerated. */\n" - "\n" - "#include \n" - "#define NTOS_MODE_USER\n" - "#include \n" - "#include \"regtests.h\"\n" - "\n" - "PVOID\n" - "AllocateMemory(ULONG Size)\n" - "{\n" - " return (PVOID) RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);\n" - "}\n" - "\n" - "VOID\n" - "FreeMemory(PVOID Base)\n" - "{\n" - " RtlFreeHeap(RtlGetProcessHeap(), 0, Base);\n" - "}\n" - "\n" - "/* This function will be called several times */\n" - "void PrepareTests()\n" - "{\n" - " static int testsRegistered = 0;\n" - " if (testsRegistered == 0)\n" - " {\n" - " HANDLE hEvent;\n" - " hEvent = OpenEventW(\n" - " EVENT_ALL_ACCESS,\n" - " FALSE,\n" - " L\"WinRegTests\");\n" - " if (hEvent != NULL)\n" - " {\n" - " SetEvent(hEvent);\n" - " CloseHandle(hEvent);\n" - " testsRegistered = 1;\n" - " InitializeTests();\n" - " RegisterTests();\n" - " PerformTests(NULL, NULL);\n" - " }\n" - " }\n" - "}\n"; - static char EXESTUB[] = "/* This file is autogenerated. */\n" "\n" @@ -542,6 +458,7 @@ static char EXESTUB[] = "{\n" " InitializeTests();\n" " RegisterTests();\n" + " SetupOnce();\n" " PerformTests(ConsoleWrite, NULL);\n" " NtTerminateProcess (NtCurrentProcess(), 0);\n" " return 0;\n" @@ -574,15 +491,13 @@ static char HOOKS_FOOTER[] = "ULONG MaxExternalDependency = ExternalDependencyCount - 1;\n"; static char HELP[] = - "REGTESTS path file makefile [-u umstubfile] [-k kmstubfile] [-e exestubfile]\n" + "REGTESTS path file makefile [-e exestubfile]\n" "REGTESTS -s stublistfile stubsfile hooksfile\n" "\n" " path Path to files\n" " file Registration file 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" - " exestubfile Optional stub for running tests internal to a module in the build environment\n" + " exestubfile Optional stub for running tests in the build environment\n" " stublistfile File with descriptions of stubs\n" " stubsfile File with stubs to create\n" " hooksfile File with hooks to create\n"; @@ -834,45 +749,25 @@ int run_registrations(int argc, return 1; } - umstubfile = NULL; - kmstubfile = NULL; exestubfile = 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 if (argv[i][1] == 'e') - { - exestubfile = convert_path(argv[++i]); - if (exestubfile[0] == 0) - { - printf("Missing exestubfile\n"); - return 1; - } - } - else - { - printf("Unknown switch\n"); - return 1; - } + if (argv[i][1] == 'e') + { + exestubfile = convert_path(argv[++i]); + if (exestubfile[0] == 0) + { + printf("Missing exestubfile\n"); + return 1; + } + } + else + { + printf("Unknown switch -%c\n", argv[i][1]); + return 1; + } } } @@ -923,26 +818,6 @@ int run_registrations(int argc, fclose(out); - /* User-mode stubfile */ - if (umstubfile != NULL) - { - if (write_file_if_changed(umstubfile, UMSTUB) != 0) - { - perror("Cannot create output user-mode stubfile"); - return 1; - } - } - - /* Kernel-mode stubfile */ - if (kmstubfile != NULL) - { - if (write_file_if_changed(kmstubfile, KMSTUB) != 0) - { - perror("Cannot create output kernel-mode stubfile"); - return 1; - } - } - /* Executable stubfile */ if (exestubfile != NULL) {