-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathCollectLinuxCommandFunctionalTests.cs
More file actions
628 lines (538 loc) · 26.7 KB
/
CollectLinuxCommandFunctionalTests.cs
File metadata and controls
628 lines (538 loc) · 26.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Diagnostics.Tests.Common;
using Microsoft.Diagnostics.Tools.Trace;
using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Internal.Common.Utils;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.Diagnostics.Tools.Trace
{
public class CollectLinuxCommandFunctionalTests
{
public static bool IsCollectLinuxSupported => CollectLinuxCommandHandler.IsSupported();
public static bool IsCollectLinuxNotSupported => !CollectLinuxCommandHandler.IsSupported();
private readonly ITestOutputHelper _outputHelper;
public CollectLinuxCommandFunctionalTests(ITestOutputHelper outputHelper)
{
_outputHelper = outputHelper;
}
private static CollectLinuxCommandHandler.CollectLinuxArgs TestArgs(
CancellationToken ct = default,
string[] providers = null,
string clrEventLevel = "",
string clrEvents = "",
string[] perfEvents = null,
string[] profile = null,
FileInfo output = null,
TimeSpan duration = default,
string name = "",
int processId = 0,
bool probe = false)
{
return new CollectLinuxCommandHandler.CollectLinuxArgs(ct,
providers ?? Array.Empty<string>(),
clrEventLevel,
clrEvents,
perfEvents ?? Array.Empty<string>(),
profile ?? Array.Empty<string>(),
output ?? new FileInfo("trace.nettrace"),
duration,
name,
processId,
probe);
}
[ConditionalTheory(nameof(IsCollectLinuxSupported))]
[MemberData(nameof(BasicCases))]
public void CollectLinuxCommandProviderConfigurationConsolidation(object testArgs, string[] expectedLines)
{
MockConsole console = new(200, 30, _outputHelper);
int exitCode = Run(testArgs, console);
Assert.Equal((int)ReturnCode.Ok, exitCode);
console.AssertSanitizedLinesEqual(CollectLinuxSanitizer, expectedLines);
}
[ConditionalTheory(nameof(IsCollectLinuxSupported))]
[MemberData(nameof(InvalidProviders))]
public void CollectLinuxCommandProviderConfigurationConsolidation_Throws(object testArgs, string[] expectedException)
{
MockConsole console = new(200, 30, _outputHelper);
int exitCode = Run(testArgs, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
console.AssertSanitizedLinesEqual(null, expectedException);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_ReportsResolveProcessErrors()
{
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(processId: -1);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
console.AssertSanitizedLinesEqual(null, FormatException("-1 is not a valid process ID"));
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_ReportsResolveProcessNameErrors()
{
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(name: "process-that-should-not-exist", processId: 0);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
console.AssertSanitizedLinesEqual(null, FormatException("There is no active process with the given name: process-that-should-not-exist"));
}
[ConditionalTheory(nameof(IsCollectLinuxSupported))]
[MemberData(nameof(ResolveProcessExceptions))]
public void CollectLinuxCommand_ResolveProcessExceptions(object testArgs, string[] expectedError)
{
MockConsole console = new(200, 30, _outputHelper);
int exitCode = Run(testArgs, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
console.AssertSanitizedLinesEqual(null, expectedError);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_ListsProcesses_WhenNoArgs()
{
MockConsole console = new(200, 2000, _outputHelper);
var args = TestArgs(probe: true, output: new FileInfo(CommonOptions.DefaultTraceName));
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
new[] {
"Probing .NET processes for support of the EventPipe UserEvents IPC command used by collect-linux. Requires runtime '10.0.0' or later.",
".NET processes that support the command:",
"",
".NET processes that do NOT support the command:",
"",
}
);
console.AssertSanitizedLinesEqual(CollectLinuxProbeSanitizer, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_CsvToConsole()
{
MockConsole console = new(200, 2000, _outputHelper);
var args = TestArgs(probe: true, output: new FileInfo("stdout"));
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
new[] {
"pid,processName,supportsCollectLinux",
""
}
);
console.AssertSanitizedLinesEqual(CollectLinuxProbeSanitizer, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_Csv()
{
MockConsole console = new(200, 2000, _outputHelper);
string tempFilePath = Path.GetTempFileName();
var args = TestArgs(probe: true, output: new FileInfo(tempFilePath));
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
new[] {
"Successfully wrote EventPipe UserEvents IPC command support results to '" + tempFilePath + "'.",
}
);
File.Delete(tempFilePath);
console.AssertSanitizedLinesEqual(null, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_ReportsResolveProcessErrors_InvalidPid()
{
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(processId: -1, probe: true);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
string[] expected = FormatException("-1 is not a valid process ID");
console.AssertSanitizedLinesEqual(null, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_ReportsResolveProcessErrors_InvalidName()
{
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(name: "process-that-should-not-exist", processId: 0, probe: true);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
string[] expected = FormatException("There is no active process with the given name: process-that-should-not-exist");
console.AssertSanitizedLinesEqual(null, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_ReportsResolveProcessErrors_BothPidAndName()
{
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(name: "dummy", processId: 1, probe: true);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.ArgumentError, exitCode);
// When both PID and name are supplied, the banner still refers to the PID
// because the implementation prioritizes ProcessId when it is non-zero.
string[] expected = FormatException("Only one of the --name or --process-id options may be specified.");
console.AssertSanitizedLinesEqual(null, expected);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_ReportsConnectionFailed_NonDotNetProcess()
{
// PID 1 (init/systemd) exists but is not a .NET process — no diagnostic port.
string pid1Name = Process.GetProcessById(1).ProcessName;
MockConsole console = new(200, 30, _outputHelper);
var args = TestArgs(processId: 1);
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.TracingError, exitCode);
console.AssertSanitizedLinesEqual(null, FormatException(
$"Unable to connect to process '{pid1Name} (1)'. The process may have exited, or it doesn't have an accessible .NET diagnostic port."));
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_Probe_ReportsConnectionFailed_NonDotNetProcess()
{
// PID 1 (init/systemd) exists but is not a .NET process — no diagnostic port.
string pid1Name = Process.GetProcessById(1).ProcessName;
MockConsole console = new(200, 2000, _outputHelper);
var args = TestArgs(processId: 1, probe: true, output: new FileInfo(CommonOptions.DefaultTraceName));
int exitCode = Run(args, console);
Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] expected = ExpectPreviewWithMessages(
new[] {
$"Could not probe process '{pid1Name} (1)'. The process may have exited, or it doesn't have an accessible .NET diagnostic port.",
}
);
console.AssertSanitizedLinesEqual(null, expected);
}
[ConditionalFact(nameof(IsCollectLinuxNotSupported))]
public void CollectLinuxCommand_NotSupported_OnNonLinux()
{
MockConsole console = new(200, 30, _outputHelper);
int exitCode = Run(TestArgs(), console);
Assert.Equal((int)ReturnCode.PlatformNotSupportedError, exitCode);
console.AssertSanitizedLinesEqual(null, new string[] {
"The collect-linux command is not supported on this platform.",
"For requirements, please visit https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-trace."
});
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_RestoresCursorVisibility_OnSuccess()
{
MockConsole console = new(200, 30, _outputHelper)
{
CursorVisible = false
};
int exitCode = Run(TestArgs(), console);
// Cursor visibility should always be restored to visible after command completes
Assert.True(console.CursorVisible, "Cursor should be visible after command completes");
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_RestoresCursorVisibility_OnError()
{
MockConsole console = new(200, 30, _outputHelper)
{
CursorVisible = false
};
var handler = new CollectLinuxCommandHandler(console);
// Simulate an error by throwing an exception in the RecordTraceInvoker
handler.RecordTraceInvoker = (cmd, len, cb) => {
throw new InvalidOperationException("Simulated error");
};
int exitCode = handler.CollectLinux(TestArgs());
// Cursor visibility should always be restored to visible even when an error occurs
Assert.True(console.CursorVisible, "Cursor should be visible after error");
Assert.Equal((int)ReturnCode.TracingError, exitCode);
}
[ConditionalTheory(nameof(IsCollectLinuxSupported))]
[InlineData(true)]
[InlineData(false)]
public void CollectLinuxCommand_DoesNotChangeCursorVisibility_WhenOutputIsRedirected(bool initialCursorVisible)
{
MockConsole console = new(200, 30, _outputHelper)
{
CursorVisible = initialCursorVisible,
IsOutputRedirected = true
};
int exitCode = Run(TestArgs(), console);
// When output is redirected, the command should not change cursor visibility,
// so the cursor should remain in its original state.
Assert.Equal(initialCursorVisible, console.CursorVisible);
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_DoesNotPrintStatusUpdates_WhenOutputIsRedirected()
{
MockConsole console = new(200, 30, _outputHelper);
console.IsOutputRedirected = true;
var handler = new CollectLinuxCommandHandler(console);
handler.RecordTraceInvoker = (cmd, len, cb) => {
// Send progress output type.
cb((uint)3, IntPtr.Zero, UIntPtr.Zero);
return 0;
};
int exitCode = handler.CollectLinux(TestArgs());
Assert.Equal((int)ReturnCode.Ok, exitCode);
string[] lines = console.Lines;
Assert.DoesNotContain(lines, l => l.Contains("Recording trace", StringComparison.OrdinalIgnoreCase));
Assert.DoesNotContain(lines, l => l.Contains("Press <Enter>", StringComparison.OrdinalIgnoreCase));
}
[ConditionalFact(nameof(IsCollectLinuxSupported))]
public void CollectLinuxCommand_DoesNotReadKey_WhenInputIsRedirected()
{
MockConsole console = new(200, 30, _outputHelper);
console.IsInputRedirected = true;
console.KeyAvailable = true;
console.NextKeyInfo = new ConsoleKeyInfo('\r', ConsoleKey.Enter, false, false, false);
var handler = new CollectLinuxCommandHandler(console);
bool callbackInvoked = false;
handler.RecordTraceInvoker = (cmd, len, cb) => {
// Send progress output type.
int result = cb((uint)3, IntPtr.Zero, UIntPtr.Zero);
// It should return 0, i.e., continue tracing, even though
// enter was pressed.
Assert.Equal(0, result);
callbackInvoked = true;
return 0;
};
int exitCode = handler.CollectLinux(TestArgs());
Assert.Equal((int)ReturnCode.Ok, exitCode);
// The important assertion is in the callback so make sure it was called.
Assert.True(callbackInvoked);
}
private static int Run(object args, MockConsole console)
{
var handler = new CollectLinuxCommandHandler(console);
handler.RecordTraceInvoker = (cmd, len, cb) => {
cb(3, IntPtr.Zero, UIntPtr.Zero);
return 0;
};
return handler.CollectLinux((CollectLinuxCommandHandler.CollectLinuxArgs)args);
}
private static string[] CollectLinuxSanitizer(string[] lines)
{
List<string> result = new();
foreach (string line in lines)
{
if (line.Contains("Recording trace.", StringComparison.OrdinalIgnoreCase))
{
result.Add("[dd:hh:mm:ss]\tRecording trace.");
}
else
{
result.Add(line);
}
}
return result.ToArray();
}
private static string[] CollectLinuxProbeSanitizer(string[] lines)
{
List<string> result = new();
foreach (string line in lines)
{
// Filter out possible pid lines
if (Regex.IsMatch(line, @"^\d"))
{
continue;
}
result.Add(line);
}
return result.ToArray();
}
public static IEnumerable<object[]> BasicCases()
{
yield return new object[] {
TestArgs(),
ExpectProvidersAndPerfEventsWithMessages(
new[]{"No providers, profiles, ClrEvents, or PerfEvents were specified, defaulting to trace profiles 'dotnet-common' + 'cpu-sampling'."},
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","000000100003801D","Informational",4,"--profile")},
new[]{LinuxProfile("cpu-sampling")})
};
yield return new object[] {
TestArgs(providers: new[]{"Foo:0x1:4"}),
ExpectProvidersAndLinux(
new[]{FormatProvider("Foo","0000000000000001","Informational",4,"--providers")},
Array.Empty<string>())
};
yield return new object[] {
TestArgs(providers: new[]{"Foo:0x1:4","Bar:0x2:4"}),
ExpectProvidersAndLinux(
new[]{
FormatProvider("Foo","0000000000000001","Informational",4,"--providers"),
FormatProvider("Bar","0000000000000002","Informational",4,"--providers")
},
Array.Empty<string>())
};
yield return new object[] {
TestArgs(profile: new[]{"cpu-sampling"}),
ExpectProvidersAndPerfEventsWithMessages(
new[]{"No .NET providers were configured."},
Array.Empty<string>(),
new[]{LinuxProfile("cpu-sampling")})
};
yield return new object[] {
TestArgs(providers: new[]{"Foo:0x1:4"}, profile: new[]{"cpu-sampling"}),
ExpectProvidersAndLinux(
new[]{FormatProvider("Foo","0000000000000001","Informational",4,"--providers")},
new[]{LinuxProfile("cpu-sampling")})
};
yield return new object[] {
TestArgs(clrEvents: "gc", profile: new[]{"cpu-sampling"}),
ExpectProvidersAndLinux(
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","0000000000000001","Informational",4,"--clrevents")},
new[]{LinuxProfile("cpu-sampling")})
};
yield return new object[] {
TestArgs(providers: new[]{"Microsoft-Windows-DotNETRuntime:0x1:4"}, profile: new[]{"cpu-sampling"}),
ExpectProvidersAndLinux(
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","0000000000000001","Informational",4,"--providers")},
new[]{LinuxProfile("cpu-sampling")})
};
yield return new object[] {
TestArgs(providers: new[]{"Microsoft-Windows-DotNETRuntime:0x1:4"}, clrEvents: "gc"),
ExpectProvidersAndPerfEventsWithMessages(
new[]{"Warning: The CLR provider was already specified through --providers or --profile. Ignoring --clrevents."},
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","0000000000000001","Informational",4,"--providers")},
Array.Empty<string>())
};
yield return new object[] {
TestArgs(clrEvents: "gc+jit"),
ExpectProvidersAndLinux(
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","0000000000000011","Informational",4,"--clrevents")},
Array.Empty<string>())
};
yield return new object[] {
TestArgs(clrEvents: "gc+jit", clrEventLevel: "5"),
ExpectProvidersAndLinux(
new[]{FormatProvider("Microsoft-Windows-DotNETRuntime","0000000000000011","Verbose",5,"--clrevents")},
Array.Empty<string>())
};
yield return new object[] {
TestArgs(perfEvents: new[]{"sched:sched_switch"}),
ExpectProvidersAndPerfEventsWithMessages(
new[]{"No .NET providers were configured."},
Array.Empty<string>(),
new[]{LinuxPerfEvent("sched:sched_switch")})
};
}
public static IEnumerable<object[]> InvalidProviders()
{
yield return new object[]
{
TestArgs(profile: new[] { "dotnet-sampled-thread-time" }),
FormatException("The specified profile 'dotnet-sampled-thread-time' does not apply to `dotnet-trace collect-linux`.")
};
yield return new object[]
{
TestArgs(profile: new[] { "unknown" }),
FormatException("Invalid profile name: unknown")
};
yield return new object[]
{
TestArgs(providers: new[] { "Foo:::Bar=0", "Foo:::Bar=1" }),
FormatException($"Provider \"Foo\" is declared multiple times with filter arguments.")
};
yield return new object[]
{
TestArgs(clrEvents: "unknown"),
FormatException("unknown is not a valid CLR event keyword")
};
yield return new object[]
{
TestArgs(clrEvents: "gc", clrEventLevel: "unknown"),
FormatException("Unknown EventLevel: unknown")
};
}
public static IEnumerable<object[]> ResolveProcessExceptions()
{
yield return new object[]
{
TestArgs(processId: -1, name: string.Empty),
FormatException("-1 is not a valid process ID")
};
yield return new object[]
{
TestArgs(processId: 1, name: "dummy"),
FormatException("Only one of the --name or --process-id options may be specified.")
};
yield return new object[]
{
TestArgs(processId: int.MaxValue, name: string.Empty),
FormatException("No process with ID 2147483647 is currently running.")
};
}
private const string ProviderHeader = "Provider Name Keywords Level Enabled By";
private static string LinuxHeader => $"{"Linux Perf Events",-80}Enabled By";
private static string LinuxProfile(string name) => $"{name,-80}--profile";
private static string LinuxPerfEvent(string spec) => $"{spec,-80}--perf-events";
private static string FormatProvider(string name, string keywordsHex, string levelName, int levelValue, string enabledBy)
{
string display = string.Format("{0, -40}", name) +
string.Format("0x{0, -18}", keywordsHex) +
string.Format("{0, -8}", $"{levelName}({levelValue})");
return string.Format("{0, -80}", display) + enabledBy;
}
private static string[] FormatException(string message)
{
List<string> result = new();
result.AddRange(PreviewMessages);
result.Add($"[ERROR] {message}");
return result.ToArray();
}
private static string DefaultOutputFile => $"Output File : {Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar}trace.nettrace";
private static readonly string[] CommonTail = [
DefaultOutputFile,
"",
"[dd:hh:mm:ss]\tRecording trace.",
"Press <Enter> or <Ctrl-C> to exit...",
];
private static string[] PreviewMessages = [
"==========================================================================================",
"The collect-linux verb is a new preview feature and relies on an updated version of the",
".nettrace file format. The latest PerfView release supports these trace files but other",
"ways of using the trace file may not work yet. For more details, see the docs at",
"https://learn.microsoft.com/dotnet/core/diagnostics/dotnet-trace.",
"=========================================================================================="
];
private static string[] ExpectPreviewWithMessages(string[] messages)
{
List<string> result = new();
result.AddRange(PreviewMessages);
if (messages.Length > 0)
{
result.AddRange(messages);
}
return result.ToArray();
}
private static string[] ExpectProvidersAndLinux(string[] dotnetProviders, string[] linuxPerfEvents)
=> ExpectProvidersAndPerfEventsWithMessages(Array.Empty<string>(), dotnetProviders, linuxPerfEvents);
private static string[] ExpectProvidersAndPerfEventsWithMessages(string[] messages, string[] dotnetProviders, string[] linuxPerfEvents)
{
List<string> result = new();
result.AddRange(PreviewMessages);
if (messages.Length > 0)
{
result.AddRange(messages);
}
result.Add("");
if (dotnetProviders.Length > 0)
{
result.Add(ProviderHeader);
result.AddRange(dotnetProviders);
result.Add("");
}
if (linuxPerfEvents.Length > 0)
{
result.Add(LinuxHeader);
result.AddRange(linuxPerfEvents);
}
else
{
result.Add("No Linux Perf Events enabled.");
}
result.Add("");
result.AddRange(CommonTail);
return result.ToArray();
}
}
}