Commit graph android_packages_modules_Co.../tests/cts
Message SHA1
Add DevSdkIgnoreRule to ApfIntegrationTest
testReadWriteProgram is annotated with IgnoreUpTo(U), but because the
class does not use the rule, that has no effect.

Fix that by adding the rule.

Note that DevSdkIgnoreRunner only affects running the whole class
(having IgnoreUpTo at the class level), not annotated individual tests.

Test: atest
Bug: 333208995
Change-Id: I56b9c0775c3f39bb0f133705e57a41717a7d777b

Remi NGUYEN VAN   commited 2024-04-09 15:26:19 +09:00
7780b674b6
Merge "Deflaking network access checks in CtsHostsideNetworkTests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-06 05:48:36 +00:00
1d73c6bea5
Suppress ktlint:standard:comment-wrapping warning
standard:comment-wrapping does not allow annotating function argument
literals inline (since block comments must not be surrounded by code).
So the following annotations are not allowed in ktlint:

foo(1 /* bar */)

Unfortunately, there are not good alternatives. Named arguments can only
be used to call Kotlin functions and are not a general solution.
Instead, disable this linter rule for the entire file.

This also adds a suppress annotation further down in the file, since
ktlint does not like the extra space required to make the comments line
up horizontally...

Test: repo upload --dry-run
Change-Id: I62fdb0347965ee3fc43783eb07af47e95af882a5

Patrick Rohr   commited 2024-04-05 11:57:42 -07:00
9c3cbe5dd2
Toggle screen state before and after ApfIntegrationTest
APF is supposed to run when the screen is off. This change turns the
screen off as part of setUp() and turns it back on in tearDown() (since
apparently CTS is run with the screen on as some tests rely on it).

turnScreenOn() / turnScreenOff() also acquire / release a partial
wakelock to prevent the CPU from suspending during the test.

Test: atest ApfIntegrationTest
Change-Id: I31f04f4d39284be387006fdd9d0a7c0e27feddb5

Patrick Rohr   commited 2024-04-05 11:57:42 -07:00
30c9382181
Resume before releasing network request
Technically, this does not matter. If the network goes away before
resume is called, then resume will fail. But the network is going away
anyway... In any case, tearing down the test in opposite order of setup
is good practice.

Test: TH
Change-Id: I21f95499dbddb6003ac12c51a67a7638058e20e3

Patrick Rohr   commited 2024-04-04 16:34:49 -07:00
39c203f431
Add testReadWriteProgram to ApfIntegrationTest for V+
Validates that reading and writing APF memory behaves as expected across
the entire range of usable memory.
Before V, APF integration is broken in many different ways, so this test
only runs on V+ for now. A separate test will be added for pre-V
devices.

Test: atest ApfIntegrationTest
Change-Id: I3002c03b51bedd23a8cfb2513f5ae01a200445a4

Patrick Rohr   commited 2024-04-04 16:34:49 -07:00
4790aa9831
Align APF capabilities test closer to VSR requirements
This change cleans up the APF capabilities test and aligns it closer to
what is written in the VSR preview:
https://androidpartner.devsite.corp.google.com/gms/policies/preview/reqs#gms-vsr-apf

This includes changing VSR API level checks to compare against literal
values, as vendor API levels do not match SDK levels anymore starting
with 202404.

See docs for more information:
https://g3doc.corp.google.com/wireless/android/partner/compatibility/g3doc/dev/write-a-test/index.md?cl=head#write-a-test-depending-on-api-level

This test should also purely be based on the VSR API level, so the
DevSdkIgnoreRule and assumption check in setUp() are being removed.

Test: TH
Change-Id: I1f80ee662721557ec63694302fa0f66a666ceeb1

Patrick Rohr   commited 2024-04-04 10:57:03 -07:00
f0766dc9e1
Do not use runShellCommandOrThrow in setUp / tearDown
setUp() / tearDown() run on devices that might not support APF in which
case they should not cause a test failure.
Tests will be appropriately guarded by checking the APF capabilities.

Test: TH
Change-Id: I8689f96ecac0a21dfb4ab8786fec11c01f30d1c2

