Commit graph android_packages_modules_Co.../staticlibs/testutils/Android.bp
Message SHA1
Add a ContentResolverWithFakeSettingsProvider class to testutils.
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 Colitti   commited 2025-06-28 11:06:53 +09:00
86625b4734
Clean up an old flag for removed downstream branches
Test: TH
Flag: EXEMPT test-only
Change-Id: I4a860c7c42afdfb5249b787daee80395096f5c84

Chalard Jean   commited 2025-05-09 14:59:29 +09:00
893f84f96e
Build net-tests-utils-host-device-common with module_current
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

Motomu Utsumi   commited 2025-04-16 08:58:33 +09:00
788ce2fa37
Use non-extended mockito for net-tests-utils
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

Remi NGUYEN VAN   commited 2025-03-10 17:59:19 +09:00
05c376a4c5
Add 'automotive-general-tests' to the CtsNetTestCases dependencies
This change adds missing dependancies of CtsNetTestCases to the automotive-general-tests zip

Change-Id: Iba2da89b380214ad785d504a484b0b72b508814d
BUG: 382649664 
Flag: TEST_ONLY

Filip Zakrzewski   commited 2025-01-16 15:25:33 -08:00
c4e71897a5
Merge "Add mcts and mcts-tethering to net-tests-utils-host-common for the dependency of ConnectivityTestPreparer" into android15-tests-dev am: 900fb00793
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3381265

Change-Id: I92961a480281fc239dcde1d0cf0480cbbd496486
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Tongbo Liu   authored and   Automerger Merge Worker   commited 2024-12-03 03:34:40 +00:00
4f1c1ea358
Add mcts and mcts-tethering to net-tests-utils-host-common for the dependency of ConnectivityTestPreparer
Bug: 379792488
Change-Id: I725bc9d7fed7df23ccc21d1f4dc4fa10e0315cc9

Tongbo Liu   commited 2024-12-02 03:11:19 +00:00
17ab27e71f
Merge "Remove mcts tags since the net-tests-utils-host-common is host_required by other CTS cases" into android15-tests-dev am: 54123391a1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3342613

Change-Id: I4495e7dfc05ca5ff20e6fddd137aaa5135558ea2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Tongbo Liu   authored and   Automerger Merge Worker   commited 2024-11-08 03:43:15 +00:00
19e2806f88
Remove mcts tags since the net-tests-utils-host-common is host_required by other CTS cases
Change-Id: Ice129f55b58f246d01eae63f555677e992fad177

Tongbo Liu   commited 2024-11-07 12:26:49 +00:00
5801f1644a
Remove dependencies on the 1-variant fallback
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

Cole Faust   commited 2024-10-22 16:31:00 -07:00
9ff8f4c81b
Add connectivity diagnostics on test failure
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

Remi NGUYEN VAN   commited 2024-10-16 10:05:35 +09:00
43730b3f0f
Improve staticlibs/Android.bp
- 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

Handa Wang   commited 2024-08-08 15:42:00 +00:00
8be10bfdff
Refactor staticlibs
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

Handa Wang   commited 2024-07-05 05:26:46 +00:00
9b0df36ea4
Move utils to staticlib
This is a no-op refactoring.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 335368434
Change-Id: I415cc22f49c437be6fe8e8ae8822af22ebefe8d1

Junyu Lai   commited 2024-06-28 11:19:54 +08:00
79b771f9bb
Add missing mcts tags
Bug: 318608673
Change-Id: I9f7e3aee05af700881f145002fd9a076afd4db7a

Tongbo Liu   commited 2024-04-15 04:48:36 +00:00
65ce1f2aa2
Separate Struct.java into its own lib.
* 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

