summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSung Yoon Whang <suwhang@microsoft.com>2019-07-01 22:25:31 -0700
committerGitHub <noreply@github.com>2019-07-01 22:25:31 -0700
commit0d8304713fb2766b84c90616d2b88a622db1924e (patch)
tree78b0a07bcd44f281a3730584e82554f0a811f184 /tests
parente6e170fdec2bb20a76126bd9b40e4a284e6c92f2 (diff)
downloadcoreclr-0d8304713fb2766b84c90616d2b88a622db1924e.tar.gz
coreclr-0d8304713fb2766b84c90616d2b88a622db1924e.tar.bz2
coreclr-0d8304713fb2766b84c90616d2b88a622db1924e.zip
test DisplayUnits/DisplayRateTimeScale properties (#25525)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/tracing/eventcounter/incrementingeventcounter.cs15
-rw-r--r--tests/src/tracing/eventcounter/incrementingpollingcounter.cs43
2 files changed, 50 insertions, 8 deletions
diff --git a/tests/src/tracing/eventcounter/incrementingeventcounter.cs b/tests/src/tracing/eventcounter/incrementingeventcounter.cs
index 3ad7693a87..a50b859ecf 100644
--- a/tests/src/tracing/eventcounter/incrementingeventcounter.cs
+++ b/tests/src/tracing/eventcounter/incrementingeventcounter.cs
@@ -23,7 +23,7 @@ namespace BasicEventSourceTests
public SimpleEventSource(string _displayName, string _displayUnits)
{
- _myCounter = new IncrementingEventCounter("test-counter", this) { DisplayName = _displayName, DisplayUnits = _displayUnits };
+ _myCounter = new IncrementingEventCounter("test-counter", this) { DisplayName = _displayName, DisplayUnits = _displayUnits, DisplayRateTimeScale = new TimeSpan(0, 0, 1) };
}
public void IncrementCounter()
@@ -41,6 +41,7 @@ namespace BasicEventSourceTests
public int incrementSum;
public string displayName;
public string displayUnits;
+ public string displayRateTimeScale;
public SimpleEventListener(string targetSourceName, EventLevel level)
{
@@ -84,6 +85,10 @@ namespace BasicEventSourceTests
{
displayUnits = payload.Value.ToString();
}
+ else if (payload.Key.Equals("DisplayRateTimeScale"))
+ {
+ displayRateTimeScale = payload.Value.ToString();
+ }
}
}
}
@@ -126,10 +131,16 @@ namespace BasicEventSourceTests
if (displayUnits != myListener.displayUnits)
{
Console.WriteLine("Test Failed");
- Console.WriteLine($"Expected to see {displayUnits} as DisplayName property in payload - saw {myListener.displayUnits}");
+ Console.WriteLine($"Expected to see {displayUnits} as DisplayUnits property in payload - saw {myListener.displayUnits}");
return 1;
}
+ if (!myListener.displayRateTimeScale.Equals("00:00:01"))
+ {
+ Console.WriteLine("Test failed");
+ Console.WriteLine($"Wrong DisplayRateTimeScale: {myListener.displayRateTimeScale}");
+ }
+
Console.WriteLine("Test passed");
return 100;
}
diff --git a/tests/src/tracing/eventcounter/incrementingpollingcounter.cs b/tests/src/tracing/eventcounter/incrementingpollingcounter.cs
index f61c985cb1..cd4ea74098 100644
--- a/tests/src/tracing/eventcounter/incrementingpollingcounter.cs
+++ b/tests/src/tracing/eventcounter/incrementingpollingcounter.cs
@@ -22,7 +22,7 @@ namespace BasicEventSourceTests
public SimpleEventSource(Func<double> getMockedCount)
{
- _mockedCounter = new IncrementingPollingCounter("failureCount", this, getMockedCount);
+ _mockedCounter = new IncrementingPollingCounter("failureCount", this, getMockedCount) { DisplayName = "Failure Count", DisplayUnits = "Count", DisplayRateTimeScale = new TimeSpan(0, 0, 1) };
}
}
@@ -35,6 +35,9 @@ namespace BasicEventSourceTests
public int FailureEventCount { get; private set; } = 0;
public bool Failed = false;
public bool MetadataSet = false;
+ public string displayName = "";
+ public string displayRateTimeScale = "";
+ public string displayUnits = "";
public SimpleEventListener(string targetSourceName, EventLevel level)
{
@@ -76,6 +79,18 @@ namespace BasicEventSourceTests
{
increment = payload.Value.ToString();
}
+ else if (payload.Key.Equals("DisplayRateTimeScale"))
+ {
+ displayRateTimeScale = payload.Value.ToString();
+ }
+ else if (payload.Key.Equals("DisplayName"))
+ {
+ displayName = payload.Value.ToString();
+ }
+ else if (payload.Key.Equals("DisplayUnits"))
+ {
+ displayUnits = payload.Value.ToString();
+ }
}
// Check if the mean is what we expect it to be
@@ -107,16 +122,32 @@ namespace BasicEventSourceTests
// Want to sleep for 5000 ms to get some counters piling up.
Thread.Sleep(5000);
- if (!myListener.Failed && mockedCountCalled > 0)
+ if (myListener.Failed || mockedCountCalled <= 0)
{
- Console.WriteLine("Test Passed");
- return 100;
+ Console.WriteLine($"Test Failed - mockedCountCalled = {mockedCountCalled}, myListener.Failed = {myListener.Failed}");
+ return 1;
}
- else
+
+ if (myListener.displayRateTimeScale != "00:00:01")
+ {
+ Console.WriteLine($"Test Failed - Incorrect DisplayRateTimeScale in payload: {myListener.displayRateTimeScale}");
+ return 1;
+ }
+
+ if (myListener.displayName != "Failure Count")
+ {
+ Console.WriteLine($"Test Failed - Incorrect DisplayName in payload: {myListener.displayName}");
+ return 1;
+ }
+
+ if (myListener.displayUnits != "Count")
{
- Console.WriteLine("Test Failed");
+ Console.WriteLine($"Test failed - Incorrect DisplayUnits in payload: {myListener.displayUnits}");
return 1;
}
+
+ Console.WriteLine("Test passed");
+ return 100;
}
}
}