Patrick Rohr   commited 2024-04-04 10:57:03 -07:00
6a62806a52
Merge "Replace connectToCell -> NetworkCallbackRule" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-04-03 04:15:41 +00:00
d5a8d41172
Call getCapabilities in setUp
Every test starts by fetching the capabilities, so it makes sense to
move it to setup.

Test: TH
Change-Id: I232355aafd91acc00079bd4efb0abd5d206d5a07

Patrick Rohr   commited 2024-04-02 14:53:30 -07:00
ad4f132c29
Use truth assumption checks
This results in more readable assumption failures.

Test: TH
Change-Id: Ie8670183ce7ebf71ba5efa015f2ff294698ed936

Patrick Rohr   commited 2024-04-02 14:53:30 -07:00
ac9b287b2c
check lateinit property ifname isInitialized in tearDown
Bug: 332464546
Change-Id: I5085ad42c9456e89974c1fc33149e468483e340f
Test: TH

Patrick Rohr   commited 2024-04-02 14:44:08 +00:00
e380bc0000
Deflaking network access checks in CtsHostsideNetworkTests
Checking that the network was successfully restricted before starting
the activities in ConnOnActivityStartTest. This avoids races between uid
state changes and device state changes in NPMS code that lead to
unpredictable UnknownHostException flakes in the first iteration.

Moving the java cache clearing to happen immediately before the check,
so no side effect from different code can impact the DNS query.

Increasing the socket-timeout to mitigate socket timeout failures.

Changing the default test URL to generate a 204 to avoid any extraneous
errors that may arise in doing other I/O, and switching to the canonical
connectivity check URL on the android.com domain.

Enabling support for passing down a custom url to use for testing
network connectivity using the runner options. This will enable easily
switching between different URLs for debugging when required.

Using a dedicated data class to encapsulate information to be returned
from test app to the instrumentation app.
This makes the logic more resilient, readable and maintainable.

Test: atest CtsHostsideNetworkTests:HostsideConnOnActivityStartTest --\
--test-arg com.android.compatibility.common.tradefed.testtype.JarHostTest:\
set-option:com.android.cts.net.HostsideConnOnActivityStartTest:\
custom-url:"https\://www.example.com"

Bug: 330406935
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:04c638ee3a5bab7895817ebfc0d3f6a69b1ee26d)
Merged-In: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4
Change-Id: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4

Suprabh Shukla   authored and   Android Build Cherrypicker Worker   commited 2024-04-02 05:51:41 +00:00
a8ad3d5ef0
Merge changes Ic4b586ae,I1b1345a6,I468ef544,I61b6263e into main
* changes:
  Grant prohr temporary ownership of ApfIntegrationTests
  Pause APF filter before starting test
  Enable new ApfFilter experiment in CTS test
  Move retrieving APF capabilities into helper function

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2024-04-02 03:41:31 +00:00
609bfabfdd
Merge "Fix flakes due to networks obtained via sync APIs" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-02 03:30:36 +00:00
455b186710
Replace connectToCell -> NetworkCallbackRule
Developers often forget to unregister requests in tests, and cleanup
code also makes tests more verbose.

Add a rule that unregisters callbacks automatically when after each test
method.

Replace current usage of connectToCell with this rule, as well as
network callback usage in CaptivePortalTest (which is one example that
did not unregister its callback).

Test: atest
Change-Id: Ie3b9c5cf529004b7b3af04bc13a7e69acfbbaa18

Remi NGUYEN VAN   commited 2024-04-02 11:18:20 +09:00
e629bb7c84
Fix flakes due to networks obtained via sync APIs
After reconnectWifiIfSupported is called, it is possible that
ConnectivityManager#getAllNetworks does not return the Network, as this
is mixing network callbacks and synchronous calls which is racy (as per
ConnectivityManager javadoc).

Ensure that networks that are reconnected in the test, wifi and
cellular, are obtained through network callbacks through CtsNetUtils.

Other networks are still obtained through the synchronous call, as they
should not change during the test, and there would be no non-racy way to
obtain them otherwise anyway as they are not guaranteed to be connected.

