Commit graph android_packages_modules_Co.../staticlibs/testutils/devicetests
Message SHA1
Move UDP header assembly to build()
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I5e070a57bfa40f95b72549cb02662f6557f78d45

Patrick Rohr   commited 2025-04-07 20:10:18 -07:00
c1cf40d38e
Add packet builder support for UDP packets
UDP packets can be built as:

val p = ether / ipv6 / udp / data
val p2 = ether / ipv4 / udp / data
val p3 = ether / ipv4 / udp / ipv4 / udp / data

This also gets rid of Icmp6Pkt in favor of a function call that
calculates the checksum over an L4 packet.

This does add a bit of duplication: the build() function for RA and NA
packets is identical, and UdpPkt#build() is not far off. However, subtle
differences in L4 packet format (namely the checksum and length
positions) make generalizing this code difficult. This is possible by
passing the checksum position, proto byte, and adding an abstract
function that fills in the L4 length field before performing checksum
calculation. However, this complexity is likely not worth it. If the
repetition becomes obvious once more protocols (such as ICMPv4/6 echo,
etc.) are added, this decision will be revisited.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ia78792418f29a3be091ebdc9bb2c26e45da9f2b1

Patrick Rohr   authored and   Maciej Żenczykowski   commited 2025-04-07 14:22:43 -07:00
328cfb5051
Add packet builder support for IPv4 packet
Options and fragments aren't currently supported.

Test: decoded test packet on packetor.com
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ia3a094cb1d2b093cae2f372cc84a72ad7e107105

Patrick Rohr   commited 2025-04-07 10:28:35 -07:00
313c1057f6
Add support to NdResponder to add custom RA
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ic7f2567f15b76478df1c438e756929a93ffd4d43

Patrick Rohr   commited 2025-04-07 10:28:35 -07:00
495edd20a8
Delete RouterAdvertisementResponder
And move all other tests over to NdResponder.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ia1e08c439a039a4ffa020318da44652fadadf5c9

Patrick Rohr   commited 2025-04-03 22:09:47 -07:00
d107a1692f
Rewrite RouterAdvertisementResponder in Kotlin
And integrate into EthernetManager. So it can make proper use of
PacketBuilderUtils.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ifbca38e6efde68e015c69bf919d079d1605310d1

Patrick Rohr   commited 2025-04-03 21:59:21 -07:00
75a83c51ad
Add support for ICMPv6 checksumming
Test: parsed packet on packetor
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Id81c57a7f9ca9ee3671768941687458100beb068

Patrick Rohr   commited 2025-04-03 16:23:08 -07:00
a39bf4ee97
Support scapy packet builder syntax
Scapy allows building packets in order, i.e. by assembling them using
the division operator: val p = ether / ipv6 / icmpv6.

This change adds support for an identical pattern. To do so, it first
assembles all packets in order inside a packet builder class. When
build() is called, it traverses the packet list in reverse and assembles
the final packet, similar to ther original instance of the code. To
support checksum generation in the future, the code also keeps track of
the "closest pseudo header packet", i.e. the nearest encapsulating IPv6
(and soon IPv4) packet. This architecture should eventually be able to
support the creation of more complex packets, for example:
val p = ether / ipv6 / ipv6-ext / udp / ipv6 / udp.

(Note that now that I am writing this, I realize that this could
probably be significantly simplified by including IPv6 extension header
support as part of Ip6Pkt and always using the encapsulating packet for
the pseudo header...)

This code does not yet implement checksum generation.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I9b0fa0e5bb66edf6928d9b96144c5ed133ebab64

Patrick Rohr   commited 2025-04-03 14:50:09 -07:00
0b8e3a26fb
Use Kotlin syntax for getters
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ic4b22e2c6154bf634bfbbe6c539bc6b26a29b3af

Patrick Rohr   commited 2025-04-02 11:41:01 -07:00
e2db1fe7e0
Return this from add*Option methods
To support friendlier builder syntax.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Iaf4250da61e2c0b5311682b2c462eb07467428f7

Patrick Rohr   commited 2025-04-02 11:37:24 -07:00
91ef24c6f6
Add some documentation to RaPkt
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I429b316a2660789316f46fae63c621d81dfe67af

Patrick Rohr   commited 2025-04-02 10:30:36 -07:00
22727f7bef
s/payload/data/ for brevity
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I03cdb93f616510c3648d91f993577cb4d846a5bd

Patrick Rohr   commited 2025-04-02 10:30:36 -07:00
2e95c356d7
Add packet builder support for neighbor advertisement
In the future, we could consider adding an ICMPv6 base class that
implements common functionality between NaPkt and RaPkt. However, given
that checksumming is not currently supported, the common functionality
is limited to only a couple of lines.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Id45f2ed43f45778e80b303bd356babcc93de1c3f

