Commit graph android_packages_modules_Co.../staticlibs/tests/unit
Message SHA1
Reduce unecessary allocation churn in MdnsServiceTypeClient.processResponse
Bug: 413371501
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.mdns.MdnsServiceTypeClientTests
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.CollectionUtilsTest
Flag: EXEMPT bugfix

Change-Id: Id9abf0b79f6db155e6895b0dd7661d0aafb6b0a7

Richard Uhler   commited 2025-08-08 10:08:36 -07:00
532b263b45
Introduce LegacyStruct to expose writeToBytes(ByteOrder)
The ByteOrder should be encoded by the field, not by the writeToBytes()
method. To fix this, a LegacyStruct is introduced which continues to
expose writeToBytes(ByteOrder) during the transition. This approach
helpfully creates a compile error when converting a Struct class back to
inheriting from Struct for all call sites of writeToBytes(ByteOrder).

Test: TH
Flag: EXEMPT mainline
Change-Id: I3b28c53ce3e884e59760744838b3518596de5c75

Patrick Rohr   commited 2025-07-28 15:58:48 -07:00
62d51d1bcd
Merge "Create CommonConnectivityJni to share between modules" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-07-24 09:56:39 -07:00
0e5defc1e9
Create CommonConnectivityJni to share between modules
Flag: EXEMPT mainline
Test: TH
Change-Id: Ia85dfd3d979803baca9e971d1083f54dff46de53

Jimi Chen   commited 2025-07-23 05:47:12 +00:00
e5a4e6b0ba
Fix permissions in RestoreEthernetRule
The previous runAsShell calls adopted permissions spuriously. This
change fixes runAsShell to consistently adopt the correct permission
for the respective API call.

Also calls setEthernetEnabled() no matter what the current state is at
the end of the test (as there is no harm in doing so).

Test: TH
Flag: EXEMPT mainline
Change-Id: Ib11b889148213b160567cf0a3b9ea72b5b0c851e

Patrick Rohr   commited 2025-07-17 13:54:12 -07:00
ac29211362
Ignore RtNetlinkMessage with null or empty interface names
This patch checks if interface name is null or empty for
RtNetlinkMessage and ignores the message if it is.

Bug: 429497348
Test: build
Flag: EXEMPT bugfix
Change-Id: I6000f5442f341f152b7fbd235affded0fa56fe50

Chuwei He   commited 2025-07-15 18:43:07 -07:00
16c8fd1166
Merge "Pass bluetoothUseRandomAddress via RoutingCoordinator constructor" into main
Motomu Utsumi   authored and   Android (Google) Code Review   commited 2025-07-14 22:47:19 -07:00
1cdb0a5609
Pass bluetoothUseRandomAddress via RoutingCoordinator constructor
This refactoring changes how the bluetoothUseRandomAddress flag is
accessed.

PrivateAddressCoordinator is in a library used by multiple mainline
modules(Tethering, NetworkStack, CaptivePortal, WiFi) and cannot
directly read a Tethering mainline beta flag.

To fix this, the flag's value is now passed down through constructors.

An alternative solution would be to split the Java library for each module,
but with this solution, a single utility class cannot be shared.

This commit is a no-op as the passed value is hardcoded to false.

Test: TH
Flag: EXEMPT refactor
Bug: 287177081
Change-Id: I5f2174ee94b55e7a7298b9742221d6e6c3c5cac5

Motomu Utsumi   commited 2025-07-15 11:20:01 +09:00
323d22a497
Merge "Refactor: Add RestoreEthernetRule for ethernet tests" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-07-10 03:58:40 -07:00
f693a0f9bf
Refactor: Add RestoreEthernetRule for ethernet tests
This is a no-op, test only refactoring.
Move ethernet state management logic from EthernetManagerTest into a
dedicated JUnit test rule, RestoreEthernetRule. This new rule is
responsible for saving the initial ethernet state, allowing tests to
enable or disable it, and restoring the original state upon test
completion.  This refactoring simplifies EthernetManagerTest and
promotes code reuse.

Flag: EXEMPT EXEMPT test only refacotring
Test: atest NetworkStaticLibTests:com.android.testutils.RestoreEthernetRuleTest \
      CtsNetTestCases:android.net.cts.EthernetManagerTest --update-device
Bug: 410731080
Change-Id: If3dd869d6af4e0c659386621fb5d92012aa574d1

Junyu Lai   commited 2025-07-10 15:25:15 +08:00
9f6a566d89
Merge changes I65fecdcd,I0acc9fcb into main
* changes:
  Add pre-test check for APF offload status
  Add util to get APF offload config

Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-08 20:24:46 -07:00
df4c09fe3a
Add util to get APF offload config
Adds a new helper function `get_apf_config_from_cmd` to retrieve the
list of enabled APF offloads for a given network interface.