Bug: 328331492
Test: atest
Change-Id: I5a511c87c64fde0276aecd6ff6599815fa08e437

Remi NGUYEN VAN   commited 2024-04-02 11:10:01 +09:00
f8999e32e1
Grant prohr temporary ownership of ApfIntegrationTests
In order to make fast progress on developing some initial APF
integration tests, grant prohr@ temporary ownership. Changes will be
reviewed with lorenzo@ out-of-band before release.

Test: n/a
Change-Id: Ic4b586aeb95902717d8e0e57f063cd7302f9b70c

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
efdfaf2c08
Pause APF filter before starting test
adb shell cmd apf <iface> install requires APF to be paused beforehand.
Resume in tearDown.

Test: atest ApfIntegrationTest
Change-Id: I1b1345a629dc03446ae3b74ab06f40a06085cd28

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
ee085cc201
Enable new ApfFilter experiment in CTS test
APF adb commands are not implemented in LegacyApfFilter. Enable the
experiment flag for all tests.

Test: atest ApfIntegrationTest
Change-Id: I468ef54498a6f780dff22d25119732b42b404199

Patrick Rohr   commited 2024-03-29 15:13:14 -07:00
e9fb2b2fb5
Move retrieving APF capabilities into helper function
Retrieving the capabilities will be required for every test, so move it
to a helper function.

Also includes two more minor improvements:
- Use runShellCommandOrThrow() instead of runShellCommand() so we
  correctly fail the test if the shell command returns an error.
- Use truth for all assertions because it creates better error messages.
  See truth.dev for more details.

Test: builds && TH
Change-Id: I61b6263eac9bf70eae4e1841baae9e3fa8ca4d6d

Patrick Rohr   commited 2024-03-29 09:58:16 -07:00
633d9811d8
Merge changes I253a0f6d,Ibc566fae,I2aad7d78,Ifc2967f6,I7f54479a into main
* changes:
  Rename wifiIfaceName to ifname
  Remove unnecessary null check
  Unregister network callback in tearDown
  Don't run test in instant app mode
  Revert^2 "Introduce initial CTS test for APF functionality"

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-28 19:29:50 +00:00
7dd3a4bd3d
Rename wifiIfaceName to ifname
Renames wifiIfaceName to ifname and capabilities to caps to make
the shell command fit on one line.

Test: TH
Change-Id: I253a0f6d99c8ce869795958503db4db4008455b6

Patrick Rohr   commited 2024-03-28 10:38:26 -07:00
50af8633d4
Remove unnecessary null check
wifiIfaceName is guaranteed to not be null when this null check is
executed, as otherwise eventuallyExpect<LinkPropertiesChanged>() has
failed or threw an assertion error a couple of lines above.

Test: TH
Change-Id: Ibc566fae7cf153dcc2976e4d6d3b208e8fa3448c

Patrick Rohr   commited 2024-03-28 10:35:49 -07:00
0f01689fde
Unregister network callback in tearDown
Representing networkCallback as a non-null lateinit var and using
property isInitialized seems more appropriate than making
networkCallback nullable. Making networkCallback nullable would require
null checks / safe calls for every use. However, from the tests'
perspective networkCallback cannot be null; the only concern is
tearDown() which has to deal with early exits from setUp() due to
assumption / assertion failures and therefore partially initialized
state.

networkCallback can only be initialized when requestNetwork() is called
as unregisterNetworkCallback() will throw an exception if the callback
was never registered.

Test: TH
Change-Id: I2aad7d781e6955b29d505e670181209c33db7680

Patrick Rohr   commited 2024-03-28 10:27:14 -07:00
4359195146
Don't run test in instant app mode
ConnectivityManager#requestNetwork requires CHANGE_NETWORK_STATE
permission which cannot be granted to instant apps.

Bug: 331496866
Test: TH
Change-Id: Ifc2967f6ec41676ce1e7396163106f76b9e6788c

Patrick Rohr   commited 2024-03-28 09:47:30 -07:00
98a231cbd6
Revert^2 "Introduce initial CTS test for APF functionality"
This reverts commit a2e859c568.

