Commit graph android_packages_modules_Co.../staticlibs/testutils/devicetests
Message SHA1
Add carrier privilege utils to CarrierConfigRule
Move the existing helper methods to acquire carrier privileges in
NetworkAgentTest.kt to CarrierConfigRule where it can be reused by other
CTS tests. Also reset the carrier service package override in the rule
cleanup.

Bug: 216524590
Test: atest NetworkAgentTest
Change-Id: Id907a2d641aa61838119e2be65654b9796464498

Quang Anh Luong   commited 2025-03-18 13:05:01 +09:00
a620310e9c
Invoke tcpdump with -l
Currently ConnectivityDiagnosticsCollector invokes tcpdump with -U,
which would causes the collector failed to log ending packets due to
packet buffering.

Test:
android.net.cts.TrafficStatsTest#testTrafficStatsForLocalhost
Bug: 393471251
Change-Id: Ibe2977097bdeeef9546ce9c83b1dfd695c31f6d1

Junyu Lai   commited 2025-03-10 23:41:50 -07:00
2685014bf7
Merge "Revert^2 "Allow collecting diagnostics from shell commands"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-05 15:57:46 -08:00
d1713458a8
Revert^2 "Allow collecting diagnostics from shell commands"
This reverts commit 3eec0163fc.

Reason for revert: Failures in b/399299587 are flakes and not related

Original message:

Allow adding output from any shell command to the test diagnostics file,
instead of just dumpsys.

This introduces a new ShellUtil that can also help run more complex
commands, with pipes and redirects or as root for example.

Bug: 317602748 
Test: atest with tests using this util
Change-Id: I609469864dfa5d520c055b648f9cac2f4443c5c6

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2025-03-04 02:54:50 -08:00
83af0f15dd
Enable Bluetooth before running testReserveL2capNetwork
Bug: 397740298
Test: TH
Change-Id: If35a4b83ab8f96d0c98b3bf2ecb8b0e68420c4fe

Patrick Rohr   commited 2025-02-26 13:50:06 -08:00
d1cca845e2
Revert "Allow collecting diagnostics from shell commands"
This reverts commit 47b6619fa8.

Reason for revert: DroidMonitor: Potential culprit for http://b/399299587 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Id7717258b960ac18a27575fdc2b0852b42ef4e7b

Liana Kazanova (xWF)   authored and   Gerrit Code Review   commited 2025-02-26 12:20:26 -08:00
3eec0163fc
Allow collecting diagnostics from shell commands
Allow adding output from any shell command to the test diagnostics file,
instead of just dumpsys.

This introduces a new ShellUtil that can also help run more complex
commands, with pipes and redirects or as root for example.

Bug: 317602748
Test: atest with tests using this util
Change-Id: I0a0b5c7be5afd9e592dd820bfdbcee39ade418f8

Remi NGUYEN VAN   commited 2025-02-26 11:39:51 +09:00
47b6619fa8
Reverse pollingCheck arguments to be more kotlin friendly
Test: TH
Change-Id: Ibe52ccd9eec619ced5f8b84896d2a1efc6c0fefc

Patrick Rohr   commited 2025-02-25 15:30:52 -08:00
7f9469e808
Move pollingCheck to testutils
Test: TH
Change-Id: I7d9362dcda095f8037467baf3602911fc3a3c072

Patrick Rohr   commited 2025-02-25 15:30:51 -08:00
b4809fdd08
Support Paramerized in SetFeatureFlagsRule
Make Parameterized compatible with SetFeatureFlagsRule. If both
are used, the method names seen by SetFeatureFlagsRule may
be followed by [\d+] in Parameterized style, leading to a method
not found exception in SetFeatureFlagsRule. With this patch, both
can be used at the same time.

Test: add a Parameterized rule to CaptivePortalLoginActivityTest
      see how it fails with MethodNotFoundError without this patch
      see how it works as expected with this patch
Change-Id: I3fe1e63600dd792bc290ed130b8598b49f2b95e1

Chalard Jean   commited 2025-02-20 15:46:39 +09:00
1c0939c365
Wait for carrier config to apply in tests
TetheringManagerTest#testRequestLatestEntitlementResult in particular
set carrier config overrides without waiting for the override to be
applied, which caused flakes.

Wait for the override to be applied when adding and clearing them.

This makes the logic to wait for the update in NetworkAgentTest
unnecessary.

Bug: 391966043
Test: atest
Change-Id: I371ff5742627ca0b1b6eb6be5f0fd19a0487ae83

Remi NGUYEN VAN   commited 2025-02-05 15:42:54 +09:00
b9ac4c8fe2
Merge "Revert^2 "Fix flakes due to tests resetting CarrierConfig"" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2025-01-24 03:29:10 -08:00
0e2102069e
Revert^2 "Fix flakes due to tests resetting CarrierConfig"
This reverts commit 19a936d3ab.

