Commit graph android_packages_modules_Co.../tests/cts/hostside
Message SHA1
Remove RecorderCallback.
This class doesn't actually serve a purpose, it only makes
TestableNetworkCallbck more complex.

Test: CtsNetTestCases ConnectivityCoverageTests
Flag: EXEMPT test-only
Change-Id: I39a598b82a3215384bdfe04980f4b280ab2c2716

Chalard Jean   commited 2025-05-19 16:35:53 +09:00
f2994122c1
Add connectivity pre-check for CtsHostsideNetworkTests
Test: atest CtsHostsideNetworkTests
Flag: TEST_ONLY
Change-Id: If7f8cd614f0528248ca87be1d3aac5396b64e071

Paul Hu   commited 2025-04-30 01:14:24 -07:00
882a44f978
Grant the NEARBY_WIFI_DEVICES permission to VpnHostside tests
Fix forward for b/405308292

Background: new / existing runtime permission is now used to guard
access to local networks. apps / tests now need to hold this permission
to do traffic with local devices.

Test: CtsHostsideNetworkTests, TH
Bug: 405308292
Change-Id: Ib4892cc817946c74094bfc5d9c54a95bb17ad30b

Chalard Jean   commited 2025-03-21 21:07:13 +09:00
042ebce713
Skip hostside tethering test if not SdkLevel.isAtLeastB()
HostsideTetheringTest#testSoftApConfigurationRedactedForOtherApps is
only applicable in B+, so skip it if not.

Bug: 403129363
Test: atest HostsideTetheringTests
Change-Id: I6b4be858befcabb1892ee4113ac2cf17b5d49ca5

Quang Anh Luong   commited 2025-03-19 19:26:24 +09:00
cd2b87e4c9
Merge "Specify the expected VPN network callbacks." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-10 02:29:53 -07:00
cd4258dcb1
Specify the expected VPN network callbacks.
The test expects validated VPN network callbacks. However, an
unexpected Wi-Fi link bandwidth change during the test introduces
flakiness. To enhance test stability, specify the expected
callbacks to reduce flakiness.

Bug: 401489016
Test: atest CtsHostsideNetworkTests --iteration
Change-Id: I152ba5a4ff6c4a124db820f0eb58bb057e4dee5b

Paul Hu   commited 2025-03-10 08:09:00 +00:00
8217a0e760
Merge "Avoid fd to be closed by ParcelFileDescriptor's finalizer" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2025-03-04 18:58:57 -08:00
ff9b941bcc
Fix incorrect comment about SDK version.
Unreleased SDK version is 10000, not 100000.

The code is already correct, only the comment is wrong.

Test: comment-only change
Change-Id: Ib006e98cbaf10b7da0f7a80df8d6a99527923743

Lorenzo Colitti   commited 2025-03-03 20:30:24 -08:00
74b941f327
Avoid fd to be closed by ParcelFileDescriptor's finalizer
testBlockIncomingPacketsis flaky since ParcelFileDescriptor's
finalizer closes fd and makes fd invalid.
This CL fixes this issue by keeping the reference to
ParcelFileDescriptor.

Bug: 394503660
Test: testBlockIncomingPackets
Change-Id: I1c1645d95b9d9ae1bd5af4ada500f50f350b6b0b

Motomu Utsumi   commited 2025-03-03 15:21:11 +09:00
7a2c62c6a0
Add CTS coverage for TetheringInterface with SoftApConfiguration
Cover TetheringInterface constructor with SoftApConfiguration and
TetheringInterface#getSoftApConfiguration.

Bug: 394510260
Test: atest TetheringManagerTest
Change-Id: I61d111bdea72b911b85e129ded93cfc02ce6ef2f

Quang Anh Luong   authored and   Quang Luong   commited 2025-02-09 22:23:53 -08:00
9c698d26ec
Merge "Skip HostsideTetheringTests if tethering not supported" into main
Quang Luong   authored and   Gerrit Code Review   commited 2025-01-07 18:37:06 -08:00
2601c39d54
Skip HostsideTetheringTests if tethering not supported
Bug: 379863419
Test: atest HostsideTetheringTests
Change-Id: I09e618508c9d6d8e8ca7c1c75ea0100665db7266

Quang Anh Luong   commited 2025-01-08 10:27:33 +09:00
abd12865e1
Replace executeAdbCommand with executeShellCommand
When an adb command starts with "shell", executeAdbCommand has special
logic to treat failures of the command as communication failures, and
try to recover the device. This causes instrumentation failures. See
NativeDevice.AdbShellAction#run.

