Skip to content

Commit 7afcd2a

Browse files
Doug-LyonsHBelusca
andauthored
[ROSAUTOTEST] Allow rosautotest to be in the same directory as its files and show its duration at the end. (reactos#7823)
Example output: [ROSAUTOTEST] System uptime 7.41 seconds ... Testing here... [ROSAUTOTEST] System uptime at start was 7.41 seconds [ROSAUTOTEST] System uptime at end was 1546.20 seconds [ROSAUTOTEST] Duration was 25.65 minutes Co-authored-by: Hermès BÉLUSCA - MAÏTO <[email protected]>
1 parent d66ad21 commit 7afcd2a

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

modules/rostests/rosautotest/CWineTest.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,27 @@ CWineTest::GetNextFile()
6464
WIN32_FIND_DATAW fd;
6565

6666
/* Did we already begin searching for files? */
67-
if(m_hFind)
67+
if (m_hFind)
6868
{
6969
/* Then get the next file (if any) */
70-
if(FindNextFileW(m_hFind, &fd))
71-
FoundFile = true;
70+
if (FindNextFileW(m_hFind, &fd))
71+
{
72+
// printf("cFileName is '%S'.\n", fd.cFileName);
73+
/* If it was NOT rosautotest.exe then proceed as normal */
74+
if (_wcsicmp(fd.cFileName, TestName) != 0)
75+
{
76+
FoundFile = true;
77+
}
78+
else
79+
{
80+
/* It was rosautotest.exe so get the next file (if any) */
81+
if (FindNextFileW(m_hFind, &fd))
82+
{
83+
FoundFile = true;
84+
}
85+
// printf("cFileName is '%S'.\n", fd.cFileName);
86+
}
87+
}
7288
}
7389
else
7490
{
@@ -91,8 +107,25 @@ CWineTest::GetNextFile()
91107
/* Search for the first file and check whether we got one */
92108
m_hFind = FindFirstFileW(FindPath.c_str(), &fd);
93109

94-
if(m_hFind != INVALID_HANDLE_VALUE)
95-
FoundFile = true;
110+
/* If we returned a good handle */
111+
if (m_hFind != INVALID_HANDLE_VALUE)
112+
{
113+
// printf("cFileName is '%S'.\n", fd.cFileName);
114+
/* If it was NOT rosautotest.exe then proceed as normal */
115+
if (_wcsicmp(fd.cFileName, TestName) != 0)
116+
{
117+
FoundFile = true;
118+
}
119+
else
120+
{
121+
/* It was rosautotest.exe so get the next file (if any) */
122+
if (FindNextFileW(m_hFind, &fd))
123+
{
124+
FoundFile = true;
125+
}
126+
// printf("cFileName is '%S'.\n", fd.cFileName);
127+
}
128+
}
96129
}
97130

98131
if(FoundFile)

modules/rostests/rosautotest/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <ndk/setypes.h>
1111
#include <ndk/exfuncs.h>
1212

13+
WCHAR TestName[MAX_PATH];
14+
1315
CConfiguration Configuration;
1416

1517
/**
@@ -87,6 +89,14 @@ extern "C" int
8789
wmain(int argc, wchar_t* argv[])
8890
{
8991
int ReturnValue = 1;
92+
DWORD TestStartTime, TestEndTime;
93+
94+
GetModuleFileNameW(NULL, TestName, _countof(TestName));
95+
// printf("Full TestName is '%S'\n", TestName);
96+
WCHAR* Name = wcsrchr(TestName, '\\');
97+
if (Name)
98+
memmove(TestName, Name + 1, (wcslen(Name + 1) + 1) * sizeof(WCHAR));
99+
// printf("Short TestName is '%S'.\n", TestName);
90100

91101
SetNtGlobalFlags();
92102

@@ -99,6 +109,7 @@ wmain(int argc, wchar_t* argv[])
99109
Configuration.GetSystemInformation();
100110
Configuration.GetConfigurationFromFile();
101111

112+
TestStartTime = GetTickCount();
102113
ss << endl
103114
<< endl
104115
<< "[ROSAUTOTEST] System uptime " << setprecision(2) << fixed;
@@ -139,6 +150,23 @@ wmain(int argc, wchar_t* argv[])
139150
WineTest.Run();
140151
}
141152

153+
/* Clear the stringstream */
154+
ss.str("");
155+
ss.clear();
156+
157+
/* Show the beginning time again */
158+
ss << "[ROSAUTOTEST] System uptime at start was " << setprecision(2) << fixed;
159+
ss << ((float)TestStartTime / 1000) << " seconds" << endl;
160+
161+
/* Show the time now so that we can see how long the tests took */
162+
TestEndTime = GetTickCount();
163+
ss << endl
164+
<< "[ROSAUTOTEST] System uptime at end was " << setprecision(2) << fixed;
165+
ss << ((float)TestEndTime / 1000) << " seconds" << endl;
166+
ss << "[ROSAUTOTEST] Duration was " << (((float)TestEndTime - (float)TestStartTime) / 1000) / 60;
167+
ss << " minutes" << endl;
168+
StringOut(ss.str());
169+
142170
/* For sysreg2 */
143171
DbgPrint("SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE\n");
144172

modules/rostests/rosautotest/precomp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,6 @@ string StringOut(const string& String, bool forcePrint = true);
8080
string UnicodeToAscii(PCWSTR UnicodeString);
8181
string UnicodeToAscii(const wstring& UnicodeString);
8282

83+
extern WCHAR TestName[MAX_PATH];
84+
8385
#endif /* _ROSAUTOTEST_H_ */

0 commit comments

Comments
 (0)