Commit graph android_packages_modules_Co.../staticlibs/testutils/devicetests/com/android
Message SHA1
Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0

Igor Chernyshev   commited 2023-04-17 21:26:58 +00:00
810be2b456
Merge "Remove pollOrThrow"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-10 04:58:22 +00:00
68783d0260
Merge "Add javadoc descriptions for family of methods"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-08 02:02:43 +00:00
10dd699d9f
Merge "Remove eventuallyExpectOrNull"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-08 02:02:22 +00:00
32a735e8fa
[ST07] Add more documentation for PacketReflector
Test: TH
Bug: 139774492
Change-Id: I778a8392a01806da313335b8103d27295b3e96e4

Junyu Lai   commited 2023-03-28 10:37:26 +08:00
63ff33b9e0
[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

Junyu Lai   commited 2023-03-27 18:45:46 +08:00
8fef4f726a
[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

Junyu Lai   commited 2023-03-27 18:25:29 +08:00
86c95b4925
Merge "Fix lint errors and adding nullability annotations in PacketReflector"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-03-20 05:49:19 +00:00
460c042999
Merge "[ST04.1] Move PacketReflector to static library"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-03-16 13:23:14 +00:00
621c1b739d
Fix lint errors and adding nullability annotations in PacketReflector
This is a no-op refactoring.

Test: TH
Bug: 139774492
Change-Id: Ibb6605a9f7add8319321e5b4960a0b9b637f1434

Junyu Lai   commited 2023-03-15 13:53:36 +08:00
388204218b
[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

Junyu Lai   commited 2023-03-15 13:35:00 +08:00
5622c37a85
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

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

Chalard Jean   commited 2023-03-07 21:48:24 +09:00
2725af813a
Remove eventuallyExpectOrNull
This is no longer used and is advantageously replaced
by a call to poll(), which has the same semantics.

Test: TH
Bug: 157405399
Change-Id: I3182fd3e3ac749e11a8f962ef1acfdca5d031b05

Chalard Jean   commited 2023-03-07 21:47:50 +09:00
0784d5dbd1
Remove eventuallyExpectOrNull usages from AOSP
This is not useful because it has the exact same semantics
as poll() : it returns the first event that matches the
predicate within the timeout, or null if none.

Unfortunately the method can't be removed until all
uses in internal master are removed, so the actual
removal will have to wait for the next patch.

Test: TH
Bug: 157405399
Change-Id: I471c44568e359f8686dcb21ae04c76ca8095f02f

Chalard Jean   commited 2023-03-07 21:47:11 +09:00
febf4ab6fb
Bubble up exceptions in visibleOnHandlerThread
Test: NetworkStaticLibTests
Fixes: 269390906
Change-Id: I3c2d330dd719869562f437c1995e85abd32dbd68

Chalard Jean   authored and   Jean Chalard   commited 2023-02-17 07:19:22 +00:00
2695fdf6ce
Merge "Remove expectLinkPropertiesThat"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-02-11 02:09:38 +00:00
35f954324f
Merge changes from topics "remove_expectblocked", "rename_reason"
* changes:
  Rename BlockedStatusInt.blocked to .reason
  Remove expectBlockedStatusCallback

Jean Chalard   authored and   Gerrit Code Review   commited 2023-02-10 05:26:50 +00:00
c67deee923
Merge "Add OS access interfaces and test impl for wear tethering"
Igor Chernyshev   authored and   Gerrit Code Review   commited 2023-02-09 21:17:54 +00:00
f063240c56
Remove expectLinkPropertiesThat
expect() is simply better

Bug: 157405399
Test: ConnectivityServiceTest NetworkStaticLibTests
Change-Id: If8da940e378722f4cde2a4e7ea3eaef3b1380f18

Chalard Jean   commited 2023-02-09 16:19:09 +09:00
36e8ff3f87
Rename BlockedStatusInt.blocked to .reason
It's a reason, so it's a lot clearer this way

Bug: 157405399
Test: ConnectivityServiceTest NetworkStaticLibTests
Change-Id: Id71d710a33b4df3c211e40141adb2aa0a535f458

Chalard Jean   commited 2023-02-09 16:19:09 +09:00
ab47793183
Remove expectBlockedStatusCallback
expect() does a better job.

Bug: 157405399
Test: ConnectivityServiceTest NetworkStaticLibTests
Change-Id: I2bc4dc0f175b8d46784dbdb3a4724dea41200dc7

Chalard Jean   commited 2023-02-09 16:19:09 +09:00
12038d2e28
Merge "Remove expectCapabilitiesWith and without"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-02-09 02:20:20 +00:00
cd18acab06
Merge "Add CtsNetTestCasesMaxTargetSdk33"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-02-07 10:44:15 +00:00
165c6ffbd6
Remove expectCapabilitiesWith and without
This is not clearer than using the base method.

Test: ConnectivityServiceTest NetworkStaticLibTests
Bug: 157405399
Change-Id: Iac9aeffb563d0a1cb6c1287b46b9bbfffc0c75ca

Chalard Jean   commited 2023-02-06 13:49:52 +09:00
ab521cf49d
Replace expectCapabilitiesThat with expectCaps
Add all the necessary overloads too.

Bug: 157405399
Test: ConnectivityServiceTest NetworkStaticLibTests
Change-Id: Idea768934182d4e2226c273fda0189942dcbf62e

Chalard Jean   commited 2023-02-06 13:49:51 +09:00
c0ba521f79
Add CtsNetTestCasesMaxTargetSdk33
The annotation is used to verify behavior for apps with max target SDK
33.

Bug: 267102290
Test: atest CtsNetTestCasesMaxTargetSdk33
Change-Id: I71ba4433389ba07553ea3d6d34a2bf64fdc132ad

Yuyang Huang   commited 2023-02-02 13:22:12 +09:00
bdb79c510f
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
Cleanup TestableNetworkCallback#assertNoCallback
Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTests
Bug: 157405399
Change-Id: I43eb47bbcf947899c18fcd9498c9064edceb0ecf

Chalard Jean   commited 2023-01-06 16:50:08 +09:00
5987fc4fbe
Introduce visibleOnHandlerThread
This is a helper function that lets a caller make sure the
side effects of a piece of code are visible both on a handler
thread and in the caller thread before continuing.

Also move HandlerUtilsTests to the tests directory of
frameworks/libs/net from the NetworkStack where it used to be

Test: NetworkStaticLibTests
Change-Id: Icf1bd8bbe1216777c52b73cfbd0a46b647b72260

Chalard Jean   commited 2022-12-22 16:17:22 +09:00
9f7d45203f
Add @JvmOverloads for eventuallyExpect and expectAvailableCallbacks
It's useful for the java code to have the overload methods for
eventuallyExpect and expectAvailableCallbacks.

Bug: 231749077
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: I6bb1385ee84d1ff1e9f0472e6de3f452ab142958

lucaslin   commited 2022-12-20 02:59:41 +00:00
4045840fd4
Interrupt thread before closing socket
Test failed when socket.close() ran, and in the other thread
we are trying to initialize an InetSocketAddress. If the socket
was closed, the port got from the socket object becomes -1 hence
the InetSocketAddress cannot be constructed and the
IllegalArgumentException would be thrown.

Interrupt thread before closing socket to prevent from the race.

Test: atest TestDnsServerTest --rerun-until-failure 1000
Fix: 259160848
Change-Id: I219ee1e32144ba9983a28765e7a84621c27c1c09

Junyu Lai   commited 2022-12-14 14:01:31 +08:00
70b03f9299
[ST03] Add test dns server for integration tests
This is re-upload of aosp/1390056, CL that fixes test is separated
in a follow-up CL that submit at the same time.

Bug: 139774492
Test: atest DnsAnswerProviderTest TestDnsServerTest
Change-Id: Ia72975f3044f009ebb0f4564a527830268a4a157

Junyu Lai   commited 2022-12-13 16:15:46 +08:00
3d4eb94be5
Add the name of the expected callback
Before :
  java.lang.AssertionError: Did not receive callback after 5000
After :
  java.lang.AssertionError: Did not receive Available after 5000ms

Test: manual
Change-Id: If46d52cb0db8ea3d418169ea330d915d835e4373

Chalard Jean   commited 2022-11-25 15:52:03 +09:00
c79a231a16
Merge "Revert "[ST03] Add test dns server for integration tests""
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-16 05:13:03 +00:00
8228246ad0
Revert "[ST03] Add test dns server for integration tests"
Revert "[ST03.1] Add DnsAnswerProviderTest"

Revert submission 1390056-st03

Reason for revert: test failed in presubmit, still under checking.
Reverted Changes:
Ia5039a47f:[ST03] Add test dns server for integration tests
I9157e030c:[ST03.1] Add DnsAnswerProviderTest

Change-Id: I1ff291ca62e2209343ed5c5e4aa3bf3e93229f47

Junyu Lai   authored and   Gerrit Code Review   commited 2022-11-15 05:55:27 +00:00
88c48e18e4
Merge "[ST03] Add test dns server for integration tests"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-14 14:01:12 +00:00
40b76e8bac
Merge "Move DeviceConfigRule to libs/net"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-14 09:34:58 +00:00
1a81ae4eb9
Merge "Add eventuallyExpect method that takes mark"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-11-14 05:55:58 +00:00
c32afc4238
Merge "[CC08] Remove expectCallback*"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-11-11 03:17:42 +00:00
664e53bd88
Move DeviceConfigRule to libs/net
The utility can be useful for tests in several repositories, not just
CTS.

Test: m
Change-Id: Id4c653793e58d91d604b388a06a7c137ed020110

Remi NGUYEN VAN   commited 2022-11-10 18:10:24 +09:00
7356d356fb
Add eventuallyExpect method that takes mark
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Fix: 254188130
Change-Id: I98ea8aef5cb21ee92ce47d97d2f9c81448b1cd9e

Junyu Lai   commited 2022-11-10 14:35:29 +08:00
53a6b7053d
[ST03] Add test dns server for integration tests
Bug: 139774492
Test: atest DnsAnswerProviderTest TestDnsServerTest
Change-Id: Ia5039a47f4b818efb09aab8174beb9d921339c3d

Junyu Lai   commited 2022-11-02 11:18:48 +08:00
be99103196
Merge "Add debug log in ensureWifiConnected"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-10-31 01:38:57 +00:00
97d0f3a563
Add debug log in ensureWifiConnected
It's sometimes not clear that tests call ensureWifiConnected
but no wifi enabled. It's hard to clarify design with wifi
stack, so add the gotten wifi info in the log to help on
debugging.

Bug: 252869312
Test: atest CtsNetTestCases
Change-Id: I3bc74dd38dd5a36a93510fc5d70c0fa00b66e842

chiachangwang   commited 2022-10-28 01:13:40 +00:00
b5e9e3fc2b
Merge "Fix errorprone warnings that should be errors"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-10-26 21:09:23 +00:00
9c549c0d53
[CC08] Remove expectCallback*
These methods have been migrated to the shorter and better
provisioned expect<> family of methods.

Test: Builds
Change-Id: I60c77bfeabe373557d61f0f8d0295b385fe5271e

Chalard Jean   commited 2022-10-24 18:54:46 +09:00
0eac837b01
[CC07] Add build tests for expect* versions
Also address some comments left on a previous patchset.

Test: NetworkStaticLibTests
Change-Id: I3ea16bb54aec31ddb0368af980483109a1bdb49b

Chalard Jean   commited 2022-10-24 18:54:45 +09:00
6f8bcae7d0
Increase the timeout for eventuallyExpect
Sometimes the tests are run under high load, e.g. immediately
after boot while all apps that listen for the boot completed
broadcast run their listeners. Under these circumstances,
40ms of leeway is tight ; on recent Android devices HZ is
commonly 100 too, meaning a general time unit of 60 will give
a little bit of air.

The drawback in this is that the test is less stringent on
TrackRecord, which as a multi-thread primitive should have
really tight tests to make sure that a non-threading primitive
(e.g. a polling implementation) doesn't pass. This patch makes
the testing on that front a little bit less reliable.

Note that this patch won't actually fix all flakes in that it
isn't really possible to guarantee the device will have any
CPU time to run the test at all anyway, but this should make
most failures go away.

Also, the argument for the time unit is never used, and can
be removed ; at least, the possibility of the timeArg() func
not using the same value as the sleep directive is scary, so
that possibility should be removed. If the time unit argument
is ever needed it can be added back, but considering the arg
has been available for years and never used, it's unlikely.

Test: NetworkStaticLibTests
Fixes: 254188131
Change-Id: Ia7a4fe775942484dcd7dc223c7710e82a8329beb

Chalard Jean   commited 2022-10-20 16:42:16 +09:00
347dd8ded4
[CC04] Have TestNetworkTracker implement HasNetwork
This already has all necessary methods, it only needs to
declare it implements the interface.

Test: ConnectivityServiceTest
Change-Id: I8de643f2b8de9765c25c3efe934c94549f341a51

Chalard Jean   commited 2022-10-19 15:46:35 +09:00
f79ca2809a