Patrick Rohr   commited 2025-04-02 10:30:36 -07:00
49eede426b
Add packet builder support for more RA options
Test: Built packet and parsed it in packetor
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I69d3451cbdd7f229f914ee5d0e4dd2c7a5178f0a

Patrick Rohr   commited 2025-04-01 16:26:30 -07:00
6269bbdedb
Remove unnecessary {}
Test: TH
Flag: EXEMPT mainline
Bug: 100
Change-Id: I4ca9f92ce6535cf6f07aa74a94ee58ced541e73f

Patrick Rohr   commited 2025-04-01 14:45:46 -07:00
62154f61be
Introduce generic packet builder utilities for use in tests
This change introduces a set of generic packet builder utility classes
that can be used in tests. The API surface aims to be similar to scapy
with a focus on ease of use.

Test: TH
Flag: EXEMPT mainline
Bug: 1
Change-Id: I9c751cece7bbad6bc38953cb52e9ab42393bab89

Patrick Rohr   commited 2025-04-01 10:48:31 -07:00
c3af22faca
Move EthernetTestInterface to testutils
To make it usable for integration tests not in CTS.

Test: TH
Change-Id: If243997f086c442d4f0ef8f3c77760fada769448

Patrick Rohr   commited 2025-03-28 10:06:13 -07:00
f23f6ae45b
Add generic createTestInterface to AutoCloseTestInterfaceRule
Test: TH
Change-Id: Ib0519f99417c94f3ae77ab1d56a81fe1fd167c0c

Patrick Rohr   commited 2025-03-28 09:50:21 -07:00
bd9376982e
Merge "Avoid unavailable APIs in ShellUtil" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-23 19:33:44 -07:00
137f2d754c
Avoid unavailable APIs in ShellUtil
executeShellCommandRwe is U+. Use executeShellCommandRw which is S+
instead, and annotate methods accordingly. stderr is not used in any
instrumentation at the moment.

Bug: 405109522
Test: atest
Change-Id: I8212cb340cfb7e5ee5d0da314613b474e4f155fc

Remi NGUYEN VAN   commited 2025-03-24 10:15:44 +09:00
b84286a35a
Don't use NetworkScore in TestableNetworkAgent
...because R doesn't know that class

Bug: 404977645
Test: NetworkAgentTest
Change-Id: Iac558bf02bb9372ba397013524839be2b0b4d415

Chalard Jean   commited 2025-03-22 02:15:57 +09:00
f68316091d
Merge "Make sure tests know to handle both early creation true and false" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-21 05:02:06 -07:00
a0fa137d85
Make sure tests know to handle both early creation true and false
This is necessary to pass tests whatever the values of the features are.

NetworkAgentTest was updated assuming the feature was true, so
this patch revives the old code for when it's false.

TestableNetworkAgent reads the feature directly from
ConnectivityManager when it's not mocked.

Test: CtsNetTestCases
Change-Id: Ia556fbb1d1b6a38a4995b021981e2693d778bfff

Chalard Jean   commited 2025-03-21 19:29:06 +09:00
0cc8d81cc7
Fix CarrierConfigRule#setHoldCarrierPrivilege race
CarrierConfigRule#setHoldCarrierPrivilege will try to acquire/drop the
carrier privilege, but does not wait for the result of the operation. If
a test immediately calls an API that requires carrier privilege before
the operation completes, then it will fail.

Fix this by waiting for the operation to succeed before returning.

Bug: 295979433
Test: presubmit
Change-Id: Ic7cc9e1dbc206fbc0c3b79058b5782d93e89f1d7

Quang Anh Luong   commited 2025-03-21 18:13:37 +09:00
d3058d5ffe
Remove the queue on the NetworkAgent side
Now that the system server has a queue doing this job,
the queue on the network agent side can be removed.

Test: ConnectivityCoverageTests, CtsNetTestCases
Change-Id: Idf0435f447cfdd28d829a867d1085771837c6f9b

Chalard Jean   commited 2025-03-18 19:23:57 +09:00
391ec5d99c
Merge "Collect diagnostics without storage permission" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2025-03-18 02:05:21 -07:00
899737e0e0
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
Collect diagnostics without storage permission
Use the shell to open the output file instead of FileOutputStream. This
allows test to use ConnectivityDiagnosticsCollector even if they do not
have storage permissions.

getOutputStreamViaShell is a method of the base class
BaseMetricListener.

Bug: 317602748
Test: atest
Change-Id: I127bb6711d14fdee059a31a8a3cfddc44b1d7800

Remi NGUYEN VAN   commited 2025-02-26 11:39:55 +09:00
8b555c29c3
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