This makes it a bit easier to use FakeSettingsProvider and
get settings change notifications. It's still difficult because
the ContentResolver#registerContentObserver methods are final and
cannot be subclassed, but at least it removes the need for some
boilerplate code.
Bug: 397521796
Flag: TEST_ONLY
Test: tests updated in next CL
Change-Id: I43b45eca964b103ad65d0db82682aa8644fcacaf
Lorenzo Colitticommited 2025-06-28 11:06:53 +09:00
Allow module with "sdk_version: module_current" to depend on
net-tests-utils-host-device-common.
This CL also makes this module visible to cronet
Bug: 311792075
Test: TH
Flag: EXEMPT Android.bp sdk_version and visibility change
Change-Id: I3b1068e12d4abbd34006aae69bbd314fcf05d060
Mockito extended tends to cause all kinds of issues due to the way it
injects itself into the bytecode of framework classes instead of
creating subclasses.
Use non-extended mockito as it is not actually necessary for current
tests.
Test: atest
Change-Id: Id2874309cce2778c4405b852df9a3ae816c4abcb
This change adds missing dependancies of CtsNetTestCases to the automotive-general-tests zip
Change-Id: Iba2da89b380214ad785d504a484b0b72b508814d
BUG: 382649664
Flag: TEST_ONLY
Filip Zakrzewskicommited 2025-01-16 15:25:33 -08:00
When adding a dependencies, if the variants don't match, but the
dependency only has 1 variant anyways, soong will always use that
variant. This makes it hard to add new variants to soong, because the
1-variant fallback stops being used and you start getting missing
variant errors. Make changes to bp files such that all dependencies
correctly specify the variant to use.
Bug: 372091092
Flag: EXEMPT refactor
Test: m nothing
Change-Id: I8d4f59044f268088b44357d27322abbdcdc3001c
When CtsNetTestCases tests fail, or when a tryTest statement fails,
collect connectivity diagnostics and output them as a test artifact.
tryTest must be followed by cleanup blocks, which often change the
configuration, so having diagnostics when the tryTest fails in addition
to after the test failure is useful.
The collected diagnostics will be available as individual test
artifacts. They should make it easier to investigate test failures, and
could be collected across test runs in an automated way.
Output files are currently limited at 20 per run, to avoid collecting
too much data in case everything is failing in the run.
Test: atest
Change-Id: Iaa48e519028dc61c03d387beeade7d41fca2ef48
- Add comments clarifying the use cases of
net-utils-framework-connectivity and net-utils-service-connectivity
- Apply stricter visibility for the staticlibs
Bug: 357803496
Test: CI
Change-Id: I0d13b436976c3194c0fe350a905a8edf3e4df73a
This CL introduces net-utils-framework-connectivity, net-utils-tethering
and net-utils-service-connectivity as staticlibs.
- net-utils-framework-connectivity will be used by
framework-connectivity-pre-jarjar.
- net-utils-service-connectivity and net-utils-tethering are the
static liraries used by service-connectivity-pre-jarjar and Tethering
respectively.
Bug: 350699020
Test: CI
Change-Id: I4dbb2b0de905a576cfcf24d2d5d1f1a261d2bd68
This is a no-op refactoring.
Test: m connectivity_multi_devices_snippet && \
atest CtsConnectivityMultiDevicesTestCases
Bug: 335368434
Change-Id: I415cc22f49c437be6fe8e8ae8822af22ebefe8d1
* Struct.java is removed from net-utils-device-common-bpf and
net-utils-device-common-struct's source list
* Created a lib net-utils-device-common-struct-base for Struct.java
* Updated libs that require Struct.java to include
net-utils-device-common-struct-base.
* Replaced net-utils-multicast-forwarding-structs with
net-utils-device-common-struct in service-connectivity
Bug: 323503345
Test: build tethering module.
Change-Id: I3f60715c3d8043b7569db7612dee9d4fa1ccba59
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.
For more details please refer to the link below,
<add g3 doc link>
Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5
A helper class to *read* java BpfMaps. This is designed to
provide direct bpf access in the caller process through
ConnectivityManager APIs.
The change also removes any statical link to
net-utils-device-common-struct from service-connectivity.
This is because net-utils-device-common-struct is already
included in framework-connectivity. Including it again in
service-connectivity would create a r8 build fail by circular
dependency.
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.StructTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.BpfNetMapsReaderTest
Bug: 297836825
Change-Id: I7a6d2eb816d0dc7343167bddd672806b199f44fe
Rename ConnectivityCheckTargetPreparer to
ConnectivityTestTargetPreparer, and the ConnectivityChecker app to
ConnectivityTestPreparer, and remove the assumption that the app only
does connectivity checks.
This will allow overriding the app with versions that have more specific
setup steps in downstream branches.
Bug: 263665773
Bug: 267413275
Test: tests using this preparer
Merged-In: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0
Change-Id: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0
The library pulls a lot of dependencies, which end up in code coverage
reports, because code coverage looks at code inside the test package
unless excluded.
Just use the existing TestPermissionUtil in the same library instead,
avoiding the need to exclude many test utilities and making the test
smaller.
Test: atest android.net.cts.ConnectivityManagerTest#testDump
Change-Id: I3ba2121ef034872acf077578644ac9e8aa92c7ef
- Move it to frameworks/libs/net/common/testutils.
- Inherit from BpfMap, so the class can be used anywhere that
uses a real BpfMap. For example, BpfCoordinatorTest uses
BpfMap, not IBpfMap.
Test: atest BpfCoordinatorTest
Change-Id: I7ee65e47fa46ac6aafc831f5b1823b44267ba2a6
Lorenzo Colitticommited 2022-02-02 00:25:40 +00:00
This allows tests to run dumpsys without worrying too much about
the nitty-gritty of finding the service, piping the output back,
etc.
Test: simple test added in other CL in topic
Change-Id: I0628c55ad199e4c888e4947e11bdb0a3b8150767
Lorenzo Colitticommited 2022-01-25 17:35:18 +09:00
We use "mts-networking" and not "mts" so that the tests and test dependencies can be properly included in the automated MTS packaging and release (go/mts-packaging).
Instead of tagging tests "mts", we should use "mts-*" where the suffix is one of https://source.corp.google.com/android/test/mts/tools/build/config.mk;l=19.
Test: built locally and verified contents
Bug: 203466102
Change-Id: I5f9bdaf699cfa2525b33178c0e30a6b794b9d5f5
This is the same thing try{} does, and allows to lift
return out of tryTest.
This allows syntaxes likeĀ :
fun foo() = try {
"Foo";
} cleanup {
doSomeCleanup()
}
}
val network = try {
registerNetworkCallback
callback.getNetwork()
} cleanup {
unregisterNetworkCallback
}
}
Note: bypassing ktlint because of b/185077240
Test: FrameworksNetTests
Change-Id: Ib8f6fde7ccfd62fdcb3c1e3b7b03909ed94d4b23
Enable the strict_updatability_linting here first as a prior
commit to enable strict_updatability_linting in connectivity
modules.
Bug: 188851968
Test: m lint-check ; atest NetworkStaticLibTests
Change-Id: Idac98a1c85bf5bb86269b1daad2b444cfb58db8a
ConnectivityCheckTargetPreparer is a tradefed target preparer that uses
the connectivitychecker app to verify device configuration, before
running any test.
The connectivitychecker app verifies that the device has a
pre-configured wifi configuration and can connect to it (except for
virtual devices where it may create the configuration itself), and
verifies that the device has a data-enabled SIM card inserted.
Checks are skipped if the device is not wifi- or mobile data-capable,
and can be skipped for local testing by running with:
atest X -- --test-arg \
com.android.testutils.ConnectivityCheckTargetPreparer:disable:true
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5b6d34a6c393863af23af57ff026b15973e9e784
A common pattern in tests is to use try-finally to make sure
cleanup is executed. This is necessary in CTS in particular to
make sure the test does not leave the device in a bad state.
The problem with using try-finally in this manner is that any
exception thrown in the finally{} block will override any thrown
in the try{} block. If the exception in finally{} is caused by
the one from try{}, then the stack trace reported by the tools
is the consequence and not the cause, making it difficult to
interpret the stack trace of automated tests.
So today, code has to make sure that either the code in
finally{} can't throw, or can't be affected by any code in
try{}, and both of these are really difficult to ensure in
presence in finally{} of code the tester does not control.
What we'd want ideally is a structure like try-finally, that
guaratees the code in finally{} is executed in all cases,
but that bubbles up the exception from try{} if any, and
will still bubble up any exception from finally{} if the
try{} block hasn't thrown.
That's what this new tool does.
Usage from Kotlin is like try-finally :
tryTest {
testing code
} cleanup {
cleanup code
}
Usage from Java can't be made as nice, but it's relatively okay :
testAndCleanup(() -> {
testing code
}, () -> {
cleanup code
});
Bugs listed below are some tests that have been affected by
this issue and have unhelpful traces.
Test: new test for this code
Bug: 198586720
Bug: 198998862
Change-Id: I54b30a7d53772feeade99274b6120a79707ad1c9
Move netlink stuff to frameworks/libs/net/common/device, and build the
source files as an individual libraray. NetworkStack module just depends
on the net-utils-device-common-netlink.
Besides, also fix the incorrect format detected by checkstyle_hook script
such as missing java doc and make some public function as private, rename
the variable and etc.
Bug: 192535368
Test: atest NetworkStaticlibTests
Change-Id: I00e7f30be1bc9ebc2e24d7cd53efc403d6ba3daa
TNM.createTunInterface() takes different parameter from S.
GTS is multi-release, so it should be compatible with S
and before S build. Add sdk version check to support it.
Bug: 186680038
Test: atest GtsNetworkStackHostTestCases:\
com.google.android.gts.networkstack.NetworkStackHostTest#\
testNetworkStack
Change-Id: I5a08068db43e507637a53a32c15a5eb453d50c32
The net test utils are used for unit tests exercising connectivity code,
and need access to its hidden APIs.
Bug: 182859030
Test: atest NetworkStaticLibTests
Ignore-AOSP-First: needs manual cherry-picks
Change-Id: I33273e5c1cc2731443f0fd745ce526473a704520
Added SPDX-license-identifier-Apache-2.0 to:
common/testutils/Android.bp
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: If307a41f295d202c3cb8b733ed74af26d3358058
Added SPDX-license-identifier-Apache-2.0 to:
common/testutils/Android.bp
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ib947b1cd6eae235e77cd55d57673360c426e80f1
Having the test targets in a different directory allows setting
visibility rules for tests only, which is necessary for access to
targets that should not be used for device builds.
Bug: 182859030
Test: m
Change-Id: Iaf426cf339a97833acf80c941db692329c6e2dcb