[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-devel-list
Subject:    Re: [Mono-dev] Tests for ParseRouteInfo
From:       Ben Woods <woodsb02 () gmail ! com>
Date:       2015-01-17 5:37:11
Message-ID: CAOc73CD9kfQSFfvkOzmGFJwi9479uEqPh2my8GTsYa-H-RL6CQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


OK, I have now added regression tests to my pull request.
https://github.com/mono/mono/pull/1404

Could someone please check whether this is good to commit now?

Cheers,
Ben


--
From: Benjamin Woods
woodsb02@gmail.com

On 15 January 2015 at 23:33, Miguel de Icaza <miguel@xamarin.com> wrote:

> It does not need to print to console.
>
> Ignore the soft failure, let us jsut assert if there is no gateway (the
> soft failure part of my email was written before I changed my mind, and
> forgot to remove it).
>
> Miguel
>
> On Thu, Jan 15, 2015 at 10:28 AM, Ben Woods <woodsb02@gmail.com> wrote:
>
>> 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
>> woodsb02@gmail.com
>>
>> On 15 January 2015 at 23:16, Miguel de Icaza <miguel@xamarin.com> 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 <woodsb02@gmail.com> 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
>>>> woodsb02@gmail.com
>>>>
>>>> _______________________________________________
>>>> Mono-devel-list mailing list
>>>> Mono-devel-list@lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>>>
>>>>
>>>
>>
>

[Attachment #5 (text/html)]

<div dir="ltr">OK, I have now added regression tests to my pull request.<div><a \
href="https://github.com/mono/mono/pull/1404">https://github.com/mono/mono/pull/1404</a><br></div><div><br></div><div>Could \
someone please check whether this is good to commit \
now?</div><div><br></div><div>Cheers,</div><div>Ben</div><div><div \
class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><br>--<br>From: \
Benjamin Woods<br><a \
href="mailto:woodsb02@gmail.com">woodsb02@gmail.com</a></div></div> <br><div \
class="gmail_quote">On 15 January 2015 at 23:33, Miguel de Icaza <span \
dir="ltr">&lt;<a href="mailto:miguel@xamarin.com" \
target="_blank">miguel@xamarin.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr">It does not need to print to console.<div><br></div><div>Ignore the soft \
failure, let us jsut assert if there is no gateway (the soft failure part of my email \
was written before I changed my mind, and forgot to remove it).</div><span \
class=""><font color="#888888"><div><br></div><div>Miguel</div></font></span></div><div \
class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On \
Thu, Jan 15, 2015 at 10:28 AM, Ben Woods <span dir="ltr">&lt;<a \
href="mailto:woodsb02@gmail.com" target="_blank">woodsb02@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr">Should a test really print to the Console? Presumably this should be \
adapted to detect if there is at least one valid route?<div><br></div><div>Also, what \
does a &quot;soft failure&quot; look like? Is there an example already in the mono \
source?<br><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for \
your help.<span><br clear="all"><div><div><br>--<br>From: Benjamin Woods<br><a \
href="mailto:woodsb02@gmail.com" target="_blank">woodsb02@gmail.com</a></div></div> \
<br></span><div><div><div class="gmail_quote">On 15 January 2015 at 23:16, Miguel de \
Icaza <span dir="ltr">&lt;<a href="mailto:miguel@xamarin.com" \
target="_blank">miguel@xamarin.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
dir="ltr">Hello,<div><br></div><div>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.</div><div><br></div><div>Miguel</div><div><br></div><div>







<p><span>using System;</span></p>
<p><span>using System.Net;</span></p>
<p><span>using System.Net.NetworkInformation;</span></p>
<p><span></span><br></p>
<p><span>public class Test</span></p>
<p><span>{</span></p>
<p><span>      public static void Main()</span></p>
<p><span>      {</span></p>
<p><span>            DisplayGatewayAddresses();</span></p>
<p><span>      }</span></p>
<p><span></span><br></p>
<p><span>      public static void DisplayGatewayAddresses()</span></p>
<p><span>      {</span></p>
<p><span>            Console.WriteLine(&quot;Gateways&quot;);</span></p>
<p><span>            NetworkInterface[] adapters   = \
NetworkInterface.GetAllNetworkInterfaces();</span></p> <p><span>            foreach \
(NetworkInterface adapter in adapters)</span></p> <p><span>            {</span></p>
<p><span>                  IPInterfaceProperties adapterProperties = \
adapter.GetIPProperties();</span></p> <p><span>                  \
GatewayIPAddressInformationCollection addresses = \
adapterProperties.GatewayAddresses;</span></p> <p><span>                  \
Console.WriteLine(adapter.Description);</span></p> <p><span>                  if \
(addresses.Count &gt;0)</span></p> <p><span>                  {</span></p>
<p><span>                        foreach (GatewayIPAddressInformation address in \
addresses)</span></p> <p><span>                        {</span></p>
<p><span>                              Console.WriteLine(&quot;   Gateway Address \
......................... : {0}&quot;,  </span></p> <p><span>                         \
address.Address.ToString());</span></p> <p><span>                        }</span></p>
<p><span>                        Console.WriteLine();</span></p>
<p><span>                  }</span></p>
<p><span>            }</span></p>
<p><span>      }</span></p>
<p><span>}</span></p></div></div><div class="gmail_extra"><br><div \
class="gmail_quote"><div><div>On Thu, Jan 15, 2015 at 8:58 AM, Ben Woods <span \
dir="ltr">&lt;<a href="mailto:woodsb02@gmail.com" \
target="_blank">woodsb02@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div \
dir="ltr">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.<div><br></div><div>I have submitted a pull request to fix this here:<br><a \
href="https://github.com/mono/mono/pull/1404" \
target="_blank">https://github.com/mono/mono/pull/1404</a><br><br>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.</div><div><br></div><div>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.</div><div><br></div><div>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).</div><div><br></div><div>Thoughts?<br><br>--<br>From: Benjamin Woods<br><a \
href="mailto:woodsb02@gmail.com" target="_blank">woodsb02@gmail.com</a> </div></div>
<br></div></div>_______________________________________________<br>
Mono-devel-list mailing list<br>
<a href="mailto:Mono-devel-list@lists.ximian.com" \
target="_blank">Mono-devel-list@lists.ximian.com</a><br> <a \
href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" \
target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br> \
<br></blockquote></div><br></div> \
</blockquote></div><br></div></div></div></div></div> </blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>



_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic