From d230f8829c7bf1235dc00074c55be5cafa130e15 Mon Sep 17 00:00:00 2001 From: Victor Perevertkin Date: Mon, 18 May 2020 05:42:53 +0300 Subject: [PATCH] [ROSAUTOTEST] Add /t parameter for repeating tests --- .../rostests/rosautotest/CConfiguration.cpp | 25 +++++++++++++++++++ modules/rostests/rosautotest/CConfiguration.h | 2 ++ modules/rostests/rosautotest/main.cpp | 25 ++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/modules/rostests/rosautotest/CConfiguration.cpp b/modules/rostests/rosautotest/CConfiguration.cpp index 95f95cac55c..f7e880d8221 100644 --- a/modules/rostests/rosautotest/CConfiguration.cpp +++ b/modules/rostests/rosautotest/CConfiguration.cpp @@ -19,6 +19,7 @@ CConfiguration::CConfiguration() : m_CrashRecovery(false), m_IsInteractive(false), m_PrintToConsole(true), + m_RepeatCount(1), m_Shutdown(false), m_Submit(false) { @@ -52,10 +53,17 @@ CConfiguration::ParseParameters(int argc, wchar_t* argv[]) { if(argv[i][0] == '-' || argv[i][0] == '/') { + unsigned long tmp_RepeatCount; + switch(argv[i][1]) { case 'c': ++i; + if (i >= argc) + { + throw CInvalidParameterException(); + } + m_Comment = UnicodeToAscii(argv[i]); break; @@ -75,6 +83,23 @@ CConfiguration::ParseParameters(int argc, wchar_t* argv[]) m_Submit = true; break; + case 't': + ++i; + if (i >= argc) + { + throw CInvalidParameterException(); + } + + tmp_RepeatCount = wcstoul(argv[i], NULL, 10); + + if (tmp_RepeatCount == 0 || tmp_RepeatCount > 10000) + { + throw CInvalidParameterException(); + } + + m_RepeatCount = tmp_RepeatCount; + break; + default: throw CInvalidParameterException(); } diff --git a/modules/rostests/rosautotest/CConfiguration.h b/modules/rostests/rosautotest/CConfiguration.h index a6a6a948796..4359f751dd2 100644 --- a/modules/rostests/rosautotest/CConfiguration.h +++ b/modules/rostests/rosautotest/CConfiguration.h @@ -12,6 +12,7 @@ private: bool m_IsInteractive; bool m_IsReactOS; bool m_PrintToConsole; + unsigned long m_RepeatCount; bool m_Shutdown; bool m_Submit; string m_Comment; @@ -33,6 +34,7 @@ public: bool DoSubmit() const { return m_Submit; } bool IsInteractive() const { return m_IsInteractive; } bool IsReactOS() const { return m_IsReactOS; } + unsigned long GetRepeatCount() const { return m_RepeatCount; } const string& GetComment() const { return m_Comment; } const wstring& GetModule() const { return m_Module; } const string& GetTest() const { return m_Test; } diff --git a/modules/rostests/rosautotest/main.cpp b/modules/rostests/rosautotest/main.cpp index 9c728d8d494..5061d7d664c 100644 --- a/modules/rostests/rosautotest/main.cpp +++ b/modules/rostests/rosautotest/main.cpp @@ -28,6 +28,7 @@ IntPrintUsage() << " Can only be run under ReactOS and relies on sysreg2," << endl << " so incompatible with /w" << endl << " /s - Shut down the system after finishing the tests." << endl + << " /t - Repeat the test times (1-10000)" << endl << " /w - Submit the results to the webservice." << endl << " Requires a \"rosautotest.ini\" with valid login data." << endl << " Incompatible with the /r option." << endl @@ -47,7 +48,6 @@ IntPrintUsage() extern "C" int wmain(int argc, wchar_t* argv[]) { - CWineTest WineTest; int ReturnValue = 1; try @@ -64,7 +64,7 @@ wmain(int argc, wchar_t* argv[]) << "[ROSAUTOTEST] System uptime " << setprecision(2) << fixed; ss << ((float)GetTickCount()/1000) << " seconds" << endl; StringOut(ss.str()); - + /* Report tests startup */ InitLogs(); ReportEventW(hLog, @@ -77,8 +77,27 @@ wmain(int argc, wchar_t* argv[]) NULL, NULL); + if (Configuration.GetRepeatCount() > 1) + { + stringstream ss1; + + ss1 << "[ROSAUTOTEST] The test will be repeated " << Configuration.GetRepeatCount() << " times" << endl; + StringOut(ss1.str()); + } + /* Run the tests */ - WineTest.Run(); + for (unsigned long i = 0; i < Configuration.GetRepeatCount(); i++) + { + CWineTest WineTest; + + if (Configuration.GetRepeatCount() > 1) + { + stringstream ss; + ss << "[ROSAUTOTEST] Running attempt #" << i+1 << endl; + StringOut(ss.str()); + } + WineTest.Run(); + } /* For sysreg2 */ DbgPrint("SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE\n"); -- 2.17.1