From 38aa51aaf2c6b1266ab679542b5fff4b4107f9fa Mon Sep 17 00:00:00 2001 From: Zhanglong Xia Date: Sun, 9 Mar 2025 13:59:17 +0800 Subject: [PATCH] skip the country code test when the country code is not support Setting country code is not a must support feature on all platforms. This commit skips the country code related tests when the platform doesn't support setting the country code. Bug: b/401793629 Test: atest ThreadNetworkIntegrationTests Change-Id: I6bb8444f70afb2635d7791af2128741bc02e8ff3 --- .../src/android/net/thread/ThreadIntegrationTest.java | 4 ++++ .../android/net/thread/ThreadNetworkShellCommandTest.java | 3 +++ .../src/android/net/thread/utils/OtDaemonController.java | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java b/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java index d41550b89c..8594518665 100644 --- a/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java +++ b/thread/tests/integration/src/android/net/thread/ThreadIntegrationTest.java @@ -40,6 +40,8 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static org.junit.Assume.assumeTrue; + import static java.util.concurrent.TimeUnit.SECONDS; import android.content.Context; @@ -216,6 +218,8 @@ public class ThreadIntegrationTest { @Test public void otDaemonRestart_latestCountryCodeIsSetToOtDaemon() throws Exception { + assumeTrue(mOtCtl.isCountryCodeSupported()); + runThreadCommand("force-country-code enabled CN"); runShellCommand("stop ot-daemon"); diff --git a/thread/tests/integration/src/android/net/thread/ThreadNetworkShellCommandTest.java b/thread/tests/integration/src/android/net/thread/ThreadNetworkShellCommandTest.java index 2f0ab34adf..5f0a17690d 100644 --- a/thread/tests/integration/src/android/net/thread/ThreadNetworkShellCommandTest.java +++ b/thread/tests/integration/src/android/net/thread/ThreadNetworkShellCommandTest.java @@ -28,6 +28,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeTrue; import android.content.Context; import android.net.thread.utils.FullThreadDevice; @@ -143,6 +144,8 @@ public class ThreadNetworkShellCommandTest { @Test public void forceCountryCode_setCN_getCountryCodeReturnsCN() { + assumeTrue(mOtCtl.isCountryCodeSupported()); + runThreadCommand("force-country-code enabled CN"); final String result = runThreadCommand("get-country-code"); diff --git a/thread/tests/integration/src/android/net/thread/utils/OtDaemonController.java b/thread/tests/integration/src/android/net/thread/utils/OtDaemonController.java index 9fbfa45867..272685fa4c 100644 --- a/thread/tests/integration/src/android/net/thread/utils/OtDaemonController.java +++ b/thread/tests/integration/src/android/net/thread/utils/OtDaemonController.java @@ -156,6 +156,12 @@ public final class OtDaemonController { return executeCommandAndParse("extpanid").get(0); } + public boolean isCountryCodeSupported() { + final String result = executeCommand("region"); + + return !result.equals("Error 12: NotImplemented\r\n"); + } + public String executeCommand(String cmd) { return SystemUtil.runShellCommand(OT_CTL + " " + cmd); }