Commit Graph

224 Commits

Author SHA1 Message Date
Junyu Lai
a62eed380c Merge "[BR01.1] Support BpfNetMapsReader" into main 2023-10-24 05:56:33 +00:00
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
Chalard Jean
a27dca2fdc Fix arg order to set-package-network-enabled in the CTS preparer
Test: manual
Change-Id: Ife55ed9dc152cd2c21e56b84201b9c34dbb04d46
2023-10-23 17:26:53 +09:00
Chalard Jean
d6f4efb1a8 Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0
2023-10-12 13:30:49 +09:00
Chalard Jean
2aa4412503 Address comments on aosp/2765367
Test: comment-only change
Change-Id: I788f6e9f5fdd913d4c5077b6bb82c19664d3cd3f
2023-09-29 15:48:09 +09:00
Chalard Jean
a10ae005df Have DevSdkIgnoreRunner support @Parameterized parameters
Test: aosp/2405723 uses this, TH is happy with existing tests
Change-Id: If47d7e239d8483716fb78a97bbc2da4e24731209
2023-09-28 21:37:31 +09:00
Jean Chalard
487191dbe6 Merge changes I8843ce7c,I90566998 into main
* changes:
  Block the package updater while CTS are running
  Add a command to block networking for an app
2023-09-22 02:26:19 +00:00
Chalard Jean
3a6544fb1f Block the package updater while CTS are running
Test: manual
Bug: 284534251
Change-Id: I8843ce7c9e14cfe3f6f3439405d519587f2656ef
2023-09-21 12:57:10 +09:00
Maciej Żenczykowski
127a1441c3 bump min_sdk_version from 29 (Q) to 30 (R)
Mainline no longer supports Q.
These files were recently moved into p/m/C as part of a refactor.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0f06ace921db6c79d63c0048bdb73d167ff606cf
2023-09-19 23:22:58 +00:00
Remi NGUYEN VAN
f1846ac13b Check that wifi, cell validates before tests
Tests are sometimes run on hardware devices with wrongly configured wifi
or cell data. Ensure that this is reported as an infra error, and not a
test error, so the root cause is easier to identify.

Bug: 264170054
Test: atest
Change-Id: I4f964fbd4ee497e8ac92f7729375b75b6c4594a3
2023-09-19 17:26:20 +09: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
Motomu Utsumi
7bca2922b8 Add class to help Kotlin to pass nullable to java @NonNull for testing
Follow up CL for aosp/2700076

Bug: 296972712
Test: build with aosp/2688146
Change-Id: Ib582ef41f34baf0bb896e32d681843358f928c87
2023-08-23 13:01:29 +09:00
Colin Cross
1d1c0e7282 Merge "Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests" into main 2023-08-21 19:04:15 +00:00
Patrick Rohr
10fe61b520 Merge "Improve test logs using TrackRecord backtrace" into main 2023-08-18 22:32:51 +00:00
Patrick Rohr
5bf2947997 Improve test logs using TrackRecord backtrace
eventuallyExpect methods should print the received callbacks since
poll() was called for better debugging.

Test: atest EthernetManagerTest
Change-Id: Ia08abf2436b050a7e319b9f70694ce3d132b4fc3
2023-08-18 09:35:13 -07:00
Patrick Rohr
0622dafd75 Merge "TrackRecord: add a method to return callbacks since last poll" into main 2023-08-18 14:10:21 +00:00
Remi NGUYEN VAN
f3bd5e5a0a Merge "Fix DevSdkIgnoreRule for Q-" into main 2023-08-14 03:15:37 +00:00
Remi NGUYEN VAN
a6e8a281a4 Fix DevSdkIgnoreRule for Q-
UnboundedSdkLevel stopped working on Q as it now depends on Set.of,
which is an R+ API. Arguably this should be fixed as its minSdk is still
29, but long-term UnboundedSdkLevel may drop Q support as modules now
only need to support R+.

Avoid using UnboundedSdkLevel on Q- in DevSdkIgnoreRule: this avoids the
above problem, and also makes it compatible with even older builds,
which may happen in GTS.

Bug: 292868272
Test: all tests using this rule
Change-Id: I5e1559d841398a6c6763283f32c9f766a3661e21
2023-08-10 16:24:48 +09:00
Patrick Rohr
533af6d72d TrackRecord: add a method to return callbacks since last poll
This change adds a backtrace() method which returns a list of events
that were received since the last time a user called poll() on a
ReadHead. This is particularly useful for logging observed events while
a poll was in progress that did not end up matching an event.

