diff --git a/reactos/ChangeLog b/reactos/ChangeLog index df43974f9f6..eac5847234c 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,29 @@ +2004-03-09 Casper S. Hornstrup + + * regtests/Makefile: Make REGTEST_TARGETS depend on *.c. + * regtests/kmregtests/driver.c: Update call to PerformTests(). + * regtests/kmrtint/kmrtint.c (RegTestMain): Update to match prototype. + * regtests/kmrtint/kmrtint.def (RegTestMain): Ditto. + * regtests/kmrtint/kmrtint.edf (RegTestMain): Ditto. + * regtests/win32base/tests/ws2event.c: New file. + * regtests/regtests/regtests.c (OUPUT_MODE_DbgPrint, + OUPUT_MODE_OutputDebugString, OUPUT_MODE_printf): Define. + (OutputMode): New variable. + (OutputRoutine): New function. + (RunTestDriver): Add TestName parameter. + (main): Parse command line to find output routine and test name. + * regtests/shared/regtests.c (PerformTest): Use specified output routine + if specified. Run only specified test if specified. + (PerformTests): Update call to PerformTest(). + * regtests/shared/regtests.h (TestOutputRoutine): Add prototype. + (TestDriverMain): Add OutputRoutine and TestName parameter. + (PerformTests): Ditto. + * regtests/win32base/Makefile (TARGET_SDKLIBS): Add ws2_32.a. + * regtests/win32base/driver.c (RegTestMain): Update to match prototype. + * regtests/win32base/win32base.def (RegTestMain): Ditto. + * regtests/win32base/win32base.edf (RegTestMain): Ditto. + * tools/regtests.c (UMSTUB): Update call to PerformTests(). + 2004-03-04 Casper S. Hornstrup * drivers/net/tcpip/tcpip/i386: New directory. diff --git a/reactos/regtests/Makefile b/reactos/regtests/Makefile index 2ee5211edd2..958a95a6141 100755 --- a/reactos/regtests/Makefile +++ b/reactos/regtests/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.3 2004/02/22 18:53:39 dwelch Exp $ +# $Id: Makefile,v 1.4 2004/03/09 22:08:04 chorns Exp $ PATH_TO_TOP = .. @@ -27,7 +27,7 @@ install: $(MAKE) -C kmrtint install $(MAKE) -C regtests install -$(REGTEST_TARGETS): kmregtests/tests/* win32base/tests/* +$(REGTEST_TARGETS): kmregtests/tests/*.c win32base/tests/*.c $(REGTESTS) ./kmregtests/tests ./kmregtests/_regtests.c ./kmregtests/Makefile.tests $(REGTESTS) ./win32base/tests ./win32base/_regtests.c ./win32base/Makefile.tests diff --git a/reactos/regtests/kmregtests/driver.c b/reactos/regtests/kmregtests/driver.c index 4a2e50fffa6..b031d8604ac 100755 --- a/reactos/regtests/kmregtests/driver.c +++ b/reactos/regtests/kmregtests/driver.c @@ -60,7 +60,7 @@ KMRegTestsRun( PIRP Irp, PIO_STACK_LOCATION IrpSp) { - PerformTests(); + PerformTests(NULL, NULL); ShutdownBochs(); Irp->IoStatus.Status = STATUS_SUCCESS; diff --git a/reactos/regtests/kmrtint/kmrtint.c b/reactos/regtests/kmrtint/kmrtint.c index a336c8c8ac1..e14ac0fb0d7 100755 --- a/reactos/regtests/kmrtint/kmrtint.c +++ b/reactos/regtests/kmrtint/kmrtint.c @@ -53,7 +53,7 @@ OpenDevice() } VOID STDCALL -RegTestMain() +RegTestMain(TestOutputRoutine OutputRoutine, LPSTR TestName) { IO_STATUS_BLOCK Iosb; HANDLE DeviceHandle; diff --git a/reactos/regtests/kmrtint/kmrtint.def b/reactos/regtests/kmrtint/kmrtint.def index 4f915f52c53..39fa60a6217 100755 --- a/reactos/regtests/kmrtint/kmrtint.def +++ b/reactos/regtests/kmrtint/kmrtint.def @@ -1,3 +1,3 @@ LIBRARY kmrtint.dll EXPORTS -RegTestMain@0 +RegTestMain@8 diff --git a/reactos/regtests/kmrtint/kmrtint.edf b/reactos/regtests/kmrtint/kmrtint.edf index 031c73fecb9..9a41aad4e41 100755 --- a/reactos/regtests/kmrtint/kmrtint.edf +++ b/reactos/regtests/kmrtint/kmrtint.edf @@ -1,3 +1,3 @@ LIBRARY kmrtint.dll EXPORTS -RegTestMain=RegTestMain@0 +RegTestMain=RegTestMain@8 diff --git a/reactos/regtests/regtests/regtests.c b/reactos/regtests/regtests/regtests.c index 5380d20a661..40b0fb80e1a 100755 --- a/reactos/regtests/regtests/regtests.c +++ b/reactos/regtests/regtests/regtests.c @@ -7,11 +7,34 @@ * 06-07-2003 CSH Created */ #define NTOS_MODE_USER +#include #include #include "regtests.h" -VOID -RunTestDriver(LPTSTR FileName) +#define OUPUT_MODE_DbgPrint 0 +#define OUPUT_MODE_OutputDebugString 1 +#define OUPUT_MODE_printf 2 + +static int OutputMode = 0; + +static void OutputRoutine(char *Buffer) +{ + if (OutputMode == OUPUT_MODE_DbgPrint) + { + DbgPrint(Buffer); + } + else if (OutputMode == OUPUT_MODE_OutputDebugString) + { + OutputDebugString(Buffer); + } + else if (OutputMode == OUPUT_MODE_printf) + { + printf(Buffer); + } +} + +static VOID +RunTestDriver(LPSTR FileName, LPSTR TestName) { TestDriverMain Main; HMODULE hModule; @@ -20,9 +43,9 @@ RunTestDriver(LPTSTR FileName) if (hModule != NULL) { Main = (TestDriverMain) GetProcAddress(hModule, "RegTestMain"); - if (Main != NULL) + if (Main != NULL) { - (Main)(); + (Main)(OutputRoutine, TestName); } FreeLibrary(hModule); } @@ -31,7 +54,36 @@ RunTestDriver(LPTSTR FileName) int main(int argc, char* argv[]) { - RunTestDriver("win32base.dll"); - RunTestDriver("kmrtint.dll"); + LPSTR testname = NULL; + int i; + + if (argc > 1) + { + i = 1; + if (argv[i][0] == '-') + { + switch (argv[i][1]) + { + case 'd': + OutputMode = OUPUT_MODE_DbgPrint; + break; + case 'o': + OutputMode = OUPUT_MODE_OutputDebugString; + break; + case 'p': + OutputMode = OUPUT_MODE_printf; + break; + default: + printf("Usage: regtests [-dop] [testname]"); + return 0; + } + i++; + } + + testname = argv[i]; + } + + RunTestDriver("win32base.dll", testname); + RunTestDriver("kmrtint.dll", testname); return 0; } diff --git a/reactos/regtests/shared/regtests.c b/reactos/regtests/shared/regtests.c index 952c45afc6b..232ba362f94 100755 --- a/reactos/regtests/shared/regtests.c +++ b/reactos/regtests/shared/regtests.c @@ -7,6 +7,7 @@ * 06-07-2003 CSH Created */ #include +#include #define NTOS_MODE_USER #include #include "regtests.h" @@ -40,18 +41,31 @@ InitializeTests() } VOID -PerformTest(PROS_TEST Test) +PerformTest(TestOutputRoutine OutputRoutine, PROS_TEST Test, LPSTR TestName) { - char TestName[200]; + char OutputBuffer[200]; char Buffer[200]; + char Name[200]; int Result; - memset(TestName, 0, sizeof(TestName)); + memset(Name, 0, sizeof(Name)); memset(Buffer, 0, sizeof(Buffer)); - if (!((Test->Routine)(TESTCMD_TESTNAME, TestName) == 0)) + if (!((Test->Routine)(TESTCMD_TESTNAME, Name) == 0)) { - strcpy(TestName, "Unnamed"); + if (TestName != NULL) + { + return; + } + strcpy(Name, "Unnamed"); + } + + if (TestName != NULL) + { + if (_stricmp(Name, TestName) != 0) + { + return; + } } #ifdef SEH @@ -67,16 +81,24 @@ PerformTest(PROS_TEST Test) if (Result != TS_OK) { - DbgPrint("ROSREGTEST: (%s) Status: Failed (%s)\n", TestName, Buffer); + sprintf(OutputBuffer, "ROSREGTEST: (%s) Status: Failed (%s)\n", Name, Buffer); } else { - DbgPrint("ROSREGTEST: (%s) Status: Success\n", TestName); + sprintf(OutputBuffer, "ROSREGTEST: (%s) Status: Success\n", Name); + } + if (OutputRoutine != NULL) + { + (*OutputRoutine)(OutputBuffer); + } + else + { + DbgPrint(OutputBuffer); } } VOID -PerformTests() +PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName) { PLIST_ENTRY CurrentEntry; PLIST_ENTRY NextEntry; @@ -87,7 +109,7 @@ PerformTests() { NextEntry = CurrentEntry->Flink; Current = CONTAINING_RECORD(CurrentEntry, ROS_TEST, ListEntry); - PerformTest(Current); + PerformTest(OutputRoutine, Current, TestName); CurrentEntry = NextEntry; } } diff --git a/reactos/regtests/shared/regtests.h b/reactos/regtests/shared/regtests.h index 4d75575b92c..96572c4e5d0 100755 --- a/reactos/regtests/shared/regtests.h +++ b/reactos/regtests/shared/regtests.h @@ -24,8 +24,18 @@ */ typedef int (*TestRoutine)(int Command, char *Buffer); -/* Test driver entry routine */ -typedef VOID STDCALL (*TestDriverMain)(); +/* + * Test output routine prototype + * Buffer - Address of buffer with text to output + */ +typedef void (*TestOutputRoutine)(char *Buffer); + +/* + * Test driver entry routine. +* OutputRoutine - Output routine. + * TestName - If NULL all tests are run. If non-NULL specifies the test to be run + */ +typedef void STDCALL (*TestDriverMain)(TestOutputRoutine OutputRoutine, char *TestName); typedef struct _ROS_TEST { @@ -37,7 +47,7 @@ extern LIST_ENTRY AllTests; extern VOID InitializeTests(); extern VOID RegisterTests(); -extern VOID PerformTests(); +extern VOID PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName); /* Routines provided by the driver */ extern PVOID AllocateMemory(ULONG Size); diff --git a/reactos/regtests/win32base/Makefile b/reactos/regtests/win32base/Makefile index 99e3806ae87..ec482903ad2 100755 --- a/reactos/regtests/win32base/Makefile +++ b/reactos/regtests/win32base/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.3 2003/12/07 11:34:41 chorns Exp $ +# $Id: Makefile,v 1.4 2004/03/09 22:08:04 chorns Exp $ PATH_TO_TOP = ../.. @@ -8,7 +8,7 @@ TARGET_TYPE = dynlink TARGET_NAME = win32base -TARGET_SDKLIBS = rtshared.a ntdll.a kernel32.a +TARGET_SDKLIBS = rtshared.a ntdll.a kernel32.a ws2_32.a TARGET_CFLAGS = -I../shared -Wall -Werror diff --git a/reactos/regtests/win32base/driver.c b/reactos/regtests/win32base/driver.c index 7680e96f7d7..9b043d3adc2 100755 --- a/reactos/regtests/win32base/driver.c +++ b/reactos/regtests/win32base/driver.c @@ -55,15 +55,15 @@ RunPrivateTests(LPTSTR FileName) /* * The module is a core OS component that is already * mapped into the current process. - * NOTE: This will cause all core OS components that are already mapped - * into the process to run their regression tests. + * NOTE: This will cause all core OS components that are already mapped + * into the process to run their regression tests. */ hThread = CreateThread(NULL, 0, DummyThreadMain, NULL, 0, NULL); if (hThread != NULL) { DWORD ErrorCode; - ErrorCode = WaitForSingleObject(hEvent, 5000); /* Wait up to 5 seconds */ - CloseHandle(hThread); + ErrorCode = WaitForSingleObject(hEvent, 5000); /* Wait up to 5 seconds */ + CloseHandle(hThread); } } else @@ -81,12 +81,13 @@ RunPrivateTests(LPTSTR FileName) VOID STDCALL -RegTestMain() +RegTestMain(TestOutputRoutine OutputRoutine, LPSTR TestName) { /* * Private module regression tests in components already mapped * (ntdll.dll, kernel32.dll, msvcrt.dll) */ + /* FIXME: Need to pass TestName to the driver */ RunPrivateTests(_T("ntdll.dll")); /* Other private module regression tests */ @@ -94,5 +95,5 @@ RegTestMain() /* Cross-module regression tests */ InitializeTests(); RegisterTests(); - PerformTests(); + PerformTests(OutputRoutine, TestName); } diff --git a/reactos/regtests/win32base/tests/ws2event.c b/reactos/regtests/win32base/tests/ws2event.c new file mode 100644 index 00000000000..5619c10522c --- /dev/null +++ b/reactos/regtests/win32base/tests/ws2event.c @@ -0,0 +1,127 @@ +#include +#include +#include + +#include "regtests.h" + +static int RunTest(char *Buffer) +{ + const WSAEVENT* lphEvents; + WORD wVersionRequested; + WSAEVENT hEvent; + WSADATA wsaData; + DWORD ErrorCode; + int startup; + + /* Require WinSock 2.0 or later */ + wVersionRequested = MAKEWORD(2, 0); + startup = WSAStartup(wVersionRequested, &wsaData); + if (startup != 0) + { + sprintf(Buffer, "WSAStartup() failed with status %d", startup); + return TS_FAILED; + } + + /* Check if the WinSock version is 2.0 */ + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 0) + { + strcpy(Buffer, "Winsock dll version is not 2.0 or higher"); + WSACleanup(); + return TS_FAILED; + } + + /* Create an event */ + hEvent = WSACreateEvent(); + if (hEvent == WSA_INVALID_EVENT) + { + sprintf(Buffer, "WSACreateEvent() failed with status %d", WSAGetLastError()); + WSACleanup(); + return TS_FAILED; + } + + /* Check that the state of the event defaults to non-signalled */ + lphEvents = &hEvent; + ErrorCode = WSAWaitForMultipleEvents(1, + lphEvents, + FALSE, + 0, + FALSE); + if (ErrorCode != WSA_WAIT_TIMEOUT) + { + sprintf(Buffer, "WSAWaitForMultipleEvents() has bad status %ld (should be WSA_WAIT_TIMEOUT (%ld))", + ErrorCode, WSA_WAIT_TIMEOUT); + WSACleanup(); + return TS_FAILED; + } + + if (!WSASetEvent(hEvent)) + { + sprintf(Buffer, "WSASetEvent() failed with status %d", WSAGetLastError()); + WSACleanup(); + return TS_FAILED; + } + + /* Check that the state of the event is now signalled */ + lphEvents = &hEvent; + ErrorCode = WSAWaitForMultipleEvents(1, + lphEvents, + FALSE, + 0, + FALSE); + if (ErrorCode != WSA_WAIT_EVENT_0) + { + sprintf(Buffer, "WSAWaitForMultipleEvents() has bad status %ld (should be WSA_WAIT_EVENT_0 (%ld))", + ErrorCode, WSA_WAIT_EVENT_0); + WSACleanup(); + return TS_FAILED; + } + + if (!WSAResetEvent(hEvent)) + { + sprintf(Buffer, "WSAResetEvent() failed with status %d", WSAGetLastError()); + WSACleanup(); + return TS_FAILED; + } + + /* Check that the state of the event is now non-signalled */ + lphEvents = &hEvent; + ErrorCode = WSAWaitForMultipleEvents(1, + lphEvents, + FALSE, + 0, + FALSE); + if (ErrorCode != WSA_WAIT_TIMEOUT) + { + /*sprintf(Buffer, "WSAWaitForMultipleEvents() now has bad status %d (should be WSA_WAIT_TIMEOUT (%d))", + ErrorCode, WSA_WAIT_TIMEOUT);*/ + WSACleanup(); + return TS_FAILED; + } + + if (!WSACloseEvent(hEvent)) + { + sprintf(Buffer, "WSACloseEvent() failed with status %d", WSAGetLastError()); + WSACleanup(); + return TS_FAILED; + } + + WSACleanup(); + + return TS_OK; +} + +int +Ws2eventTest(int Command, char *Buffer) +{ + switch (Command) + { + case TESTCMD_RUN: + return RunTest(Buffer); + case TESTCMD_TESTNAME: + strcpy(Buffer, "Winsock 2 event"); + return TS_OK; + default: + break; + } + return TS_FAILED; +} diff --git a/reactos/regtests/win32base/win32base.def b/reactos/regtests/win32base/win32base.def index acb9dd17905..40c09bb895b 100755 --- a/reactos/regtests/win32base/win32base.def +++ b/reactos/regtests/win32base/win32base.def @@ -1,3 +1,3 @@ LIBRARY win32base.dll EXPORTS -RegTestMain@0 +RegTestMain@8 diff --git a/reactos/regtests/win32base/win32base.edf b/reactos/regtests/win32base/win32base.edf index ec7a45280ad..2bc277a1afd 100755 --- a/reactos/regtests/win32base/win32base.edf +++ b/reactos/regtests/win32base/win32base.edf @@ -1,3 +1,3 @@ LIBRARY win32base.dll EXPORTS -RegTestMain=RegTestMain@0 +RegTestMain=RegTestMain@8 diff --git a/reactos/tools/regtests.c b/reactos/tools/regtests.c index ea28f56913b..b763a822b6d 100755 --- a/reactos/tools/regtests.c +++ b/reactos/tools/regtests.c @@ -480,7 +480,7 @@ static char UMSTUB[] = " testsRegistered = 1;\n" " InitializeTests();\n" " RegisterTests();\n" - " PerformTests();\n" + " PerformTests(NULL, NULL);\n" " }\n" " }\n" "}\n";