Commit graph android_packages_modules_Co.../tests
Message SHA1
Use helper function getIndexForValue in MulticastRoutingCoordinator.
The SparseArray.indexOfValue() uses == to compare values,
MulticastRoutingCoordinator uses SparseArray with String type values,
and the indexOfValue function would sometimes return -1 when looking for
a value in the SparseArray.

Added a helper function getIndexForValue in CollectionUtils to get index
by comparing values with equals, and used this function in MulticastRoutingCoordinator.

Updated
MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc
test case to use copies of interface names when updating the multicast
configs, so the test would fail without this fix.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.CollectionUtilsTest#testGetIndexForValue
atest android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc

Change-Id: I862242d6be01b8552cdd6af6c9691948a9f0bfe0

Yang Sun   commited 2024-04-23 17:22:15 +08:00
4e7baadc71
Add DevSdkIgnoreRule to ApfIntegrationTest
testReadWriteProgram is annotated with IgnoreUpTo(U), but because the
class does not use the rule, that has no effect.

Fix that by adding the rule.

Note that DevSdkIgnoreRunner only affects running the whole class
(having IgnoreUpTo at the class level), not annotated individual tests.

Test: atest
Bug: 333208995
Change-Id: I56b9c0775c3f39bb0f133705e57a41717a7d777b

Remi NGUYEN VAN   commited 2024-04-09 15:26:19 +09:00
7780b674b6
Merge "Deflaking network access checks in CtsHostsideNetworkTests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-06 05:48:36 +00:00
1d73c6bea5
Suppress ktlint:standard:comment-wrapping warning
standard:comment-wrapping does not allow annotating function argument
literals inline (since block comments must not be surrounded by code).
So the following annotations are not allowed in ktlint:

foo(1 /* bar */)

Unfortunately, there are not good alternatives. Named arguments can only
be used to call Kotlin functions and are not a general solution.
Instead, disable this linter rule for the entire file.

This also adds a suppress annotation further down in the file, since
ktlint does not like the extra space required to make the comments line
up horizontally...

Test: repo upload --dry-run
Change-Id: I62fdb0347965ee3fc43783eb07af47e95af882a5

Patrick Rohr   commited 2024-04-05 11:57:42 -07:00
9c3cbe5dd2
Toggle screen state before and after ApfIntegrationTest
APF is supposed to run when the screen is off. This change turns the
screen off as part of setUp() and turns it back on in tearDown() (since
apparently CTS is run with the screen on as some tests rely on it).

turnScreenOn() / turnScreenOff() also acquire / release a partial
wakelock to prevent the CPU from suspending during the test.

Test: atest ApfIntegrationTest
Change-Id: I31f04f4d39284be387006fdd9d0a7c0e27feddb5

Patrick Rohr   commited 2024-04-05 11:57:42 -07:00
30c9382181
Resume before releasing network request
Technically, this does not matter. If the network goes away before
resume is called, then resume will fail. But the network is going away
anyway... In any case, tearing down the test in opposite order of setup
is good practice.

Test: TH
Change-Id: I21f95499dbddb6003ac12c51a67a7638058e20e3

Patrick Rohr   commited 2024-04-04 16:34:49 -07:00
39c203f431
Add testReadWriteProgram to ApfIntegrationTest for V+
Validates that reading and writing APF memory behaves as expected across
the entire range of usable memory.
Before V, APF integration is broken in many different ways, so this test
only runs on V+ for now. A separate test will be added for pre-V
devices.

Test: atest ApfIntegrationTest
Change-Id: I3002c03b51bedd23a8cfb2513f5ae01a200445a4

Patrick Rohr   commited 2024-04-04 16:34:49 -07:00
4790aa9831
Align APF capabilities test closer to VSR requirements
This change cleans up the APF capabilities test and aligns it closer to
what is written in the VSR preview:
https://androidpartner.devsite.corp.google.com/gms/policies/preview/reqs#gms-vsr-apf

This includes changing VSR API level checks to compare against literal
values, as vendor API levels do not match SDK levels anymore starting
with 202404.

See docs for more information:
https://g3doc.corp.google.com/wireless/android/partner/compatibility/g3doc/dev/write-a-test/index.md?cl=head#write-a-test-depending-on-api-level

This test should also purely be based on the VSR API level, so the
DevSdkIgnoreRule and assumption check in setUp() are being removed.

Test: TH
Change-Id: I1f80ee662721557ec63694302fa0f66a666ceeb1

Patrick Rohr   commited 2024-04-04 10:57:03 -07:00
f0766dc9e1
Do not use runShellCommandOrThrow in setUp / tearDown
setUp() / tearDown() run on devices that might not support APF in which
case they should not cause a test failure.
Tests will be appropriately guarded by checking the APF capabilities.

Test: TH
Change-Id: I8689f96ecac0a21dfb4ab8786fec11c01f30d1c2

Patrick Rohr   commited 2024-04-04 10:57:03 -07:00
6a62806a52
Merge "Use NsdServiceInfo ifIndex in MdnsDiscoveryManager" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-03 05:14:54 +00:00
08b316bab0
Merge "Replace connectToCell -> NetworkCallbackRule" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-04-03 04:15:41 +00:00
d5a8d41172
Use NsdServiceInfo ifIndex in MdnsDiscoveryManager
NsdServiceInfo may contain an interface index if it was obtained from a
previous discovery callback which found a service on an interface that
does not belong to any Network.

In that case, subsequent resolve or registerServiceInfoCallback queries
using that NsdServiceInfo should only be done on the matching interface.
Apps may otherwise receive replies from other networks, with different
interface addresses.

As a simple fix, still request sockets from all interfaces in that case,
but only create the MdnsServiceTypeClients on matching sockets.

The sockets are created / cleaned up based on the lifecycle of the
requests, which does not change.

Fixes: 332262554
Test: atest
Change-Id: I2bbb498d4a0d37725f019a4cf5e367fef76fa0e8

Remi NGUYEN VAN   commited 2024-04-03 12:58:51 +09:00
894f181c89
Call getCapabilities in setUp
Every test starts by fetching the capabilities, so it makes sense to
move it to setup.

Test: TH
Change-Id: I232355aafd91acc00079bd4efb0abd5d206d5a07

Patrick Rohr   commited 2024-04-02 14:53:30 -07:00
ad4f132c29
Use truth assumption checks
This results in more readable assumption failures.

Test: TH
Change-Id: Ie8670183ce7ebf71ba5efa015f2ff294698ed936

Patrick Rohr   commited 2024-04-02 14:53:30 -07:00
ac9b287b2c
Merge "Allow HW address retrieval from EthernetNetworkFactory" into main
Chris Desir   authored and   Gerrit Code Review   commited 2024-04-02 16:27:09 +00:00
36061871d7
check lateinit property ifname isInitialized in tearDown
Bug: 332464546
Change-Id: I5085ad42c9456e89974c1fc33149e468483e340f
Test: TH

Patrick Rohr   commited 2024-04-02 14:44:08 +00:00
e380bc0000
Merge "[mDNS] pretty print txt values in log" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-04-02 08:15:34 +00:00
777b9ba0ca
[mDNS] pretty print txt values in log
Without this commit, the Thread service logs look like:

```
03-27 14:50:07.033   739  1924 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #2CF8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: id=֞�"ҽD���.�j���nn=OpenThreadrv=1sb=������tv=1.3.0
03-27 14:50:07.033   739  1924 I NsdPublisher: vn=Android
                                                         xa=Q�;�P,�
                                                                   xp=ޭ��������

```

With this commit, the Thread service logs look like:

```
03-27 13:37:31.672   741  1925 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #7CE8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: {id=0x70A5AE087668D7522919F40D1684D182, mn=Thread Border Router, nn=OpenThread, rv=1, sb=0x00000021, tv=1.3.0, vn=Android, xa=0x06EC93E283A47CE8, xp=0xDEAD00BEEF00CAFE}
```

Bug: 329366417
Change-Id: I6b15e93ad117f4ebb5762df85e359a705bd65b7d

Kangping Dong   commited 2024-04-02 14:47:57 +08:00
aca202e4d9
Deflaking network access checks in CtsHostsideNetworkTests
Checking that the network was successfully restricted before starting
the activities in ConnOnActivityStartTest. This avoids races between uid
state changes and device state changes in NPMS code that lead to
unpredictable UnknownHostException flakes in the first iteration.

Moving the java cache clearing to happen immediately before the check,
so no side effect from different code can impact the DNS query.

Increasing the socket-timeout to mitigate socket timeout failures.

Changing the default test URL to generate a 204 to avoid any extraneous
errors that may arise in doing other I/O, and switching to the canonical
connectivity check URL on the android.com domain.

Enabling support for passing down a custom url to use for testing
network connectivity using the runner options. This will enable easily
switching between different URLs for debugging when required.

Using a dedicated data class to encapsulate information to be returned
from test app to the instrumentation app.
This makes the logic more resilient, readable and maintainable.

Test: atest CtsHostsideNetworkTests:HostsideConnOnActivityStartTest --\
--test-arg com.android.compatibility.common.tradefed.testtype.JarHostTest:\
set-option:com.android.cts.net.HostsideConnOnActivityStartTest:\
custom-url:"https\://www.example.com"

Bug: 330406935
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:04c638ee3a5bab7895817ebfc0d3f6a69b1ee26d)
Merged-In: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4
Change-Id: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4

Suprabh Shukla   authored and   Android Build Cherrypicker Worker   commited 2024-04-02 05:51:41 +00:00
a8ad3d5ef0
Merge "Add a flag to disable the background firewall chain" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-04-02 05:47:56 +00:00
aeacff5033
Merge changes Ic4b586ae,I1b1345a6,I468ef544,I61b6263e into main
* changes:
  Grant prohr temporary ownership of ApfIntegrationTests
  Pause APF filter before starting test
  Enable new ApfFilter experiment in CTS test
  Move retrieving APF capabilities into helper function

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2024-04-02 03:41:31 +00:00
609bfabfdd
Merge "Fix flakes due to networks obtained via sync APIs" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-02 03:30:36 +00:00
455b186710
Replace connectToCell -> NetworkCallbackRule
Developers often forget to unregister requests in tests, and cleanup
code also makes tests more verbose.

Add a rule that unregisters callbacks automatically when after each test
method.

Replace current usage of connectToCell with this rule, as well as
network callback usage in CaptivePortalTest (which is one example that
did not unregister its callback).

Test: atest
Change-Id: Ie3b9c5cf529004b7b3af04bc13a7e69acfbbaa18

Remi NGUYEN VAN   commited 2024-04-02 11:18:20 +09:00
e629bb7c84
Fix flakes due to networks obtained via sync APIs
After reconnectWifiIfSupported is called, it is possible that
ConnectivityManager#getAllNetworks does not return the Network, as this
is mixing network callbacks and synchronous calls which is racy (as per
ConnectivityManager javadoc).

Ensure that networks that are reconnected in the test, wifi and
cellular, are obtained through network callbacks through CtsNetUtils.

Other networks are still obtained through the synchronous call, as they
should not change during the test, and there would be no non-racy way to
obtain them otherwise anyway as they are not guaranteed to be connected.

Bug: 328331492
Test: atest
Change-Id: I5a511c87c64fde0276aecd6ff6599815fa08e437

Remi NGUYEN VAN   commited 2024-04-02 11:10:01 +09:00
f8999e32e1
Add a flag to disable the background firewall chain
The BACKGROUND firewall chain has been recently added. We want to
be able to turn it off in case of contingencies with a device-config
flag flip.

The flag is assumed to be boot-stable and its value is read at boot.
When the flag is off, we ignore any operation on this firewall chain.

Additionally, this chain is always considered disabled on versions
upto UPSIDE_DOWN_CAKE.

Note: All firewall chains are in disabled state at boot by default.

Test: atest FrameworksNetTests
Test: Manually, using adb shell device_config commands.

Bug: 331484830
Change-Id: I9ccc483e02e27a584da6714931466a9f2ec95ca9

Suprabh Shukla   commited 2024-04-01 16:37:32 -07:00
724d8972e4
Allow HW address retrieval from EthernetNetworkFactory
Test: atest EthernetNetworkFactoryTest
Bug: 142259350
Change-Id: I160d8ffd02a1a520d245fbf2b41832d9b3951a89

Chris Desir   commited 2024-04-01 13:45:19 -07:00
e50dd30fc8
Merge "Changes to support satellite stats appear as TYPE_MOBILE" into main
Nagendra Prasad Nagarle Basavaraju   authored and   Gerrit Code Review   commited 2024-04-01 14:33:37 +00:00
ad48c49ee0
Merge "[coverage] add integration tests for ServiceManagerWrapper" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-04-01 12:20:06 +00:00
aef1e27c1f
Changes to support satellite stats appear as TYPE_MOBILE
With satellite transport supported at device and satellite
network to appear under type mobile, considers cellular or
satellite, or combination of both interfaces under mobile interfaces.

Note: getUidStatsForTransport(TRANSPORT_SATELLITE) is not supported,
considering the same interface name could be used by cellular as well,
supporting this might lead to double counting problem.

Bug: 329003473
Test: atest FrameworksNetTests
Change-Id: I85465cedcc5550fa0555dc36b3be364ac90aade1

Nagendra Prasad Nagarle Basavaraju   commited 2024-04-01 10:53:02 +00:00
756ca07f80
Merge "Revert "Use Service handler thread for NetworkStatsObservers"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-01 10:20:27 +00:00
93c6bf6f84
Revert "Use Service handler thread for NetworkStatsObservers"
This reverts commit 8b1d824ad2.

Reason for revert: b/332214348


Fix: 332214348
Change-Id: Iac8b9a11fb5b1c2e704eada62869c8c8552b3804

Junyu Lai   commited 2024-04-01 09:06:55 +00:00
86edb59bd4
[coverage] add integration tests for ServiceManagerWrapper
add tests for ServiceManagerWrapper.java to coverage native NDK APIs
used in this module.

Bug: 330417869
Change-Id: Ibeb277fe1fea361b4e0fca58f3291d7fa925ab7f

Kangping Dong   commited 2024-04-01 16:11:39 +08:00
c465f64431
Merge "SatelliteAccessController enhancements to handle delete user scenario" into main
Nagendra Prasad Nagarle Basavaraju   authored and   Gerrit Code Review   commited 2024-04-01 06:19:52 +00:00
6cbb7cf3d5
SatelliteAccessController enhancements to handle delete user scenario
- Handle onRoleHoldersChanged is not triggered even if the user has a
  default app setup and gets deleted scenario.

- Adding ACTION_USER_REMOVED intent filter, to monitor for User
  removal. This to used to update satellite fallback uid list
  and to keep allowed uid range updated at multi layer request
  of track default and satellite transport with Internet
  restricted capability

Bug: 326373613
Test: atest FrameworksNetTests
Change-Id: I1f30cd129309486bccbc61802ed600c142077411

Nagendra Prasad Nagarle Basavaraju   commited 2024-04-01 04:19:12 +00:00
0668238d50
Grant prohr temporary ownership of ApfIntegrationTests
In order to make fast progress on developing some initial APF
integration tests, grant prohr@ temporary ownership. Changes will be
reviewed with lorenzo@ out-of-band before release.

Test: n/a
Change-Id: Ic4b586aeb95902717d8e0e57f063cd7302f9b70c

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
efdfaf2c08
Pause APF filter before starting test
adb shell cmd apf <iface> install requires APF to be paused beforehand.
Resume in tearDown.

Test: atest ApfIntegrationTest
Change-Id: I1b1345a629dc03446ae3b74ab06f40a06085cd28

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
ee085cc201
Enable new ApfFilter experiment in CTS test
APF adb commands are not implemented in LegacyApfFilter. Enable the
experiment flag for all tests.

