Commit graph android_packages_modules_Co.../staticlibs/tests/unit/host/python
Message SHA1
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
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
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
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
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
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
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
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
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
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
Add packet capture and match network_stack adb command to to apf_utils
It wraps the following 3 commands for multi-devices tests
- cmd network_stack capture start <interface>
- cmd network_stack capture stop <interface>
- cmd network_stack capture matched-packet-counts <interface> <pkt-in-hex>

Add a helper function `is_packet_capture_supported` as APFv6 precondition check.
Test: atest NetworkStaticLibHostPythonTests

Change-Id: I526c678c6e753cee3969b04a56ab33e5e3d1600d

Jimi Chen   commited 2024-10-07 13:33:57 +00:00
1644f95852
Support get multiple ipv4/ipv6 addresses in apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I806696437acf905c049762d59a46c866ff0584ef

Jimi Chen   commited 2024-09-27 06:55:54 +00:00
738bf999d5
Add get ipv4/ipv6 address function to apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I535bdca481f600b95603206bf368a106cbb45b42

Jimi Chen   commited 2024-09-20 05:45:19 +00:00
b756497e05
Add packet_utils for multi-devices tests
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I211d071232d1730c043eef29e1bf2bce27a6e2a6

Jimi Chen   commited 2024-09-20 05:41:20 +00:00
0e1c1cc92d
Import absl-py library from codebase
This removes the need of pip install absl-py and
virtual env usage from the tests.

Test: atest NetworkStaticLibHostPythonTests
Bug: N/A
Change-Id: I2259f7702ecc6b5e7b7b23e2bf44fa28a5a2e07b

Junyu Lai   commited 2024-08-23 21:11:30 +08:00
f84b9074e0
Refactor Drop EtherCat packet test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf tests.

This includes:
1. Add a method to send packet and expect counter increases.
2. Inline the packet construction code in the test method.

Test: atest NetworkStaticLibHostPythonTests
Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 350880989
Change-Id: Iadcfd97740033306af1b6a474004cbf0699ddd1b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
6f6b1a4684
Refactor ApfV4Test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf test classes.

This includes:
1. Move initialization code to a base class, which setup a hotspot
   and a client connects to it, and enable doze mode to
   activate the apf.
2. Check whether send raw packet is supported before testing.

Test: m connectivity_multi_devices_snippet && \
  atest CtsConnectivityMultiDevicesTestCases
Test: atest NetworkStaticLibHostPythonTests
Bug: 350880989
Change-Id: I6376935883653182728e473e2f5533407d993d7b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
cf655869ba
Support get apf capabilities from network_stack shell command
This utility reads output of cmd network_stack apf ${iface_name}
capabilities. This is needed for the tests to skip if the apf
version is too old.

Test: atest NetworkStaticLibHostPythonTests
Bug: 352132428
Change-Id: I1f8b523c3e6f687c2e919993bc18392dc25dbbf7

Junyu Lai   commited 2024-07-11 17:43:21 +08:00
c6fae35cfd
Remove packet type and dst mac when sending raw packet
This is now derived from the passed packet data by
NetworkStack.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Ida06c00e6f499b782cb903c9fa0a4154c2d8cf84

Junyu Lai   commited 2024-07-03 12:33:11 +08:00
161dc10f60
Support VirtualEnv and parameterized tests
This commit introduces the use of VirtualEnv to manage test
dependencies. Specifically:
  1. `PythonVirtualenvPreparer` is invoked before running tests
     to set up the isolated Python environment.
  2. The test is declared as a `MoblyBinaryHostTest` to enable
     VirtualEnv compatibility, as `PythonBinaryHostTest` lacks
     this support.
  3. The Mobly test runner is invoked manually to accommodate
     multiple test classes, which is not supported by
     `mobly.test_runner.main()`.
  4. Test classes are refactored to inherit from
     `mobly.BaseTestClass` for compatibility with the Mobly
     test runner.

This change is a prerequisite for subsequent commits that will
install libraries via `pip install`, facilitating isolated
dependency management for improved test reliability and
maintainability.

Also, this commit uses parameterized annotation from absl
to rewrite several tests as paremeterized tests.

Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Iffa2f8fa81c3913f3e08cca01b2c009ca959db73

Junyu Lai   commited 2024-07-03 02:02:40 +00:00
3085caaac0
Add support for sending raw packets
This commit includes several new functions to support sending custom
raw Ethernet packets. This includes methods for retrieving
MAC addresses, sending empty EtherCAT packets, and sending
arbitrary raw packets with specified types and destinations.
These functions are primarily intended for testing purposes
and rely on the `send-raw-packet-downstream` command provided
by NetworkStack.

Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Iae7879bf92e1dda8fbd32b92ff166e82c87593c7

Junyu Lai   commited 2024-07-01 16:53:50 +08:00
4a1baf042b
Add apf_utils for multi-device tests
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: I79064abcb88fbcee00ec9ec998ba5a3e2d3478a6

Junyu Lai   commited 2024-07-01 13:44:12 +08:00
b0f759c42a
Add adb_utils for multidevice test
This commit adds the necessary code for 'adb_utils' to enable APF
multi-device testing which will be introduced in follow-up patches.
This includes utilities of issuing shell command, parsing dumpsys
key-value pairs, controlling doze mode and screen state.

Additionally, unit tests are added to verify the basic functionality.

Test: atest NetworkStaticLibHostPythonTests

Bug: 335368434
Change-Id: I580e91b494580ec9105c8988972845d38c104031

Junyu Lai   commited 2024-07-01 13:33:13 +08:00
bed4480ffd
Add assert_utils for multidevice test
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: I2a9ee97b84cb16791c0c5e3cb03120e67ffeb0af

Junyu Lai   commited 2024-07-01 12:23:59 +08:00
850e6fae54