Skip to content

Commit

Permalink
[tests] Simplify NWPathTest.EnumerateGatewayTest (#20853)
Browse files Browse the repository at this point in the history
* Remove code to test NWPath.EnumerateInterfaces, because this method is already tested elsewhere.
* Assume that if the test fails to find any gateways, it might be because the
  current machine doesn't have any (which happens on one of my machines), and
  in that case ignore the test.
  • Loading branch information
rolfbjarne authored Jul 10, 2024
1 parent b3fc0d9 commit 4fd259d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tests/monotouch-test/Network/NWPathTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,21 @@ public void EnumerateGatewayNullCallbackTest ()
public void EnumerateGatewayTest ()
{
var e1 = new TaskCompletionSource<bool> ();
var e2 = new TaskCompletionSource<bool> ();
var monitor = new NWPathMonitor ();
try {
monitor.SetQueue (DispatchQueue.DefaultGlobalQueue);
monitor.Start ();
monitor.SnapshotHandler += path => {
path.EnumerateGateways (gateway => {
e1.TrySetResult (true);
return true;
});
path.EnumerateInterfaces (@interface => {
e2.TrySetResult (true);
return true;
});
};
monitor.Start ();
var rv = TestRuntime.RunAsync (TimeSpan.FromSeconds (5),
Task.CompletedTask,
Task.WhenAll (e1.Task, e2.Task));
e1.Task);
if (!rv)
TestRuntime.IgnoreInCI ("This test doesn't seem to be working on the bots, uncommon network setup?");
Assert.Ignore ("No gateways on this machine?"); // no gateways isn't all that uncommon, so just always ignore in this case.
Assert.IsTrue (rv, "Called back");
} finally {
monitor.Cancel ();
Expand Down

8 comments on commit 4fd259d

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.