-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --clrevents flag to dotnet-trace (#738)
* Add clrevents flag * Ignore clrevents if providers is already specified * Docs change * Change the error message a little bit * case insensitive comparison for keywords, add clreventlevel option * Threw back in a line that was deleted accidentally * Add test for CLR provider parsing * use stringcomparer instead of tolower
- Loading branch information
Showing
4 changed files
with
216 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Diagnostics.NETCore.Client; | ||
using System; | ||
using Xunit; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Diagnostics.Tools.Trace | ||
{ | ||
public class CLRProviderParsingTests | ||
{ | ||
private static string CLRProviderName = "Microsoft-Windows-DotNETRuntime"; | ||
|
||
[Theory] | ||
[InlineData("gc")] | ||
[InlineData("Gc")] | ||
[InlineData("GC")] | ||
public void ValidSingleCLREvent(string providerToParse) | ||
{ | ||
var provider = Extensions.ToCLREventPipeProvider(providerToParse, "4"); | ||
Assert.True(provider.Name == CLRProviderName); | ||
Assert.True(provider.Keywords == 1); | ||
Assert.True(provider.EventLevel == System.Diagnostics.Tracing.EventLevel.Informational); | ||
Assert.True(provider.Arguments == null); | ||
} | ||
|
||
[Theory] | ||
[InlineData("nosuchevent")] | ||
[InlineData("something")] | ||
[InlineData("haha")] | ||
public void InValidSingleCLREvent(string providerToParse) | ||
{ | ||
Assert.Throws<ArgumentException>(() => Extensions.ToCLREventPipeProvider(providerToParse, "4")); | ||
} | ||
|
||
[Theory] | ||
[InlineData("gc+gchandle")] | ||
[InlineData("gc+GCHandle")] | ||
[InlineData("GC+GCHandle")] | ||
public void ValidManyCLREvents(string providerToParse) | ||
{ | ||
var provider = Extensions.ToCLREventPipeProvider(providerToParse, "5"); | ||
Assert.True(provider.Name == CLRProviderName); | ||
Assert.True(provider.Keywords == 3); | ||
Assert.True(provider.EventLevel == System.Diagnostics.Tracing.EventLevel.Verbose); | ||
Assert.True(provider.Arguments == null); | ||
} | ||
|
||
[Theory] | ||
[InlineData("informational")] | ||
[InlineData("4")] | ||
[InlineData("Informational")] | ||
[InlineData("InFORMationAL")] | ||
public void ValidCLREventLevel(string clreventlevel) | ||
{ | ||
var provider = Extensions.ToCLREventPipeProvider("gc", clreventlevel); | ||
Assert.True(provider.Name == CLRProviderName); | ||
Assert.True(provider.Keywords == 1); | ||
Assert.True(provider.EventLevel == System.Diagnostics.Tracing.EventLevel.Informational); | ||
Assert.True(provider.Arguments == null); | ||
} | ||
|
||
[Theory] | ||
[InlineData("something")] | ||
[InlineData("hello")] | ||
public void InvalidCLREventLevel(string clreventlevel) | ||
{ | ||
Assert.Throws<ArgumentException>(() => Extensions.ToCLREventPipeProvider("gc", clreventlevel)); | ||
} | ||
} | ||
} |