mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
2004-10-23 Casper S. Hornstrup <chorns@users.sourceforge.net>
* Makefile: Support regtests_implib. * rules.mak (REGTESTS_PATH): Define. * drivers/net/tcpip/makefile (TARGET_BUILDENV_TEST): Remove. * drivers/net/tcpip/tests/Makefile: Update. * lib/gdiplus/tests/.cvsignore: Ditto. * lib/gdiplus/tests/Makefile: Ditto. * lib/kernel32/tests/Makefile: Ditto. * lib/kernel32/tests/stubs.tst (HeapAlloc, HeapFree): Add. * lib/ws2_32/makefile (TARGET_REGTESTS): Define to yes. * regtests/Makefile: Update. * regtests/shared/regtests.c (_alloca): Define. (FrameworkGetHook): Move to here. * regtests/shared/regtests.h (_AssertTrue, _AssertFalse): Define. (_GetModuleHandleA, _GetProcAddress, _LoadLibraryA): Define. (FrameworkGetExportedFunctionNameInternal): Define. * subsys/win32k/tests/makefile: Update. * tools/helper.mk: Create dependencies. * tools/regtests.c: Move FrameworkGetHook; Support forwarded exports. * lib/ws2_32/tests: New directory. * lib/ws2_32/tests/.cvsignore: New file. * lib/ws2_32/tests/Makefile: Ditto. * lib/ws2_32/tests/stubs.tst: Ditto. * lib/ws2_32/tests/tests: New directory. * lib/ws2_32/tests/tests/.cvsignore: New file. * lib/ws2_32/tests/tests/WinsockEvent.c: New file. * regtests/regtests: New directory. * regtests/regtests/.cvsignore: New file. * regtests/regtests/Makefile: Ditto. * regtests/regtests/regtests.c: Ditto. * regtests/regtests/regtests.def: Ditto. svn path=/trunk/; revision=11406
This commit is contained in:
parent
825e1dc162
commit
eae828b789
25 changed files with 441 additions and 124 deletions
|
@ -1,3 +1,36 @@
|
|||
2004-10-23 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* Makefile: Support regtests_implib.
|
||||
* rules.mak (REGTESTS_PATH): Define.
|
||||
* drivers/net/tcpip/makefile (TARGET_BUILDENV_TEST): Remove.
|
||||
* drivers/net/tcpip/tests/Makefile: Update.
|
||||
* lib/gdiplus/tests/.cvsignore: Ditto.
|
||||
* lib/gdiplus/tests/Makefile: Ditto.
|
||||
* lib/kernel32/tests/Makefile: Ditto.
|
||||
* lib/kernel32/tests/stubs.tst (HeapAlloc, HeapFree): Add.
|
||||
* lib/ws2_32/makefile (TARGET_REGTESTS): Define to yes.
|
||||
* regtests/Makefile: Update.
|
||||
* regtests/shared/regtests.c (_alloca): Define.
|
||||
(FrameworkGetHook): Move to here.
|
||||
* regtests/shared/regtests.h (_AssertTrue, _AssertFalse): Define.
|
||||
(_GetModuleHandleA, _GetProcAddress, _LoadLibraryA): Define.
|
||||
(FrameworkGetExportedFunctionNameInternal): Define.
|
||||
* subsys/win32k/tests/makefile: Update.
|
||||
* tools/helper.mk: Create dependencies.
|
||||
* tools/regtests.c: Move FrameworkGetHook; Support forwarded exports.
|
||||
* lib/ws2_32/tests: New directory.
|
||||
* lib/ws2_32/tests/.cvsignore: New file.
|
||||
* lib/ws2_32/tests/Makefile: Ditto.
|
||||
* lib/ws2_32/tests/stubs.tst: Ditto.
|
||||
* lib/ws2_32/tests/tests: New directory.
|
||||
* lib/ws2_32/tests/tests/.cvsignore: New file.
|
||||
* lib/ws2_32/tests/tests/WinsockEvent.c: New file.
|
||||
* regtests/regtests: New directory.
|
||||
* regtests/regtests/.cvsignore: New file.
|
||||
* regtests/regtests/Makefile: Ditto.
|
||||
* regtests/regtests/regtests.c: Ditto.
|
||||
* regtests/regtests/regtests.def: Ditto.
|
||||
|
||||
2004-10-20 Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
|
||||
* lib/gdiplus/makefile (TARGET_BUILDENV_TEST): Remove.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.254 2004/10/23 17:07:06 weiden Exp $
|
||||
# $Id: Makefile,v 1.255 2004/10/23 21:05:11 chorns Exp $
|
||||
#
|
||||
# Global makefile
|
||||
#
|
||||
|
@ -137,7 +137,8 @@ depends: $(LIB_STATIC:%=%_depends) $(LIB_FSLIB:%=%_depends) msvcrt_depends $(DLL
|
|||
implib: hallib $(LIB_STATIC) $(COMPONENTS:%=%_implib) $(HALS:%=%_implib) $(BUS:%=%_implib) \
|
||||
$(LIB_STATIC:%=%_implib) $(LIB_FSLIB:%=%_implib) msvcrt_implib $(DLLS:%=%_implib) \
|
||||
$(KERNEL_DRIVERS:%=%_implib) $(SUBSYS:%=%_implib) \
|
||||
$(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) $(EXT_MODULES:%=%_implib)
|
||||
$(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) $(EXT_MODULES:%=%_implib) \
|
||||
$(REGTESTS:%=%_implib)
|
||||
|
||||
test: $(COMPONENTS:%=%_test) $(HALS:%=%_test) $(BUS:%=%_test) \
|
||||
$(LIB_STATIC:%=%_test) $(LIB_FSLIB:%=%_test) msvcrt_test $(DLLS:%=%_test) \
|
||||
|
@ -889,6 +890,9 @@ $(SUBSYS:%=%_bootcd): %_bootcd:
|
|||
$(REGTESTS): %: $(IMPLIB)
|
||||
$(MAKE) --silent -C regtests
|
||||
|
||||
$(REGTESTS:%=%_implib): %_implib: dk
|
||||
$(MAKE) --silent -C regtests implib
|
||||
|
||||
$(REGTESTS:%=%_clean): %_clean:
|
||||
$(MAKE) -C regtests clean
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
# $Id: makefile,v 1.28 2004/10/18 19:11:06 chorns Exp $
|
||||
# $Id: makefile,v 1.29 2004/10/23 21:05:11 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_REGTESTS = yes
|
||||
|
||||
TARGET_BUILDENV_TEST = yes
|
||||
|
||||
TARGET_TYPE = export_driver
|
||||
|
||||
TARGET_NAME = tcpip
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# $Id: Makefile,v 1.3 2004/10/18 19:11:07 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = library
|
||||
TARGET_TYPE = test
|
||||
|
||||
TARGET_NAME = regtests
|
||||
|
||||
|
@ -14,18 +12,8 @@ TARGET_CFLAGS = -I$(REGTESTS_PATH_INC)
|
|||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
_rtstub.o \
|
||||
_regtests.o \
|
||||
_hooks.o \
|
||||
_stubs.o \
|
||||
$(addprefix tests/, $(TESTS))
|
||||
TARGET_OBJECTS = $(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
run: all
|
||||
@$(CC) -o _runtest.exe _rtstub.o regtests.a $(SDK_PATH_LIB)/rtshared.a $(LIBS) -lntdll
|
||||
@_runtest.exe
|
||||
@$(RM) _runtest.exe
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
_hooks.c
|
||||
_regtests.c
|
||||
_rtstub.c
|
||||
_hooks.c
|
||||
_stubs.S
|
||||
Makefile.tests
|
||||
*.d
|
||||
|
|
|
@ -21,12 +21,7 @@ TARGET_LIBS = ../gdiplus.a
|
|||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
_rtstub.o \
|
||||
_regtests.o \
|
||||
_hooks.o \
|
||||
_stubs.o \
|
||||
$(addprefix tests/, $(TESTS))
|
||||
TARGET_OBJECTS = $(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: Makefile,v 1.3 2004/10/20 20:51:21 chorns Exp $
|
||||
# $Id: Makefile,v 1.4 2004/10/23 21:05:11 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -14,12 +14,7 @@ TARGET_LIBS = ../kernel32.a
|
|||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
_rtstub.o \
|
||||
_regtests.o \
|
||||
_hooks.o \
|
||||
_stubs.o \
|
||||
$(addprefix tests/, $(TESTS))
|
||||
TARGET_OBJECTS = $(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ ntdll.dll CsrClientCallServer@16
|
|||
ntdll.dll CsrClientConnectToServer@0
|
||||
ntdll.dll CsrReleaseParameterBuffer@4
|
||||
ntdll.dll DbgUiContinue@8
|
||||
ntdll.dll HeapAlloc@12=RtlAllocateHeap
|
||||
ntdll.dll HeapFree@12=RtlFreeHeap
|
||||
ntdll.dll LdrAccessResource@16
|
||||
ntdll.dll LdrDisableThreadCalloutsForDll@4
|
||||
ntdll.dll LdrFindResource_U@16
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# $Id: makefile,v 1.16 2004/08/15 18:53:07 chorns Exp $
|
||||
# $Id: makefile,v 1.17 2004/10/23 21:05:11 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
TARGET_REGTESTS = yes
|
||||
|
||||
TARGET_TYPE = dynlink
|
||||
|
||||
TARGET_NAME = ws2_32
|
||||
|
|
9
reactos/lib/ws2_32/tests/.cvsignore
Normal file
9
reactos/lib/ws2_32/tests/.cvsignore
Normal file
|
@ -0,0 +1,9 @@
|
|||
_regtests.c
|
||||
_rtstub.c
|
||||
_hooks.c
|
||||
_stubs.S
|
||||
Makefile.tests
|
||||
*.d
|
||||
*.o
|
||||
*.a
|
||||
*.pch
|
19
reactos/lib/ws2_32/tests/Makefile
Normal file
19
reactos/lib/ws2_32/tests/Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = test
|
||||
|
||||
TARGET_NAME = regtests
|
||||
|
||||
TARGET_LIBPATH = .
|
||||
|
||||
TARGET_CFLAGS = -I$(REGTESTS_PATH_INC)
|
||||
|
||||
TARGET_LIBS = ../ws2_32.a
|
||||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = $(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
18
reactos/lib/ws2_32/tests/stubs.tst
Normal file
18
reactos/lib/ws2_32/tests/stubs.tst
Normal file
|
@ -0,0 +1,18 @@
|
|||
kernel32.dll CreateEventW@16
|
||||
kernel32.dll InitializeCriticalSection@4
|
||||
kernel32.dll DeleteCriticalSection@4
|
||||
kernel32.dll EnterCriticalSection@4
|
||||
kernel32.dll ExitProcess@4
|
||||
kernel32.dll FreeLibrary@4
|
||||
kernel32.dll GetLastError@0
|
||||
kernel32.dll GetProcAddress@8
|
||||
kernel32.dll GetProcessHeap@0
|
||||
ntdll.dll HeapAlloc@12=RtlAllocateHeap
|
||||
ntdll.dll HeapFree@12=RtlFreeHeap
|
||||
kernel32.dll LeaveCriticalSection@4
|
||||
kernel32.dll LoadLibraryW@4
|
||||
kernel32.dll lstrcpyA@8
|
||||
ntdll.dll ResetEvent@4
|
||||
ntdll.dll SetEvent@4
|
||||
ntdll.dll WaitForMultipleObjectsEx@20
|
||||
kernel32.dll CloseHandle@4
|
2
reactos/lib/ws2_32/tests/tests/.cvsignore
Normal file
2
reactos/lib/ws2_32/tests/tests/.cvsignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.d
|
||||
*.o
|
90
reactos/lib/ws2_32/tests/tests/WinsockEvent.c
Normal file
90
reactos/lib/ws2_32/tests/tests/WinsockEvent.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include "regtests.h"
|
||||
|
||||
#define TestHandle (HANDLE) 1
|
||||
|
||||
static BOOL CloseHandleSuccessCalled = FALSE;
|
||||
|
||||
static BOOL STDCALL
|
||||
MockCloseHandleSuccess(HANDLE hObject)
|
||||
{
|
||||
CloseHandleSuccessCalled = TRUE;
|
||||
_AssertEqualValue(TestHandle, hObject);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HOOK HooksSuccess[] =
|
||||
{
|
||||
{"CloseHandle", MockCloseHandleSuccess},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static void
|
||||
TestWSACloseEventSuccess()
|
||||
{
|
||||
BOOL result;
|
||||
|
||||
_SetHooks(HooksSuccess);
|
||||
result = WSACloseEvent(TestHandle);
|
||||
_AssertTrue(result);
|
||||
_AssertEqualValue(NO_ERROR, WSAGetLastError());
|
||||
_AssertTrue(CloseHandleSuccessCalled);
|
||||
_UnsetAllHooks();
|
||||
}
|
||||
|
||||
|
||||
static BOOL CloseHandleFailureCalled = FALSE;
|
||||
|
||||
static BOOL STDCALL
|
||||
MockCloseHandleFailure(HANDLE hObject)
|
||||
{
|
||||
CloseHandleFailureCalled = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HOOK HooksFailure[] =
|
||||
{
|
||||
{"CloseHandle", MockCloseHandleFailure},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static void
|
||||
TestWSACloseEventFailure()
|
||||
{
|
||||
BOOL result;
|
||||
|
||||
_SetHooks(HooksFailure);
|
||||
result = WSACloseEvent(TestHandle);
|
||||
_AssertFalse(result);
|
||||
_AssertEqualValue(WSA_INVALID_HANDLE, WSAGetLastError());
|
||||
_AssertTrue(CloseHandleFailureCalled);
|
||||
_UnsetAllHooks();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
TestWSACloseEvent()
|
||||
{
|
||||
TestWSACloseEventSuccess();
|
||||
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")
|
|
@ -1,14 +1,18 @@
|
|||
# $Id: Makefile,v 1.5 2004/10/18 19:11:07 chorns Exp $
|
||||
|
||||
PATH_TO_TOP = ..
|
||||
|
||||
all:
|
||||
$(MAKE) -C regtests all
|
||||
$(MAKE) -C shared all
|
||||
|
||||
implib:
|
||||
- $(MAKE) -C regtests implib
|
||||
|
||||
clean:
|
||||
- $(MAKE) -C regtests clean
|
||||
- $(MAKE) -C shared clean
|
||||
|
||||
install:
|
||||
$(MAKE) -C regtests install
|
||||
$(MAKE) -C shared install
|
||||
|
||||
.PHONY: all clean install
|
||||
|
|
11
reactos/regtests/regtests/.cvsignore
Executable file
11
reactos/regtests/regtests/.cvsignore
Executable file
|
@ -0,0 +1,11 @@
|
|||
temp.exp
|
||||
*.d
|
||||
*.a
|
||||
*.o
|
||||
*.dll
|
||||
*.coff
|
||||
*.sym
|
||||
*.tmp
|
||||
*.gch
|
||||
*.pch
|
||||
*.map
|
16
reactos/regtests/regtests/Makefile
Executable file
16
reactos/regtests/regtests/Makefile
Executable file
|
@ -0,0 +1,16 @@
|
|||
PATH_TO_TOP = ../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = dynlink
|
||||
|
||||
TARGET_NAME = regtests
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
regtests.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
28
reactos/regtests/regtests/regtests.c
Executable file
28
reactos/regtests/regtests/regtests.c
Executable file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: regtests/regtests/regtests.c
|
||||
* PURPOSE: Regression testing framework
|
||||
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* UPDATE HISTORY:
|
||||
* 23-10-2004 CSH Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
HMODULE STDCALL
|
||||
_GetModuleHandleA(LPCSTR lpModuleName)
|
||||
{
|
||||
return GetModuleHandleA(lpModuleName);
|
||||
}
|
||||
|
||||
FARPROC STDCALL
|
||||
_GetProcAddress(HMODULE hModule,
|
||||
LPCSTR lpProcName)
|
||||
{
|
||||
return GetProcAddress(hModule, lpProcName);
|
||||
}
|
||||
|
||||
HINSTANCE STDCALL
|
||||
_LoadLibraryA(LPCSTR lpLibFileName)
|
||||
{
|
||||
return LoadLibraryA(lpLibFileName);
|
||||
}
|
5
reactos/regtests/regtests/regtests.def
Normal file
5
reactos/regtests/regtests/regtests.def
Normal file
|
@ -0,0 +1,5 @@
|
|||
LIBRARY REGTESTS.DLL
|
||||
EXPORTS
|
||||
_GetModuleHandleA@4
|
||||
_GetProcAddress@8
|
||||
_LoadLibraryA@4
|
|
@ -23,22 +23,20 @@ char *_Buffer;
|
|||
|
||||
static LIST_ENTRY AllTests;
|
||||
|
||||
int
|
||||
DriverTest()
|
||||
void *_alloca(size_t size)
|
||||
{
|
||||
/* Dummy */
|
||||
return 0;
|
||||
void *ret;
|
||||
|
||||
asm ("movl %1, %%eax\n"
|
||||
"addl $3, %%eax\n"
|
||||
"andl $-4, %%eax\n"
|
||||
"subl %%eax, %%esp\n"
|
||||
"movl %%esp, %0\n"
|
||||
: "=m" (ret) : "m" (size) : "eax");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_regtestsTest()
|
||||
{
|
||||
/* Dummy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
InitializeTests()
|
||||
{
|
||||
|
@ -83,7 +81,7 @@ PerformTest(TestOutputRoutine OutputRoutine, PROS_TEST Test, LPSTR TestName)
|
|||
(Test->Routine)(TESTCMD_RUN);
|
||||
#ifdef SEH
|
||||
} __except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Result = TS_FAILED;
|
||||
_Result = TS_FAILED;
|
||||
strcpy(Buffer, "Failed due to exception");
|
||||
}
|
||||
#endif
|
||||
|
@ -128,7 +126,7 @@ AddTest(TestRoutine Routine)
|
|||
{
|
||||
PROS_TEST Test;
|
||||
|
||||
Test = (PROS_TEST) AllocateMemory(sizeof(ROS_TEST));
|
||||
Test = (PROS_TEST) malloc(sizeof(ROS_TEST));
|
||||
if (Test == NULL)
|
||||
{
|
||||
DbgPrint("Out of memory");
|
||||
|
@ -139,3 +137,9 @@ AddTest(TestRoutine Routine)
|
|||
|
||||
InsertTailList(&AllTests, &Test->ListEntry);
|
||||
}
|
||||
|
||||
PVOID STDCALL
|
||||
FrameworkGetHook(ULONG index)
|
||||
{
|
||||
return FrameworkGetHookInternal(index);
|
||||
}
|
||||
|
|
|
@ -50,35 +50,63 @@ AppendAssertion(char *message)
|
|||
_Result = TS_FAILED;
|
||||
}
|
||||
|
||||
#define _AssertTrue(_Condition) \
|
||||
{ \
|
||||
if (!(_Condition)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Condition was not true at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertFalse(_Condition) \
|
||||
{ \
|
||||
if (_Condition) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Condition was not false at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertEqualValue(_Expected, _Actual) \
|
||||
{ \
|
||||
if ((_Expected) != (_Actual)) \
|
||||
ULONG __Expected = (ULONG) (_Expected); \
|
||||
ULONG __Actual = (ULONG) (_Actual); \
|
||||
if ((__Expected) != (__Actual)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Expected %d/0x%.08x was %d/0x%.08x at %s:%d", \
|
||||
(_Expected), (_Expected), (_Actual), (_Actual), __FILE__, __LINE__); \
|
||||
(__Expected), (__Expected), (__Actual), (__Actual), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertEqualWideString(_Expected, _Actual) \
|
||||
{ \
|
||||
if (wcscmp((_Expected), (_Actual)) != 0) \
|
||||
LPWSTR __Expected = (LPWSTR) (_Expected); \
|
||||
LPWSTR __Actual = (LPWSTR) (_Actual); \
|
||||
if (wcscmp((__Expected), (__Actual)) != 0) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Expected %S was %S at %s:%d", \
|
||||
(_Expected), (_Actual), __FILE__, __LINE__); \
|
||||
(__Expected), (__Actual), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertNotEqualValue(_Expected, _Actual) \
|
||||
{ \
|
||||
if ((_Expected) == (_Actual)) \
|
||||
ULONG __Expected = (ULONG) (_Excepted); \
|
||||
ULONG __Actual = (ULONG) (_Actual); \
|
||||
if ((__Expected) == (__Actual)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Actual value expected to be different from %d/0x%.08x at %s:%d", \
|
||||
(_Expected), (_Expected), __FILE__, __LINE__); \
|
||||
(__Expected), (__Expected), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
@ -115,15 +143,12 @@ extern VOID InitializeTests();
|
|||
extern VOID RegisterTests();
|
||||
extern VOID PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName);
|
||||
|
||||
/* Routines provided by the driver */
|
||||
extern PVOID AllocateMemory(ULONG Size);
|
||||
extern VOID FreeMemory(PVOID Base);
|
||||
|
||||
|
||||
typedef struct _API_DESCRIPTION
|
||||
{
|
||||
PCHAR FileName;
|
||||
PCHAR FunctionName;
|
||||
PCHAR ForwardedFunctionName;
|
||||
PVOID FunctionAddress;
|
||||
PVOID MockFunctionAddress;
|
||||
} API_DESCRIPTION, *PAPI_DESCRIPTION;
|
||||
|
@ -131,33 +156,60 @@ typedef struct _API_DESCRIPTION
|
|||
extern API_DESCRIPTION ExternalDependencies[];
|
||||
extern ULONG MaxExternalDependency;
|
||||
|
||||
HMODULE STDCALL
|
||||
_GetModuleHandleA(LPCSTR lpModuleName);
|
||||
|
||||
FARPROC STDCALL
|
||||
_GetProcAddress(HMODULE hModule,
|
||||
LPCSTR lpProcName);
|
||||
|
||||
HINSTANCE STDCALL
|
||||
_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
|
||||
static inline PCHAR
|
||||
FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription)
|
||||
{
|
||||
if (ApiDescription->ForwardedFunctionName != NULL)
|
||||
{
|
||||
return ApiDescription->ForwardedFunctionName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApiDescription->FunctionName;
|
||||
}
|
||||
}
|
||||
|
||||
static inline PVOID
|
||||
FrameworkGetFunction(PAPI_DESCRIPTION ApiDescription)
|
||||
{
|
||||
HMODULE hModule;
|
||||
PVOID Function;
|
||||
PVOID function;
|
||||
PCHAR exportedFunctionName;
|
||||
|
||||
hModule = GetModuleHandleA(ApiDescription->FileName);
|
||||
exportedFunctionName = FrameworkGetExportedFunctionNameInternal(ApiDescription);
|
||||
|
||||
hModule = _GetModuleHandleA(ApiDescription->FileName);
|
||||
if (hModule != NULL)
|
||||
{
|
||||
Function = GetProcAddress(hModule, ApiDescription->FunctionName);
|
||||
function = _GetProcAddress(hModule, exportedFunctionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
hModule = LoadLibraryA(ApiDescription->FileName);
|
||||
hModule = _LoadLibraryA(ApiDescription->FileName);
|
||||
if (hModule != NULL)
|
||||
{
|
||||
Function = GetProcAddress(hModule, ApiDescription->FunctionName);
|
||||
function = _GetProcAddress(hModule, exportedFunctionName);
|
||||
//FreeLibrary(hModule);
|
||||
}
|
||||
}
|
||||
return Function;
|
||||
return function;
|
||||
}
|
||||
|
||||
static inline PVOID STDCALL
|
||||
static inline PVOID
|
||||
FrameworkGetHookInternal(ULONG index)
|
||||
{
|
||||
PVOID address;
|
||||
PCHAR exportedFunctionName;
|
||||
|
||||
if (index > MaxExternalDependency)
|
||||
return NULL;
|
||||
|
@ -168,8 +220,10 @@ FrameworkGetHookInternal(ULONG index)
|
|||
if (ExternalDependencies[index].FunctionAddress != NULL)
|
||||
return ExternalDependencies[index].FunctionAddress;
|
||||
|
||||
exportedFunctionName = FrameworkGetExportedFunctionNameInternal(&ExternalDependencies[index]);
|
||||
|
||||
printf("Calling function '%s' in DLL '%s'.\n",
|
||||
ExternalDependencies[index].FunctionName,
|
||||
exportedFunctionName,
|
||||
ExternalDependencies[index].FileName);
|
||||
|
||||
address = FrameworkGetFunction(&ExternalDependencies[index]);
|
||||
|
@ -177,7 +231,7 @@ FrameworkGetHookInternal(ULONG index)
|
|||
if (address == NULL)
|
||||
{
|
||||
printf("Function '%s' not found in DLL '%s'.\n",
|
||||
ExternalDependencies[index].FunctionName,
|
||||
exportedFunctionName,
|
||||
ExternalDependencies[index].FileName);
|
||||
}
|
||||
ExternalDependencies[index].FunctionAddress = address;
|
||||
|
@ -193,7 +247,7 @@ _SetHook(PCHAR name,
|
|||
PAPI_DESCRIPTION api;
|
||||
ULONG index;
|
||||
|
||||
for (index = 0; index < MaxExternalDependency; index++)
|
||||
for (index = 0; index <= MaxExternalDependency; index++)
|
||||
{
|
||||
api = &ExternalDependencies[index];
|
||||
if (strcmp(api->FunctionName, name) == 0)
|
||||
|
@ -244,7 +298,7 @@ _UnsetAllHooks()
|
|||
PAPI_DESCRIPTION api;
|
||||
ULONG index;
|
||||
|
||||
for (index = 0; index < MaxExternalDependency; index++)
|
||||
for (index = 0; index <= MaxExternalDependency; index++)
|
||||
{
|
||||
api = &ExternalDependencies[index];
|
||||
api->MockFunctionAddress = NULL;
|
||||
|
|
|
@ -178,5 +178,5 @@ export OS2_PATH_LIB=$(OS2_PATH)/lib
|
|||
export OS2_PATH_INC=$(OS2_PATH)/include
|
||||
|
||||
# Other systems integration
|
||||
export ROOT_PATH=$(PATH_TO_TOP)/..
|
||||
export REGTESTS_PATH=$(PATH_TO_TOP)/regtests
|
||||
export REGTESTS_PATH_INC=$(PATH_TO_TOP)/regtests/shared
|
||||
|
|
|
@ -14,12 +14,7 @@ TARGET_LIBS = ../win32k.a
|
|||
|
||||
-include Makefile.tests
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
_rtstub.o \
|
||||
_regtests.o \
|
||||
_hooks.o \
|
||||
_stubs.o \
|
||||
$(addprefix tests/, $(TESTS))
|
||||
TARGET_OBJECTS = $(addprefix tests/, $(TESTS))
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: helper.mk,v 1.90 2004/10/21 18:04:48 arty Exp $
|
||||
# $Id: helper.mk,v 1.91 2004/10/23 21:05:12 chorns Exp $
|
||||
#
|
||||
# Helper makefile for ReactOS modules
|
||||
# Variables this makefile accepts:
|
||||
|
@ -371,6 +371,7 @@ ifeq ($(TARGET_TYPE),test)
|
|||
MK_BOOTCDDIR := system32
|
||||
MK_DISTDIR := # none
|
||||
MK_RES_BASE :=
|
||||
TARGET_OBJECTS := _rtstub.o _regtests.o $(TARGET_OBJECTS)
|
||||
endif
|
||||
|
||||
|
||||
|
@ -661,6 +662,10 @@ MK_NOSTRIPNAME := $(MK_BASENAME).nostrip$(MK_EXT)
|
|||
|
||||
MK_EXTRADEP := $(filter %.h,$(TARGET_OBJECTS))
|
||||
|
||||
ifeq ($(TARGET_TYPE),test)
|
||||
MK_EXTRADEP += _stubs.o _hooks.o
|
||||
endif
|
||||
|
||||
# We don't want to link header files
|
||||
MK_OBJECTS := $(filter-out %.h,$(TARGET_OBJECTS))
|
||||
|
||||
|
@ -876,8 +881,8 @@ endif # MK_MODE
|
|||
# Static library target
|
||||
ifeq ($(MK_MODE),static)
|
||||
|
||||
$(MK_FULLNAME): $(TARGET_OBJECTS)
|
||||
$(AR) -r $(MK_FULLNAME) $(TARGET_OBJECTS)
|
||||
$(MK_FULLNAME): $(MK_EXTRADEP) $(MK_OBJECTS)
|
||||
$(AR) -r $(MK_FULLNAME) $(MK_OBJECTS)
|
||||
@echo $(MK_BASENAME)$(MK_EXT) was successfully built.
|
||||
|
||||
# Static libraries dont have a nostrip version
|
||||
|
@ -1017,7 +1022,7 @@ endif
|
|||
|
||||
REGTEST_TESTS = $(wildcard tests/tests/*.c)
|
||||
|
||||
$(REGTEST_TARGETS): $(REGTEST_TESTS)
|
||||
$(REGTEST_TARGETS): $(REGTEST_TESTS) ./tests/stubs.tst
|
||||
$(REGTESTS) ./tests/tests ./tests/_regtests.c ./tests/Makefile.tests -e ./tests/_rtstub.c
|
||||
$(REGTESTS) -s ./tests/stubs.tst ./tests/_stubs.S ./tests/_hooks.c
|
||||
|
||||
|
@ -1064,8 +1069,11 @@ endif
|
|||
|
||||
ifeq ($(TARGET_TYPE),test)
|
||||
run: all
|
||||
@$(CC) -o _runtest.exe _rtstub.o regtests.a $(SDK_PATH_LIB)/rtshared.a $(TARGET_LIBS) -lntdll
|
||||
@$(CC) -nostdlib -o _runtest.exe regtests.a $(TARGET_LIBS) _stubs.o \
|
||||
$(SDK_PATH_LIB)/rtshared.a $(SDK_PATH_LIB)/regtests.a _hooks.o -lmsvcrt -lntdll
|
||||
@$(CP) $(REGTESTS_PATH)/regtests/regtests.dll regtests.dll
|
||||
@_runtest.exe
|
||||
@$(RM) regtests.dll
|
||||
@$(RM) _runtest.exe
|
||||
endif
|
||||
|
||||
|
|
|
@ -515,23 +515,18 @@ static char UMSTUB[] =
|
|||
static char EXESTUB[] =
|
||||
"/* This file is autogenerated. */\n"
|
||||
"\n"
|
||||
"#include <stdio.h>\n"
|
||||
"#include <windows.h>\n"
|
||||
"#define NTOS_MODE_USER\n"
|
||||
"#include <ntos.h>\n"
|
||||
"#include \"regtests.h\"\n"
|
||||
"\n"
|
||||
"PVOID\n"
|
||||
"AllocateMemory(ULONG Size)\n"
|
||||
"{\n"
|
||||
" return (PVOID) RtlAllocateHeap(RtlGetProcessHeap(), 0, Size);\n"
|
||||
"}\n"
|
||||
"#if defined(__USE_W32API)\n"
|
||||
" #define HANDLE PVOID\n"
|
||||
" #define NTSTATUS ULONG\n"
|
||||
"\n"
|
||||
"VOID\n"
|
||||
"FreeMemory(PVOID Base)\n"
|
||||
"{\n"
|
||||
" RtlFreeHeap(RtlGetProcessHeap(), 0, Base);\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"
|
||||
|
@ -540,7 +535,10 @@ static char EXESTUB[] =
|
|||
"}\n"
|
||||
"\n"
|
||||
"int\n"
|
||||
"main()\n"
|
||||
"mainCRTStartup(HANDLE hInstance,\n"
|
||||
" HANDLE hPrevInstance,\n"
|
||||
" LPSTR lpszCmdParam,\n"
|
||||
" int nCmdShow)\n"
|
||||
"{\n"
|
||||
" InitializeTests();\n"
|
||||
" RegisterTests();\n"
|
||||
|
@ -573,13 +571,7 @@ static char HOOKS_FOOTER[] =
|
|||
"};\n"
|
||||
"\n"
|
||||
"#define ExternalDependencyCount %d\n"
|
||||
"ULONG MaxExternalDependency = ExternalDependencyCount - 1;\n"
|
||||
"\n"
|
||||
"PVOID STDCALL\n"
|
||||
"FrameworkGetHook(ULONG index)\n"
|
||||
"{\n"
|
||||
" return FrameworkGetHookInternal(index);\n"
|
||||
"}\n";
|
||||
"ULONG MaxExternalDependency = ExternalDependencyCount - 1;\n";
|
||||
|
||||
static char HELP[] =
|
||||
"REGTESTS path file makefile [-u umstubfile] [-k kmstubfile] [-e exestubfile]\n"
|
||||
|
@ -616,7 +608,7 @@ write_hooks_footer(FILE *hooks_out, unsigned long nr_stubs)
|
|||
}
|
||||
|
||||
char *
|
||||
get_undecorate_name(char *buf,
|
||||
get_undecorated_name(char *buf,
|
||||
char *decoratedname)
|
||||
{
|
||||
int start = 0;
|
||||
|
@ -639,20 +631,56 @@ get_undecorate_name(char *buf,
|
|||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
write_stub(FILE *stubs_out, FILE *hooks_out, char *dllname,
|
||||
char *decoratedname, unsigned int stub_index)
|
||||
char *
|
||||
get_forwarded_export(char *forwardedexport)
|
||||
{
|
||||
char buf[300];
|
||||
|
||||
if (forwardedexport == NULL)
|
||||
{
|
||||
strcpy(buf, "NULL");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buf, "\"%s\"", forwardedexport);
|
||||
}
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
void
|
||||
write_stub(FILE *stubs_out, FILE *hooks_out, char *dllname,
|
||||
char *decoratedname_and_forward, unsigned int stub_index)
|
||||
{
|
||||
char buf[300];
|
||||
char *p;
|
||||
char *decoratedname = NULL;
|
||||
char *forwardedexport = NULL;
|
||||
|
||||
p = strtok(decoratedname_and_forward, "=");
|
||||
if (p != NULL)
|
||||
{
|
||||
decoratedname = p;
|
||||
|
||||
p = strtok(NULL, "=");
|
||||
forwardedexport = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
decoratedname = decoratedname_and_forward;
|
||||
forwardedexport = decoratedname_and_forward;
|
||||
}
|
||||
|
||||
fprintf(stubs_out, ".globl _%s\n", decoratedname);
|
||||
fprintf(stubs_out, "_%s:\n", decoratedname);
|
||||
fprintf(stubs_out, " pushl $%d\n", stub_index);
|
||||
fprintf(stubs_out, " jmp passthrough\n");
|
||||
fprintf(stubs_out, "\n");
|
||||
|
||||
fprintf(hooks_out, " {\"%s\", \"%s\", NULL, NULL},\n",
|
||||
dllname, get_undecorate_name(buf, decoratedname));
|
||||
forwardedexport = get_forwarded_export(forwardedexport);
|
||||
fprintf(hooks_out, " {\"%s\", \"%s\", %s, NULL, NULL},\n",
|
||||
dllname,
|
||||
get_undecorated_name(buf, decoratedname),
|
||||
forwardedexport);
|
||||
free(forwardedexport);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -664,7 +692,7 @@ create_stubs_and_hooks(
|
|||
char line[INPUT_BUFFER_SIZE];
|
||||
char *s;
|
||||
char *dllname;
|
||||
char *decoratedname;
|
||||
char *decoratedname_and_forward;
|
||||
int stub_index;
|
||||
|
||||
write_stubs_header(stubs_out);
|
||||
|
@ -679,13 +707,14 @@ create_stubs_and_hooks(
|
|||
* DLLNAME (e.g. ntdll.dll)
|
||||
* DECORATED NAME (e.g. NtCreateProcess@32, @InterlockedIncrement@4 or printf)
|
||||
*/
|
||||
stub_index = 0; /* First stub has index zero */
|
||||
|
||||
for (
|
||||
/* First stub has index zero */
|
||||
stub_index = 0;
|
||||
;
|
||||
/* Go on until EOF or read zero bytes */
|
||||
((!feof(in)) && (fgets(line, sizeof line, in) != NULL));
|
||||
/* Next stub index */
|
||||
stub_index++)
|
||||
)
|
||||
{
|
||||
/*
|
||||
* Remove, if present, the trailing LF.
|
||||
|
@ -709,16 +738,24 @@ create_stubs_and_hooks(
|
|||
s = & line[0];
|
||||
if ((*s) != '#' && (*s) != '\0')
|
||||
{
|
||||
/* Extract the DLL name */
|
||||
dllname = (char *) strtok(s," \t");
|
||||
/* Extract the decorated function name */
|
||||
decoratedname = (char *) strtok(NULL," \t");
|
||||
/* Extract the argument count */
|
||||
write_stub(stubs_out, hooks_out, dllname, decoratedname, stub_index);
|
||||
/* Extract the DLL name */
|
||||
dllname = (char *) strtok(s, " \t");
|
||||
if (dllname != NULL && strlen(dllname) > 0)
|
||||
{
|
||||
/*
|
||||
* Extract the decorated function name and possibly forwarded export.
|
||||
* Format:
|
||||
* decoratedname=forwardedexport (no DLL name)
|
||||
*/
|
||||
decoratedname_and_forward = (char *) strtok(NULL, " \t");
|
||||
/* Extract the argument count */
|
||||
write_stub(stubs_out, hooks_out, dllname, decoratedname_and_forward, stub_index);
|
||||
stub_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
write_hooks_footer(hooks_out, stub_index + 1);
|
||||
write_hooks_footer(hooks_out, stub_index);
|
||||
}
|
||||
|
||||
int run_stubs(int argc,
|
||||
|
|
Loading…
Reference in a new issue