diff options
author | Victor "Nate" Graf <nategraf1@gmail.com> | 2018-01-02 09:47:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-02 09:47:20 -0800 |
commit | c1bbdae7964b19b7063074d36e6af960f0cdc3a0 (patch) | |
tree | e554fc74fbb22c6ce9dd488fb02ba4f08ee89e89 /tests | |
parent | 35bba0c5b29e9dfd2744b09e577f6111ef7de9d7 (diff) | |
download | coreclr-c1bbdae7964b19b7063074d36e6af960f0cdc3a0.tar.gz coreclr-c1bbdae7964b19b7063074d36e6af960f0cdc3a0.tar.bz2 coreclr-c1bbdae7964b19b7063074d36e6af960f0cdc3a0.zip |
Retry: Enable EventPipe across Unix and Windows (#15611)
* Revert "Revert "Enable EventPipe across Unix and Windows (#14772)" (#15609)"
This reverts commit 302005ca8ae14eade37ddf4ac6e900617c1c166a.
* Fix ARM build break
* Use more explicit references to resolve build failures
* Fix compat with python3
* Disable FeaturePerfTracing on Windows as it is not ready
* Disable test for incomplete functionality
* Fix test diabled patterns
* Add license header
* Use keyword types for managed code
* Add message prefix
* More precisly condition generation of eventing sources
* Remove erroneously added changes
Diffstat (limited to 'tests')
26 files changed, 454 insertions, 38 deletions
diff --git a/tests/runtest.proj b/tests/runtest.proj index 9c12e275d7..3ab7b9f708 100644 --- a/tests/runtest.proj +++ b/tests/runtest.proj @@ -12,7 +12,6 @@ <ItemGroup> <DisabledTestDir Include="Common" /> - <DisabledTestDir Include="tracing" /> <_SkipTestDir Include="@(DisabledTestDir)" /> </ItemGroup> @@ -404,4 +403,4 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). <Target Name="Clean"> <RemoveDir Condition=" '$(BuildWrappers)'=='true'" Directories="$(XunitWrapperGeneratedCSDirBase);$(XunitWrapperOutputIntermediatedDirBase)" ContinueOnError="WarnAndContinue" /> </Target> -</Project>
\ No newline at end of file +</Project> diff --git a/tests/src/CoreMangLib/cti/system/convert/convertfrombase64string.cs b/tests/src/CoreMangLib/cti/system/convert/convertfrombase64string.cs index f6b3927147..e91dde147f 100644 --- a/tests/src/CoreMangLib/cti/system/convert/convertfrombase64string.cs +++ b/tests/src/CoreMangLib/cti/system/convert/convertfrombase64string.cs @@ -81,10 +81,10 @@ public class ConvertFromBase64String try { byte[] output = Convert.FromBase64String(input); - if (!Utilities.CompareBytes(output, expected)) + if (!TestLibrary.Utilities.CompareBytes(output, expected)) { TestFramework.LogInformation("Input string: " + input); - TestFramework.LogError("001", "Conversion not correct. Expect: " + Utilities.ByteArrayToString(expected) + ", Actual: " + Utilities.ByteArrayToString(output)); + TestFramework.LogError("001", "Conversion not correct. Expect: " + TestLibrary.Utilities.ByteArrayToString(expected) + ", Actual: " + TestLibrary.Utilities.ByteArrayToString(output)); retVal = false; } } diff --git a/tests/src/CoreMangLib/cti/system/string/stringcompare9.cs b/tests/src/CoreMangLib/cti/system/string/stringcompare9.cs index 230d45f915..75d59aae19 100644 --- a/tests/src/CoreMangLib/cti/system/string/stringcompare9.cs +++ b/tests/src/CoreMangLib/cti/system/string/stringcompare9.cs @@ -128,10 +128,10 @@ public class StringCompare try { - CultureInfo oldCi = Utilities.CurrentCulture; - Utilities.CurrentCulture = new CultureInfo("hu-HU"); + CultureInfo oldCi = TestLibrary.Utilities.CurrentCulture; + TestLibrary.Utilities.CurrentCulture = new CultureInfo("hu-HU"); retVal &= TestStrings("dzsdzs", "ddzs"); - Utilities.CurrentCulture = oldCi; + TestLibrary.Utilities.CurrentCulture = oldCi; retVal &= TestStrings("\u00C0nimal", "A\u0300nimal"); @@ -210,7 +210,7 @@ public class StringCompare StringBuilder output = new StringBuilder(); for (int i = 0; i < str.Length; i++) { - output.Append(Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); + output.Append(TestLibrary.Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); if (i != (str.Length - 1)) output.Append(", "); } return output.ToString(); diff --git a/tests/src/CoreMangLib/cti/system/string/stringequals6.cs b/tests/src/CoreMangLib/cti/system/string/stringequals6.cs index be60b76ed9..fa89733729 100644 --- a/tests/src/CoreMangLib/cti/system/string/stringequals6.cs +++ b/tests/src/CoreMangLib/cti/system/string/stringequals6.cs @@ -127,10 +127,10 @@ public class StringEquals try { - CultureInfo oldCi = Utilities.CurrentCulture; - Utilities.CurrentCulture = new CultureInfo("hu-HU"); + CultureInfo oldCi = TestLibrary.Utilities.CurrentCulture; + TestLibrary.Utilities.CurrentCulture = new CultureInfo("hu-HU"); retVal &= TestStrings("dzsdzs", "ddzs"); - Utilities.CurrentCulture = oldCi; + TestLibrary.Utilities.CurrentCulture = oldCi; retVal &= TestStrings("\u00C0nimal", "A\u0300nimal"); @@ -207,7 +207,7 @@ public class StringEquals StringBuilder output = new StringBuilder(); for (int i = 0; i < str.Length; i++) { - output.Append(Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); + output.Append(TestLibrary.Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); if (i != (str.Length - 1)) output.Append(", "); } return output.ToString(); diff --git a/tests/src/CoreMangLib/cti/system/string/stringindexof10.cs b/tests/src/CoreMangLib/cti/system/string/stringindexof10.cs index 3d037dcd65..979d96ff49 100644 --- a/tests/src/CoreMangLib/cti/system/string/stringindexof10.cs +++ b/tests/src/CoreMangLib/cti/system/string/stringindexof10.cs @@ -91,10 +91,10 @@ public class StringIndexOf try { - CultureInfo oldCi = Utilities.CurrentCulture; - Utilities.CurrentCulture = new CultureInfo("hu-HU"); + CultureInfo oldCi = TestLibrary.Utilities.CurrentCulture; + TestLibrary.Utilities.CurrentCulture = new CultureInfo("hu-HU"); retVal &= TestStrings("Foodzsdzsbar", "ddzs"); - Utilities.CurrentCulture = oldCi; + TestLibrary.Utilities.CurrentCulture = oldCi; retVal &= TestStrings("\u00C0nimal", "A\u0300"); @@ -177,7 +177,7 @@ public class StringIndexOf StringBuilder output = new StringBuilder(); for (int i = 0; i < str.Length; i++) { - output.Append(Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); + output.Append(TestLibrary.Utilities.ByteArrayToString(BitConverter.GetBytes(str[i]))); if (i != (str.Length - 1)) output.Append(", "); } return output.ToString(); diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetbytes1.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetbytes1.cs index 2ea8d51fd0..c25f168360 100644 --- a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetbytes1.cs +++ b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetbytes1.cs @@ -318,10 +318,10 @@ class EncodingGetBytes1 try { byte[] bytes = enc.GetBytes(str); - if (!Utilities.CompareBytes(bytes, expected)) + if (!TestLibrary.Utilities.CompareBytes(bytes, expected)) { result = false; - TestFramework.LogError("001", "Error in " + id + ", unexpected comparison result. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected: " + Utilities.ByteArrayToString(expected)); + TestFramework.LogError("001", "Error in " + id + ", unexpected comparison result. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected: " + TestLibrary.Utilities.ByteArrayToString(expected)); } } catch (Exception exc) @@ -340,7 +340,7 @@ class EncodingGetBytes1 { byte[] bytes = enc.GetBytes(str); result = false; - TestFramework.LogError("005", "Error in " + id + ", Expected exception not thrown. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); + TestFramework.LogError("005", "Error in " + id + ", Expected exception not thrown. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); } catch (Exception exc) { @@ -360,10 +360,10 @@ class EncodingGetBytes1 try { byte[] bytes = enc.GetBytes(chars); - if (!Utilities.CompareBytes(bytes, expected)) + if (!TestLibrary.Utilities.CompareBytes(bytes, expected)) { result = false; - TestFramework.LogError("003", "Error in " + id + ", unexpected comparison result. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected: " + Utilities.ByteArrayToString(expected)); + TestFramework.LogError("003", "Error in " + id + ", unexpected comparison result. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected: " + TestLibrary.Utilities.ByteArrayToString(expected)); } } catch (Exception exc) @@ -382,7 +382,7 @@ class EncodingGetBytes1 { byte[] bytes = enc.GetBytes(str); result = false; - TestFramework.LogError("007", "Error in " + id + ", Expected exception not thrown. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); + TestFramework.LogError("007", "Error in " + id + ", Expected exception not thrown. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); } catch (Exception exc) { @@ -403,7 +403,7 @@ class EncodingGetBytes1 { byte[] bytes = enc.GetBytes(str, index, count); result = false; - TestFramework.LogError("009", "Error in " + id + ", Expected exception not thrown. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); + TestFramework.LogError("009", "Error in " + id + ", Expected exception not thrown. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); } catch (Exception exc) { @@ -424,7 +424,7 @@ class EncodingGetBytes1 { int output = enc.GetBytes(str, index, count, bytes, bIndex); result = false; - TestFramework.LogError("011", "Error in " + id + ", Expected exception not thrown. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); + TestFramework.LogError("011", "Error in " + id + ", Expected exception not thrown. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); } catch (Exception exc) { @@ -445,7 +445,7 @@ class EncodingGetBytes1 { int output = enc.GetBytes(str, index, count, bytes, bIndex); result = false; - TestFramework.LogError("013", "Error in " + id + ", Expected exception not thrown. Actual bytes " + Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); + TestFramework.LogError("013", "Error in " + id + ", Expected exception not thrown. Actual bytes " + TestLibrary.Utilities.ByteArrayToString(bytes) + ", Expected exception type: " + excType.ToString()); } catch (Exception exc) { diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs Binary files differindex cc1953ce88..1f61bbdeba 100644 --- a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs +++ b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs Binary files differindex 0f24507700..e191e01173 100644 --- a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs +++ b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs Binary files differindex 44289f7b0d..f4116e4d3f 100644 --- a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs +++ b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs diff --git a/tests/src/CoreMangLib/cti/system/timespan/timespantostring_str.cs b/tests/src/CoreMangLib/cti/system/timespan/timespantostring_str.cs index 4d5e5493d9..b9faa109d9 100644 --- a/tests/src/CoreMangLib/cti/system/timespan/timespantostring_str.cs +++ b/tests/src/CoreMangLib/cti/system/timespan/timespantostring_str.cs @@ -22,8 +22,8 @@ public class TimeSpanTest if ((args.Length > 0) && args[0].ToLower() == "true") verbose = true; - Logging.WriteLine("CurrentCulture: " + Utilities.CurrentCulture.Name); - Logging.WriteLine("CurrentUICulture: " + Utilities.CurrentCulture.Name); + Logging.WriteLine("CurrentCulture: " + TestLibrary.Utilities.CurrentCulture.Name); + Logging.WriteLine("CurrentUICulture: " + TestLibrary.Utilities.CurrentCulture.Name); RunTests(); } @@ -50,7 +50,7 @@ public class TimeSpanTest // The current implementation uses the same character as the default NumberDecimalSeparator // for a culture, but this is an implementation detail and could change. No user overrides // are respected. - String GDecimalSeparator = Utilities.CurrentCulture.NumberFormat.NumberDecimalSeparator; + String GDecimalSeparator = TestLibrary.Utilities.CurrentCulture.NumberFormat.NumberDecimalSeparator; // Standard formats foreach (TimeSpan ts in Support.InterestingTimeSpans) { @@ -169,7 +169,7 @@ public class TimeSpanTest // Vary current culture - Utilities.CurrentCulture = CultureInfo.InvariantCulture; + TestLibrary.Utilities.CurrentCulture = CultureInfo.InvariantCulture; foreach (TimeSpan ts in Support.InterestingTimeSpans) { String defaultFormat = Support.CFormat(ts); @@ -183,7 +183,7 @@ public class TimeSpanTest VerifyToString(ts, "G", Support.GFormat(ts, ".")); } - Utilities.CurrentCulture = new CultureInfo("en-US"); + TestLibrary.Utilities.CurrentCulture = new CultureInfo("en-US"); foreach (TimeSpan ts in Support.InterestingTimeSpans) { String defaultFormat = Support.CFormat(ts); @@ -197,7 +197,7 @@ public class TimeSpanTest VerifyToString(ts, "G", Support.GFormat(ts, ".")); } - Utilities.CurrentCulture = new CultureInfo("de-DE"); + TestLibrary.Utilities.CurrentCulture = new CultureInfo("de-DE"); foreach (TimeSpan ts in Support.InterestingTimeSpans) { String defaultFormat = Support.CFormat(ts); diff --git a/tests/src/CoreMangLib/cti/system/uint64/uint64tostring2.cs b/tests/src/CoreMangLib/cti/system/uint64/uint64tostring2.cs index 8d4f23f442..497efe39c6 100644 --- a/tests/src/CoreMangLib/cti/system/uint64/uint64tostring2.cs +++ b/tests/src/CoreMangLib/cti/system/uint64/uint64tostring2.cs @@ -23,7 +23,7 @@ public class UInt64ToString1 retVal = PosTest5() && retVal; TestLibrary.TestFramework.LogInformation("[Negative]"); - if (Utilities.IsWindows) + if (TestLibrary.Utilities.IsWindows) { // retVal = NegTest1() && retVal; // Disabled until neutral cultures are available } diff --git a/tests/src/Interop/BestFitMapping/BestFitMapping.cs b/tests/src/Interop/BestFitMapping/BestFitMapping.cs Binary files differindex 643ddc9d21..1778d79e4e 100755 --- a/tests/src/Interop/BestFitMapping/BestFitMapping.cs +++ b/tests/src/Interop/BestFitMapping/BestFitMapping.cs diff --git a/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj b/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj index 77cba12414..563a9a7087 100644 --- a/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj +++ b/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj @@ -67,6 +67,9 @@ <PackageReference Include="System.Threading"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> + <PackageReference Include="System.Threading.Thread"> + <Version>4.4.0-beta-24913-02</Version> + </PackageReference> <PackageReference Include="System.Threading.Tasks"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> diff --git a/tests/src/JIT/config/benchmark/benchmark.csproj b/tests/src/JIT/config/benchmark/benchmark.csproj index 5ade686330..4d49fdee3e 100644 --- a/tests/src/JIT/config/benchmark/benchmark.csproj +++ b/tests/src/JIT/config/benchmark/benchmark.csproj @@ -76,6 +76,9 @@ <PackageReference Include="System.Threading"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> + <PackageReference Include="System.Threading.Thread"> + <Version>4.4.0-beta-24913-02</Version> + </PackageReference> <PackageReference Include="System.Threading.Tasks"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> diff --git a/tests/src/dirs.proj b/tests/src/dirs.proj index 471598d82d..cb1c1b000d 100644 --- a/tests/src/dirs.proj +++ b/tests/src/dirs.proj @@ -30,6 +30,8 @@ <DisabledProjects Include="Performance\performance.csproj" /> <DisabledProjects Include="Loader\classloader\generics\regressions\DD117522\Test.csproj" /> <DisabledProjects Include="Loader\classloader\generics\GenericMethods\VSW491668.csproj" /> <!-- issue 5501 --> + <DisabledProjects Include="tracing\eventsource*\*.csproj" /> + <DisabledProjects Include="tracing\eventpipe*\*.csproj" /> </ItemGroup> <ItemGroup> diff --git a/tests/src/performance/performance.csproj b/tests/src/performance/performance.csproj index 8c2cd3c7de..94caf35ac2 100644 --- a/tests/src/performance/performance.csproj +++ b/tests/src/performance/performance.csproj @@ -70,6 +70,9 @@ <PackageReference Include="System.Threading"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> + <PackageReference Include="System.Threading.Thread"> + <Version>4.4.0-beta-24913-02</Version> + </PackageReference> <PackageReference Include="System.Threading.Tasks"> <Version>4.4.0-beta-24913-02</Version> </PackageReference> diff --git a/tests/src/tracing/common/common.csproj b/tests/src/tracing/common/common.csproj index ca34349b16..ca10e7ffe2 100644 --- a/tests/src/tracing/common/common.csproj +++ b/tests/src/tracing/common/common.csproj @@ -12,7 +12,7 @@ <CLRTestKind>BuildOnly</CLRTestKind> <DefineConstants>$(DefineConstants);STATIC</DefineConstants> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <CLRTestPriority>1</CLRTestPriority> + <CLRTestPriority>0</CLRTestPriority> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> diff --git a/tests/src/tracing/eventlistener/EventListener.cs b/tests/src/tracing/eventlistener/EventListener.cs new file mode 100644 index 0000000000..dcadd622e7 --- /dev/null +++ b/tests/src/tracing/eventlistener/EventListener.cs @@ -0,0 +1,77 @@ +using System; +using System.IO; +using System.Diagnostics.Tracing; +using Tracing.Tests.Common; + +namespace Tracing.Tests +{ + [EventSource(Name = "SimpleEventSource")] + class SimpleEventSource : EventSource + { + public SimpleEventSource() : base(true) { } + + [Event(1)] + internal void MathResult(int x, int y, int z, string formula) { this.WriteEvent(1, x, y, z, formula); } + } + + internal sealed class SimpleEventListener : EventListener + { + private readonly string _targetSourceName; + private readonly EventLevel _level; + + public int EventCount { get; private set; } = 0; + + public SimpleEventListener(string targetSourceName, EventLevel level) + { + // Store the arguments + _targetSourceName = targetSourceName; + _level = level; + } + + protected override void OnEventSourceCreated(EventSource source) + { + if (source.Name.Equals(_targetSourceName)) + { + EnableEvents(source, _level); + } + } + + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + EventCount++; + } + } + + class EventPipeSmoke + { + private static int messageIterations = 100; + + static int Main(string[] args) + { + bool pass = false; + using(var listener = new SimpleEventListener("SimpleEventSource", EventLevel.Verbose)) + { + SimpleEventSource eventSource = new SimpleEventSource(); + + Console.WriteLine("\tStart: Messaging."); + // Send messages + // Use random numbers and addition as a simple, human readble checksum + Random generator = new Random(); + for(int i=0; i<messageIterations; i++) + { + int x = generator.Next(1,1000); + int y = generator.Next(1,1000); + string formula = String.Format("{0} + {1} = {2}", x, y, x+y); + + eventSource.MathResult(x, y, x+y, formula); + } + Console.WriteLine("\tEnd: Messaging.\n"); + + Console.WriteLine($"\tEventListener recieved {listener.EventCount} event(s)\n"); + pass = listener.EventCount == messageIterations; + } + + return pass ? 100 : -1; + } + } +} diff --git a/tests/src/tracing/eventlistener/eventlistener.csproj b/tests/src/tracing/eventlistener/eventlistener.csproj new file mode 100644 index 0000000000..9002d93e12 --- /dev/null +++ b/tests/src/tracing/eventlistener/eventlistener.csproj @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{8E3244CB-407F-4142-BAAB-E7A55901A5FA}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <CLRTestKind>BuildAndRun</CLRTestKind> + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="EventListener.cs" /> + <ProjectReference Include="../common/common.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs b/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs index c12893d38a..2fa8786fd2 100644 --- a/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs +++ b/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs @@ -1,7 +1,5 @@ using System; -using System.Threading.Tasks; using System.IO; - using Tracing.Tests.Common; namespace Tracing.Tests diff --git a/tests/src/tracing/eventpipesmoke/eventpipesmoke.csproj b/tests/src/tracing/eventpipesmoke/eventpipesmoke.csproj index 8ba6eb5c4a..4a1cd0c0ce 100644 --- a/tests/src/tracing/eventpipesmoke/eventpipesmoke.csproj +++ b/tests/src/tracing/eventpipesmoke/eventpipesmoke.csproj @@ -12,7 +12,7 @@ <CLRTestKind>BuildAndRun</CLRTestKind> <DefineConstants>$(DefineConstants);STATIC</DefineConstants> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> - <CLRTestPriority>1</CLRTestPriority> + <CLRTestPriority>0</CLRTestPriority> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup> diff --git a/tests/src/tracing/eventpipetrace/EventPipeTrace.cs b/tests/src/tracing/eventpipetrace/EventPipeTrace.cs new file mode 100644 index 0000000000..af0c619ef9 --- /dev/null +++ b/tests/src/tracing/eventpipetrace/EventPipeTrace.cs @@ -0,0 +1,110 @@ +using System; +using System.IO; +using Tracing.Tests.Common; +using Microsoft.Diagnostics.Tracing; +using Microsoft.Diagnostics.Tracing.Parsers; +using Microsoft.Diagnostics.Tracing.Parsers.Clr; + +namespace Tracing.Tests +{ + class EventPipeTrace + { + private static int allocIterations = 10000; + private static int gcIterations = 10; + + static void AssertEqual<T>(T left, T right) where T : IEquatable<T> + { + if (left.Equals(right) == false) + { + throw new Exception(string.Format("Values were not equal! {0} and {1}", left, right)); + } + } + + static int Main(string[] args) + { + bool pass = true; + bool keepOutput = false; + + // Use the first arg as an output filename if there is one + string outputFilename = null; + if (args.Length >= 1) { + outputFilename = args[0]; + keepOutput = true; + } + else { + outputFilename = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".netperf"; + } + + try + { + Console.WriteLine("\tStart: Enable tracing."); + TraceControl.EnableDefault(outputFilename); + Console.WriteLine("\tEnd: Enable tracing.\n"); + + Console.WriteLine("\tStart: Generating CLR events"); + // Allocate for allocIterations iterations. + for(int i=0; i<allocIterations; i++) + { + GC.KeepAlive(new object()); + } + // GC gcIternation times + for(int i=0; i<gcIterations; i++) + { + GC.Collect(); + } + Console.WriteLine("\tEnd: Generating CLR Events\n"); + + Console.WriteLine("\tStart: Disable tracing."); + TraceControl.Disable(); + Console.WriteLine("\tEnd: Disable tracing.\n"); + + Console.WriteLine("\tStart: Processing events from file."); + int allocTickCount = 0; + int gcTriggerCount = 0; + using (var trace = TraceEventDispatcher.GetDispatcherFromFileName(outputFilename)) + { + trace.Clr.GCAllocationTick += delegate(GCAllocationTickTraceData data) + { + allocTickCount += 1; + + // Some basic integrity checks + // AssertEqual(data.TypeName, "System.Object"); https://github.com/Microsoft/perfview/issues/470 + AssertEqual(data.AllocationKind.ToString(), GCAllocationKind.Small.ToString()); + AssertEqual(data.ProviderName, "Microsoft-Windows-DotNETRuntime"); + AssertEqual(data.EventName, "GC/AllocationTick"); + }; + trace.Clr.GCTriggered += delegate(GCTriggeredTraceData data) + { + gcTriggerCount += 1; + + // Some basic integrity checks + AssertEqual(data.Reason.ToString(), GCReason.Induced.ToString()); + AssertEqual(data.ProviderName, "Microsoft-Windows-DotNETRuntime"); + AssertEqual(data.EventName, "GC/Triggered"); + }; + + trace.Process(); + } + Console.WriteLine("\tEnd: Processing events from file.\n"); + + Console.WriteLine("\tProcessed {0} GCAllocationTick events", allocTickCount); + Console.WriteLine("\tProcessed {0} GCTriggered events", gcTriggerCount); + + pass &= allocTickCount > 0; + pass &= gcTriggerCount == gcIterations; + } + finally { + if (keepOutput) + { + Console.WriteLine("\n\tOutput file: {0}", outputFilename); + } + else + { + System.IO.File.Delete(outputFilename); + } + } + + return pass ? 100 : 0; + } + } +} diff --git a/tests/src/tracing/eventpipetrace/eventpipetrace.csproj b/tests/src/tracing/eventpipetrace/eventpipetrace.csproj new file mode 100644 index 0000000000..ec7305abe9 --- /dev/null +++ b/tests/src/tracing/eventpipetrace/eventpipetrace.csproj @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{8E3244CB-407F-4142-BAAB-E7A55901A5FA}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <CLRTestKind>BuildAndRun</CLRTestKind> + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="EventPipeTrace.cs" /> + <ProjectReference Include="../common/common.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project>
\ No newline at end of file diff --git a/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs b/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs index b7d321dde6..ddd5192e18 100644 --- a/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs +++ b/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs @@ -1,8 +1,6 @@ using System; -using System.Threading.Tasks; using System.IO; using System.Diagnostics.Tracing; - using Tracing.Tests.Common; namespace Tracing.Tests diff --git a/tests/src/tracing/eventsourcetrace/EventSourceTrace.cs b/tests/src/tracing/eventsourcetrace/EventSourceTrace.cs new file mode 100644 index 0000000000..57a53183ed --- /dev/null +++ b/tests/src/tracing/eventsourcetrace/EventSourceTrace.cs @@ -0,0 +1,131 @@ +using System; +using System.IO; +using System.Collections.Generic; +using Tracing.Tests.Common; +using System.Diagnostics.Tracing; +using Microsoft.Diagnostics.Tracing; +using Microsoft.Diagnostics.Tracing.Parsers; +using Microsoft.Diagnostics.Tracing.Parsers.Clr; + +namespace Tracing.Tests +{ + [EventSource(Name = "SimpleEventSource")] + class SimpleEventSource : EventSource + { + public SimpleEventSource() : base(true) { } + + [Event(1)] + internal void MathResult(int x, int y, int z, string formula) { this.WriteEvent(1, x, y, z, formula); } + } + + class EventSourceTrace + { + private static int messageIterations = 10000; + + public static TraceConfiguration GetConfig(EventSource eventSource, string outputFile="default.netperf") + { + // Setup the configuration values. + uint circularBufferMB = 1024; // 1 GB + uint level = 5;//(uint)EventLevel.Informational; + TimeSpan profSampleDelay = TimeSpan.FromMilliseconds(1); + + // Create a new instance of EventPipeConfiguration. + TraceConfiguration config = new TraceConfiguration(outputFile, circularBufferMB); + // Setup the provider values. + // Public provider. + string providerName = eventSource.Name; + UInt64 keywords = 0xffffffffffffffff; + + // Enable the provider. + config.EnableProvider(providerName, keywords, level); + + // Set the sampling rate. + config.SetSamplingRate(profSampleDelay); + + return config; + } + + static int Main(string[] args) + { + bool pass = true; + bool keepOutput = false; + + // Use the first arg as an output filename if there is one + string outputFilename = null; + if (args.Length >= 1) { + outputFilename = args[0]; + keepOutput = true; + } + else { + outputFilename = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".netperf"; + } + + SimpleEventSource eventSource = new SimpleEventSource(); + + try + { + Console.WriteLine("\tStart: Enable tracing."); + TraceControl.Enable(GetConfig(eventSource, outputFilename)); + Console.WriteLine("\tEnd: Enable tracing.\n"); + + Console.WriteLine("\tStart: Messaging."); + // Send messages + // Use random numbers and addition as a simple, human readble checksum + Random generator = new Random(); + for(int i=0; i<messageIterations; i++) + { + int x = generator.Next(1,1000); + int y = generator.Next(1,1000); + string formula = String.Format("{0} + {1} = {2}", x, y, x+y); + + eventSource.MathResult(x, y, x+y, formula); + } + Console.WriteLine("\tEnd: Messaging.\n"); + + Console.WriteLine("\tStart: Disable tracing."); + TraceControl.Disable(); + Console.WriteLine("\tEnd: Disable tracing.\n"); + + Console.WriteLine("\tStart: Processing events from file."); + int msgCount = 0; + using (var trace = TraceEventDispatcher.GetDispatcherFromFileName(outputFilename)) + { + var names = new HashSet<string>(); + + trace.Dynamic.All += delegate(TraceEvent data) + { + if (!names.Contains(data.ProviderName)) + { + Console.WriteLine("\t{0}", data.ProviderName); + names.Add(data.ProviderName); + } + + if (data.ProviderName == "SimpleEventSource") + { + msgCount += 1; + } + }; + + trace.Process(); + } + Console.WriteLine("\tEnd: Processing events from file.\n"); + + Console.WriteLine("\tProcessed {0} events from EventSource", msgCount); + + pass &= msgCount == messageIterations; + } + finally { + if (keepOutput) + { + Console.WriteLine("\n\tOutput file: {0}", outputFilename); + } + else + { + System.IO.File.Delete(outputFilename); + } + } + + return pass ? 100 : 0; + } + } +} diff --git a/tests/src/tracing/eventsourcetrace/eventsourcetrace.csproj b/tests/src/tracing/eventsourcetrace/eventsourcetrace.csproj new file mode 100644 index 0000000000..833146ec64 --- /dev/null +++ b/tests/src/tracing/eventsourcetrace/eventsourcetrace.csproj @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{8E3244CB-407F-4142-BAAB-E7A55901A5FA}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <CLRTestKind>BuildAndRun</CLRTestKind> + <DefineConstants>$(DefineConstants);STATIC</DefineConstants> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <Compile Include="EventSourceTrace.cs" /> + <ProjectReference Include="../common/common.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project>
\ No newline at end of file |