Merge "skip the country code test when the country code is not support" into main

This commit is contained in:
Treehugger Robot 2025-03-09 21:49:10 -07:00 • committed by Gerrit Code Review
commit 749898bb1e
3 changed files with 13 additions and 0 deletions

View file

@ -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;
@ -213,6 +215,8 @@ public class ThreadIntegrationTest {
@Test
public void otDaemonRestart_latestCountryCodeIsSetToOtDaemon() throws Exception {
assumeTrue(mOtCtl.isCountryCodeSupported());
runThreadCommand("force-country-code enabled CN");
runShellCommand("stop ot-daemon");

View file

@ -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;
@ -139,6 +140,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");

View file

@ -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);
}