@@ -630,7 +630,6 @@ public int RunReliabilityTests(string testConfig, bool doReplay)
630
630
return ( 99 ) ;
631
631
}
632
632
633
- #if ! PROJECTK_BUILD
634
633
[ DllImport ( "kernel32.dll" ) ]
635
634
private extern static void DebugBreak ( ) ;
636
635
@@ -639,7 +638,6 @@ public int RunReliabilityTests(string testConfig, bool doReplay)
639
638
640
639
[ DllImport ( "kernel32.dll" ) ]
641
640
private extern static void OutputDebugString ( string debugStr ) ;
642
- #endif
643
641
644
642
/// <summary>
645
643
/// Checks to see if we should block all execution due to a fatal error
@@ -661,20 +659,11 @@ private static void NoExitPoll()
661
659
}
662
660
internal static void MyDebugBreak ( string extraData )
663
661
{
664
- #if ! PROJECTK_BUILD
665
662
if ( IsDebuggerPresent ( ) )
666
663
{
667
- OutputDebugString ( String . Format ( "\r \n \r \n \r \n RELIABILITYFRAMEWORK DEBUGBREAK: Breaking in because test throw an exception ( {0}) \r \n \r \n \r \n " , extraData ) ) ;
664
+ Console . WriteLine ( string . Format ( "DebugBreak: {0}" , extraData ) ) ;
668
665
DebugBreak ( ) ;
669
666
}
670
- else
671
- #else
672
- if ( Debugger . IsAttached )
673
- {
674
- Console . WriteLine ( string . Format ( "DebugBreak: breaking in because test threw an exception: {0}" , extraData ) ) ;
675
- Debugger . Break ( ) ;
676
- }
677
- #endif
678
667
{
679
668
// We need to stop the process now,
680
669
// but all the threads are still running
@@ -1081,25 +1070,46 @@ private void TestSetShutdown(int totalTestsToRun)
1081
1070
_logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1082
1071
Console . WriteLine ( msg ) ;
1083
1072
1073
+ int secondsIter = 5 ;
1084
1074
int waitCnt = 0 ;
1085
- while ( _testsRunningCount > 0 && waitCnt < 7200 ) // wait a max of 2 hours for the tests to exit...
1086
- {
1087
- Thread . Sleep ( 1000 ) ;
1088
- Console . Write ( "\b \b \b \b {0,4}" , _testsRunningCount ) ;
1075
+ int waitCntTotal = _curTestSet . MaximumWaitTime * 60 / secondsIter ;
1076
+ msg = String . Format ( "START WAITING for {0}s" , _curTestSet . MaximumWaitTime * 60 ) ;
1077
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1078
+ long lastAllocatedBytes = GC . GetTotalAllocatedBytes ( false ) ;
1079
+ while ( _testsRunningCount > 0 && waitCnt < waitCntTotal )
1080
+ {
1081
+ Thread . Sleep ( secondsIter * 1000 ) ;
1082
+ long currentAllocatedBytes = GC . GetTotalAllocatedBytes ( false ) ;
1083
+ msg = String . Format ( "============current number of tests running {0,4}, allocated {1:n0} so far, {2:n0} since last; (GC {3}:{4}:{5}), waited {6}s" ,
1084
+ _testsRunningCount , currentAllocatedBytes , ( currentAllocatedBytes - lastAllocatedBytes ) ,
1085
+ GC . CollectionCount ( 0 ) ,
1086
+ GC . CollectionCount ( 1 ) ,
1087
+ GC . CollectionCount ( 2 ) ,
1088
+ ( waitCnt * secondsIter ) ) ;
1089
+ lastAllocatedBytes = currentAllocatedBytes ;
1090
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1091
+
1092
+ for ( int i = 0 ; i < _curTestSet . Tests . Length ; i ++ )
1093
+ {
1094
+ if ( _curTestSet . Tests [ i ] . RunningCount != 0 )
1095
+ {
1096
+ msg = String . Format ( "Still running: {0}" , _curTestSet . Tests [ i ] . RefOrID ) ;
1097
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1098
+ }
1099
+ }
1089
1100
waitCnt ++ ;
1090
1101
}
1091
1102
}
1092
1103
1093
1104
// let the user know what tests haven't finished...
1094
1105
if ( _testsRunningCount != 0 )
1095
1106
{
1096
- string msg ;
1097
-
1107
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , "************Timeout reached************" ) ;
1098
1108
for ( int i = 0 ; i < _curTestSet . Tests . Length ; i ++ )
1099
1109
{
1100
1110
if ( _curTestSet . Tests [ i ] . RunningCount != 0 )
1101
1111
{
1102
- msg = String . Format ( "Still running: {0}" , _curTestSet . Tests [ i ] . RefOrID ) ;
1112
+ string msg = String . Format ( "Still running: {0}" , _curTestSet . Tests [ i ] . RefOrID ) ;
1103
1113
_logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1104
1114
Console . WriteLine ( msg ) ;
1105
1115
AddFailure ( "Test Hang" , _curTestSet . Tests [ i ] , - 1 ) ;
@@ -1116,6 +1126,9 @@ private void TestSetShutdown(int totalTestsToRun)
1116
1126
[ MethodImpl ( MethodImplOptions . NoInlining ) ]
1117
1127
private void TestIsHungDebugBreak ( )
1118
1128
{
1129
+ string msg = String . Format ( "break" ) ;
1130
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1131
+
1119
1132
MyDebugBreak ( "TestHang" ) ;
1120
1133
}
1121
1134
@@ -1165,7 +1178,8 @@ private void StartTest(ReliabilityTest test)
1165
1178
1166
1179
Interlocked . Increment ( ref _testsRunningCount ) ;
1167
1180
test . TestStarted ( ) ;
1168
- _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . TestStarter , String . Format ( "RF.StartTest, RTs({0}) - Instances of this test: {1} - New Test:{2}" , _testsRunningCount , test . RunningCount , test . RefOrID ) ) ;
1181
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . TestStarter , String . Format ( "RF.StartTest, RTs({0}) - Instances of this test: {1} - New Test:{2}, {3} threads" ,
1182
+ _testsRunningCount , test . RunningCount , test . RefOrID , Process . GetCurrentProcess ( ) . Threads . Count ) ) ;
1169
1183
1170
1184
newThread . Start ( test ) ;
1171
1185
}
@@ -1207,7 +1221,11 @@ private void StartTestWorker(object test)
1207
1221
#if PROJECTK_BUILD
1208
1222
Task . Factory . StartNew ( ( ) =>
1209
1223
{
1210
- Console . WriteLine ( "==============================running test: {0}==============================" , daTest . Assembly ) ;
1224
+ string msg = String . Format ( "==============================[tid: {0, 4}, running test: {1} STATUS: START, {2} tests running {3} threads ==============================" ,
1225
+ Thread . CurrentThread . ManagedThreadId , daTest . Assembly , _testsRunningCount ,
1226
+ Process . GetCurrentProcess ( ) . Threads . Count ) ;
1227
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1228
+
1211
1229
try
1212
1230
{
1213
1231
daTest . EntryPointMethod . Invoke ( null , new object [ ] { ( daTest . Arguments == null ) ? new string [ 0 ] : daTest . GetSplitArguments ( ) } ) ;
@@ -1220,6 +1238,10 @@ private void StartTestWorker(object test)
1220
1238
1221
1239
Console . WriteLine ( e ) ;
1222
1240
}
1241
+ msg = String . Format ( "==============================[tid: {0, 4}, running test: {1} STATUS: DONE, {2} tests running {3} threads ==============================" ,
1242
+ Thread . CurrentThread . ManagedThreadId , daTest . Assembly , _testsRunningCount ,
1243
+ Process . GetCurrentProcess ( ) . Threads . Count ) ;
1244
+ _logger . WriteToInstrumentationLog ( _curTestSet , LoggingLevels . StartupShutdown , msg ) ;
1223
1245
Interlocked . Increment ( ref _testsRanCount ) ;
1224
1246
SignalTestFinished ( daTest ) ;
1225
1247
} ) ;
0 commit comments