Flag: EXEMPT mainline
Bug: 419427388
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I0acc9fcbf2e8bc6f4d8f309c2ec64c003c325c42

Jimi Chen   commited 2025-07-08 04:10:41 +00:00
7c190ecb78
Support AutoReleaseBluetoothRule
This change introduces a utility class to disable
Bluetooth before testing, in case it was previously connected
as the default network.

Flag: EXEMPT test only
Test: atest NetworkStaticLibTests:com.android.testutils.AutoReleaseBluetoothRuleTest \
      --update-device
Bug: 410731080
Change-Id: I95afc6174698bf73b21d95a85c02e107ee0d59f7

Junyu Lai   commited 2025-07-01 17:52:22 +08:00
c5c80cc9ab
Don't blame a non-existent test for not restoring default networking
RestoreDefaultNetwork is a virtual test, causing a lot of confusion among
testers who can't reproduce or run this test.
Instead, blame the test that actually failed to restore the default network.

Before :
```
[1/2] android.net.cts.MultinetworkApiTest#testFoo: PASSED (253ms)
[2/2] android.net.cts.MultinetworkApiTest#RestoreDefaultNetwork: FAILED (54ms)

STACKTRACE:
java.lang.IllegalStateException: testFoo does not restore the default network. Default network has caps null ; expected a network with transports = WIFI
        at com.android.testutils.DefaultNetworkRestoreMonitor$listener$1.testFinished(DefaultNetworkRestoreMonitor.kt:64)
```

After :
```
[1/2] android.net.cts.MultinetworkApiTest#testFoo: PASSED (353ms)
[2/2] android.net.cts.MultinetworkApiTest#testFoo: FAILED (54ms)

STACKTRACE:
java.lang.IllegalStateException: testFoo does not restore the default network. Default network has caps null ; expected a network with transports = WIFI
        at com.android.testutils.DefaultNetworkRestoreMonitor$listener$1.testFinished(DefaultNetworkRestoreMonitor.kt:64)
```

Test: this
Flag: EXEMPT test-only
Bug: 413188127
Change-Id: Ia17bc9ddeedbd9303e5788ef79fb190e6e9dca1e

Chalard Jean   commited 2025-06-20 15:12:31 +09:00
00275e3f44
Make a base class for testable callbacks
Have TestableNetworkCallback adopt it, as a first client. It's also by
far the most complex.

Test: TH
Flag: EXEMPT test-only
Change-Id: Ie58d051b4478c901b7f0f54e89a67d22f1ee2ce2

Chalard Jean   commited 2025-06-10 17:22:01 +09:00
2db96977db
Merge "Revert "Make a base class for testable callbacks"" into main
Priyanka Advani (xWF)   authored and   Android (Google) Code Review   commited 2025-06-05 13:02:09 -07:00
130e55e17e
Revert "Make a base class for testable callbacks"
This reverts commit a77d5ac126.

Reason for revert: Droidmonitor created revert due to b/422782308. Will be verifying through ABTD before submission.

Fix: 422782308
Change-Id: I00825e0f17a9a9e0d152ac8ebe767da3f267fbb1

Priyanka Advani (xWF)   authored and   Android (Google) Code Review   commited 2025-06-05 11:35:49 -07:00
827aa58224
Merge "Make a base class for testable callbacks" into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-06-05 05:12:50 -07:00
595ab39d06
Make a base class for testable callbacks
Have TestableNetworkCallback adopt it, as a first client. It's also by
far the most complex.

Test: TH
Flag: EXEMPT test-only
Change-Id: Ifd636a09d0695f04b17330c4987f2b7b742508fa

Chalard Jean   commited 2025-06-05 16:13:34 +09:00
a77d5ac126
Format multidevice tests with pyformat
Use the following commands to apply pyformat
pyformat -i -r --force_quote_type single staticlibs/
pyformat -i -r --force_quote_type single tests/

Flag: EXEMPT mainline
Bug: 419423721
Test: TH
Change-Id: I0d3914ec652664ed4ec5d44afc25d97ff8bb4626

Jimi Chen   commited 2025-06-04 14:27:06 +00:00
ead97d1ef3
Merge changes from topic "destroy_socket_at_cs" into main
* changes:
  Destroy sockets lacking permission at CS.
  Destroy sockets with nlmsg RTM_DELADDR
  Destroy sockets with NetworkAgent update event
  Add a Map to NetworkAgent list for IP address
  Add socket destroying methods to InetDiagMessage.

