Commit graph android_packages_modules_Co.../staticlibs/testutils
Message SHA1
Merge changes Ia25b28d5,Ic6bbd8c0 into main
* changes:
  Fix flakes due to tests resetting CarrierConfig
  Fix lint errors in NetworkAgentTest

Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-19 20:01:08 -08:00
4ab11df911
Fix flakes due to tests resetting CarrierConfig
Some tests use CarrierConfigManager#overrideConfig(subId, bundle) to set
some configs, and then overrideConfig(subId, null) to reset the
override.  However this also resets overrides that may have been set by
the instrumentation, such as ConnectivityTestTargetPreparer /
CarrierConfigSetupTest.

Avoid this by providing a common utility to set and tear down carrier
config, which reset the overrides to the original setting value instead
of clearing all overrides.

Test: atest
Bug: 253698734
Change-Id: Ia25b28d551b62205c52f91e0ffad1b94710c0828

Remi NGUYEN VAN   commited 2025-01-20 11:55:39 +09:00
c7ed1a195a
Add 'automotive-general-tests' to the CtsNetTestCases dependencies
This change adds missing dependancies of CtsNetTestCases to the automotive-general-tests zip

Change-Id: Iba2da89b380214ad785d504a484b0b72b508814d
BUG: 382649664 
Flag: TEST_ONLY

Filip Zakrzewski   commited 2025-01-16 15:25:33 -08:00
c4e71897a5
Merge changes Iddc8975b,I2cedd584 into main
* changes:
  Add diagnostics on failure for PrivateDns test
  Wait for default route for wifi check

Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-15 00:45:15 -08:00
ba7089227f
Merge "Address lint warnings in diagnostics collector" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-15 00:13:15 -08:00
cbf9b1163e
Add diagnostics on failure for PrivateDns test
IWLAN on U 24Q2 release may cause this test to fail, but this was
supposed to be addresed by CarrierConfigSetupTest already.

Add diagnostics on failure to figure out if the IWLAN config is as
expected.

Test: atest
Bug: 253698734
Change-Id: Iddc8975bb473979f9c2769cd178ef75644b82aa7

Remi NGUYEN VAN   commited 2025-01-15 16:12:40 +09:00
4d47b52f6d
Wait for default route for wifi check
Instead of only waiting for an IPv6 address, wait for global IPv6
addresses to be routable.

This mirrors the check used for AI_ADDRCONFIG in DnsResolver. Without
this, the later call to network.getAllByName may only return IPv4
addresses if IPv6 global addresses are not reachable.

Test: atest
Change-Id: I2cedd58431eb8abeb5ffd9fb8daedb061586373b

Remi NGUYEN VAN   commited 2025-01-15 16:12:04 +09:00
ee21b71492
Address lint warnings in diagnostics collector
This change was generated by running the formatting tool.

Test: m
Change-Id: I38f5b3d0cc60c12b3a312a9e8498565f73a638f1

Remi NGUYEN VAN   commited 2025-01-15 16:05:29 +09:00
6f694d0ef9
Merge changes from topic "resolv_cancellation" into main
* changes:
  Add CTS test for DnsResolver cancellation
  Add DnsResolverTapTest

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2025-01-07 19:05:25 -08:00
26630dcd06
Return the matched event from TestableNetworkOfferCallback
Since the requestId is generated by CS, the only way to get a hold of it
is by intercepting the onNetworkNeeded() callback.

Test: TH
Change-Id: I8d66d287633151f9cfe7053c2b934121d2c96dbc

Patrick Rohr   commited 2024-12-20 15:15:28 -08:00
da8ae0edfe
Add support for testing onReserved callbacks
Test: TH
Change-Id: I0d35567dae5865cc2de9e5f6811f1b9a57a04cbd

Patrick Rohr   commited 2024-12-20 15:15:28 -08:00
fe3d77a042
Merge "Dump tcpdump on failure in testUidTagStateDetails" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-12-10 07:15:41 +00:00
75cd08977d
Merge "Reconnect to wifi if supported" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-05 09:30:12 +00:00
bd579b4658
Merge "Make ConnectivityTestPreparer.apk path explicit" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-12-05 08:55:46 +00:00
af139d7b7d
Reconnect to wifi if supported
Some tests may disable wifi when testing, for example,
tests which setup cellular default network.
Reconnect to wifi to prevent from flaky.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Bug: N/A
Change-Id: Ic0e27efc0e82698618c651c0a78b000c0ffe2131

Junyu Lai   commited 2024-12-05 08:12:25 +00:00
ad713e007a
Make ConnectivityTestPreparer.apk path explicit
Instead of using recursive search in test directories to find
ConnectivityTestPreparer.apk, only search for it in the dependencies of
net-tests-utils-host-common.

The default strategy for finding test files is to do a recursive search
in test directories, which may find wrong files in wrong directories.
In particular, if some MTS test includes the checker APK, and that test
is linked to a module that boards the train at a version different from
this target preparer, there could be a version difference between the
APK and the host-side preparer.

Follow-up changes will remove ConnectivityTestPreparer.apk from the
dependencies of each test case so it does not appear multiple times in
test suites like android-mts.zip, but this change makes the process
more deterministic.

