Commit graph android_packages_modules_Co.../staticlibs/testutils/host
Message SHA1
Merge "Add at_least_B() decorator to restrict multi-device tests to Android B+ capable device." into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-03-13 12:01:33 -07:00
d5dd81741c
Add at_least_B() decorator to restrict multi-device tests to Android B+ capable device.
Test: TH
Change-Id: Id5fde8c59560bb84bed062331121c3524f362c7b

Jimi Chen   commited 2025-03-13 14:05:09 +00:00
476552a7ae
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
Do not expect validated when connect to Wi-Fi for upstream type None
Currently, upstream network validation is always required, even
for type None. This is unnecessary for APF and mDNS tests, as
they can be executed on local networks. Additionally, some
devices lack the ability to perform network validation when the
hotspot is enabled due to hardware limitations. Therefore, remove
the validation check for upstream type None.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Bug: 335368434
Bug: 396551848
Change-Id: If2a96cf9d62e37fc27be6193f9ce9b9cfc8613df

Junyu Lai   authored and   Paul Hu   commited 2025-02-17 21:22:19 -08:00
d16aa5538e
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
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 "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
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
Retrieve IPv4 and IPv6 addresses for client and server device in test setup
Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases
Change-Id: Icba82832fa1840ea1a3299f61027666d4dd90d46

Jimi Chen   commited 2024-10-07 13:34:02 +00:00
4c3a13c048
Add send and check reply packet function for multi-devices tests
The `send_packet_and_expect_reply_received` start capurting packets,
and then send out request packets, then get expected packets counts to validate.
In the end, stop capturing for the specified interface.

Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases
Change-Id: I275534a45ce0ed363fa8ab9d12272d25845aa598

Jimi Chen   commited 2024-10-07 13:34:01 +00:00
d07d47b1d3
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
Merge "Revert "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat"" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-26 18:12:15 +00:00
b437e753f7
Revert "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat"
This reverts commit 46102348e0.

Reason for revert: mistakenly submitted.

Change-Id: I6072a9828a8cc0633ca35ea2ecf7707f2b3573a1

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-26 18:11:41 +00:00
c3eccf9ef4
Merge "Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-25 21:02:35 +00:00
aabad69006
Use unicast instead of broadcast as ethernet destination in test_apf_drop_ethercat
To prevent packet dropped earlier by multicast filtering,
use unicast ethernet destination instead

Bug: 360730207
Test: m connectivity_multi_devices_snippet && atest CtsConnectivityMultiDevicesTestCases:ApfV4Test
Change-Id: I4816b71f68f349abf1423c7013bb058ccc233d61

Jimi Chen   authored and   Maciej Żenczykowski   commited 2024-09-25 19:42:01 +00:00
46102348e0
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
Check APF version, VSR API level, and Android version
This commit introduces checks for APF version, VSR API level,
and Android version to decide whether an APFv4 test should be
run, skipped, or fail:
* If Android version is less than V, skip the test
* If VSR API level is greater than or equal to 14 and APF
  version is less than 4, fail the test
* Otherwise, if APF version is less than 4, skip the test

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Fix: 352132428
Change-Id: I023164fb59ad40f489abea2e0c45761efc39699b

Junyu Lai   commited 2024-09-10 18:06:28 +08:00
73711f7b41
Setup Wi-Fi P2P connection
Add functionalities to setup Wi-Fi P2P connection for subsequent
Wi-Fi P2P mDns tests

Bug: 343311941
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: I060509deb32c078829c1108f9ae2a29561e00d53

Paul Hu   commited 2024-08-13 07:20:21 +00:00
3e24dec82a
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
Move apf test to a standalone file
This is a no-op refactoring, which is preparation for follow-up
changes to add more apfv4 tests.

This includes:
  1. Add a entry point for multi-device tests to collect
     test cases from different files.
  2. Move multi-device initialization code to a base class.
  3. Make different test classes inherit the base class.

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

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
32a2d151cc
Add wifip2p_utils and Wifip2pMultiDevicesSnippet
Add wifip2p_utils and Wifip2pMultiDevicesSnippet for subsequent
Wi-Fi P2P mDns tests

Bug: 343311941
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: Icfdea97595292e024269e789673e3b1e23aa37ee

Paul Hu   commited 2024-07-16 08:51:41 +00:00
f5020471fe
Merge "Add SDK check for mdns test" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-15 09:39:01 +00:00
30a22238d1
Add SDK check for mdns test
The mDNS test should be conducted with an SDK version higher
than Android T (align with NsdManagerTest CTS, as NsdManager is
only updatable on T+). Add an SDK version precondition check to
ensure both devices are available for testing.

