[ROSAUTOTEST]
authorThomas Faber <thomas.faber@reactos.org>
Tue, 23 Jun 2015 10:06:38 +0000 (10:06 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Tue, 23 Jun 2015 10:06:38 +0000 (10:06 +0000)
- Flush cout after each write as already done by Colin in r66855, per ROSTESTS-158
- Use DbgPrint instead of OutputDebugStringA again because the latter only calls the former anyway
Fixes test summary lines not being recognized by Testman, especially on VMware.

A little summary so we don't keep going back and forth with this function:
1) Only writing complete lines is required to that the output doesn't mix with debug output from other components. See r55618
2) OutputDebugStringA splits its input into 512-byte-sized blocks with no regard for line breaks, so using it with strings larger than 512 bytes breaks (1).
3) OutputDebugStringA eventually calls DbgPrint("%s", string) anyway so using it with chunks smaller than 512 bytes is not an optimization
As a result, yes this function MUST split up the lines itself, this can't be optimized or simplified away! kthxbye
ROSTESTS-178 #resolve

svn path=/trunk/; revision=68246

rostests/rosautotest/tools.cpp

index c925c14..b5276ba 100644 (file)
@@ -2,7 +2,7 @@
  * PROJECT:     ReactOS Automatic Testing Utility
  * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
  * PURPOSE:     Various helper functions
  * PROJECT:     ReactOS Automatic Testing Utility
  * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
  * PURPOSE:     Various helper functions
- * COPYRIGHT:   Copyright 2008-2009 Colin Finck <colin@reactos.org>
+ * COPYRIGHT:   Copyright 2008-2015 Colin Finck <colin@reactos.org>
  */
 
 #include "precomp.h"
  */
 
 #include "precomp.h"
@@ -136,7 +136,7 @@ StringOut(const string& String, bool forcePrint)
                 }
 
                 DbgString[size] = 0;
                 }
 
                 DbgString[size] = 0;
-                OutputDebugStringA(DbgString);
+                DbgPrint("%s", DbgString);
             }
 
             last_newline = curr_pos;
             }
 
             last_newline = curr_pos;
@@ -150,11 +150,11 @@ StringOut(const string& String, bool forcePrint)
     {
         /* Output the whole string */
         if(Configuration.DoPrint())
     {
         /* Output the whole string */
         if(Configuration.DoPrint())
-            cout << NewString;
+            cout << NewString << flush;
 
         memcpy(DbgString, NewString.c_str() + start, size);
         DbgString[size] = 0;
 
         memcpy(DbgString, NewString.c_str() + start, size);
         DbgString[size] = 0;
-        OutputDebugStringA(DbgString);
+        DbgPrint("%s", DbgString);
 
         NewString.clear();
         return NewString;
 
         NewString.clear();
         return NewString;
@@ -162,7 +162,7 @@ StringOut(const string& String, bool forcePrint)
 
     /* Output full lines only */
     if(Configuration.DoPrint())
 
     /* Output full lines only */
     if(Configuration.DoPrint())
-        cout << NewString.substr(0, start);
+        cout << NewString.substr(0, start) << flush;
 
     /* Return the remaining chunk */
     return NewString.substr(start, size);
 
     /* Return the remaining chunk */
     return NewString.substr(start, size);