Test: mts-tradefed run mts-dev -m CtsTetheringTest
Bug: 377716515
Change-Id: I3b00ef9a0bd1d29e8734f44413be4ff16879c574

Remi NGUYEN VAN   commited 2024-12-05 14:46:29 +09:00
4a79993944
Merge "Add mcts and mcts-tethering to net-tests-utils-host-common for the dependency of ConnectivityTestPreparer" into android15-tests-dev am: 900fb00793
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3381265

Change-Id: I92961a480281fc239dcde1d0cf0480cbbd496486
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Tongbo Liu   authored and   Automerger Merge Worker   commited 2024-12-03 03:34:40 +00:00
4f1c1ea358
Dump tcpdump on failure in testUidTagStateDetails
Add support for dumping tcpdump on test failure into the conndiag
artifact, and apply it to testUidTagStateDetails.

testUidTagStateDetails has recently been flaking due to unidentified
extra traffic, and this may help identify that traffic. Having an easy
way to collect tcpdump on test failure should help diagnose flakes going
forward as well.

Bug: 345322466
Test: atest
Change-Id: Ib2881be3df82b3b31b3a524987f775fa03279f63

Remi NGUYEN VAN   commited 2024-12-02 12:52:20 +09:00
8f265c9b43
Add mcts and mcts-tethering to net-tests-utils-host-common for the dependency of ConnectivityTestPreparer
Bug: 379792488
Change-Id: I725bc9d7fed7df23ccc21d1f4dc4fa10e0315cc9

Tongbo Liu   commited 2024-12-02 03:11:19 +00:00
17ab27e71f
Merge "Only report tryTest errors when not caught" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-02 01:48:40 +00:00
739a6c4320
Only report tryTest errors when not caught
Instead of reporting tryTest errors when the tryTest block throws,
report them in the cleanup block if no catch block has caught it.

This fixes a bug where tests that use tryTest/catch would collect
diagnostics in expected cases.

Test: atest
Change-Id: Ic53ae54f1945a2784becd50e5890fad8e7461474

Remi NGUYEN VAN   commited 2024-12-02 09:26:53 +09:00
fc724ab59a
Merge "Add isDebuggable() to DeviceInfoUtils for Android R compatibility" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2024-11-29 10:11:14 +00:00
6ac23bd155
Merge "Fix assertEventuallyTrue timeout" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-11-29 09:01:18 +00:00
bb3b38d71e
Add DnsResolverTapTest
Add a test class (with currently no test case) to verify DnsResolver on
tap interfaces.

Test: atest
Change-Id: I3cbf9bb829a76f8c0f76cfb9a8365e955fb7710b

Remi NGUYEN VAN   commited 2024-11-29 16:28:22 +09:00
fb3159db52
Fix assertEventuallyTrue timeout
A nanosecond is 1E6 milliseconds, not 1000.

Test: atest
Change-Id: Iaa5fc15b4dc5a735d1a7bdbf7642c1376d2f41d9

Remi NGUYEN VAN   commited 2024-11-29 16:28:16 +09:00
2229796976
Add isDebuggable() to DeviceInfoUtils for Android R compatibility
Introduced the isDebuggable() helper method in DeviceInfoUtils. This
method provides a consistent way to determine if the device is in
debuggable mode across different Android versions. Since
Build.isDebuggable() is not available in Android R, the method checks
the "ro.debuggable" system property as a fallback, ensuring
compatibility.

Bug: 381327071
Test: TH
Change-Id: Ibf77bcfc50378d88458baf07683e7bf2065734de

Yuyang Huang   commited 2024-11-29 15:38:21 +09:00
bb815f25dd
Merge "Add QUIC testing to test preparer" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-11-29 01:15:18 +00:00
323c15448a
Add QUIC testing to test preparer
In addition to verifying that the wifi network is validated, also verify
that it can use QUIC on both IPv4 and IPv6.

This makes setup issues more obvious and avoids blaming individual
tests, by failing the whole module in case devices are connected to
access points that do not meet the test prerequisites.

The QUIC test (including the test packet) is mostly taken from
NativeMultinetworkJni.cpp and written in Kotlin.

Test: atest
Change-Id: I1c0381e1ad4146d4827fbc1bf095da13dfe3d124

Remi NGUYEN VAN   commited 2024-11-29 08:42:51 +09:00
cc8b8f9165
Merge "Fix setup on devices without printflags" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-11-25 05:55:53 +00:00
b028a6f264
Fix setup on devices without printflags
Instead of running printflags directly, which on devices that do not
have the binary hangs indefinitely, run "sh -c printflags".

printflags is in the default base_system.mk but some OEMs may strip it
out. sh is much less likely to be removed.

Bug: 379183423
Test: atest
Change-Id: I66af42b2cfbf5cb427c740ef710d8eb3d1d7f1ef

Remi NGUYEN VAN   commited 2024-11-25 13:19:25 +09:00
282b7be3c6
Add diagnostics to testNativeDatagramTransmission
When the test fails, retry it 10 times, and an extra time on the
original source port. Report results in the connectivity diagnostics
file header so they can be parsed across tests.

