Skip to content
Merged
Changes from all commits
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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.DotNet.RemoteExecutor;
using Microsoft.DotNet.XUnitExtensions; using Microsoft.DotNet.XUnitExtensions;
using Xunit; using Xunit;


Expand All @@ -28,8 +29,12 @@ public static void EventSource_ExistsWithCorrectId()
Assert.NotEmpty(EventSource.GenerateManifest(esType, "assemblyPathToIncludeInManifest")); Assert.NotEmpty(EventSource.GenerateManifest(esType, "assemblyPathToIncludeInManifest"));
} }


[ConditionalFact] [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void GetHostEntry_InvalidHost_LogsError() public void GetHostEntry_InvalidHost_LogsError()
{
try
{
RemoteExecutor.Invoke(static () =>
{ {
using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Error)) using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Error))
{ {
Expand Down Expand Up @@ -60,10 +65,20 @@ public void GetHostEntry_InvalidHost_LogsError()
Assert.NotNull(ev.Payload[2]); Assert.NotNull(ev.Payload[2]);
} }
} }
}).Dispose();
}
catch (Exception ex) when (ex.ToString().Contains(nameof(SkipTestException), StringComparison.Ordinal))
{
throw new SkipTestException(ex.ToString());
}
} }


[ConditionalFact] [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public async Task GetHostEntryAsync_InvalidHost_LogsError() public void GetHostEntryAsync_InvalidHost_LogsError()
{
try
{
RemoteExecutor.Invoke(static async () =>
{ {
using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Error)) using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Error))
{ {
Expand Down Expand Up @@ -95,6 +110,12 @@ await listener.RunWithCallbackAsync(ev => events.Enqueue(ev), async () =>
Assert.NotNull(ev.Payload[2]); Assert.NotNull(ev.Payload[2]);
} }
} }
}).Dispose();
}
catch (Exception ex) when (ex.ToString().Contains(nameof(SkipTestException), StringComparison.Ordinal))
{
throw new SkipTestException(ex.ToString());
}


static async Task WaitForErrorEventAsync(ConcurrentQueue<EventWrittenEventArgs> events) static async Task WaitForErrorEventAsync(ConcurrentQueue<EventWrittenEventArgs> events)
{ {
Expand All @@ -110,8 +131,12 @@ static async Task WaitForErrorEventAsync(ConcurrentQueue<EventWrittenEventArgs>
} }
} }


[ConditionalFact] [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void GetHostEntry_ValidName_NoErrors() public void GetHostEntry_ValidName_NoErrors()
{
try
{
RemoteExecutor.Invoke(static () =>
{ {
using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Verbose)) using (var listener = new TestEventListener("Private.InternalDiagnostics.System.Net.NameResolution", EventLevel.Verbose))
{ {
Expand All @@ -137,6 +162,12 @@ public void GetHostEntry_ValidName_NoErrors()
// No errors or warning for successful query. // No errors or warning for successful query.
Assert.True(events.Count(ev => (int)ev.Level > (int)EventLevel.Informational) == 0); Assert.True(events.Count(ev => (int)ev.Level > (int)EventLevel.Informational) == 0);
} }
}).Dispose();
}
catch (Exception ex) when (ex.ToString().Contains(nameof(SkipTestException), StringComparison.Ordinal))
{
throw new SkipTestException(ex.ToString());
}
} }
} }
} }