Test: atest EthernetManagerTest
Change-Id: If019cf9eb5e3e9268c5e6b74edbd8f49959cc71c
2023-08-09 05:26:36 -07:00
Colin Cross
d91c89ba51 Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: I2a2c91188b64619fca190a9bd7812d32f9610abd
2023-08-08 14:26:10 -07:00
Remi NGUYEN VAN
837837e0fe Use requestNetwork for mobile data, not a callback
On devices that do not have always active mobile data, it needs
to be requested for onAvailable to be called.

Change-Id: Ic814684bcd06389c013a6e6636487d9b47627901
Test: TH
2023-08-01 08:48:32 +00:00
Junyu Lai
3416eae310 Merge "Make SkipPresubmit annotation visible by HostsideVpnTests" into main 2023-07-28 02:06:17 +00:00
Remi NGUYEN VAN
7035b4418d Merge "Add an annotation for @SkipMainlinePresubmit" into main 2023-07-27 02:13:22 +00: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
5e4900dbbe Add an annotation for @SkipMainlinePresubmit
This will typically be used in mainline-presubmit TEST_MAPPING
configuration to exclude some tests.

This is necessary as some tests are flaky in mainline configurations
(when running on older devices), and they need to be disabled to meet
SLO requirements, but they are not flaky on presubmit using the latest
platform builds.

Test: m
Change-Id: Ia532d6d3f9833ddec613d79c0eb517d20a1c529a
2023-07-26 13:37:47 +09:00
Mike Yu
8f4debc3f9 Add DnsResolverModuleTest annotation
This annotation can be used to mark a test case that requires
the latest resolv module. Tests that don't run with the latest
resolv module (for example CtsNetTestCasesLatestSdk) can exclude
the testcases being flaky due to some known issues in old resolv
module.

Bug: 279846955
Test: TreeHugger
Change-Id: Ie19eed1c4aa17645c4eec45493e7999027a01205
2023-06-26 07:40:18 +00:00
Xiao Ma
267467ec93 Merge "Add NetworkStackModuleTest annotation." 2023-06-05 01:45:01 +00:00
Junyu Lai
14a8c7d913 Merge "Fix crash when socket read is interrupted" 2023-06-01 05:39:33 +00:00
Xiao Ma
cff263aa10 Add NetworkStackModuleTest annotation.
This annotation can be used to exclude the testcases which requires the
latest NetworkStack module in the CTS/MTS suite.

Bug: 283200648
Test: atest CtsTetheringTestLatestSdk
Change-Id: Idaffed93af077c2998081142af7b3bfa311dcd90
2023-06-01 13:34:01 +09:00
Junyu Lai
ab3fee4246 Fix crash when socket read is interrupted
The exception is thrown in some normal cases e.g. interrupt()
called when Os.read is blocked and waiting for the input.
Ignore such events.

Test: 1. atest NetworkStackCoverageMtsConfigTests on S device
      2. atest com.android.cts.net.HostsideVpnTests
      3. atest NetworkStatsIntegrationTest
Bug: 259632210
Change-Id: Ibff41312d9c7431c2b19f780844ab3a81b48f9e8
2023-05-31 14:14:01 +08:00
Hansen Kurli
8b39bca655 Merge "Use ThrowingSupplier for visibleOnHandlerThread." 2023-05-24 02:39:07 +00:00
Hansen Kurli
0cd46d480d Use ThrowingSupplier for visibleOnHandlerThread.
In order to return values from functions that are run on the handler
thread, use a ThrowingSupplier instead of a ThrowingRunnable.
Also maintain the case with ThrowingRunnable by overloading.

Test: NetworkStaticLibTests
Change-Id: Ic1b86f9f764997ce5d6848f04185194a961d1106
2023-05-23 06:17:52 +00:00
Treehugger Robot
cc4ccc466c Merge "Correctly test for an object being of the correct type" 2023-05-22 10:41:03 +00:00
Chalard Jean
677b663aaf Correctly test for an object being of the correct type
This `as? T` instruction warns that this is an unchecked cast.
It's unchecked in the literal sense : the compiler actually
doesn't check that the var is of that type. Accordingly, this
will only fail if `it` is null, which never happens.

Concretely what that means is that Java code calling this
method like

  expect(AVAILABLE, network)

...will actually pass for *any* callback matching the network,
because the class is not checked.

Thankfully this code is recent and there doesn't seem to be a
lot of tests that got accepted by this bug when they should
have been rejected.

Test: ConnectivityServiceTest, TH
      new test in this patch that fails before but succeeds after