Reason for revert: fix in aosp/3016578

Change-Id: I7f54479a9fcedd084952d8413bab203dc6f708f2

Patrick Rohr   commited 2024-03-28 09:47:22 -07:00
5731e44b84
Revert "Introduce initial CTS test for APF functionality"
This reverts commit c15663c782.

Reason for revert: b/331504289 flakiness

Change-Id: I3fbc5b7f3ac3d4c6255ec4ca59b76dec196e6aa6

Yuyang Huang   authored and   Gerrit Code Review   commited 2024-03-27 05:37:21 +00:00
a2e859c568
Introduce initial CTS test for APF functionality
Added CTS test cases verifying APF version, maximum length, and packet
format.

Test: TH
Change-Id: I3f6f453fc0b906a5e290ebe8649c66b8e62fffb2

Yuyang Huang   commited 2024-03-25 17:37:03 +09:00
c15663c782
[mdns] restart probing/announcing the services on host address removal
When some of a custom host's addresses are removed, the services which
are using the custom host should be updated accordingly:
- For the services being probed, the probing should be restarted with
  the updated address records.
- For the services which already finished probing, they should be
  re-announced with the updated address records.

For example, here is a scenario where the fix is necessary:
1. Register a host (host1) with addresses (addresses1)
2. Register a service (service1) using the host1.
3. Unregister the host1.
4. Re-register the host1 with different addresses (addresses2).

Then the probing messages of the second registration of host1 may
conflict with the announcements of service1 (which containing addresses
records of the addresses1). This is an undesired conflict. Restarting
the announcement of service1 when updating the addresses of host1
can get rid of this conflict.

Bug: 327304356

Change-Id: Ie97b72f1482c69fb5f24eab3ce9ed8f7cea957ec

Handa Wang   commited 2024-03-24 14:06:32 +00:00
734de7a1d5
Merge "Put known answers to query packets" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-22 04:18:38 +00:00
248424dc69
[EthernetManagerTest] Skip the test if EthernetManager is null
On Emulator system image, EthernetManager is not supported and it will
cause test crash when the "!!" operator is in place. Therefore, we
should skip the test before the lazy evaluation.

BUG: 323896504

Change-Id: I0f6f7bbb8ff7394730b193cf3f4ab5d89e65fa96
Signed-off-by: Weilun Du <wdu@google.com>

Weilun Du   commited 2024-03-19 14:09:39 -04:00
1137ed88e2
Merge "deflake android.net.cts.NetworkStatsManagerTest#testUidTagStateDetails" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-18 03:47:44 +00:00
80383822b1
Put known answers to query packets
To support known-answer suppression, the querier should include
its known answers within each query packet. This allows the
service to determine whether a response is necessary based on
the querier's existing knowledge.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I2fb421aff1ae150b310e1a44f50f098a3edb9992

Paul Hu   commited 2024-03-15 07:45:59 +00:00
541df66912
Add test for dropping packets to VPN address from non VPN-interface
Bug: 295800201
Test: HostsideVpnTests
Change-Id: I0785ee1562fa50c1b6a4aca9ac077ad753cc2700

Motomu Utsumi   commited 2024-03-15 15:23:55 +09:00
ffa2bce381
deflake android.net.cts.NetworkStatsManagerTest#testUidTagStateDetails
2024-1 kernel security patch is making this test more flaky:
  tcp: fix delayed ACKs for MSS boundary condition
Relax boundary to make it less flaky.

Test: atest CtsNetTestCases:NetworkStatsManagerTest \
      --rerun-until-failure 100
Fix: 329328758
Change-Id: I9afe77da90beebce99f9d519dbabda5d771ac253

Junyu Lai   commited 2024-03-15 14:11:37 +08:00
6dc4f684c8
Merge changes I7ad55374,I4a0c7f6e into main
* changes:
  Add test to verify callbacks for enable/disableInterface APIs
  Fix enable/disableInterface APIs to properly affect administrative state

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2024-03-14 23:47:55 +00:00
a8e3bfb7df
Merge "Revert^4 "Re-enable the tests for background restrictions"" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-03-14 21:48:58 +00:00
ddeec3a7ad
Add test to verify callbacks for enable/disableInterface APIs
For some reason, InterfaceStateListener callbacks when calling
enableInterface() / disableInterface() were missing test coverage.