Sewook Seo   authored and   Android (Google) Code Review   commited 2025-05-30 16:00:11 -07:00
13e6742742
Merge "Refactor: apply pyformat for coding style consistency" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-28 07:26:50 -07:00
0d0d3a6534
Refactor: apply pyformat for coding style consistency
add pyformat for presubmit hook

Flag: EXEMPT mainline
Bug: 419423721
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: I9abc5cee454e8c8e21ce7e3c134145857680251f

Jimi Chen   commited 2025-05-28 12:44:57 +00:00
dcbe9b403d
Merge "Replace get_apf_counter from apf shell command instead of dumpsys" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-05-27 23:37:11 -07:00
bd96bad987
Replace get_apf_counter from apf shell command instead of dumpsys
Flag: EXEMPT mainline
Bug: 419423721
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I6f5f93acb13503ce23066b1541c0843f6d7951d2

Jimi Chen   commited 2025-05-28 04:55:33 +00:00
5e69785de3
Add socket destroying methods to InetDiagMessage.
Add socket destroying methods by address and permission to InetDiagMessage
to move that functions to ConnectivityService from Netd.

Bug: 373280981
Bug: 331139818
Flag: android.net.platform.flags.connectivity_service_destroy_socket
Test: atest NetworkStaticLibTests
Test: device test
Change-Id: I3c2136df5dfd618d1c757c07bce2b4211b807237

Sewook Seo   commited 2025-05-27 01:35:49 +00:00
45163857b2
Add NetworkCapabilities transport types into NetworkIdentity.
This change updates NetworkIdentity to have NetworkCapabilities
transport types for improved network identification, and updates
NetworkIdentitySet for backward compatibility with older data.

Flag: EXEMPT implemented in the counter-part CL
Test: atest ConnectivityCoverageTests --test-filter \
      'NetworkIdentity*' --update-device
Test: atest ConnectivityCoverageTests --test-filter \
      'NetworkStats*' --update-device
Bug: 419123367
Change-Id: I26cc770d90b4687d832dd029d9a11db03404db39

Junyu Lai   commited 2025-05-24 00:30:41 +08:00
bebd4090ae
Fix a bug in poll(from)
Test: new test in this patch
Flag: EXEMPT test-only
Change-Id: I00d367ce9db47e3fd30d27816b68280ab418f988

Chalard Jean   commited 2025-05-19 16:35:54 +09:00
f0252b1cf4
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
Remove deprecated SC_V2 constant
Test: TH
Flag: EXEMPT test-only
Change-Id: I3444fad305f49294ed8c3a850b631f385678c117

Chalard Jean   commited 2025-05-15 09:03:59 +09:00
9373e3442e
Change creation methods in RtNetlinkLinkMessage to take index(1/2)
Currently methods to create netlink message in RtNetlinkLinkMessage
take interface name, while interface index is a more deterministic way
to define an interface.

This patch changes these methods from taking interface name to taking
interface index.

Bug: 404378068
Test: NetworkStaticLibTests
Flag: EXEMPT mainline
Change-Id: I0754ee53eb0160e67f24e36340abf91b1e87d0e7

Chuwei He   commited 2025-05-13 12:06:54 +09:00
b1110454bb
Adding IpAddress Struct type to store ip v4 and v6 addresses.
IPv4 addresses will be converted as v4-mapped-v6 address while
writting it to byte form. v4-mapped-v6 addresses in byte form will be
parsed to Inet4Address while converting it back.

Bug: 392509494
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.StructTest
Flag: EXEMPT refactor
Change-Id: Ia906d2cae7bb7402ff937da267c2552431b2d0f7

Sarup Dalwani   commited 2025-04-30 07:42:25 -07:00
746540b874
File the per-app request for opted-in satellite-optimized apps
Test: ConnectivityCoverageTest
Bug: 410731080
Flag: EXEMPT controlled in counter-part change ag/33220291
Change-Id: I0307f697a441c2810cafd4643d381e66a0ac9243

Chalard Jean   commited 2025-04-27 02:12:44 +09:00
76a60c1654
Replace Message with related arguments in RealtimeScheduler
This change ensures that the Message object is created and
obtained within RealtimeScheduler, preventing modification
by the caller.

Fix: 386274963
Test: atest ConnectivityCoverageTests NetworkStaticLibTests
Flag: EXEMPT bug fix
Change-Id: I4c919857bcaa2d49717859dca9c88a243cbb7a41

Paul Hu   commited 2025-04-22 01:45:13 -07:00
1dea0d630e
Correct race condition in RealtimeSchedulerTest
This commit corrects a race condition in the RealtimeSchedulerTest. The
fix ensures that when the TestHandler processes a message, it first adds
the message to the executionTimes before calling cv.open(). This change
guarantees the correct order of operations and prevents potential
synchronization issues.

