mirror of
https://github.com/reactos/reactos.git
synced 2024-10-31 03:48:17 +00:00
Show execution time of tests
svn path=/trunk/; revision=15876
This commit is contained in:
parent
4f0032f8d7
commit
45a93411a7
|
@ -54,3 +54,35 @@ _WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
return WaitForSingleObject(hHandle, dwMilliseconds);
|
return WaitForSingleObject(hHandle, dwMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD STDCALL
|
||||||
|
_GetLastError()
|
||||||
|
{
|
||||||
|
return GetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
_CloseHandle(HANDLE handle)
|
||||||
|
{
|
||||||
|
CloseHandle (handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime,
|
||||||
|
LPFILETIME lpExitTime, LPFILETIME lpKernelTime,
|
||||||
|
LPFILETIME lpUserTime)
|
||||||
|
{
|
||||||
|
return GetThreadTimes(hThread, lpCreationTime, lpExitTime,
|
||||||
|
lpKernelTime, lpUserTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_SetPriorityClass(HANDLE hProcess, DWORD dwPriorityClass)
|
||||||
|
{
|
||||||
|
return SetPriorityClass(hProcess, dwPriorityClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_SetThreadPriority(HANDLE hThread, int nPriority)
|
||||||
|
{
|
||||||
|
return SetThreadPriority(hThread, nPriority);
|
||||||
|
}
|
||||||
|
|
|
@ -7,3 +7,8 @@ _LoadLibraryA@4
|
||||||
_CreateThread@24
|
_CreateThread@24
|
||||||
_TerminateThread@8
|
_TerminateThread@8
|
||||||
_WaitForSingleObject@8
|
_WaitForSingleObject@8
|
||||||
|
_GetLastError@0
|
||||||
|
_CloseHandle@4
|
||||||
|
_GetThreadTimes@20
|
||||||
|
_SetPriorityClass@8
|
||||||
|
_SetThreadPriority@8
|
||||||
|
|
|
@ -37,6 +37,17 @@ InitializeTests()
|
||||||
InitializeListHead(&AllTests);
|
InitializeListHead(&AllTests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
FormatExecutionTime(char *buffer, LPFILETIME time)
|
||||||
|
{
|
||||||
|
ULONG milliseconds = time->dwLowDateTime / 10000;
|
||||||
|
|
||||||
|
sprintf(buffer,
|
||||||
|
"%ldms",
|
||||||
|
milliseconds);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
PerformTest(PVOID _arg)
|
PerformTest(PVOID _arg)
|
||||||
{
|
{
|
||||||
|
@ -44,11 +55,18 @@ PerformTest(PVOID _arg)
|
||||||
TestOutputRoutine OutputRoutine = Args->OutputRoutine;
|
TestOutputRoutine OutputRoutine = Args->OutputRoutine;
|
||||||
PROS_TEST Test = Args->Test;
|
PROS_TEST Test = Args->Test;
|
||||||
LPSTR TestName = Args->TestName;
|
LPSTR TestName = Args->TestName;
|
||||||
|
HANDLE hThread;
|
||||||
|
FILETIME time;
|
||||||
|
FILETIME ExecutionTime;
|
||||||
char OutputBuffer[5000];
|
char OutputBuffer[5000];
|
||||||
char Buffer[5000];
|
char Buffer[5000];
|
||||||
|
char Format[100];
|
||||||
|
|
||||||
|
hThread = GetCurrentThread();
|
||||||
|
_SetThreadPriority(hThread, THREAD_PRIORITY_IDLE);
|
||||||
|
|
||||||
memset(Buffer, 0, sizeof(Buffer));
|
memset(Buffer, 0, sizeof(Buffer));
|
||||||
|
|
||||||
_SEH_TRY {
|
_SEH_TRY {
|
||||||
_Result = TS_OK;
|
_Result = TS_OK;
|
||||||
_Buffer = Buffer;
|
_Buffer = Buffer;
|
||||||
|
@ -58,22 +76,30 @@ PerformTest(PVOID _arg)
|
||||||
sprintf(Buffer, "due to exception 0x%lx", _SEH_GetExceptionCode());
|
sprintf(Buffer, "due to exception 0x%lx", _SEH_GetExceptionCode());
|
||||||
} _SEH_END;
|
} _SEH_END;
|
||||||
|
|
||||||
if (_Result != TS_OK)
|
if (_Result == TS_OK)
|
||||||
{
|
{
|
||||||
|
if (!_GetThreadTimes(hThread,
|
||||||
|
&time,
|
||||||
|
&time,
|
||||||
|
&time,
|
||||||
|
&ExecutionTime))
|
||||||
|
{
|
||||||
|
ExecutionTime.dwLowDateTime = 10;
|
||||||
|
ExecutionTime.dwHighDateTime = 10;
|
||||||
|
}
|
||||||
|
sprintf(OutputBuffer,
|
||||||
|
"[%s] Success [%s]\n",
|
||||||
|
TestName,
|
||||||
|
FormatExecutionTime(Format,
|
||||||
|
&ExecutionTime));
|
||||||
|
}
|
||||||
|
else
|
||||||
sprintf(OutputBuffer, "[%s] Failed (%s)\n", TestName, Buffer);
|
sprintf(OutputBuffer, "[%s] Failed (%s)\n", TestName, Buffer);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(OutputBuffer, "[%s] Success\n", TestName);
|
|
||||||
}
|
|
||||||
if (OutputRoutine != NULL)
|
if (OutputRoutine != NULL)
|
||||||
{
|
|
||||||
(*OutputRoutine)(OutputBuffer);
|
(*OutputRoutine)(OutputBuffer);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
DbgPrint(OutputBuffer);
|
DbgPrint(OutputBuffer);
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,19 +134,12 @@ PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName)
|
||||||
if (_Result != TS_OK)
|
if (_Result != TS_OK)
|
||||||
{
|
{
|
||||||
if (TestName != NULL)
|
if (TestName != NULL)
|
||||||
{
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
strcpy(Name, "Unnamed");
|
strcpy(Name, "Unnamed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestName != NULL)
|
if ((TestName != NULL) && (_stricmp(Name, TestName) != 0))
|
||||||
{
|
continue;
|
||||||
if (_stricmp(Name, TestName) != 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get timeout for test */
|
/* Get timeout for test */
|
||||||
TimeOut = 0;
|
TimeOut = 0;
|
||||||
|
@ -128,44 +147,34 @@ PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName)
|
||||||
_Buffer = (char *)&TimeOut;
|
_Buffer = (char *)&TimeOut;
|
||||||
(Current->Routine)(TESTCMD_TIMEOUT);
|
(Current->Routine)(TESTCMD_TIMEOUT);
|
||||||
if (_Result != TS_OK || TimeOut == INFINITE)
|
if (_Result != TS_OK || TimeOut == INFINITE)
|
||||||
{
|
|
||||||
TimeOut = 5000;
|
TimeOut = 5000;
|
||||||
}
|
|
||||||
|
|
||||||
/* Run test in thread */
|
/* Run test in thread */
|
||||||
hThread = _CreateThread(NULL, 0, PerformTest, (PVOID)&Args, 0, NULL);
|
hThread = _CreateThread(NULL, 0, PerformTest, (PVOID)&Args, 0, NULL);
|
||||||
if (hThread == NULL)
|
if (hThread == NULL)
|
||||||
{
|
|
||||||
sprintf(OutputBuffer,
|
sprintf(OutputBuffer,
|
||||||
"[%s] Failed (CreateThread failed: 0x%x)\n",
|
"[%s] Failed (CreateThread() failed: %d)\n",
|
||||||
Name, (unsigned int)GetLastError());
|
Name, (unsigned int)_GetLastError());
|
||||||
}
|
|
||||||
else if (_WaitForSingleObject(hThread, TimeOut) == WAIT_TIMEOUT)
|
else if (_WaitForSingleObject(hThread, TimeOut) == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
if (!_TerminateThread(hThread, 0))
|
if (!_TerminateThread(hThread, 0))
|
||||||
{
|
|
||||||
sprintf(OutputBuffer,
|
sprintf(OutputBuffer,
|
||||||
"[%s] Failed (Test timed out - %d ms, TerminateThread failed: 0x%x)\n",
|
"[%s] Failed (timed out after %dms; TerminateThread() failed: %d)\n",
|
||||||
Name, (int)TimeOut, (unsigned int)GetLastError());
|
Name, (int)TimeOut, (unsigned int)_GetLastError());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
sprintf(OutputBuffer, "[%s] Failed (timed out after %dms)\n", Name, (int)TimeOut);
|
||||||
sprintf(OutputBuffer, "[%s] Failed (Test timed out - %d ms)\n", Name, (int)TimeOut);
|
_CloseHandle(hThread);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_CloseHandle(hThread);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutputRoutine != NULL)
|
if (OutputRoutine != NULL)
|
||||||
{
|
|
||||||
(*OutputRoutine)(OutputBuffer);
|
(*OutputRoutine)(OutputBuffer);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
DbgPrint(OutputBuffer);
|
DbgPrint(OutputBuffer);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,23 @@ _TerminateThread(HANDLE hThread, DWORD dwExitCode);
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
|
_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
|
||||||
|
|
||||||
|
DWORD STDCALL
|
||||||
|
_GetLastError();
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
_CloseHandle(HANDLE handle);
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime,
|
||||||
|
LPFILETIME lpExitTime, LPFILETIME lpKernelTime,
|
||||||
|
LPFILETIME lpUserTime);
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_SetPriorityClass(HANDLE hProcess, DWORD dwPriorityClass);
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
_SetThreadPriority(HANDLE hThread, int nPriority);
|
||||||
|
|
||||||
|
|
||||||
static inline PCHAR
|
static inline PCHAR
|
||||||
FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription)
|
FrameworkGetExportedFunctionNameInternal(PAPI_DESCRIPTION ApiDescription)
|
||||||
|
|
|
@ -608,7 +608,7 @@ MingwBackend::GenerateRegTestsRunTarget () const
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"REGTESTS_RUN_TARGET = regtests.dll\n" );
|
"REGTESTS_RUN_TARGET = regtests.dll\n" );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"$(REGTESTS_RUN_TARGET):\n" );
|
"$(REGTESTS_RUN_TARGET): $(REGTESTS_TARGET)\n" );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
|
"\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
|
||||||
fprintf ( fMakefile, "\n" );
|
fprintf ( fMakefile, "\n" );
|
||||||
|
|
|
@ -333,6 +333,7 @@ TestSupportCode::WriteStartupFile ( Module& module )
|
||||||
s = s + sprintf ( s, " LPSTR lpszCmdParam,\n" );
|
s = s + sprintf ( s, " LPSTR lpszCmdParam,\n" );
|
||||||
s = s + sprintf ( s, " int nCmdShow)\n" );
|
s = s + sprintf ( s, " int nCmdShow)\n" );
|
||||||
s = s + sprintf ( s, "{\n" );
|
s = s + sprintf ( s, "{\n" );
|
||||||
|
s = s + sprintf ( s, " _SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);\n" );
|
||||||
s = s + sprintf ( s, " InitializeTests();\n" );
|
s = s + sprintf ( s, " InitializeTests();\n" );
|
||||||
s = s + sprintf ( s, " RegisterTests();\n" );
|
s = s + sprintf ( s, " RegisterTests();\n" );
|
||||||
s = s + sprintf ( s, " SetupOnce();\n" );
|
s = s + sprintf ( s, " SetupOnce();\n" );
|
||||||
|
|
Loading…
Reference in a new issue