Replace executeAdbCommand with executeShellCommand to avoid
instrumentation failures when the command does not succeed.

Test: atest ProcNetTest
Fixes: 385404810
Change-Id: I693f422f63cf592202ab3e49a9958c61f779b4d5

Remi NGUYEN VAN   commited 2024-12-24 13:36:57 +09:00
44bc3f7393
Merge "Add WRITE_ALLOWLISTED_DEVICE_CONFIG perm when modifying DeviceConfig" into main
Michael Groover   authored and   Gerrit Code Review   commited 2024-11-19 17:13:23 +00:00
5380288dd7
Add hostside CTS tests for SoftApConfig redaction
Add hostside CTS tests to test for SoftApConfiguration being redacted
from TetheringInterface for apps that don't own that config.

Bug: 216524590
Test: atest CtsHostsideNetworkTests
Change-Id: I823c8e94cc6fe10c6118e7a694da368e585bbd69

Quang Anh Luong   commited 2024-11-19 19:32:19 +09:00
b5b82cc424
Add WRITE_ALLOWLISTED_DEVICE_CONFIG perm when modifying DeviceConfig
Android 16 introduces restrictions on the DeviceConfig flags that
can be modified by the shell user by removing the WRITE_DEVICE_CONFIG
permission from this user and replacing it with the
WRITE_ALLOWLISTED_DEVICE_CONFIG permission; with this permission,
only those flags that have been allowlisted can be modified. This
commit adds the ALLOWLISTED permission to any test that explicitly
adopts the shell permission identity with the WRITE_DEVICE_CONFIG
permission; the WRITE_DEVICE_CONFIG permission is not removed to
ensure tests do not break when run on previous platform releases
without the ALLOWLISTED permission.

Bug: 364083026
Flag: TEST_ONLY
Test: Manually ran all modified tests
Change-Id: Iad68063550f99f3dc78ac2f0483dad98a8a93f2e

Michael Groover   commited 2024-11-18 23:28:24 -06:00
a3882a238b
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
Merge changes I2368f118,I57eb7c6d,I66e4e537,If510519b,Ia441170c into main
* changes:
  Skip testRouterSolicitations on T- devices.
  Remove CtsHostsideNetworkTestAppNext.
  Set all hostside network tests apps' target SDK to 10000.
  Consolidate defaults for hostside network tests apps.
  Stop depending on shims in CtsHostsideNetworkTests.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-09-23 23:53:02 +00:00
daab4db187
Skip testRouterSolicitations on T- devices.
This does not lways pass on some devices before U. Now that the
test is being added to MCTS, and needs to be backwards
compatible, skip this test on T- devices.

Test: atest CtsHostsideNetworkTests
Change-Id: I2368f118d2539d70a97c937485f5179c47ba28d7

Lorenzo Colitti   commited 2024-09-20 15:04:11 +09:00
eca630007a
Remove CtsHostsideNetworkTestAppNext.
This is now identical to CtsHostsideNetworkTestsApp, and we're
getting rid of -Next targets anyway, so there's no point in
keeping it.

Bug: 365191921
Test: atest CtsHostsideNetworkTests
Change-Id: I57eb7c6d9bc37d222a9449bbc85265e7c6ec9ffc

Lorenzo Colitti   commited 2024-09-20 14:48:51 +09:00
0820ccb033
Set all hostside network tests apps' target SDK to 10000.
This ensures they are subject to the most restrictive target SDK
restrictions and that we never have to manually increment their
target SDK version.

Bug: 365191921
Test: atest CtsHostsideNetworkTests
Change-Id: I66e4e53720b2860094b7a4d3194a81a063b116da

Lorenzo Colitti   commited 2024-09-20 14:48:19 +09:00
6a655a02d1
Consolidate defaults for hostside network tests apps.
For now, only share a couple of statements (min_sdk_version and
platform_apis). More will be added later.

Also, remove the test_suites stanzas everywhere. These are not
relevant for test apps because the APKs will be pulled in by
the data: stanzas anyway.

Bug: 365191921
Test: atest CtsHostsideNetworkTests
Change-Id: If510519b3bdd6ab27c1923bae523cddb694e0ecc

Lorenzo Colitti   commited 2024-09-20 14:48:12 +09:00
64cd28ddd7
Stop depending on shims in CtsHostsideNetworkTests.
These are no longer necessary, and now that udc-mainline-prod is
gone, we are moving away from shims entirely.

Bug: 365191921
Test: test-only change
Change-Id: Ia441170c25a04d7b146b48e170d53e0916d49ecf

