@@ -52,9 +52,14 @@ public static int TestEntryPoint()
5252 return - 1 ;
5353 }
5454
55- string traceFilePath = Path . GetTempFileName ( ) ;
56- File . Delete ( traceFilePath ) ; // record-trace requires the output file to not exist
57- traceFilePath = Path . ChangeExtension ( traceFilePath , ".nettrace" ) ;
55+ string traceFilePath = Path . Combine ( appBaseDir , "trace.nettrace" ) ; // Path.GetTempFileName();
56+ string helixWorkItemDirectory = Environment . GetEnvironmentVariable ( "HELIX_WORKITEM_UPLOAD_ROOT" ) ;
57+ if ( helixWorkItemDirectory != null && Directory . Exists ( helixWorkItemDirectory ) )
58+ {
59+ traceFilePath = Path . Combine ( helixWorkItemDirectory , "trace.nettrace" ) ;
60+ }
61+ // File.Delete(traceFilePath); // record-trace requires the output file to not exist
62+ // traceFilePath = Path.ChangeExtension(traceFilePath, ".nettrace");
5863
5964 ProcessStartInfo recordTraceStartInfo = new ( ) ;
6065 recordTraceStartInfo . FileName = "sudo" ;
@@ -112,7 +117,7 @@ public static int TestEntryPoint()
112117 traceeProcess . BeginErrorReadLine ( ) ;
113118
114119 Console . WriteLine ( $ "Waiting for tracee process to exit...") ;
115- if ( ! traceeProcess . HasExited && ! traceeProcess . WaitForExit ( 5000 ) )
120+ if ( ! traceeProcess . HasExited && ! traceeProcess . WaitForExit ( 15000 ) )
116121 {
117122 Console . WriteLine ( $ "Tracee process did not exit within the 5s timeout, killing it.") ;
118123 traceeProcess . Kill ( ) ;
@@ -125,7 +130,7 @@ public static int TestEntryPoint()
125130 Console . WriteLine ( $ "Stopping record-trace with SIGINT.") ;
126131 Kill ( recordTraceProcess . Id , SIGINT ) ;
127132 Console . WriteLine ( $ "Waiting for record-trace to exit...") ;
128- if ( ! recordTraceProcess . WaitForExit ( 20000 ) )
133+ if ( ! recordTraceProcess . WaitForExit ( 30000 ) )
129134 {
130135 // record-trace needs to stop gracefully to generate the trace file
131136 Console . WriteLine ( $ "record-trace did not exit within the 20s timeout, killing it.") ;
@@ -147,7 +152,7 @@ public static int TestEntryPoint()
147152 if ( ! ValidateTraceeEvents ( traceFilePath ) )
148153 {
149154 Console . Error . WriteLine ( $ "Trace file `{ traceFilePath } ` does not contain expected events.") ;
150- UploadTraceFile ( traceFilePath ) ;
155+ // UploadTraceFile(traceFilePath);
151156 return - 1 ;
152157 }
153158
@@ -157,21 +162,32 @@ public static int TestEntryPoint()
157162 private static bool ValidateTraceeEvents ( string traceFilePath )
158163 {
159164 using EventPipeEventSource source = new EventPipeEventSource ( traceFilePath ) ;
165+ bool startEventFound = false ;
166+ bool stopEventFound = false ;
160167 bool allocationSampledEventFound = false ;
161168
162169 source . Dynamic . All += ( TraceEvent e ) =>
163170 {
164171 if ( e . ProviderName == "Microsoft-Windows-DotNETRuntime" )
165172 {
166- if ( e . EventName == "AllocationSampled" || ( e . ID == ( TraceEventID ) 303 && e . EventName . StartsWith ( "Unknown" ) ) )
173+ Console . WriteLine ( $ "Event: { e . ProviderName } - { e . EventName } (ID: { e . ID } )") ;
174+ if ( e . EventName == "GC/Start" || ( e . ID == ( TraceEventID ) 1 && e . EventName . StartsWith ( "Unknown" ) ) )
175+ {
176+ startEventFound = true ;
177+ }
178+ else if ( e . EventName == "GC/Stop" || ( e . ID == ( TraceEventID ) 2 && e . EventName . StartsWith ( "Unknown" ) ) )
179+ {
180+ stopEventFound = true ;
181+ }
182+ else if ( e . EventName == "AllocationSampled" || ( e . ID == ( TraceEventID ) 303 && e . EventName . StartsWith ( "Unknown" ) ) )
167183 {
168184 allocationSampledEventFound = true ;
169185 }
170186 }
171187 } ;
172188
173189 source . Process ( ) ;
174- return allocationSampledEventFound ;
190+ return startEventFound && stopEventFound && allocationSampledEventFound ;
175191 }
176192
177193 private static void UploadTraceFile ( string traceFilePath )
0 commit comments