Test: atest EthernetManagerTest
Change-Id: I7ad553746d3839097c2878934d79219efde267c8

Patrick Rohr   commited 2024-03-14 14:46:52 -07:00
3cccf8eea3
Merge "Simplify the logic in the hasServiceTypeClientsForNetwork" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-14 08:17:12 +00:00
230767d4d4
Merge "[mdns] fix race conditions in MdnsAdvertiser" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-03-13 12:41:56 +00:00
51648211ee
[mdns] fix race conditions in MdnsAdvertiser
There is a race condition in MdnsAdvertiser when removing the last
service:
1. When the last service is removed, it will call the destroyNow()
   to tear down the interface advertiser and schedule a onDestroyed()
   callback for MdnsAdvetiser to do further cleanup
2. If another serivce is registered after removing the last service but
   before onDestroyed() is invoked, then onAdvertiserDestroyed() will
   return false and the InterfaceAdvertiserRequest is kept in the map in
   MdnsAdvertiser. This is because the newly registered service is in
   the mPendingRestionstrations.
3. The problem is that InterfaceAdvertiserRequest now have no
   InterfaceAdvertiser (because the only advertiser has already
   destroyed) and cause the newly registered service can't be
   advertised.

It needs to schedule onDestroyed() on the handler thread because we
can't do modify-during-iteration, but this introduces the race condition
here.

The fix in this commit changes to not destroy the InterfaceAdvertiser
immediately when the last service is removed but destroy when there are
no pending registrations in the InterfaceAdvertiserRequest.

Test: atest --iterations 100 CtsNetTestCases:android.net.cts.NsdManagerTest#testRegisterService_registerImmediatelyAfterUnregister_serviceFound
Change-Id: I6b6f01e6ddf103d16a8b0296af000dc8262ea65b

Kangping Dong   commited 2024-03-13 17:28:35 +08:00
36f8b3f6ad
Simplify the logic in the hasServiceTypeClientsForNetwork
Address the follow-up comments in aosp/2967209.

Bug: 324156009
Test: atest android.net.cts.NsdManagerTest
Change-Id: I36ad58b3bd0b8ff2e8a97327a9e09bf577b12b31

Paul Hu   commited 2024-03-13 07:17:08 +00:00
f7c5d6e642
Merge "Specify the desired callback type to deflake the tests" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-03-13 02:40:49 +00:00
4d9f787ead
Specify the desired callback type to deflake the tests
The test expects the absence of default network changes. However,
fluctuations in network capability during the test can introduce
flakiness. To enhance test stability, specify a callback for
deflaking.

Test: atest CtsHostsideNetworkTests
Bug: 329188322
Change-Id: I9ea2d5a03981f3a6584964d5a5a11e80f293edd2

Chiachang Wang   commited 2024-03-12 09:35:18 +00:00
fee93b0528
Merge "Add CtsTetheringTest to MTS" into main
Quang Luong   authored and   Gerrit Code Review   commited 2024-03-11 22:03:32 +00:00
11d14dd5af
Revert^4 "Re-enable the tests for background restrictions"
7ff923029e
Reason for revert: b/327713895 was a false alarm.

Change-Id: Ia6742630eece19eeb8bdfa25f861726c7237ab6d

Suprabh Shukla   commited 2024-03-09 05:32:56 +00:00
b11b071422
Merge "Revert^3 "Re-enable the tests for background restrictions"" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-03-08 07:54:19 +00:00
9862a0e36d
Revert^3 "Re-enable the tests for background restrictions"
344e4c9bf9

Bug: 327713895
Change-Id: Ieb3cf27943f139a35b1bf89f57adbf31bd00f285

Suprabh Shukla   commited 2024-03-08 02:49:23 +00:00
7ff923029e
Merge "CTS for request transform state" into main
Yan Yan   authored and   Gerrit Code Review   commited 2024-03-07 00:47:12 +00:00
66591a1101