Skip to content

Commit 2a0162b

Browse files
authored
validate AllocationTick event (#103290)
1 parent f5efc59 commit 2a0162b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/tests/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation.cs

+13-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public static int TestEntryPoint()
2525
// Validation is done with _DoesTraceContainEvents
2626
new Dictionary<string, ExpectedEventCount>(){{ "Microsoft-Windows-DotNETRuntime", -1 }},
2727
_eventGeneratingActionForGC,
28-
//GCKeyword (0x1): 0b1
29-
new List<EventPipeProvider>(){new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1)},
28+
// GCKeyword (0x1): 0b1, GCAllocationTick requries Verbose level
29+
new List<EventPipeProvider>(){new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Verbose, 0b1)},
3030
1024, _DoesTraceContainGCEvents, enableRundownProvider:false);
3131

3232
// Run the 2nd test scenario only if the first one passes
@@ -35,7 +35,7 @@ public static int TestEntryPoint()
3535
ret = IpcTraceTest.RunAndValidateEventCounts(
3636
new Dictionary<string, ExpectedEventCount>(){{ "Microsoft-DotNETCore-EventPipe", 1 }},
3737
_eventGeneratingActionForExceptions,
38-
//ExceptionKeyword (0x8000): 0b1000_0000_0000_0000
38+
// ExceptionKeyword (0x8000): 0b1000_0000_0000_0000
3939
new List<EventPipeProvider>(){new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000)},
4040
1024, _DoesTraceContainExceptionEvents, enableRundownProvider:false);
4141

@@ -64,6 +64,9 @@ public static int TestEntryPoint()
6464
RuntimeEventValidation eventValidation = new RuntimeEventValidation();
6565
eventValidation = null;
6666
GC.Collect();
67+
68+
// Explicitly targeting AllocationTick event
69+
GC.KeepAlive(new int[1000]);
6770
}
6871
};
6972

@@ -114,6 +117,9 @@ public static int TestEntryPoint()
114117
source.Clr.GCSuspendEEStart += (eventData) => GCSuspendEEEvents += 1;
115118
source.Clr.GCSuspendEEStop += (eventData) => GCSuspendEEEndEvents += 1;
116119

120+
int GCAllocationTickEvents = 0;
121+
source.Clr.GCAllocationTick += (eventData) => GCAllocationTickEvents += 1;
122+
117123
return () => {
118124
Logger.logger.Log("Event counts validation");
119125

@@ -132,7 +138,10 @@ public static int TestEntryPoint()
132138
bool GCSuspendEEStartStopResult = GCSuspendEEEvents >= 50 && GCSuspendEEEndEvents >= 50;
133139
Logger.logger.Log("GCSuspendEEStartStopResult check: " + GCSuspendEEStartStopResult);
134140

135-
return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult ? 100 : -1;
141+
Logger.logger.Log("GCAllocationTickEvents: " + GCAllocationTickEvents);
142+
bool GCAllocationTickResult = GCAllocationTickEvents > 0;
143+
144+
return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult && GCAllocationTickResult ? 100 : -1;
136145
};
137146
};
138147

0 commit comments

Comments
 (0)