Merge "Apply jarjar rules on coverage tests"

This commit is contained in:
Remi NGUYEN VAN
2021-06-30 23:53:57 +00:00
committed by Gerrit Code Review
6 changed files with 49 additions and 16 deletions

View File

@@ -22,7 +22,7 @@ filegroup {
name: "TetheringTestsJarJarRules", name: "TetheringTestsJarJarRules",
srcs: ["jarjar-rules.txt"], srcs: ["jarjar-rules.txt"],
visibility: [ visibility: [
"//frameworks/base/packages/Tethering/tests:__subpackages__", "//packages/modules/Connectivity/tests:__subpackages__",
"//packages/modules/Connectivity/Tethering/tests:__subpackages__", "//packages/modules/Connectivity/Tethering/tests:__subpackages__",
] ]
} }

View File

@@ -78,9 +78,27 @@ android_test {
compile_multilib: "both", compile_multilib: "both",
} }
android_library {
name: "TetheringCoverageTestsLib",
min_sdk_version: "30",
static_libs: [
"NetdStaticLibTestsLib",
"NetworkStaticLibTestsLib",
"NetworkStackTestsLib",
"TetheringTestsLatestSdkLib",
"TetheringIntegrationTestsLatestSdkLib",
],
jarjar_rules: ":TetheringTestsJarJarRules",
manifest: "AndroidManifest_coverage.xml",
visibility: [
"//packages/modules/Connectivity/tests:__subpackages__"
],
}
// Special version of the tethering tests that includes all tests necessary for code coverage // Special version of the tethering tests that includes all tests necessary for code coverage
// purposes. This is currently the union of TetheringTests, TetheringIntegrationTests and // purposes. This is currently the union of TetheringTests, TetheringIntegrationTests and
// NetworkStackTests. // NetworkStackTests.
// TODO: remove in favor of ConnectivityCoverageTests, which includes below tests and more
android_test { android_test {
name: "TetheringCoverageTests", name: "TetheringCoverageTests",
platform_apis: true, platform_apis: true,
@@ -91,11 +109,7 @@ android_test {
defaults: ["libnetworkstackutilsjni_deps"], defaults: ["libnetworkstackutilsjni_deps"],
static_libs: [ static_libs: [
"modules-utils-native-coverage-listener", "modules-utils-native-coverage-listener",
"NetdStaticLibTestsLib", "TetheringCoverageTestsLib",
"NetworkStaticLibTestsLib",
"NetworkStackTestsLib",
"TetheringTestsLatestSdkLib",
"TetheringIntegrationTestsLatestSdkLib",
], ],
jni_libs: [ jni_libs: [
// For mockito extended // For mockito extended

View File

@@ -75,7 +75,6 @@ java_defaults {
"libstaticjvmtiagent", "libstaticjvmtiagent",
"libtetherutilsjni", "libtetherutilsjni",
], ],
jarjar_rules: ":TetheringTestsJarJarRules",
} }
// Library containing the unit tests. This is used by the coverage test target to pull in the // Library containing the unit tests. This is used by the coverage test target to pull in the
@@ -100,4 +99,5 @@ android_test {
], ],
defaults: ["TetheringTestsDefaults"], defaults: ["TetheringTestsDefaults"],
compile_multilib: "both", compile_multilib: "both",
jarjar_rules: ":TetheringTestsJarJarRules",
} }

View File

@@ -112,3 +112,9 @@ java_library {
"com.android.tethering", "com.android.tethering",
], ],
} }
filegroup {
name: "connectivity-jarjar-rules",
srcs: ["jarjar-rules.txt"],
visibility: ["//packages/modules/Connectivity:__subpackages__"],
}

View File

@@ -43,6 +43,23 @@ java_library {
], ],
} }
// Connectivity coverage tests combines Tethering and Connectivity tests, each with their
// respective jarjar rules applied.
// Some tests may be duplicated (in particular static lib tests), as they need to be run under both
// jarjared packages to cover both usages.
android_library {
name: "ConnectivityCoverageTestsLib",
min_sdk_version: "30",
static_libs: [
"FrameworksNetTestsLib",
"NetdStaticLibTestsLib",
"NetworkStaticLibTestsLib",
],
jarjar_rules: ":connectivity-jarjar-rules",
manifest: "AndroidManifest_coverage.xml",
visibility: ["//visibility:private"],
}
android_test { android_test {
name: "ConnectivityCoverageTests", name: "ConnectivityCoverageTests",
// Tethering started on SDK 30 // Tethering started on SDK 30
@@ -62,13 +79,9 @@ android_test {
// (some tests would fail). // (some tests would fail).
// TODO: consider removing extended mockito usage in tests that use it, for performance // TODO: consider removing extended mockito usage in tests that use it, for performance
"mockito-target-extended-minus-junit4", "mockito-target-extended-minus-junit4",
"FrameworksNetTestsLib",
"modules-utils-native-coverage-listener", "modules-utils-native-coverage-listener",
"NetdStaticLibTestsLib", "ConnectivityCoverageTestsLib",
"NetworkStaticLibTestsLib", "TetheringCoverageTestsLib",
"NetworkStackTestsLib",
"TetheringTestsLatestSdkLib",
"TetheringIntegrationTestsLatestSdkLib",
], ],
jni_libs: [ jni_libs: [
// For mockito extended // For mockito extended

View File

@@ -19,6 +19,8 @@ package android.net.metrics;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static com.android.net.module.util.NetworkCapabilitiesUtils.unpackBits;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.timeout;
@@ -31,8 +33,6 @@ import android.net.Network;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4;
import com.android.internal.util.BitUtils;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -49,7 +49,7 @@ import java.util.List;
@SmallTest @SmallTest
public class IpConnectivityLogTest { public class IpConnectivityLogTest {
private static final int FAKE_NET_ID = 100; private static final int FAKE_NET_ID = 100;
private static final int[] FAKE_TRANSPORT_TYPES = BitUtils.unpackBits(TRANSPORT_WIFI); private static final int[] FAKE_TRANSPORT_TYPES = unpackBits(TRANSPORT_WIFI);
private static final long FAKE_TIME_STAMP = System.currentTimeMillis(); private static final long FAKE_TIME_STAMP = System.currentTimeMillis();
private static final String FAKE_INTERFACE_NAME = "test"; private static final String FAKE_INTERFACE_NAME = "test";
private static final IpReachabilityEvent FAKE_EV = private static final IpReachabilityEvent FAKE_EV =