From d09bb0773ab7182a2f6303144208dbcf19218e79 Mon Sep 17 00:00:00 2001 From: Hungming Chen Date: Mon, 29 Aug 2022 21:43:55 +0800 Subject: [PATCH] EthernetTetheringTest: toggle wifi while test network is not selected Used to avoid flaky test because upstream changed events order can't be guaranteed. Once tethering choose non-test upstream {wifi, ..}, test network wont't be chosen. Fix flaky tests which are using initTetheringTester(): testIcmpv6Echo testTetherClatUdp testTetherUdpV4_VerifyBpf testTetherUdpV4 testTetherUdpV4Dns testTetherUdpV6 Moreover, add permission ACCESS_WIFI_STATE to AndroidManifest.xml to avoid nested runAsShell while using CtsNetUtils to access WIFI. STACKTRACE: java.lang.IllegalStateException: adoptShellPermissionIdentity calls must not be nested at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:49) at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:70) at com.android.testutils.TestPermissionUtil.runAsShell$default(TestPermissionUtil.kt:65) at com.android.testutils.TestPermissionUtil.runAsShell(Unknown Source:16) at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:293) at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:255) at android.net.cts.util.CtsNetUtils.toggleWifi(CtsNetUtils.java:160) Bug: 243314243 Test: atest EthernetTetheringTest Change-Id: I814899ae71f5c302d490a0dd81d7210ac138faa5 --- Tethering/tests/integration/Android.bp | 1 + .../tests/integration/AndroidManifest.xml | 1 + .../android/net/EthernetTetheringTest.java | 77 +++++++++++++++++-- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/Tethering/tests/integration/Android.bp b/Tethering/tests/integration/Android.bp index 9aa2cff821..11e3dc07fe 100644 --- a/Tethering/tests/integration/Android.bp +++ b/Tethering/tests/integration/Android.bp @@ -28,6 +28,7 @@ java_defaults { static_libs: [ "NetworkStackApiStableLib", "androidx.test.rules", + "cts-net-utils", "mockito-target-extended-minus-junit4", "net-tests-utils", "net-utils-device-common-bpf", diff --git a/Tethering/tests/integration/AndroidManifest.xml b/Tethering/tests/integration/AndroidManifest.xml index 9303d0a20b..7527913a4c 100644 --- a/Tethering/tests/integration/AndroidManifest.xml +++ b/Tethering/tests/integration/AndroidManifest.xml @@ -17,6 +17,7 @@ package="com.android.networkstack.tethering.tests.integration"> +