Lorenzo Colitti   commited 2024-09-20 14:48:08 +09:00
2f87cc0610
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
Make the CTS VPN hostside tests pass on R.
Fix: 365138990
Test: test-only change
Change-Id: I1a5729872ee3dac1380a4013c9aa2f7e32859376

Lorenzo Colitti   commited 2024-09-09 19:47:44 +09:00
51d8d9c785
Skip automatic on/off keepalives before U.
The API to start them was only added in U.

The actual failure here is not an error in calling the API, it's
the fact that the test is using CollectionUtils from the
framework jar instead of statically linked copy. This might be
a problem with jarjar rules. That said, given that these APIs
are module-lib, and were only added in U, it's probably OK to
test them only on U.

Bug: 365129333
Test: CtsHostsideNetworkTests passes on redfin running S
Change-Id: I0b6a030e9ebcab573515fb58becadee8298bd653

Lorenzo Colitti   commited 2024-09-09 19:47:44 +09:00
c2a8d8f642
Extend CtsHostsideNetworkTests support to Android R (API 30)
Updated the testing app and AIDL interface used by
CtsHostsideNetworkTests to support min_sdk_version 30, ensuring
compatibility with Android R devices.

Test: TH
Change-Id: Ib334f95cf9bd199cce46b2c98d40d8361179aac3

Yuyang Huang   authored and   Lorenzo Colitti   commited 2024-09-09 19:47:44 +09:00
cea1e6034f
Set min_sdk_version to 31 for CtsHostsideNetworkTestsAidl.
This allows CtsHostideNetworkTests to run on S. Setting minsdk
to S is required because if the minsdk is T or above, the AIDL
compiler will generate code that contains Parcel#obtain(IBinder),
which only exists on T+.

Fix: 365129333
Test: atest CtsHostsideNetworkTests passes on redfin running S
Change-Id: Icac58bcc27194129014a0d615b5ca43b8f352ebd

Lorenzo Colitti   commited 2024-09-09 18:43:15 +09:00
4071ab64a1
Give CtsHostsideNetworkTests helper apps a min_sdk_version
Missing min_sdk_version will make the helper apps failed to install on
older Android releases.

Bug: 364110022
Test: TH
Change-Id: I2b53d3547d175786574064f9b8b24ea5d302a3ff

Yuyang Huang   commited 2024-09-03 15:17:36 +09:00
4d61c23b5f
Merge "Skip TestDropPacketToVpnAddress if the feature is disabled" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-09-02 07:52:02 +00:00
b8950d144a
Skip TestDropPacketToVpnAddress if the feature is disabled
INGRESS_TO_VPN_ADDRESS_FILTERING is disabled due to b/352424251 and
testDropPacketToVpnAddress fails if the feature is disabled.
So skip testDropPacketToVpnAddress if the feature is disabled.

Bug: 362434644
Test: adb shell device_config put tethering
      ingress_to_vpn_address_filtering -1
Test: atest CtsHostsideNetworkTests

Change-Id: Ib16a7550dcf93dd9ecf29047b1c4f101ff6d610d

Motomu Utsumi   commited 2024-09-02 15:21:30 +09:00
9d5d7d0779
Add mainline module controller for tethering
Bug: 361813608
Bug: 358007993
Change-Id: I4287f0670fd7b3b1ccbeaa7056b6bbedc6768f7e

Tongbo Liu   authored and   Lorenzo Colitti   commited 2024-08-30 15:04:34 +00:00
603b8e0205
Give CtsHostsideNetworkTests helper apps a min_sdk_version.
This allows them to run on older Android releases.

Fix: 358007993
Test: test-only change
Change-Id: I3c1e7eb6a3aeb53ae9bb2dadb5827d5987755905

Lorenzo Colitti   commited 2024-08-21 09:40:49 +00:00
630b81546d
Re-enable HostsideVpnTests on presubmit
Some tests were disabled by aosp/2676836 since these tests were flaky
(b/291701394).
b/291701394 was fixed. So, this CL re-enables them on presubmit.

Bug: 291701394
Bug: 342557183
Test: VpnTest --iterations 10
Change-Id: I299dd0dfd7d6cbdea2ad97477b5613c78af421e1

Motomu Utsumi   commited 2024-06-07 17:59:23 +09:00
660584a69f
Update VpnTest#testDefault to use otherUid that has internet permission
Bug: 342557183
Test: VpnTest
Change-Id: If4a256df9ef96285c65dd285c7d37696dbd82298

Motomu Utsumi   commited 2024-06-07 17:59:20 +09:00
dda2d35b0c
Add sdk_version property to cts tests
This change specifies the sdk_version property to the cts test modules
so that the test modules do not depend on the framework, and utilize the
test api instead.