Reason for revert: revert^2 to verify if this CL really break TH.

Change-Id: I8600883785881d857b7e79cf16459e33080fa82b

Yuyang Huang   authored and   Gerrit Code Review   commited 2025-01-23 18:56:11 -08:00
6f99275476
Merge "Revert "Fix flakes due to tests resetting CarrierConfig"" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2025-01-23 18:55:18 -08:00
55105df5ee
Revert "Fix flakes due to tests resetting CarrierConfig"
This reverts commit c7ed1a195a.

Reason for revert: possibly fails on S

Bug: 391766151
Change-Id: I24c72b48e037c2e2b7852bcc8300de777a391557

Maciej Å»enczykowski   commited 2025-01-23 15:38:01 -08:00
19a936d3ab
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
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
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
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
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
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
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
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 "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
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 "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
Merge "Do not run diagnostics on assumption failures" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 07:16:44 +00:00
8eff4fd04b
Do not run diagnostics on assumption failures
Assumption failures are not actual failures, do not run connectivity
diagnostics for these.

Test: atest
Change-Id: I1d78eb6f12412e13cf4c29718ff8869ed089f491

Remi NGUYEN VAN   commited 2024-10-16 15:26:47 +09:00
3feb788aa5
Merge "Add options to disable diagnostics collector" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-16 06:02:22 +00:00
5024551d11
Add options to disable diagnostics collector
Disable by default on local builds (which generally have "eng.username"
as their INCREMENTAL version), and add an option to allow disabling
manually on other builds as well.

Test: atest

Change-Id: I2d406a55ba0e3d57ed30e740b6c011124905b8d7

Remi NGUYEN VAN   commited 2024-10-16 13:27:14 +09:00
2665f0a4d5
Merge "Add connectivity diagnostics on test failure" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-10-16 04:11:58 +00:00
c0ebf16036
Add connectivity diagnostics on test failure
When CtsNetTestCases tests fail, or when a tryTest statement fails,
collect connectivity diagnostics and output them as a test artifact.

tryTest must be followed by cleanup blocks, which often change the
configuration, so having diagnostics when the tryTest fails in addition
to after the test failure is useful.

The collected diagnostics will be available as individual test
artifacts. They should make it easier to investigate test failures, and
could be collected across test runs in an automated way.

Output files are currently limited at 20 per run, to avoid collecting
too much data in case everything is failing in the run.

Test: atest
Change-Id: Iaa48e519028dc61c03d387beeade7d41fca2ef48

Remi NGUYEN VAN   commited 2024-10-16 10:05:35 +09:00
43730b3f0f
Rename TapPacketReader to PollPacketReader for broader applicability
* Renamed TapPacketReader to PollPacketReader to better reflect its
  functionality beyond TAP interface interaction.
* The class includes general logic for polling and sending packets to
  file descriptors, making it suitable for wider use cases.

Test: TH
Change-Id: Icdf9a9d7ef6f49b589ed9cdbd05159ab95e7e5d9

Yuyang Huang   commited 2024-10-15 13:42:05 +09:00
eb3c631b89
Merge changes from topics "ddr-tests-in-networkstack", "move-fakedns" into main
* changes:
  Move to one unified implementation of FakeDns.
  Add test utils for SVCB packet generation.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-09-19 06:19:31 +00:00
3627907075
Move to one unified implementation of FakeDns.
Take the functionality from the (better) FakeDns in NetworkStack,
move it to the FakeDns in staticlibs, and port it to kotlin.

Test: test-only change
Change-Id: I6d0b4a348ca86ab69785cdf722c259ef6a92ce4b

Lorenzo Colitti   commited 2024-09-19 12:51:28 +09:00
5355fce9b2
Remove assert for R+
Mainline only ships to R+ devices, so this assertion is guaranteed to be
true.

Change-Id: I1fbc0a50dc35a306d782a0219955c51954deeca7
Test: TH

Patrick Rohr   commited 2024-09-12 04:32:59 +00:00
d393a9d8d4
Add test utils for SVCB packet generation.
This is based on patchset 22 of aosp/2453209.

Bug: 240259333
Test: test-only code, will be covered by NetworkMonitorTest
Change-Id: Ibede3fb519e6f1d0c3d99886f553ee006ddfebc9

Lorenzo Colitti   commited 2024-09-10 14:47:57 +09:00
93f2efbe86
Throw IllegalStateException when inserting an existing item
This commit throws IllegalStateException instead of
IllegalArgumentException when inserting an existing item
to TestBpfMap to fit the current behavior in the
production code.

This is safe given that this is only for test and no one is
currently check the exception.

Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Bug: 354619988
Change-Id: I1e5c6e99a0d95b44dd556de8805bb16c3d1a4f61

Junyu Lai   commited 2024-09-04 18:48:56 +08:00
c1856de66e