Commit Graph

26 Commits

Author SHA1 Message Date
Junyu Lai
626045a601 [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
2023-10-23 20:11:02 +08:00
Motomu Utsumi
c480039309 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
2023-09-11 11:53:46 +09:00
Junyu Lai
af464eb494 Make SkipPresubmit annotation visible by HostsideVpnTests
Test: TH
Bug: 291701394
Change-Id: I93d72a809b2779deec3c8182c5efed6d38393ab8
2023-07-26 14:42:56 +08:00
Remi NGUYEN VAN
e2b5213774 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
2023-05-16 15:14:30 +09:00
Igor Chernyshev
810be2b456 Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0
2023-04-17 21:26:58 +00:00
Igor Chernyshev
004c5b422b Add OS access interfaces and test impl for wear tethering
Bug: 245971639

Change-Id: I750c2e9bbe8c9a3992ae91d9fea4958bfce60828
2023-01-13 17:57:01 +00:00
Nandu Suram
8d88f8bb36 include ats target
fixes: 244138449

include ats target

Change-Id: I462b13a5b1332c8afdf46761f1cbad545e7cf291
2022-09-08 23:00:44 +00:00
Remi NGUYEN VAN
675cdf6d99 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
2022-02-16 18:52:32 +09:00
Lorenzo Colitti
167102daab 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
2022-02-02 00:25:40 +00:00
Lorenzo Colitti
375241c99b 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
2022-01-25 17:35:18 +09:00
Kimberly Kreider
3786fb81da Merge "Update net-tests-utils-host-common tag to "mts-networking"" 2022-01-20 22:22:59 +00:00
Kimberly Kreider
c9232670c2 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
2022-01-19 23:02:23 +00:00
Chalard Jean
fee2cab5d6 Correct a comment
Test: TH
Change-Id: I08ac8f0f40b9e3732564da73057cd3d22c06c79b
2021-11-25 19:55:59 +09:00
Chalard Jean
b6fdf63095 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
2021-11-25 16:26:42 +09:00
Chiachang Wang
7068c88921 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
2021-11-19 15:41:27 +08:00
Remi NGUYEN VAN
c02dcd721a 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
2021-11-04 19:57:21 +09:00
Chalard Jean
63e8809f5b 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
2021-09-17 07:59:31 +00:00
Chalard Jean
5872cb8dbd 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
2021-09-17 12:21:09 +09:00
Xiao Ma
049b884c90 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
2021-08-04 07:56:23 +00:00
Xiao Ma
57b3442c65 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
2021-07-29 03:52:09 +00:00
Chiachang Wang
c26c836c02 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
2021-06-22 13:15:21 +00:00
Chiachang Wang
40803d4701 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
2021-06-22 12:32:40 +08:00
Remi NGUYEN VAN
2202e61492 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
2021-04-01 06:39:46 +00:00
Bob Badour
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: If307a41f295d202c3cb8b733ed74af26d3358058
2021-03-31 19:53:56 -07:00
Bob Badour
9802148967 [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
2021-03-30 22:55:10 -07:00
Remi NGUYEN VAN
be2a07fce3 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
2021-03-30 16:52:09 +09:00