2004-10-24 Casper S. Hornstrup <chorns@users.sourceforge.net>
authorCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 24 Oct 2004 17:51:29 +0000 (17:51 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 24 Oct 2004 17:51:29 +0000 (17:51 +0000)
* 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.

svn path=/trunk/; revision=11420

reactos/ChangeLog
reactos/ntoskrnl/Makefile
reactos/ntoskrnl/tests/.cvsignore [new file with mode: 0644]
reactos/ntoskrnl/tests/Makefile [new file with mode: 0644]
reactos/ntoskrnl/tests/setup.c [new file with mode: 0644]
reactos/ntoskrnl/tests/stubs.tst [new file with mode: 0644]
reactos/ntoskrnl/tests/tests/.cvsignore [new file with mode: 0644]
reactos/regtests/regtests/regtests.c
reactos/regtests/regtests/regtests.def
reactos/regtests/shared/regtests.h
reactos/tools/regtests.c

index 6d209ef..fa54f09 100644 (file)
@@ -1,3 +1,19 @@
+2004-10-24  Casper S. Hornstrup  <chorns@users.sourceforge.net>
+
+       * 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  <chorns@users.sourceforge.net>
 
        * config (REGRESSIONTESTS): Remove.
index c22532e..a84df20 100644 (file)
@@ -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 (file)
index 0000000..a6e5b61
--- /dev/null
@@ -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 (file)
index 0000000..7ae8965
--- /dev/null
@@ -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 (file)
index 0000000..86ae3e6
--- /dev/null
@@ -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 (file)
index 0000000..16177be
--- /dev/null
@@ -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 (file)
index 0000000..31dc307
--- /dev/null
@@ -0,0 +1,2 @@
+*.d
+*.o
index 79df018..db0170b 100755 (executable)
@@ -26,3 +26,9 @@ _LoadLibraryA(LPCSTR lpLibFileName)
 {
   return LoadLibraryA(lpLibFileName);
 }
+
+VOID STDCALL
+_ExitProcess(UINT uExitCode)
+{
+  ExitProcess(uExitCode);
+}
index 355d2e6..a6f552a 100644 (file)
@@ -1,5 +1,6 @@
 LIBRARY REGTESTS.DLL
 EXPORTS
+_ExitProcess@4
 _GetModuleHandleA@4
 _GetProcAddress@8
 _LoadLibraryA@4
index 9e63c0f..8ef3276 100755 (executable)
@@ -171,6 +171,9 @@ _GetProcAddress(HMODULE hModule,
 HINSTANCE STDCALL
 _LoadLibraryA(LPCSTR lpLibFileName);
 
+VOID STDCALL
+_ExitProcess(UINT uExitCode);
+
 static inline PCHAR
 FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription)
 {
index 500bb35..bb29ac7 100755 (executable)
@@ -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");