From d5e2ac94d1b8f867eff84485d7ab8724819c8eca Mon Sep 17 00:00:00 2001 From: Handa Wang Date: Wed, 17 Jan 2024 10:00:52 +0800 Subject: [PATCH] Ensure the Thread integration test only run on CuttleFish devices This is because the test case relies on **simulation** Thread radio, which is currently only available on CuttleFish. Bug: 295843010 Test: atest android.net.thread.BorderRoutingTest Change-Id: Icd29d91c9ec9912e27191e97fe7f58e9067c1d8c --- .../src/android/net/thread/BorderRoutingTest.java | 4 ++++ .../src/android/net/thread/IntegrationTestUtils.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java b/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java index 5d3818a4b5..ba7e4b8f23 100644 --- a/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java +++ b/thread/tests/integration/src/android/net/thread/BorderRoutingTest.java @@ -18,6 +18,7 @@ package android.net.thread; import static android.Manifest.permission.MANAGE_TEST_NETWORKS; import static android.net.thread.IntegrationTestUtils.isExpectedIcmpv6Packet; +import static android.net.thread.IntegrationTestUtils.isSimulatedThreadRadioSupported; import static android.net.thread.IntegrationTestUtils.newPacketReader; import static android.net.thread.IntegrationTestUtils.readPacketFrom; import static android.net.thread.IntegrationTestUtils.waitFor; @@ -33,6 +34,7 @@ import static com.google.common.io.BaseEncoding.base16; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assume.assumeTrue; import android.content.Context; import android.net.LinkProperties; @@ -131,6 +133,8 @@ public class BorderRoutingTest { @Test public void infraDevicePingTheadDeviceOmr_Succeeds() throws Exception { + assumeTrue(isSimulatedThreadRadioSupported()); + /* *
          * Topology:
diff --git a/thread/tests/integration/src/android/net/thread/IntegrationTestUtils.java b/thread/tests/integration/src/android/net/thread/IntegrationTestUtils.java
index 9d9a4ff749..c465d572ec 100644
--- a/thread/tests/integration/src/android/net/thread/IntegrationTestUtils.java
+++ b/thread/tests/integration/src/android/net/thread/IntegrationTestUtils.java
@@ -25,6 +25,7 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
 import android.net.TestNetworkInterface;
 import android.os.Handler;
 import android.os.SystemClock;
+import android.os.SystemProperties;
 
 import com.android.net.module.util.Struct;
 import com.android.net.module.util.structs.Icmpv6Header;
@@ -50,6 +51,12 @@ import java.util.function.Supplier;
 public final class IntegrationTestUtils {
     private IntegrationTestUtils() {}
 
+    /** Returns whether the device supports simulated Thread radio. */
+    public static boolean isSimulatedThreadRadioSupported() {
+        // The integration test uses SIMULATION Thread radio so that it only supports CuttleFish.
+        return SystemProperties.get("ro.product.model").startsWith("Cuttlefish");
+    }
+
     /**
      * Waits for the given {@link Supplier} to be true until given timeout.
      *