Instead of only checking that a sim card that supports data connectivity
is inserted, also check that there is an available cellular network.
This helps ensure that the device is setup with a working data plan and
APN configuration.
Bug: 242628522
Test: atest CtsNetTestCases
Change-Id: Id47d49de77da5d9f7a87ff34b954c61662965c9e
...and rename ExceptionUtils to FunctionalUtils as the old name
would no longer be appropriate.
Test: FrameworksNetTests
Change-Id: I2affd69fb84d7f250b4a45497eec6c052bf6ec50
Currently RouterAdvertisementResponder always uses a prefix of
2001:db8::/64, even if there are multiple instances on different
interfaces. Randomize the prefix instead.
Test: TH
Bug: 240323229
Change-Id: I585ca804845f4278187602a6c9816470dcea04f8
Throwing an exception in RaResponder crashes the test process (as it
runs in a secondary thread). This is not very useful as that will fail
the execution of all the other tests.
Adding a log statement instead of throwing an exception makes more sense
as the tests will most likely fail anyways.
Test: atest EthernetManagerTest
Change-Id: I9c5f5dc417dad7df1c7f729caa4e0259ed71591f
stop() calls interrupt which does not terminate the thread instantly.
Therefore, it should wait for the thread to join, as otherwise the
caller has no way of knowing when it is safe to close the underlying fd.
This led to frequent test process crashes during EthernetManagerTest
runs.
Test: atest EthernetManagerTest
Change-Id: I28f0d46c4f0295acffa5ec9f04964cd73d3de928
Add support to respond to neighbor solicitations in addition to router
solicitations. This is useful for tests that need to send IPv6 traffic
through a tap interface. I have previously experimented with the target
link-layer address option in the RA, but it did not seem to prevent a
subsequent NS.
As a TODO, this class should be renamed to NdResponder (and possibly
rewritten in Kotlin).
Test: test only change
Bug: 235559605
Change-Id: I33bac507082fa89d1a5ae02cbe671ce7f5f09b07
The annotation is used to verify behavior for apps with max target SDK
30.
Bug: 235355681
Test: atest CtsNetTestCasesMaxTargetSdk30
Change-Id: Idb358ee1179bc3b6ef9ddbe7b567532822bdc64e
Add a method to check if the current kernel version is at least from a
given version.
Bug: 236783925
Test: atest com.android.testutils.DeviceInfoUtilsTest --iterations
Change-Id: If0509b8ccad895c31d9447fee06789540002f666
UnboundedSdkLevel provides a generic and supported way to check for
development SDK level, which makes it unnecessary to update
DevSdkIgnoreRule yearly.
Also this allows using UDC with DevSdkIgnoreRule / DevSdkIgnoreRunner.
Test: Tests using this rule
Change-Id: I151df06ce1498ecbf81c01de8884ebbac83cf7d7
Throwable could be used as a type argument to catch(), but it would
possibly never be caught, because the method only catches Exception.
Notably, junit assertions fail with AssertionError, which is not a
subclass of Exception. Due to that, tests or utilities like
DeviceConfigRule that have failing assertions in catch() would not
run the subsequent cleanup steps.
Bug: 210377950
Test: atest CleanupTest
Change-Id: I54e2922cb466f077ba4d219f8c3c6f885316296c
This does not work because when the permissions are dropped, all
previously-adopted permissions will be dropped as well. Attempts
to do so will likely result in hard-to-understand test failures.
On S+, where we can detect this, fail with a clear error message.
Test: treehugger
Bug: 225092753
Change-Id: I1587ab77f885c595f0b9168c6739303c6227218e
Add a mockService method to support the common usage that requires
mocking the system service from with a mock context.
Bug: 231373589
Test: atest FrameworksNetTests
Change-Id: Id17af4027a019834c1779be550f4329b1edd6809
The code added to DevSdkIgnoreRule to process the max target SDK
annotations in aosp/2110064 was incorrect. It is trying to match
the annotation name, but ::class.simpleName returns something
like Proxy$3, not the actual name of the annotation. Use
annotationClass.simpleName instead, which actually works.
This was not caught in aosp/2110064 because it contained an even
worse error which broke DevSdkIgnoreRule completely. That was
fixed in aosp/2114653.
Bug: 233553525
Test: LinkPropertiesTest#testExcludedRoutesDisabled passes on user build
Change-Id: If9220e5ef00fafea556604b251b2106d15d063f8
setupTestNetwork only supports the LinkProperties argument starting from
R. Keep overloads that specify only LinkAddresses and mark the
LinkAddress initTestNetwork version as requiring R.
Bug: 234879676
Test: atest CaptivePortalLoginTests on a Q device
Change-Id: I66c0ad9663bffb0ec2659d67c2ca6f4d167e15a6
Tests using DevSdkIgnoreRule are currently not being run at all,
as the call to base.evaluate() was removed.
Bug: 233553525
Bug: 234680138
Change-Id: Ice2d1c85f5b886b1fcd5214046ae554d6c66134b
Test: atest
This is the follow CL to fix the comment from
https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1810276/3/common/testutils/devicetests/com/android/testutils/TestNetworkTracker.kt#45
TestNetworkService only default configure interface name, link addresses,
and routing. To support specify some configuration (e.g. dns server) which
TestNetworkService doesn't default configuration, extend iniTestNetwork
pass LinkProperties.
Bug: 183166581
Test: atest EthernetTetheringTest
atest ConnectivityManagerTest
atest TetheringModuleTest
atest CaptivePortalLoginActivityTest
Change-Id: I560d95516159fa05007057614ac47591fbb3a08c
This skips a test if the APK it's running in targets an SDK
above 31. This allows us to add such tests to CtsNetTestCases,
which is currently targeting SDK 33.
By using the annotation as an include-annotation filter in
AndroidTestTemplate.xml, this makes it very easy to create a
clone of CtsNetTestCases that targets SDK 31 and which only runs
tests annotated with this annotation. Thus, CtsNetTestCases and
CtsNetTestCasesLatestSdk will run all tests that pass if target
SDK is 33, and CtsNetTestCasesMaxTargetSdk31 will only run the
tests that requires target SDK 31. See other CL in topic.
Bug: 233553525
Test: atest CtsNetTestCasesMaxTargetSdk31:android.net.LinkPropertiesTest
Test: atest CtsNetTestCasesLatestSdk:android.net.LinkPropertiesTest
Change-Id: Ib5df3bbc659d6a737a846fdf57cddee002e4e9ae
Add a class Version and string helper for handling a three-part
kernel version number.
Test: atest com.android.testutils.DeviceInfoUtilsTest
Bug: 232332847
Change-Id: I0f229e935bd8332ef2ef93fc910a576df9c054ae
Divide the NetworkPolicyManager API
notifyStatsProviderWarningOrLimitReached into the following two APIs:
1. notifyStatsProviderWarningReached()
2. notifyStatsProviderLimitReached()
Bug: 216474563
Test: atest NetworkStatsServiceTest NetworkPolicyManagerTest
NetworkPolicyManagerServiceTest OffloadControllerTest
Change-Id: I9d399ea32b656727bf155283265693d3f0d4b9cf
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
IBpfMap#forEach allows concurrent map access (deleting from the map
while iterating), so we should allow this in TestBpfMap as well.
Test: builds
Change-Id: I89dc7e4daf1d0cfc1aac57cad4ea7f1e50f5f20c
Currently, expectAvailableCallbacks requires that the caller know
in advance what the validation state is. This CL allows the
caller to pass in validated = null to indicate that it does not
matter whether the network is validated or not.
Test: modified CTS test in other CL in topic
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Change-Id: Ie54806a4a1d907de630819e11f9e34602cc55ef4
The library pulls a lot of dependencies, which end up in code coverage
reports, because code coverage looks at code inside the test package
unless excluded.
Just use the existing TestPermissionUtil in the same library instead,
avoiding the need to exclude many test utilities and making the test
smaller.
Test: atest android.net.cts.ConnectivityManagerTest#testDump
Change-Id: I3ba2121ef034872acf077578644ac9e8aa92c7ef
Converting BiConsumer to ThrowingBiconsumer allows an
exception to correctly be thrown from the BiConsumer action
in forEach() from BpfMap.
Change-Id: I34363c5aa8b07c4cbd703e899381a95062d2b75b
This patch allows not passing a network to expectCallback
to allow receiving a callback when the network isn't known.
This is supported in other expect* methods but somehow was
missed in this one.
Test: Ikev2VpnRunnerTest, which uses this ability
Change-Id: Ifd20dd8789ff8b277bac3a73ddd23e2fe9febbca
- Move it to frameworks/libs/net/common/testutils.
- Inherit from BpfMap, so the class can be used anywhere that
uses a real BpfMap. For example, BpfCoordinatorTest uses
BpfMap, not IBpfMap.
Test: atest BpfCoordinatorTest
Change-Id: I7ee65e47fa46ac6aafc831f5b1823b44267ba2a6
This allows tests to run dumpsys without worrying too much about
the nitty-gritty of finding the service, piping the output back,
etc.
Test: simple test added in other CL in topic
Change-Id: I0628c55ad199e4c888e4947e11bdb0a3b8150767