Change-Id: I2e48dae28ff92045f002cfb2798d383c9c19d5ed
2023-05-22 17:55:11 +09:00
Remi NGUYEN VAN
90edff826a Disable Play auto-update during tests
For devices using Play services, disable auto-update during tests, as it
may interfere with them. For example, Webview may be killed if it is
opened while the update is applied.

Bug: 263665773
Test: atest
Change-Id: I9613d739ad0763c882a1971879aa743f4541a75c
2023-05-16 15:14:53 +09: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
Treehugger Robot
f01d29eae6 Merge "Add packet filters for IPv6 UDP" 2023-05-08 08:45:34 +00:00
Igor Chernyshev
810be2b456 Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0
2023-04-17 21:26:58 +00:00
Treehugger Robot
68783d0260 Merge "Remove pollOrThrow" 2023-04-10 04:58:22 +00:00
Jean Chalard
10dd699d9f Merge "Add javadoc descriptions for family of methods" 2023-04-08 02:02:43 +00:00
Jean Chalard
32a735e8fa Merge "Remove eventuallyExpectOrNull" 2023-04-08 02:02:22 +00:00
Junyu Lai
63ff33b9e0 [ST07] Add more documentation for PacketReflector
Test: TH
Bug: 139774492
Change-Id: I778a8392a01806da313335b8103d27295b3e96e4
2023-03-28 10:37:26 +08:00
Junyu Lai
8fef4f726a [ST06.2] Read http body for PUT or POST http request
Currently, the test http server will respond whenever
http request is read, no matter how much data was declared
in the Content-Length header. For tests that uses POST
request to test uplink traffic this is not good enough.

Invoke parseBody to read data from input stream to make
sure the http body is read.

Test: atest android.net.NetworkStatsIntegrationTest \
      --rerun-until-failure 100
Bug: 139774492
Change-Id: I1b71f3e55747d104e4a8796611517d93f178321f
2023-03-27 18:45:46 +08:00
Junyu Lai
86c95b4925 [ST05.3] Support PacketBridge
For testing purposes, a TestNetworkInterface provides a
FileDescriptor which allows content injection on the test
network. However, this could be hard to use because the
callers need to compose IP packets in order to inject
content to the test network.

In order to remove the need of composing the IP packets,
this class forwards IP packets between two
TestNetworkInterface instances. Thus, the TCP/IP headers
could be parsed/composed automatically by the protocol stack of
this additional TestNetworkInterface, while the payload is
supplied by the servers run on the interface.

Test: 1. atest android.net.NetworkStatsIntegrationTest
      2. atest com.android.cts.net.HostsideVpnTests
Bug: 139774492
Change-Id: I8fe5a434d6d727a81d106a967dcdca157424e12e
2023-03-27 18:25:29 +08:00
Junyu Lai
460c042999 Merge "Fix lint errors and adding nullability annotations in PacketReflector" 2023-03-20 05:49:19 +00:00
Junyu Lai
621c1b739d Merge "[ST04.1] Move PacketReflector to static library" 2023-03-16 13:23:14 +00:00
Junyu Lai
388204218b Fix lint errors and adding nullability annotations in PacketReflector
This is a no-op refactoring.

Test: TH
Bug: 139774492
Change-Id: Ibb6605a9f7add8319321e5b4960a0b9b637f1434
2023-03-15 13:53:36 +08:00
Junyu Lai
5622c37a85 [ST04.1] Move PacketReflector to static library
This is also needed by integration test in NetworkStack module
in follow-up CLs. Move to a common place first.
This is a no-op refactoring.

Test: atest com.android.cts.net.HostsideVpnTests
Bug: 139774492
Change-Id: Ifc7ed4c93edfb0f6f8eb47231f6df40332d2c10c
2023-03-15 13:35:00 +08:00
Chalard Jean
c2cf7eb82d Remove pollOrThrow
This method is better removed, because it doesn't follow the
naming conventions we want to keep in this file. It also isn't
useful :
• There is only one use of it outside tests, and it's in the
  same file. It's trivial to inline it.
• The method has a unit test, which becomes useless once the
  method is inlined.
• There is a corresponding command in the interpreter, but it's
  only used by the unit test and therefore can be removed once
  the unit test is removed.

Test: TH
Bug: 157405399
Change-Id: Ib5b1369ac28e4577adc98204e42ff2f27729e64c
2023-03-07 21:48:24 +09:00
Chalard Jean
2725af813a Add javadoc descriptions for family of methods
Test: comment-only change
Bug: 157405399
Change-Id: I58ccb8b05a8ffb82d4575b727bb48dfb21b191fd
2023-03-07 21:48:24 +09:00