Test: TH
Bug: 403413950
Flag: EXEMPT bugfix
Change-Id: I16dee5475db315b1b40d0779db4ff31407bf54b5

Yuyang Huang   commited 2025-04-08 18:21:12 +09:00
428d25ceac
Merge "Use scapy to generate ARP packet in multi-device test" into main am: 4703e17d98
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3549447

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

Yuyang Huang   authored and   Automerger Merge Worker   commited 2025-03-20 17:02:27 -07:00
e9726e8983
Use scapy to generate ARP packet in multi-device test
Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I30adfe7ca2fef83ed4ef2ea3e5bc2291b9016530

Jimi Chen   commited 2025-03-20 12:25:57 +00:00
f0343a65d1
Merge "Add get exclude all host IPv6 multicast addresses function to apf_utils" into main am: b3add265bc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3549123

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

Jimi Chen   authored and   Automerger Merge Worker   commited 2025-03-20 00:24:54 -07:00
d9d6eec8ce
Add get exclude all host IPv6 multicast addresses function to apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: Ib05eaf6ac94e9511a43b4b494eb5935746f50aa7

Jimi Chen   commited 2025-03-19 13:41:41 +00:00
ceefdceafd
Merge "Fix missing function in NetworkStaticLibHostPythonTests" into main am: d492666256 am: 58b5b18514
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3547922

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

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-03-18 02:56:16 -07:00
33e4070cc6
Fix missing function in NetworkStaticLibHostPythonTests
This change corrects a missing function error, which was renamed in aosp/3545962.

Test: atest NetworkStaticLibHostPythonTests
Change-Id: I2f51702adfa48f2207ef4dd79f641c8f57d15ac7

Jimi Chen   commited 2025-03-17 23:56:23 -07:00
e6c9b28c2b
Merge "Use non-tentative IPv6 addresses in multi-device test" into main am: d1cbad238c am: 0054a2627f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3545962

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

Jimi Chen   authored and   Automerger Merge Worker   commited 2025-03-17 23:14:55 -07:00
c93e762867
Use non-tentative IPv6 addresses in multi-device test
This update ensures multi-device offload tests retrieve only non-tentative IPv6 addresses,
preventing test caused by tentative addresses undergoing duplicate address detection.

Test: atest NetworkStaticLibHostPythonTests
Change-Id: Id2f61a34eda01a6e8e0457647229fe438a85c232

Jimi Chen   commited 2025-03-17 06:31:46 +00:00
2bfe2654d1
Merge "Use NLM_F_REQUEST_ACK in createGetLinkMessage()" into main am: 9981725b18 am: 3bc13845a9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3475690

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

Chuwei He   authored and   Automerger Merge Worker   commited 2025-03-13 19:00:30 -07:00
7bc8681d88
Use NLM_F_REQUEST_ACK in createGetLinkMessage()
This rtnl message is used with sendOneShotKernelMessage() which expects
that kernel returns an ACK. We need to set NLM_F_ACK explicitly for
that.

Bug: 379021505
Test: Manually run and no more exception with EAGAIN.
Change-Id: Iba21fedf60f5eca63eceee9362e252952bb805c1

Chuwei He   commited 2025-03-12 18:30:04 -07:00
03a10fd14d
packages/modules/Connectivity: remove usages of deprecated Mockito matchers
Test: m checkbuild
Flag: TEST_ONLY
Bug: 310268946
Change-Id: Icef421511b6fed6dc7912a9b703773ba5700c62a

Adrian Roos   commited 2025-03-10 02:16:21 +01:00
6cc971daab
Merge "Stop using Mockito static mocking in BpfDumpTest" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2025-03-06 19:50:26 -08:00
1d1cc3a36d
Use 'ip link' to prevent permission errors in non-root environments
The 'ip link show' requires root permissions, causing errors.
This change replaces 'ip link show' with 'ip link'.

Bug: 401123634
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I82b219ae9179f23e3233f797aeb4aa3740e6d3ec

Jimi Chen   commited 2025-03-07 00:25:34 +00:00
c471fc945c
Stop using Mockito static mocking in BpfDumpTest
Test: NetworkStaticLibTests
Bug: 399571370
Bug: 397721725
Change-Id: I0d183378b08261ff24485aff4ad636cdae1851c9

Motomu Utsumi   commited 2025-03-06 09:00:18 +09:00
d27097f585
Move SkDestroyListener to under staticlibs
Upcoming CL use SkDestroyListener from ConnectivityService

Bug: 311792075
Test: atest FrameworksNetTests
Change-Id: I96dec7e13aaa574b90e7caf3b559ee5172848e51

Motomu Utsumi   commited 2025-02-21 09:26:11 +09:00
1135975109