Test: atest ApfIntegrationTest
Change-Id: I468ef54498a6f780dff22d25119732b42b404199

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
e9fb2b2fb5
Move retrieving APF capabilities into helper function
Retrieving the capabilities will be required for every test, so move it
to a helper function.

Also includes two more minor improvements:
- Use runShellCommandOrThrow() instead of runShellCommand() so we
  correctly fail the test if the shell command returns an error.
- Use truth for all assertions because it creates better error messages.
  See truth.dev for more details.

Test: builds && TH
Change-Id: I61b6263eac9bf70eae4e1841baae9e3fa8ca4d6d

Patrick Rohr   commited 2024-03-29 09:58:16 -07:00
633d9811d8
Address kotlin coding style erros
Test: m
Change-Id: Id2109a57d062df9629b6a41bc33d3a2f2662b2cd

Paul Hu   commited 2024-03-29 07:08:32 +00:00
48321f8d4a
Merge "Support multiple query packets" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-03-29 01:12:31 +00:00
e805c9a9ce
Merge changes I253a0f6d,Ibc566fae,I2aad7d78,Ifc2967f6,I7f54479a into main
* changes:
  Rename wifiIfaceName to ifname
  Remove unnecessary null check
  Unregister network callback in tearDown
  Don't run test in instant app mode
  Revert^2 "Introduce initial CTS test for APF functionality"

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-28 19:29:50 +00:00
7dd3a4bd3d
Rename wifiIfaceName to ifname
Renames wifiIfaceName to ifname and capabilities to caps to make
the shell command fit on one line.

Test: TH
Change-Id: I253a0f6d99c8ce869795958503db4db4008455b6

Patrick Rohr   commited 2024-03-28 10:38:26 -07:00
50af8633d4
Remove unnecessary null check
wifiIfaceName is guaranteed to not be null when this null check is
executed, as otherwise eventuallyExpect<LinkPropertiesChanged>() has
failed or threw an assertion error a couple of lines above.

Test: TH
Change-Id: Ibc566fae7cf153dcc2976e4d6d3b208e8fa3448c

Patrick Rohr   commited 2024-03-28 10:35:49 -07:00
0f01689fde
Unregister network callback in tearDown
Representing networkCallback as a non-null lateinit var and using
property isInitialized seems more appropriate than making
networkCallback nullable. Making networkCallback nullable would require
null checks / safe calls for every use. However, from the tests'
perspective networkCallback cannot be null; the only concern is
tearDown() which has to deal with early exits from setUp() due to
assumption / assertion failures and therefore partially initialized
state.

networkCallback can only be initialized when requestNetwork() is called
as unregisterNetworkCallback() will throw an exception if the callback
was never registered.

Test: TH
Change-Id: I2aad7d781e6955b29d505e670181209c33db7680

Patrick Rohr   commited 2024-03-28 10:27:14 -07:00
4359195146
Don't run test in instant app mode
ConnectivityManager#requestNetwork requires CHANGE_NETWORK_STATE
permission which cannot be granted to instant apps.

Bug: 331496866
Test: TH
Change-Id: Ifc2967f6ec41676ce1e7396163106f76b9e6788c

Patrick Rohr   commited 2024-03-28 09:47:30 -07:00
98a231cbd6
Revert^2 "Introduce initial CTS test for APF functionality"
This reverts commit a2e859c568.

Reason for revert: fix in aosp/3016578

Change-Id: I7f54479a9fcedd084952d8413bab203dc6f708f2

Patrick Rohr   commited 2024-03-28 09:47:22 -07:00
5731e44b84
Merge "Add annotation in CSTest to set flag values before instantiating CS" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-28 13:02:22 +00:00
4a58e69e59
Merge "Use bpf map based isUidNetworkingBlocked on V+" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-28 12:23:49 +00:00
e7a49305ee
Merge "Fix lint errors" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-03-28 09:36:13 +00:00
7a9f5e9502
Fix lint errors
Format correction by ktlint.py --format

Test: TH
Bug: N/A
Change-Id: I886bdc9dee9c9e86bfdce1602343340010015212

Junyu Lai   commited 2024-03-28 17:06:51 +08:00
a96b97d24a