Bug: 343311941
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: Id5505b5d0746515689dc1646116a16fcfb8ece64

Paul Hu   commited 2024-07-15 08:53:31 +00:00
e7fd5a53e1
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
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
Move utils to staticlib
This is a no-op refactoring.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 335368434
Change-Id: I415cc22f49c437be6fe8e8ae8822af22ebefe8d1

Junyu Lai   commited 2024-06-28 11:19:54 +08:00
79b771f9bb
Add ignore-mobile-data-check option to preparer
Allow tests to use ConnectivityTestTargetPreparer with
require-mobile-data=false, if the test only requires wifi.

Bug: 340098257
Test: atest
Change-Id: I32b67932fc9973f374c975f2fd8009699f5d2725

Remi NGUYEN VAN   commited 2024-06-14 15:09:30 +09:00
070094d857
Refresh time before connectivity tests
After checking that networking is available, force a time sync.

This should avoid flakes where time changes during tests, for example
for tests using test settings like test_url_expiration_time in
NetworkMonitor.

Fixes: 342489019
Test: atest
Change-Id: I0c07440679bc14dcf5cddf55fb1391d3ed76feba

Remi NGUYEN VAN   commited 2024-06-04 16:06:19 +09:00
4ae1387146
Fix arg order to set-package-network-enabled in the CTS preparer
Test: manual
Change-Id: Ife55ed9dc152cd2c21e56b84201b9c34dbb04d46

Chalard Jean   commited 2023-10-23 17:26:53 +09:00
a27dca2fdc
Block the package updater while CTS are running
Test: manual
Bug: 284534251
Change-Id: I8843ce7c9e14cfe3f6f3439405d519587f2656ef

Chalard Jean   commited 2023-09-21 12:57:10 +09:00
3a6544fb1f
Disable Play auto-update during tests
For devices using Play services, disable auto-update during tests, as it
may interfere with them. For example, Webview may be killed if it is
opened while the update is applied.

Bug: 263665773
Test: atest
Change-Id: I9613d739ad0763c882a1971879aa743f4541a75c

Remi NGUYEN VAN   commited 2023-05-16 15:14:53 +09:00
90edff826a
Make ConnectivityCheckTargetPreparer more generic
Rename ConnectivityCheckTargetPreparer to
ConnectivityTestTargetPreparer, and the ConnectivityChecker app to
ConnectivityTestPreparer, and remove the assumption that the app only
does connectivity checks.

This will allow overriding the app with versions that have more specific
setup steps in downstream branches.

Bug: 263665773
Bug: 267413275
Test: tests using this preparer
Merged-In: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0
Change-Id: Icb9b1eb8eb1c75f89cb751e0ca696ea96359e6d0

Remi NGUYEN VAN   commited 2023-05-16 15:14:30 +09:00
e2b5213774
Use TargetSetupError for ConnectivityCheck
If the preparer throws AssertionError, tests will still
be retried without re-running the preparer. It needs
to throw TargetSetupError to indicate that setup failed.

Change-Id: Id01845536a216e1a3ca1c671c97f7bcd992c354e
Fixes: 254542801
Test: atest

Remi NGUYEN VAN   commited 2022-12-13 14:58:40 +09:00
449c01f6f6
Add DisableConfigSyncTargetPreparer
The TargetPreparer disables DeviceConfig sync before a test module, and
attempts to reset it to its original state afterwards.

It only supports S+ as the associated commands are not available on R-.
The format of commands has also changed in some T branches , so support
legacy format if the newer format is not supported by the device.

Bug: 210377950
Test: atest CtsNetTestCases using the preparer, verify setting set
      during the test.
Change-Id: Iaabaa1050b024e1378ab1cf87a394cc8ebab227b

Remi NGUYEN VAN   commited 2022-03-09 12:23:49 +09:00
d12797dba4
Add ConnectivityCheckTargetPreparer
ConnectivityCheckTargetPreparer is a tradefed target preparer that uses
the connectivitychecker app to verify device configuration, before
running any test.

The connectivitychecker app verifies that the device has a
pre-configured wifi configuration and can connect to it (except for
virtual devices where it may create the configuration itself), and
verifies that the device has a data-enabled SIM card inserted.

Checks are skipped if the device is not wifi- or mobile data-capable,
and can be skipped for local testing by running with:

  atest X -- --test-arg \
    com.android.testutils.ConnectivityCheckTargetPreparer:disable:true

Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5b6d34a6c393863af23af57ff026b15973e9e784

Remi NGUYEN VAN   commited 2021-11-04 19:57:21 +09:00
c02dcd721a