Yang Sun   commited 2024-03-27 20:15:17 +08:00
3aa62e6773
[DON'T BLOCK] Test ownership migration rules
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

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Fix the dependency of CtsNetTestCasesMaxTargetSdk
Bug: 318958910
Change-Id: I71499f2a5244030c5c83c2102585c4c0c3da5db4

Tongbo Liu   commited 2024-01-23 09:24:49 +00:00
47524106d0
Add mcts tag to MainlineCTS networking test modules which is used for build all the mainline CTS tests.
Bug: 316436957

Change-Id: I0e7ab773075fb0dfd154dde45a710d1c1823c914

Tongbo Liu   commited 2023-12-19 11:03:50 +00:00
199357ba68
[BR01.1] Support BpfNetMapsReader
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

Junyu Lai   commited 2023-10-23 20:11:02 +08:00
626045a601
Merge remote-tracking branch 'remotes/aosp/tmp_libs_net_move' into libs_net_move_merge
frameworks/libs/net/common ->
packages/modules/Connectivity/staticlibs

frameworks/libs/net/client-libs ->
packages/modules/Connectivity/staticlbs/client-libs

Test: TH
Bug: 296014682
Change-Id: I5dc78f0c4653e20312ab3d488b1e69262dbb9840

Motomu Utsumi   commited 2023-09-11 11:53:46 +09:00
c480039309
Make SkipPresubmit annotation visible by HostsideVpnTests
Test: TH
Bug: 291701394
Change-Id: I93d72a809b2779deec3c8182c5efed6d38393ab8

Junyu Lai   commited 2023-07-26 14:42:56 +08:00
af464eb494
Make ConnectivityCheckTargetPreparer more generic
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

Remi NGUYEN VAN   commited 2023-05-16 15:14:30 +09:00
e2b5213774
Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0

Igor Chernyshev   commited 2023-04-17 21:26:58 +00:00
810be2b456
Add OS access interfaces and test impl for wear tethering
Bug: 245971639

Change-Id: I750c2e9bbe8c9a3992ae91d9fea4958bfce60828

Igor Chernyshev   commited 2023-01-13 17:57:01 +00:00
004c5b422b
include ats target
fixes: 244138449

include ats target

Change-Id: I462b13a5b1332c8afdf46761f1cbad545e7cf291

Nandu Suram   commited 2022-09-08 23:00:44 +00:00
8d88f8bb36
Remove dependency on compatibility-device-util-axt
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

Remi NGUYEN VAN   commited 2022-02-16 18:52:32 +09:00
675cdf6d99
Turn TestBpfMap into a common utility class.
- 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 Colitti   commited 2022-02-02 00:25:40 +00:00
167102daab
Add a DumpTestUtils class to do service dumps in tests.
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 Colitti   commited 2022-01-25 17:35:18 +09:00
375241c99b
Merge "Update net-tests-utils-host-common tag to "mts-networking""
Kimberly Kreider   authored and   Gerrit Code Review   commited 2022-01-20 22:22:59 +00:00
3786fb81da
Update net-tests-utils-host-common tag to "mts-networking"
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

Kimberly Kreider   commited 2022-01-19 23:02:23 +00:00
c9232670c2
Correct a comment
Test: TH
Change-Id: I08ac8f0f40b9e3732564da73057cd3d22c06c79b

Chalard Jean   commited 2021-11-25 19:55:59 +09:00
fee2cab5d6
tryTest to return its last evaluated expression
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

Chalard Jean   commited 2021-11-25 16:26:42 +09:00
b6fdf63095
Enable strict_updatability_linting in frameworks/libs/net
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

Chiachang Wang   commited 2021-11-19 15:41:27 +08:00
7068c88921
Add ConnectivityCheckTargetPreparer
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

Remi NGUYEN VAN   commited 2021-11-04 19:57:21 +09:00
c02dcd721a
Add a new utility to improve stack traces from automatic testing am: 6b56526bec
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1821095

Change-Id: I587f022c0a53dc56e654738686e222d384039500

Chalard Jean   authored and   Automerger Merge Worker   commited 2021-09-17 07:59:31 +00:00
63e8809f5b
Add a new utility to improve stack traces from automatic testing
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

Chalard Jean   commited 2021-09-17 12:21:09 +09:00
5872cb8dbd
Migrate netlink-client to net-utils-device-common-netlink. am: a5abbe6529 am: 3818589c93
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1755889

Change-Id: Ia1a45efa17b46d2787e7385d6fb3e1e4648060fa

Xiao Ma   authored and   Automerger Merge Worker   commited 2021-08-04 07:56:23 +00:00
049b884c90
Migrate netlink-client to net-utils-device-common-netlink.
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

Xiao Ma   commited 2021-07-29 03:52:09 +00:00
57b3442c65
Merge "Add fall back to createTunInterface when running on R" am: 80ce99810c am: 682f69146a
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1742033

Change-Id: I845db2f17d53fa6827224d4ffee2548dfce4fec5

Chiachang Wang   authored and   Automerger Merge Worker   commited 2021-06-22 13:15:21 +00:00
c26c836c02
Add fall back to createTunInterface when running on R
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

Chiachang Wang   commited 2021-06-22 12:32:40 +08:00
40803d4701
Allow hidden connectivity APIs in net test utils
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

Remi NGUYEN VAN   commited 2021-04-01 06:39:46 +00:00
2202e61492
[LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
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

Bob Badour   commited 2021-03-31 19:53:56 -07:00
5aacbafb88
[LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
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

Bob Badour   commited 2021-03-30 22:55:10 -07:00
9802148967
Move net-test-utils to its own directory
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

Remi NGUYEN VAN   commited 2021-03-30 16:52:09 +09:00
be2a07fce3