Should a test really print to the Console? Presumably this should be adapted to detect if there is at least one valid route?
Also, what does a "soft failure" look like? Is there an example already in the mono source? Thanks for your help. -- From: Benjamin Woods [email protected] On 15 January 2015 at 23:16, Miguel de Icaza <[email protected]> wrote: > Hello, > > Considering that we do not even have a test, I think it would be nice to > turn one of the samples on the git discussion into the test. While not > 100% robust, we could check that at least *one* of the interfaces has a > gateway, and perhaps make this into a soft failure for those that do not > actually have a network with a gateway when running the tests. > > Miguel > > using System; > > using System.Net; > > using System.Net.NetworkInformation; > > > public class Test > > { > > public static void Main() > > { > > DisplayGatewayAddresses(); > > } > > > public static void DisplayGatewayAddresses() > > { > > Console.WriteLine("Gateways"); > > NetworkInterface[] adapters = > NetworkInterface.GetAllNetworkInterfaces(); > > foreach (NetworkInterface adapter in adapters) > > { > > IPInterfaceProperties adapterProperties = > adapter.GetIPProperties(); > > GatewayIPAddressInformationCollection addresses = > adapterProperties.GatewayAddresses; > > Console.WriteLine(adapter.Description); > > if (addresses.Count >0) > > { > > foreach (GatewayIPAddressInformation address in addresses) > > { > > Console.WriteLine(" Gateway Address > ......................... : {0}", > > address.Address.ToString()); > > } > > Console.WriteLine(); > > } > > } > > } > > } > > On Thu, Jan 15, 2015 at 8:58 AM, Ben Woods <[email protected]> wrote: > >> Mono is not able to get the system gateway address on Mac OSX or BSD when >> performing GetIPProperties on an a NetworkInterface. This is due to the >> mono class libraries solely utilising the /proc/net/route file, which is >> only available on Linux. >> >> I have submitted a pull request to fix this here: >> https://github.com/mono/mono/pull/1404 >> >> The last comment on the pull request is that the code looks good, but it >> would be nice to have a test added to the regression test suite. As I >> understand it, the test code would reside >> in mcs/class/System/Test/System.Net.NetworkInformation. >> >> What do you think the test would look like? Seeing as mono does not >> support setting the routing table, only reading it, it is difficult to >> assert that the default gateway would be. >> >> Perhaps simply that the code executes without error, regardless of the >> result, even if it is empty (it is possible for a system to not have a >> default route, after all). >> >> Thoughts? >> >> -- >> From: Benjamin Woods >> [email protected] >> >> _______________________________________________ >> Mono-devel-list mailing list >> [email protected] >> http://lists.ximian.com/mailman/listinfo/mono-devel-list >> >> >
_______________________________________________ Mono-devel-list mailing list [email protected] http://lists.ximian.com/mailman/listinfo/mono-devel-list
