From c1bbdae7964b19b7063074d36e6af960f0cdc3a0 Mon Sep 17 00:00:00 2001 From: "Victor \"Nate\" Graf" Date: Tue, 2 Jan 2018 09:47:20 -0800 Subject: 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 --- tests/runtest.proj | 3 +- .../cti/system/convert/convertfrombase64string.cs | 4 +- .../cti/system/string/stringcompare9.cs | 8 +- .../CoreMangLib/cti/system/string/stringequals6.cs | 8 +- .../cti/system/string/stringindexof10.cs | 8 +- .../cti/system/text/encoding/encodinggetbytes1.cs | 18 +-- .../system/text/encoding/encodinggetcharcount.cs | Bin 26652 -> 26676 bytes .../cti/system/text/encoding/encodinggetchars1.cs | Bin 40576 -> 40600 bytes .../cti/system/text/encoding/encodinggetstring.cs | Bin 26012 -> 26036 bytes .../cti/system/timespan/timespantostring_str.cs | 12 +- .../cti/system/uint64/uint64tostring2.cs | 2 +- tests/src/Interop/BestFitMapping/BestFitMapping.cs | Bin 66960 -> 66984 bytes .../benchmark+roslyn/benchmark+roslyn.csproj | 3 + tests/src/JIT/config/benchmark/benchmark.csproj | 3 + tests/src/dirs.proj | 2 + tests/src/performance/performance.csproj | 3 + tests/src/tracing/common/common.csproj | 2 +- tests/src/tracing/eventlistener/EventListener.cs | 77 ++++++++++++ .../src/tracing/eventlistener/eventlistener.csproj | 32 +++++ tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs | 2 - .../tracing/eventpipesmoke/eventpipesmoke.csproj | 2 +- tests/src/tracing/eventpipetrace/EventPipeTrace.cs | 110 +++++++++++++++++ .../tracing/eventpipetrace/eventpipetrace.csproj | 30 +++++ .../tracing/eventsourcesmoke/EventSourceSmoke.cs | 2 - .../tracing/eventsourcetrace/EventSourceTrace.cs | 131 +++++++++++++++++++++ .../eventsourcetrace/eventsourcetrace.csproj | 30 +++++ 26 files changed, 454 insertions(+), 38 deletions(-) create mode 100644 tests/src/tracing/eventlistener/EventListener.cs create mode 100644 tests/src/tracing/eventlistener/eventlistener.csproj create mode 100644 tests/src/tracing/eventpipetrace/EventPipeTrace.cs create mode 100644 tests/src/tracing/eventpipetrace/eventpipetrace.csproj create mode 100644 tests/src/tracing/eventsourcetrace/EventSourceTrace.cs create mode 100644 tests/src/tracing/eventsourcetrace/eventsourcetrace.csproj (limited to 'tests') 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 @@ - <_SkipTestDir Include="@(DisabledTestDir)" /> @@ -404,4 +403,4 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). - \ No newline at end of file + 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 index cc1953ce88..1f61bbdeba 100644 Binary files a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs and b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetcharcount.cs differ diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs index 0f24507700..e191e01173 100644 Binary files a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs and b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetchars1.cs differ diff --git a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs index 44289f7b0d..f4116e4d3f 100644 Binary files a/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs and b/tests/src/CoreMangLib/cti/system/text/encoding/encodinggetstring.cs differ 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 index 643ddc9d21..1778d79e4e 100755 Binary files a/tests/src/Interop/BestFitMapping/BestFitMapping.cs and b/tests/src/Interop/BestFitMapping/BestFitMapping.cs differ 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 @@ 4.4.0-beta-24913-02 + + 4.4.0-beta-24913-02 + 4.4.0-beta-24913-02 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 @@ 4.4.0-beta-24913-02 + + 4.4.0-beta-24913-02 + 4.4.0-beta-24913-02 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 @@ + + 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 @@ 4.4.0-beta-24913-02 + + 4.4.0-beta-24913-02 + 4.4.0-beta-24913-02 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 @@ BuildOnly $(DefineConstants);STATIC true - 1 + 0 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 + + + + Debug + AnyCPU + 2.0 + {8E3244CB-407F-4142-BAAB-E7A55901A5FA} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + BuildAndRun + $(DefineConstants);STATIC + true + 0 + + + + + + + + + False + + + + + + + + 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 @@ BuildAndRun $(DefineConstants);STATIC true - 1 + 0 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 left, T right) where T : IEquatable + { + 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 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 @@ + + + + + Debug + AnyCPU + 2.0 + {8E3244CB-407F-4142-BAAB-E7A55901A5FA} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + BuildAndRun + $(DefineConstants);STATIC + true + 0 + + + + + + + False + + + + + + + + \ 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(); + + 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 @@ + + + + + Debug + AnyCPU + 2.0 + {8E3244CB-407F-4142-BAAB-E7A55901A5FA} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + BuildAndRun + $(DefineConstants);STATIC + true + 1 + + + + + + + False + + + + + + + + \ No newline at end of file -- cgit v1.2.3