Test: TH
Bug: 345499522
Change-Id: I876fb8681dadad9d123bedb38d67c1a31b0f3a54

Jihoon Kang   commited 2024-06-06 21:35:00 +00:00
5848825c42
Update VpnTest#testDefault to check other uid blocked status
On V+, ConnectivityService generates blockedReasons based on bpf map
contents even if the uid does not exist on device.
So if allowlist chain (e.g. background chain) is enabled, network access
from non existing uid is considered blocked.

Test: VpnTest#testDefault
Bug: 342557183
Change-Id: I7776c1ea0d546e53a3495d4db6d42c573b6d1f7f

Motomu Utsumi   commited 2024-05-28 19:15:13 +09:00
5d96fada30
Avoid fd to be closed by ParcelFileDescriptor's finalizer
testDropPacketToVpnAddress is flaky since ParcelFileDescriptor's
finalizer closes fd and makes fd invalid.
This CL fixes this issue by keeping the reference to
ParcelFileDescriptor.

Bug: 334644322
Test: VpnTest
Change-Id: Ib8f094725b39ac5824cd9a62918efe51f86e5cb1

Motomu Utsumi   commited 2024-05-07 23:02:15 +09:00
6e7529bccd
Merge "Fix the test flake in testChangeUnderlyingNetworks" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-05-03 01:42:34 +00:00
769a365fe7
Merge "Breaking up hostside network tests module" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-04-30 19:46:23 +00:00
da77ebefa9
Breaking up hostside network tests module
Tests for the connectivity module and network policy are both currently
residing in the same cts module leading to significant problems while
maintaining the tests. Breaking them up into two separate modules so
making changes and maintaining error free tests is easier.

Development of network policy changes occurs in non-updatable system
code so relevant tests should be moved outside of the apex module
respository. This will be possible after this change.

Network policy related tests are moved to the new module
CtsHostsideNetworkPolicyTests, with classes renamed accordingly.

Since some code was shared between tests, that code is now duplicated in
the new module.

No functional change to tests is intended. Further refactorings to
better suit the new structure should be pursued independently via
follow-up changes in respective modules from now on.

Test: atest CtsHostsideNetworkTests
Test: atest CtsHostsideNetworkPolicyTests

Bug: 322115994
Change-Id: I2c6ad2281ede6bad099c971b1f212244881a262d

Suprabh Shukla   commited 2024-04-26 12:11:13 -07:00
0001cfd931
Move VPN hardware assumption check to the end of setup
tearDown expect setUp is executed.
So move VPN hardware assumption check after all the setUps

Test: atest HostsideVpnTests
Bug: 330070197
Change-Id: I671897764908dc0188bcb2aef7177f1e4d573a8f

Motomu Utsumi   commited 2024-04-24 09:42:42 +00:00
d992ae133a
Fix the test flake in testChangeUnderlyingNetworks
The testChangeUnderlyingNetworks test enables the Wi-Fi network
and ensures it's connected. However, the CS can switch the
default network to Wi-Fi at any time when it becomes validated,
and if this happens after the test obtains the active network,
it leads to a mismatch on underlying networks and causes the test
to fail. Therefore, ensure the Wi-Fi network is validated before
obtaining the active network.

Fix: 332967125
Test: atest CtsHostsideNetworkTests:com.android.cts.net.\
      HostsideVpnTests#testChangeUnderlyingNetworks --iteration
Change-Id: If71c2ea6608f26b1dbc9802ef49e1f14b202c156

Paul Hu   commited 2024-04-22 06:49:47 +00:00
1e7203bfd3
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
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
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
Add test for dropping packets to VPN address from non VPN-interface
Bug: 295800201
Test: HostsideVpnTests
Change-Id: I0785ee1562fa50c1b6a4aca9ac077ad753cc2700

Motomu Utsumi   commited 2024-03-15 15:23:55 +09:00
ffa2bce381
Merge "Revert^4 "Re-enable the tests for background restrictions"" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-03-14 21:48:58 +00:00
ddeec3a7ad
Merge "Specify the desired callback type to deflake the tests" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-03-13 02:40:49 +00:00
4d9f787ead
Specify the desired callback type to deflake the tests
The test expects the absence of default network changes. However,
fluctuations in network capability during the test can introduce
flakiness. To enhance test stability, specify a callback for
deflaking.

Test: atest CtsHostsideNetworkTests
Bug: 329188322
Change-Id: I9ea2d5a03981f3a6584964d5a5a11e80f293edd2

Chiachang Wang   commited 2024-03-12 09:35:18 +00:00
fee93b0528