Skip to content

Commit a6f60f7

Browse files
committed
Capture and validate actual output in the profiler rejit test
1 parent 330bbc1 commit a6f60f7

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/tests/profiler/rejit/rejit.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ class RejitWithInlining //: ProfilerTest
1010
{
1111
static readonly Guid ReJitProfilerGuid = new Guid("66F7A9DF-8858-4A32-9CFF-3AD0787E0186");
1212

13+
static System.Text.StringBuilder OutputBuilder = new ();
14+
15+
[MethodImplAttribute(MethodImplOptions.NoInlining)]
16+
public static void TestWriteLine(string s)
17+
{
18+
OutputBuilder.AppendLine(s);
19+
Console.WriteLine(s);
20+
}
21+
1322
[MethodImplAttribute(MethodImplOptions.NoInlining)]
1423
private static int MaxInlining()
1524
{
@@ -20,18 +29,28 @@ private static int MaxInlining()
2029

2130
TriggerReJIT();
2231

32+
OutputBuilder.Clear();
33+
2334
// TriggerInliningChain triggers a ReJIT, now this time we should call
2435
// in to the ReJITted code
2536
TriggerDirectInlining();
2637
CallMethodWithoutInlining();
2738
TriggerInliningChain();
2839

40+
if (!OutputBuilder.ToString().Contains("Hello from profiler rejit method"))
41+
return 1234;
42+
2943
TriggerRevert();
3044

45+
OutputBuilder.Clear();
46+
3147
TriggerDirectInlining();
3248
CallMethodWithoutInlining();
3349
TriggerInliningChain();
3450

51+
if (OutputBuilder.ToString().Contains("Hello from profiler rejit method"))
52+
return 1235;
53+
3554
return 100;
3655
}
3756

@@ -50,42 +69,42 @@ private static void TriggerRevert()
5069
[MethodImplAttribute(MethodImplOptions.NoInlining)]
5170
private static void TriggerInliningChain()
5271
{
53-
Console.WriteLine("TriggerInlining");
72+
TestWriteLine("TriggerInlining");
5473
// Test Inlining through another method
5574
InlineeChain1();
5675
}
5776

5877
[MethodImplAttribute(MethodImplOptions.NoInlining)]
5978
private static void TriggerDirectInlining()
6079
{
61-
Console.WriteLine("TriggerDirectInlining");
80+
TestWriteLine("TriggerDirectInlining");
6281
InlineeTarget();
6382
}
6483

6584
[MethodImplAttribute(MethodImplOptions.NoInlining)]
6685
private static void CallMethodWithoutInlining()
6786
{
68-
Console.WriteLine("CallMethodWithoutInlining");
87+
TestWriteLine("CallMethodWithoutInlining");
6988
Action callMethod = InlineeTarget;
7089
callMethod();
7190
}
7291

7392
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
7493
private static void InlineeChain1()
7594
{
76-
Console.WriteLine("Inline.InlineeChain1");
95+
TestWriteLine("Inline.InlineeChain1");
7796
InlineeTarget();
7897
}
7998

8099
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
81100
public static void InlineeTarget()
82101
{
83-
Console.WriteLine("Inline.InlineeTarget");
102+
TestWriteLine("Inline.InlineeTarget");
84103
}
85104

86105
public static int RunTest(string[] args)
87106
{
88-
Console.WriteLine("maxinlining");
107+
TestWriteLine("maxinlining");
89108
return MaxInlining();
90109
}
91110

@@ -108,22 +127,22 @@ public class SeparateClassNeverLoaded
108127
[MethodImplAttribute(MethodImplOptions.NoInlining)]
109128
private static void TriggerInliningChain()
110129
{
111-
Console.WriteLine("TriggerInlining");
130+
RejitWithInlining.TestWriteLine("TriggerInlining");
112131
// Test Inlining through another method
113132
InlineeChain1();
114133
}
115134

116135
[MethodImplAttribute(MethodImplOptions.NoInlining)]
117136
private static void TriggerDirectInlining()
118137
{
119-
Console.WriteLine("TriggerDirectInlining");
138+
RejitWithInlining.TestWriteLine("TriggerDirectInlining");
120139
RejitWithInlining.InlineeTarget();
121140
}
122141

123142
[MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
124143
private static void InlineeChain1()
125144
{
126-
Console.WriteLine("Inline.InlineeChain1");
145+
RejitWithInlining.TestWriteLine("Inline.InlineeChain1");
127146
RejitWithInlining.InlineeTarget();
128147
}
129148
}

0 commit comments

Comments
 (0)