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
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
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
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
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
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
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 Shuklaauthored and Android Build Cherrypicker Workercommited 2024-04-02 05:51:41 +00:00
* 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 Żenczykowskiauthored and Gerrit Code Reviewcommited 2024-04-02 03:41:31 +00:00
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
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
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
APF adb commands are not implemented in LegacyApfFilter. Enable the
experiment flag for all tests.
Test: atest ApfIntegrationTest
Change-Id: I468ef54498a6f780dff22d25119732b42b404199
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
* 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 Robotauthored and Gerrit Code Reviewcommited 2024-03-28 19:29:50 +00:00
Renames wifiIfaceName to ifname and capabilities to caps to make
the shell command fit on one line.
Test: TH
Change-Id: I253a0f6d99c8ce869795958503db4db4008455b6
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
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
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
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>
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
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
For some reason, InterfaceStateListener callbacks when calling
enableInterface() / disableInterface() were missing test coverage.
Test: atest EthernetManagerTest
Change-Id: I7ad553746d3839097c2878934d79219efde267c8
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
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