This should help investigate issues possibly linked to UDP packets not
being routed properly depending on the port.

Test: atest
Bug: 375477810
Bug: 253698734
Bug: 324389407
Bug: 338090529
Change-Id: I8400b40257aa25a373c5a3ec96868d6877e0afb1

Remi NGUYEN VAN   commited 2024-11-25 09:21:36 +09:00
956b8621da
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
Merge "Remove mcts tags since the net-tests-utils-host-common is host_required by other CTS cases" into android15-tests-dev am: 54123391a1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3342613

Change-Id: I4495e7dfc05ca5ff20e6fddd137aaa5135558ea2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Tongbo Liu   authored and   Automerger Merge Worker   commited 2024-11-08 03:43:15 +00:00
19e2806f88
Remove mcts tags since the net-tests-utils-host-common is host_required by other CTS cases
Change-Id: Ice129f55b58f246d01eae63f555677e992fad177

Tongbo Liu   commited 2024-11-07 12:26:49 +00:00
5801f1644a
Merge "Add config for client-side traffic stats rate-limit cache." into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-10-31 07:22:36 +00:00
30ff675df5
Add config for client-side traffic stats rate-limit cache.
This is a no-op change since the config is not used yet, and
the feature flag will be gradually rolled out instead of enabled
by default.
However, this change is necessary for follow-up changes to enable
toggling the feature and configuring its behavior through device
configuration flags.

This change includes:

 1. Disable the service-side cache flag if the client-side flag
    is enabled.
 2. Since the apps don't have enough permission to check the
    feature flag from DeviceConfig. Provides a binder interface
    for returning per-UID config,
    which only returns cache enabled if the SDK level is V+
    or the app's target SDK is V+.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
      FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
      CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
      FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: Id9761e4aea65fabe6466c875b787e178317a1da2

Junyu Lai   commited 2024-10-30 23:02:59 +08:00
b9071f8512
Merge "Disable IWLAN in tests on 24Q2" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-30 09:35:41 +00:00
e11336f01d
Disable IWLAN in tests on 24Q2
24Q2 reconnects mobile data when Wi-Fi is toggled when IWLAN is used,
which breaks multinetwork tests. Disable IWLAN as a workaround on such
builds.

Bug: 368477391
Test: atest
Change-Id: Ia5748dc2378c5fc4a43ff83e6b47e629eb8bf77a

Remi NGUYEN VAN   commited 2024-10-30 17:41:03 +09:00
1372ac2140
Merge "Add log when resetting DeviceConfig" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-25 02:25:38 +00:00
bdeff0e8e6
Add log when resetting DeviceConfig
The log should help investigate flakes, by knowing at which point
DeviceConfig is being reset and to which value.

Test: atest
Change-Id: Ia7392ad57d3df17b0d5194158b402f52bc90f7e3

Remi NGUYEN VAN   commited 2024-10-25 09:20:12 +09:00
001be79f0f
Merge "Remove dependencies on the 1-variant fallback" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-24 06:56:10 +00:00
ed99321230
Merge "Fix flakes due to cell reconnecting on wifi toggle" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-24 04:02:13 +00:00
e486d1d6b2
Fix flakes due to cell reconnecting on wifi toggle
On some networks, telephony may teardown its network
(unregisterAfterReplacement) when wifi is toggled to change the MMS
capability.

Update testRejectUnvalidated_TearDownNetwork to take that into account:
right after toggling wifi to make it unvalidated, wifi may still be
default if mobile data is being reconnected. Wait for mobile data to
reconnect and validate in that case.

Bug: 296403855
Test: atest
Change-Id: Ief46bed41ecb23d75c9a1f58e7a272e7f3de7caf

Remi NGUYEN VAN   commited 2024-10-24 11:22:56 +09:00
c19e8a00cc
Merge "Refactor is_packet_capture_supported() by expect_throws()" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-10-24 01:19:30 +00:00
6833d84d0b
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 "Add expect_throws() to assert_utils.py to check expected exception" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-10-22 07:05:01 +00:00
7a4a85bf44
Refactor is_packet_capture_supported() by expect_throws()
Test: atest NetworkStaticLibHostPythonTests
Change-Id: Ibbc249e3d6ef182207ba3fe37c47bab7e099f2b0

Jimi Chen   commited 2024-10-22 03:07:27 +00:00
13a9f53d98
Add expect_throws() to assert_utils.py to check expected exception
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I2e181f5b6f41e6de228d516dff970d47cfa3eaf6

Jimi Chen   commited 2024-10-22 03:06:47 +00:00
a0c0168ae6
Merge "Add report header to failure diagnostics" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-18 04:46:04 +00:00
40b2466b1d
Add report header to failure diagnostics
Add a one line header of JSON info about the failure in failure
diagnostics reports.

This can then be automatically collected to calculate statistics about
particular failures, for example how often they happen when wifi is not
connected, not validated etc.

Test: atest
Change-Id: Ic4c99c53fc2686aaf2f1651522aa2f0d82d0cb86

Remi NGUYEN VAN   commited 2024-10-18 09:41:33 +09:00
e980872140