Don't run the ping test on certain Android devices
authorMarek Habersack <grendel@twistedcode.net>
Wed, 22 Jun 2016 12:42:51 +0000 (14:42 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 22 Jun 2016 12:46:40 +0000 (14:46 +0200)
As described in https://bugzilla.xamarin.com/show_bug.cgi?id=34883 at
least Samsung SG3 doesn't allow access to the local network
interface (in fact, even ifconfig doesn't work on the device). Therefore
the test needs to be disabled on those devices. This is the first part
of the fix, the second one will be implemented in Xamarin.Android test
suite which will provide the AndroidShouldPingWork method which will
check the device id against list of those that do not work for this
test.

Part #1 of fix for https://bugzilla.xamarin.com/show_bug.cgi?id=34883

mcs/class/System/Test/System.Net.NetworkInformation/PingTest.cs

index 6e83c3090ec0038d44a7c54e04cc73e5ed99c56a..2cbdb6838ca70d001a1c3478acd40a7d2871a302 100644 (file)
@@ -7,9 +7,11 @@ using System.Threading;
 namespace MonoTests.System.Net.NetworkInformation
 {
        [TestFixture]
-       public class PingTest
+       public partial class PingTest
        {
-               [Test] 
+               partial void AndroidShouldPingWork (ref bool shouldWork);
+
+               [Test]
                public void PingFail()
                {
 #if MONOTOUCH
@@ -26,8 +28,13 @@ namespace MonoTests.System.Net.NetworkInformation
 #if MONOTOUCH
                        Assert.Ignore ("Ping implementation is broken on MT (requires sudo access)");
 #else
-                       var p = new Ping ().Send ("127.0.0.1");
-                       Assert.AreEqual(IPStatus.Success, p.Status);
+                       bool shouldWork = true;
+                       AndroidShouldPingWork (ref shouldWork);
+                       if (shouldWork) {
+                               var p = new Ping ().Send ("127.0.0.1");
+                               Assert.AreEqual(IPStatus.Success, p.Status);
+                       } else
+                               Assert.Ignore ("Ping will not work on this Android device");
 #endif
                }