Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Expose OSThreadId and TimeStamp on EventWrittenEventArgs #19002

Merged
merged 13 commits into from
Aug 1, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace Debug.Assert with test-local Assert.
  • Loading branch information
brianrob committed Jul 31, 2018
commit 8250cd9b11a12f33e2c4afb6aa894ed27794c1d9
24 changes: 16 additions & 8 deletions tests/src/baseservices/threading/coverage/OSThreadId/OSThreadId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public static int Main(string[] args)
{
// The property to be tested is internal.
Type runtimeThreadType = typeof(object).Assembly.GetType("Internal.Runtime.Augments.RuntimeThread");
Debug.Assert(runtimeThreadType != null);
Assert(runtimeThreadType != null);
PropertyInfo osThreadIdProperty = runtimeThreadType.GetProperty("CurrentOSThreadId", BindingFlags.NonPublic | BindingFlags.Static);
Debug.Assert(osThreadIdProperty != null);
Assert(osThreadIdProperty != null);
s_osThreadIdGetMethod = osThreadIdProperty.GetGetMethod(true);
Debug.Assert(s_osThreadIdGetMethod != null);
Assert(s_osThreadIdGetMethod != null);

// Test the main thread.
Debug.Assert(GetCurrentThreadId() > 0);
Assert(GetCurrentThreadId() > 0);

// Create more threads.
Thread[] threads = new Thread[NumThreads];
Expand Down Expand Up @@ -53,8 +53,8 @@ public static int Main(string[] args)
}
else
{
Debug.Assert(s_threadIds[i] > 0);
Debug.Assert(previousThreadId != s_threadIds[i]);
Assert(s_threadIds[i] > 0);
Assert(previousThreadId != s_threadIds[i]);
previousThreadId = s_threadIds[i];
}
}
Expand All @@ -71,7 +71,7 @@ private static void ThreadProc(object state)
{
// Get the thread index.
int threadIndex = (int)state;
Debug.Assert(threadIndex >= 0 && threadIndex < NumThreads);
Assert(threadIndex >= 0 && threadIndex < NumThreads);

// Wait for all threads to be created.
s_resetEvent.WaitOne();
Expand All @@ -81,10 +81,18 @@ private static void ThreadProc(object state)
ulong threadId = GetCurrentThreadId();

// Ensure that the thread ID is valid.
Debug.Assert(threadId > 0);
Assert(threadId > 0);

// Save the thread ID so that it can be checked for duplicates.
s_threadIds[threadIndex] = threadId;
}

private static void Assert(bool condition)
{
if (!condition)
{
throw new Exception("Assertion failed.");
}
}
}
}