Merge "ConnectivityCoverageTests refactoring"
This commit is contained in:
@@ -137,9 +137,6 @@
|
||||
"exclude-annotation": "androidx.test.filters.RequiresDevice"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TetheringCoverageTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]"
|
||||
}
|
||||
],
|
||||
"auto-postsubmit": [
|
||||
|
||||
@@ -83,68 +83,3 @@ android_test {
|
||||
compile_multilib: "both",
|
||||
jarjar_rules: ":NetworkStackJarJarRules",
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "TetheringCoverageTestsLib",
|
||||
min_sdk_version: "30",
|
||||
static_libs: [
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
"NetworkStackTestsLib",
|
||||
"TetheringTestsLatestSdkLib",
|
||||
"TetheringIntegrationTestsLatestSdkLib",
|
||||
],
|
||||
// Jarjar rules should normally be applied on final artifacts and not intermediate libraries as
|
||||
// applying different rules on intermediate libraries can cause conflicts when combining them
|
||||
// (the resulting artifact can end up with multiple incompatible implementations of the same
|
||||
// classes). But this library is used to combine tethering coverage tests with connectivity
|
||||
// coverage tests into a single coverage target. The tests need to use the same jarjar rules as
|
||||
// covered production code for coverage to be calculated properly, so jarjar is applied
|
||||
// separately on each set of tests.
|
||||
jarjar_rules: ":TetheringCoverageJarJarRules",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
visibility: [
|
||||
"//packages/modules/Connectivity/tests:__subpackages__"
|
||||
],
|
||||
}
|
||||
|
||||
// Combine NetworkStack and Tethering jarjar rules for coverage target. The jarjar files are
|
||||
// simply concatenated in the order specified in srcs.
|
||||
genrule {
|
||||
name: "TetheringCoverageJarJarRules",
|
||||
srcs: [
|
||||
":TetheringTestsJarJarRules",
|
||||
":NetworkStackJarJarRules",
|
||||
],
|
||||
out: ["jarjar-rules-tethering-coverage.txt"],
|
||||
cmd: "cat $(in) > $(out)",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
// Special version of the tethering tests that includes all tests necessary for code coverage
|
||||
// purposes. This is currently the union of TetheringTests, TetheringIntegrationTests and
|
||||
// NetworkStackTests.
|
||||
// TODO: remove in favor of ConnectivityCoverageTests, which includes below tests and more
|
||||
android_test {
|
||||
name: "TetheringCoverageTests",
|
||||
platform_apis: true,
|
||||
min_sdk_version: "30",
|
||||
target_sdk_version: "31",
|
||||
test_suites: ["device-tests", "mts-tethering"],
|
||||
test_config: "AndroidTest_Coverage.xml",
|
||||
defaults: ["libnetworkstackutilsjni_deps"],
|
||||
static_libs: [
|
||||
"modules-utils-native-coverage-listener",
|
||||
"TetheringCoverageTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
"libdexmakerjvmtiagent",
|
||||
"libstaticjvmtiagent",
|
||||
// For NetworkStackUtils included in NetworkStackBase
|
||||
"libnetworkstackutilsjni",
|
||||
"libcom_android_networkstack_tethering_util_jni",
|
||||
],
|
||||
compile_multilib: "both",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.android.networkstack.tethering.tests.coverage">
|
||||
|
||||
<application tools:replace="android:label"
|
||||
android:debuggable="true"
|
||||
android:label="Tethering coverage tests">
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.networkstack.tethering.tests.coverage"
|
||||
android:label="Tethering coverage tests">
|
||||
</instrumentation>
|
||||
</manifest>
|
||||
@@ -1,13 +0,0 @@
|
||||
<configuration description="Runs coverage tests for Tethering">
|
||||
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
|
||||
<option name="test-file-name" value="TetheringCoverageTests.apk" />
|
||||
</target_preparer>
|
||||
|
||||
<option name="test-tag" value="TetheringCoverageTests" />
|
||||
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
|
||||
<option name="package" value="com.android.networkstack.tethering.tests.coverage" />
|
||||
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
|
||||
<option name="hidden-api-checks" value="false"/>
|
||||
<option name="device-listeners" value="com.android.modules.utils.testing.NativeCoverageHackInstrumentationListener" />
|
||||
</test>
|
||||
</configuration>
|
||||
@@ -7,6 +7,8 @@ rule com.android.internal.util.MessageUtils* com.android.networkstack.tethering.
|
||||
rule com.android.internal.util.State* com.android.networkstack.tethering.util.State@1
|
||||
rule com.android.internal.util.StateMachine* com.android.networkstack.tethering.util.StateMachine@1
|
||||
rule com.android.internal.util.TrafficStatsConstants* com.android.networkstack.tethering.util.TrafficStatsConstants@1
|
||||
# Keep other com.android.internal.util as-is
|
||||
rule com.android.internal.util.** @0
|
||||
|
||||
rule android.util.LocalLog* com.android.networkstack.tethering.util.LocalLog@1
|
||||
|
||||
|
||||
@@ -43,10 +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.
|
||||
// Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target.
|
||||
// The jarjar files are simply concatenated in the order specified in srcs.
|
||||
// jarjar stops at the first matching rule, so order of concatenation affects the output.
|
||||
genrule {
|
||||
name: "ConnectivityCoverageJarJarRules",
|
||||
srcs: [
|
||||
"tethering-jni-jarjar-rules.txt",
|
||||
":connectivity-jarjar-rules",
|
||||
":TetheringTestsJarJarRules",
|
||||
":NetworkStackJarJarRules",
|
||||
],
|
||||
out: ["jarjar-rules-connectivity-coverage.txt"],
|
||||
// Concat files with a line break in the middle
|
||||
cmd: "for src in $(in); do cat $${src}; echo; done > $(out)",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "ConnectivityCoverageTestsLib",
|
||||
min_sdk_version: "30",
|
||||
@@ -54,8 +67,11 @@ android_library {
|
||||
"FrameworksNetTestsLib",
|
||||
"NetdStaticLibTestsLib",
|
||||
"NetworkStaticLibTestsLib",
|
||||
"NetworkStackTestsLib",
|
||||
"TetheringTestsLatestSdkLib",
|
||||
"TetheringIntegrationTestsLatestSdkLib",
|
||||
],
|
||||
jarjar_rules: ":connectivity-jarjar-rules",
|
||||
jarjar_rules: ":ConnectivityCoverageJarJarRules",
|
||||
manifest: "AndroidManifest_coverage.xml",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
@@ -80,7 +96,6 @@ android_test {
|
||||
"mockito-target-extended-minus-junit4",
|
||||
"modules-utils-native-coverage-listener",
|
||||
"ConnectivityCoverageTestsLib",
|
||||
"TetheringCoverageTestsLib",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
|
||||
10
tests/common/tethering-jni-jarjar-rules.txt
Normal file
10
tests/common/tethering-jni-jarjar-rules.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Match the tethering jarjar rules for utils backed by
|
||||
# libcom_android_networkstack_tethering_util_jni, so that this JNI library can be used as-is in the
|
||||
# test. The alternative would be to build a test-specific JNI library
|
||||
# (libcom_android_connectivity_tests_coverage_jni ?) that registers classes following whatever
|
||||
# jarjar rules the test is using, but this is a bit less realistic (using a different JNI library),
|
||||
# and complicates the test build. It would be necessary if TetheringUtils had a different package
|
||||
# name in test code though, as the JNI library name is deducted from the TetheringUtils package.
|
||||
rule com.android.net.module.util.BpfMap* com.android.networkstack.tethering.util.BpfMap@1
|
||||
rule com.android.net.module.util.BpfUtils* com.android.networkstack.tethering.util.BpfUtils@1
|
||||
rule com.android.net.module.util.TcUtils* com.android.networkstack.tethering.util.TcUtils@1
|
||||
Reference in New Issue
Block a user