[ROSAUTOTEST] Add /t parameter for repeating tests
authorVictor Perevertkin <victor.perevertkin@reactos.org>
Mon, 18 May 2020 02:42:53 +0000 (05:42 +0300)
committerVictor Perevertkin <victor@perevertkin.ru>
Tue, 23 Jun 2020 23:40:18 +0000 (02:40 +0300)
modules/rostests/rosautotest/CConfiguration.cpp
modules/rostests/rosautotest/CConfiguration.h
modules/rostests/rosautotest/main.cpp

index 95f95ca..f7e880d 100644 (file)
@@ -19,6 +19,7 @@ CConfiguration::CConfiguration()
     : m_CrashRecovery(false),
       m_IsInteractive(false),
       m_PrintToConsole(true),
     : m_CrashRecovery(false),
       m_IsInteractive(false),
       m_PrintToConsole(true),
+      m_RepeatCount(1),
       m_Shutdown(false),
       m_Submit(false)
 {
       m_Shutdown(false),
       m_Submit(false)
 {
@@ -52,10 +53,17 @@ CConfiguration::ParseParameters(int argc, wchar_t* argv[])
     {
         if(argv[i][0] == '-' || argv[i][0] == '/')
         {
     {
         if(argv[i][0] == '-' || argv[i][0] == '/')
         {
+            unsigned long tmp_RepeatCount;
+
             switch(argv[i][1])
             {
                 case 'c':
                     ++i;
             switch(argv[i][1])
             {
                 case 'c':
                     ++i;
+                    if (i >= argc)
+                    {
+                        throw CInvalidParameterException();
+                    }
+
                     m_Comment = UnicodeToAscii(argv[i]);
                     break;
 
                     m_Comment = UnicodeToAscii(argv[i]);
                     break;
 
@@ -75,6 +83,23 @@ CConfiguration::ParseParameters(int argc, wchar_t* argv[])
                     m_Submit = true;
                     break;
 
                     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();
             }
                 default:
                     throw CInvalidParameterException();
             }
index a6a6a94..4359f75 100644 (file)
@@ -12,6 +12,7 @@ private:
     bool m_IsInteractive;
     bool m_IsReactOS;
     bool m_PrintToConsole;
     bool m_IsInteractive;
     bool m_IsReactOS;
     bool m_PrintToConsole;
+    unsigned long m_RepeatCount;
     bool m_Shutdown;
     bool m_Submit;
     string m_Comment;
     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; }
     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; }
     const string& GetComment() const { return m_Comment; }
     const wstring& GetModule() const { return m_Module; }
     const string& GetTest() const { return m_Test; }
index 9c728d8..5061d7d 100644 (file)
@@ -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
          << "                   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 <num>     - Repeat the test <num> 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
          << "    /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[])
 {
 extern "C" int
 wmain(int argc, wchar_t* argv[])
 {
-    CWineTest WineTest;
     int ReturnValue = 1;
 
     try
     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());
            << "[ROSAUTOTEST] System uptime " << setprecision(2) << fixed;
         ss << ((float)GetTickCount()/1000) << " seconds" << endl;
         StringOut(ss.str());
-        
+
         /* Report tests startup */
         InitLogs();
         ReportEventW(hLog,
         /* Report tests startup */
         InitLogs();
         ReportEventW(hLog,
@@ -77,8 +77,27 @@ wmain(int argc, wchar_t* argv[])
                       NULL,
                       NULL);
 
                       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 */
         /* 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");
 
         /* For sysreg2 */
         DbgPrint("SYSREG_CHECKPOINT:THIRDBOOT_COMPLETE\n");