diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 6d209efac3c..fa54f09b09f 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,19 @@ +2004-10-24 Casper S. Hornstrup + + * ntoskrnl/Makefile (TARGET_REGTESTS): Define to yes. + * regtests/regtests/regtests.c (_ExitProcess): Declare. + * regtests/regtests/regtests.def (_ExitProcess@4): Ditto. + * regtests/shared/regtests.h (_ExitProcess): Ditto. + * tools/regtests.c: Exit process using _ExitProcess(); + Properly support fastcall symbols. + * ntoskrnl/tests: New directory. + * ntoskrnl/tests/tests: Ditto. + * ntoskrnl/tests/.cvsignore: New file. + * ntoskrnl/tests/Makefile: Ditto. + * ntoskrnl/tests/setup.c: Ditto. + * ntoskrnl/tests/stubs.tst: Ditto. + * ntoskrnl/tests/tests/.cvsignore: Ditto. + 2004-10-24 Casper S. Hornstrup * config (REGRESSIONTESTS): Remove. diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index c22532e1609..a84df2083e8 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -4,6 +4,8 @@ PATH_TO_TOP := .. include $(PATH_TO_TOP)/config +TARGET_REGTESTS = yes + TARGET_TYPE = kernel TARGET_NAME = ntoskrnl diff --git a/reactos/ntoskrnl/tests/.cvsignore b/reactos/ntoskrnl/tests/.cvsignore new file mode 100644 index 00000000000..a6e5b61676a --- /dev/null +++ b/reactos/ntoskrnl/tests/.cvsignore @@ -0,0 +1,9 @@ +_regtests.c +_rtstub.c +_hooks.c +_stubs.S +Makefile.tests +*.d +*.o +*.a +*.pch diff --git a/reactos/ntoskrnl/tests/Makefile b/reactos/ntoskrnl/tests/Makefile new file mode 100644 index 00000000000..7ae89656900 --- /dev/null +++ b/reactos/ntoskrnl/tests/Makefile @@ -0,0 +1,25 @@ +PATH_TO_TOP = ../.. + +TARGET_TYPE = test + +TARGET_NAME = regtests + +TARGET_LIBPATH = . + +TARGET_CFLAGS = -I$(REGTESTS_PATH_INC) + +TARGET_LIBS = \ + ../ntoskrnl.a \ + $(SDK_PATH_LIB)/rtl.a \ + $(SDK_PATH_LIB)/rosrtl.a \ + $(SDK_PATH_LIB)/pseh.a + +-include Makefile.tests + +TARGET_OBJECTS = \ + setup.o \ + $(addprefix tests/, $(TESTS)) + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk diff --git a/reactos/ntoskrnl/tests/setup.c b/reactos/ntoskrnl/tests/setup.c new file mode 100644 index 00000000000..86ae3e62d0e --- /dev/null +++ b/reactos/ntoskrnl/tests/setup.c @@ -0,0 +1,5 @@ +#include "regtests.h" + +_SetupOnce() +{ +} diff --git a/reactos/ntoskrnl/tests/stubs.tst b/reactos/ntoskrnl/tests/stubs.tst new file mode 100644 index 00000000000..16177be73a9 --- /dev/null +++ b/reactos/ntoskrnl/tests/stubs.tst @@ -0,0 +1,59 @@ +hal.dll __divdi3 +hal.dll __udivdi3 +hal.dll __moddi3 +hal.dll __umoddi3 +hal.dll _init_end__ +hal.dll _init_start__ +hal.dll _text_end__ +hal.dll @ExAcquireFastMutex@4 +hal.dll @ExReleaseFastMutex@4 +hal.dll @ExTryToAcquireFastMutex@4 +hal.dll HalAcquireDisplayOwnership@4 +hal.dll HalAllocateAdapterChannel@16 +hal.dll HalAllocateCommonBuffer@16 +hal.dll HalAllProcessorsStarted@0 +hal.dll HalBeginSystemInterrupt@12 +hal.dll HalDisableSystemInterrupt@8 +hal.dll HalDisplayString@ +hal.dll HalDisplayString@4 +hal.dll HalEnableSystemInterrupt@12 +hal.dll HalEndSystemInterrupt@8 +hal.dll HalFreeCommonBuffer@24 +hal.dll HalGetAdapter@8 +hal.dll HalGetEnvironmentVariable@12 +hal.dll HalInitializeProcessor@8 +hal.dll HalInitSystem@8 +hal.dll HalQueryRealTimeClock@4 +hal.dll HalReadDmaCounter@4 +hal.dll HalReleaseDisplayOwnership@0 +hal.dll HalReportResourceUsage@0 +hal.dll @HalRequestSoftwareInterrupt@4 +hal.dll HalReturnToFirmware@4 +hal.dll HalSetEnvironmentVariable@8 +hal.dll HalSetRealTimeClock@4 +hal.dll IoAssignDriveLetters@16 +hal.dll IoFlushAdapterBuffers@24 +hal.dll IoFreeAdapterChannel@4 +hal.dll IoFreeMapRegisters@12 +hal.dll IoMapTransfer@24 +hal.dll KdPortGetByteEx@8 +hal.dll KdPortInitializeEx@12 +hal.dll KdPortPutByteEx@8 +hal.dll KeAcquireSpinLock@8 +hal.dll KeFlushWriteBuffer@0 +hal.dll KeGetCurrentIrql@0 +hal.dll KeLowerIrql@4 +hal.dll KeQueryPerformanceCounter@4 +hal.dll KeRaiseIrql@8 +hal.dll KeRaiseIrqlToDpcLevel@0 +hal.dll KeRaiseIrqlToSynchLevel@0 +hal.dll KeReleaseSpinLock@8 +hal.dll @KfAcquireSpinLock@4 +hal.dll @KfLowerIrql@4 +hal.dll @KfReleaseSpinLock@8 +hal.dll READ_PORT_UCHAR@4 +hal.dll READ_PORT_ULONG@4 +hal.dll READ_PORT_USHORT@4 +hal.dll WRITE_PORT_UCHAR@8 +hal.dll WRITE_PORT_ULONG@8 +hal.dll WRITE_PORT_USHORT@8 \ No newline at end of file diff --git a/reactos/ntoskrnl/tests/tests/.cvsignore b/reactos/ntoskrnl/tests/tests/.cvsignore new file mode 100644 index 00000000000..31dc3078b3a --- /dev/null +++ b/reactos/ntoskrnl/tests/tests/.cvsignore @@ -0,0 +1,2 @@ +*.d +*.o diff --git a/reactos/regtests/regtests/regtests.c b/reactos/regtests/regtests/regtests.c index 79df018a2ba..db0170b00d0 100755 --- a/reactos/regtests/regtests/regtests.c +++ b/reactos/regtests/regtests/regtests.c @@ -26,3 +26,9 @@ _LoadLibraryA(LPCSTR lpLibFileName) { return LoadLibraryA(lpLibFileName); } + +VOID STDCALL +_ExitProcess(UINT uExitCode) +{ + ExitProcess(uExitCode); +} diff --git a/reactos/regtests/regtests/regtests.def b/reactos/regtests/regtests/regtests.def index 355d2e67a84..a6f552ac314 100644 --- a/reactos/regtests/regtests/regtests.def +++ b/reactos/regtests/regtests/regtests.def @@ -1,5 +1,6 @@ LIBRARY REGTESTS.DLL EXPORTS +_ExitProcess@4 _GetModuleHandleA@4 _GetProcAddress@8 _LoadLibraryA@4 diff --git a/reactos/regtests/shared/regtests.h b/reactos/regtests/shared/regtests.h index 9e63c0f5545..8ef32763699 100755 --- a/reactos/regtests/shared/regtests.h +++ b/reactos/regtests/shared/regtests.h @@ -171,6 +171,9 @@ _GetProcAddress(HMODULE hModule, HINSTANCE STDCALL _LoadLibraryA(LPCSTR lpLibFileName); +VOID STDCALL +_ExitProcess(UINT uExitCode); + static inline PCHAR FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription) { diff --git a/reactos/tools/regtests.c b/reactos/tools/regtests.c index 500bb351a26..bb29ac7ce6e 100755 --- a/reactos/tools/regtests.c +++ b/reactos/tools/regtests.c @@ -433,17 +433,6 @@ static char EXESTUB[] = "\n" "#include \"regtests.h\"\n" "\n" - "#if defined(__USE_W32API)\n" - " #define HANDLE PVOID\n" - " #define NTSTATUS ULONG\n" - "\n" - " NTSTATUS STDCALL\n" - " NtTerminateProcess(HANDLE ProcessHandle,\n" - " NTSTATUS ExitStatus);\n" - "\n" - " #define NtCurrentProcess() ((HANDLE) 0xFFFFFFFF)\n" - "#endif\n" - "\n" "void\n" "ConsoleWrite(char *Buffer)\n" "{\n" @@ -460,7 +449,7 @@ static char EXESTUB[] = " RegisterTests();\n" " SetupOnce();\n" " PerformTests(ConsoleWrite, NULL);\n" - " NtTerminateProcess (NtCurrentProcess(), 0);\n" + " _ExitProcess(0);\n" " return 0;\n" "}\n"; @@ -522,6 +511,18 @@ write_hooks_footer(FILE *hooks_out, unsigned long nr_stubs) fprintf(hooks_out, HOOKS_FOOTER, nr_stubs); } +char * +get_symbolname(char *decoratedname) +{ + char buf[300]; + + if (decoratedname[0] == '@') + return strdup(decoratedname); + strcpy(buf, "_"); + strcat(buf, decoratedname); + return strdup(buf); +} + char * get_undecorated_name(char *buf, char *decoratedname) @@ -570,6 +571,7 @@ write_stub(FILE *stubs_out, FILE *hooks_out, char *dllname, char *p; char *decoratedname = NULL; char *forwardedexport = NULL; + char *symbolname = NULL; p = strtok(decoratedname_and_forward, "="); if (p != NULL) @@ -585,8 +587,10 @@ write_stub(FILE *stubs_out, FILE *hooks_out, char *dllname, forwardedexport = decoratedname_and_forward; } - fprintf(stubs_out, ".globl _%s\n", decoratedname); - fprintf(stubs_out, "_%s:\n", decoratedname); + symbolname = get_symbolname(decoratedname); + fprintf(stubs_out, ".globl %s\n", symbolname); + fprintf(stubs_out, "%s:\n", symbolname); + free(symbolname); fprintf(stubs_out, " pushl $%d\n", stub_index); fprintf(stubs_out, " jmp passthrough\n"); fprintf(stubs_out, "\n");