Commit Graph

52 Commits

Author SHA1 Message Date
Hungming Chen
c56679d1b5 Migrate compareMajorMinorVersion from ConnectivityManagerTest
Move compareMajorMinorVersion() and getVersionFromString()
from ConnectivityManagerTest.java.

Test: atest DeviceInfoUtilsTest
Change-Id: Ib8245890856a3e4518e48e0afeada746a24e8b22
2022-04-29 13:52:57 +08:00
Patrick Rohr
86dd5872be Create RouterAdvertisementResponder
This is useful for tests that need a provisioned tap interface.

Test: TH
Change-Id: I9a2eb3d8697bbcbfdb65563da609534b929a0715
2022-04-08 13:52:15 +02:00
Frank
4e70104466 [DU04-3]Appropriate changes to the NetworkPolicyManager API
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
2022-03-16 12:27:08 +08:00
Treehugger Robot
798eebdade Merge "Add support for unknown Network to expectCallback" 2022-02-28 21:57:29 +00:00
Maciej Żenczykowski
0a7883f994 Merge "Change TestBpfMap to use ConcurrentHashMap" 2022-02-19 20:20:24 +00:00
Lorenzo Colitti
0a0877006d Merge "Allow of expectAvailableCallbacks when validation state is unknown." 2022-02-18 17:04:27 +00:00
Patrick Rohr
aeff1238bb Change TestBpfMap to use ConcurrentHashMap
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
2022-02-18 11:59:43 +01:00
Lorenzo Colitti
5fec18b980 Allow of expectAvailableCallbacks when validation state is unknown.
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
2022-02-17 17:45:05 +09:00
Remi NGUYEN VAN
48ce320ad3 Merge "Remove dependency on compatibility-device-util-axt" 2022-02-17 06:14:47 +00:00
Remi NGUYEN VAN
675cdf6d99 Remove dependency on compatibility-device-util-axt
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
2022-02-16 18:52:32 +09:00
Tyler Wear
8e377130c9 Add ThrowingBiConsumer to IBpfMap
Converting BiConsumer to ThrowingBiconsumer allows an
exception to correctly be thrown from the BiConsumer action
in forEach() from BpfMap.

Change-Id: I34363c5aa8b07c4cbd703e899381a95062d2b75b
2022-02-15 15:35:54 -08:00
Chalard Jean
1a21b9a9db Add support for unknown Network to expectCallback
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
2022-02-09 03:22:43 +09:00
Lorenzo Colitti
167102daab Turn TestBpfMap into a common utility class.
- 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
2022-02-02 00:25:40 +00:00
Lorenzo Colitti
e6cb32b01b Merge "Add Override for onDscpPolicyStatusUpdated" 2022-01-27 23:25:54 +00:00
Lorenzo Colitti
375241c99b Add a DumpTestUtils class to do service dumps in tests.
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
2022-01-25 17:35:18 +09:00
Tyler Wear
580cabf981 Add Override for onDscpPolicyStatusUpdated
Add override to allow for DscpPolicyTest to use updated
NetworkAgent callbacks.

Bug: 202871011
Change-Id: I2082f6553e56ff941a309e031184d6e0dfb88514
2022-01-21 11:32:35 -08:00
Maciej Żenczykowski
11e656cbf8 Merge "Add DSCP Status Callback to TestableNetworkAgent" 2022-01-21 19:03:11 +00:00
Tyler Wear
ee9f5afef5 Add DSCP Status Callback to TestableNetworkAgent
Add new callback for Dscp status's.

Test: atest DscpPolicyTest
Change-Id: Ib47c246e3f92045ca32b681b380315dfdfedc182
2022-01-21 05:21:48 +00:00
Chiachang Wang
3e6dd45b85 Update case to correctly support usage for T
Update condition to correctly support the usage for T.
Also update the S code since it was updated to corresponding
number.

Bug: 215294242
Test: test using DevSdkIgnoreRule
Change-Id: Ia94cb7f5a0aaf92515e5e2b924d1ab6cc050e074
2022-01-20 11:26:51 +08:00
Chalard Jean
b91c5a3a9c Fix blocked status error message
assertEquals syntax is (expected, actual) and not the
other way around

Error message before :
java.lang.AssertionError: Unexpected blocked status 32 expected:<32> but was:<0>
Error message after :
java.lang.AssertionError: Unexpected blocked status 32 expected:<0> but was:<32>

Test: FrameworksNetTests
Change-Id: I27f912db9a83fe418b659553829580a2802c20db
2022-01-07 11:16:33 +00:00
Remi NGUYEN VAN
6b6701d5bc Merge "Move TestableNetworkAgent to Common Util Location" 2021-12-14 12:49:15 +00:00
Treehugger Robot
876367a5b8 Merge "Add more logs in TestableNetworkStatsProvider" 2021-12-08 12:56:18 +00:00
Tyler Wear
fbbfadf393 Move TestableNetworkAgent to Common Util Location
To prep TestableNetworkAgent being accessible for multiple
tests, move to common location.

Change-Id: Ib885553550259509b4843cdbc91d2b4bbfaa5fb8
2021-12-03 10:12:00 -08:00
Junyu Lai
bb84528e38 Add more logs in TestableNetworkStatsProvider
Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
Bug: 175742577
Change-Id: Ib8f45a20879517af08f9bf9cbb2b16314351d2da
2021-11-25 09:47:23 +00:00
paulhu
9053e46508 Add ContextUtils
Some tests need to create a Context with assigned user and
should delegate to orignal Context. Thus, add
ContextUtils#mockContextAsUser to factorize the usage.

Bug: 170593746
Test: atest FrameworksNetTests
Change-Id: I93f64a141709e181276ed4b5195811c36100c1d0
2021-11-22 21:05:07 +08:00
Remi NGUYEN VAN
c02dcd721a 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
2021-11-04 19:57:21 +09:00
Junyu Lai
749459c3bd Add getter for quotaBytes
Since the counter part test is in internal branch only.
Change the member of OnSetLimit makes it fail to build on the
rvc+aosp branch.
Thus, add a getter for backward compatibility since the rvc test
does not recognize limitBytes.

This change also addresses some nullability confusions that are
not going to happen.

Test: m gts && atest \
          GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
      on R & S codebase.
Bug: 191327585
Change-Id: I91dc8cb2297ca503c49b78bf1102cc5572d16530
2021-10-05 10:14:24 +00:00
Junyu Lai
16b160bfcb Add OnSetWarningAndLimit into TestableNetworkStatsProvider
This change also address left comments at ag/15010113.

Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
Bug: 191327585
Merged-In: I100668cc6d4cecbaff29d027d37d313dd48854f3
Change-Id: Ib1f3820fe8502b939d36cef29bdb8dea428604b5
  (cherry-picked from ag/15061296)
2021-10-01 10:13:23 +00:00
Remi NGUYEN VAN
c2a28e0490 Implement DevSdkIgnoreRule with SdkLevel
DevSdkIgnoreRule currently considers a build with SDK 30, version code T
as being S, but it is generally considered as being T for development
that happens in that branch.

Change the implementation of DevSdkIgnoreRule to be consistent with the
SdkLevel utility.

Test: tests using DevSdkIgnoreRule
Change-Id: Ie81b84dff8fef8eac2cfe9694f0265e5bf11b3e6
2021-09-17 16:11:45 +09:00
markchien
14f746c07a Add initTestNetwork with a list of LinkAddress
To support setup test network with both ipv4 and ipv6. Add overloading
function for initTestNetwork to allow specify mutiple addresses.

Also allow to get TestNetworkInterface from this test network, so the
caller can use it to send and write packets.

Test: atest EthernetTetheringTest
Change-Id: Ic7626582c021dee824f95900e4de8efee861a9ea
2021-08-31 07:42:45 +00:00
Xiao Ma
da2904c7d1 Append link-layer address parameter in makeNewNeighborMessage.
Append link-layer address parameter in makeNewNeighMessage, the caller
can assign different link-layer address as netlink attributes, which is
helpful for testing and simulating the case although the neighbor is
still reachable, the link-layer address has changed. If no special link
layer address is assigned, just use the default constant MAC address.

Bug: 162944199
Test: atest NetworkStaticLibsTest NetworkStackTests
Change-Id: I49de035075fa97655358be0089f0fbee293823a0
2021-08-06 13:36:07 +00:00
Xiao Ma
57b3442c65 Migrate netlink-client to net-utils-device-common-netlink.
Move netlink stuff to frameworks/libs/net/common/device, and build the
source files as an individual libraray. NetworkStack module just depends
on the net-utils-device-common-netlink.

Besides, also fix the incorrect format detected by checkstyle_hook script
such as missing java doc and make some public function as private, rename
the variable and etc.

Bug: 192535368
Test: atest NetworkStaticlibTests
Change-Id: I00e7f30be1bc9ebc2e24d7cd53efc403d6ba3daa
2021-07-29 03:52:09 +00:00
Treehugger Robot
5fa15e6098 Merge "Add assertNoCallbackThat" 2021-07-16 12:29:03 +00:00
Chiachang Wang
cdf45529ad Add assertNoCallbackThat
assertNoCallback() fails when any callbacks are received.
In some cases, the test is expected to not to receive certain
callback, like available or lost. Depending on the network
environment, network may trigger linkproperties change. It will
fail the test, but these callback does not go against the
intention of the test. It should not fail the test. Thus, add
this method to allow tests to verify no certain callback received.

Bug: 192239030
Test: atest TestableNetworkCallbackTest
Change-Id: I7db720becb23636f85a9ac21192f8185eceb22fe
2021-07-16 12:19:39 +08:00
Remi NGUYEN VAN
a7702b6379 Add filterable, sortable to DevSdkIgnoreRunner
Without a Filterable implementation like the AndroidJUnit4 runner,
DevSdkIgnoreRunner will still run tests annotated with @AppModeFull or
@SdkSuppress. Filterable should be implemented by runners that support
filtering as per the JUnit documentation, so the DevSdkIgnoreRunner did
not support filtering and would run all tests.

Add a Filterable implementation based on the base AndroidJUnit4 runner.

Bug: 192530637
Test: atest CtsNetTestCasesLatestSdk adding annotations to tests
Change-Id: Ica9451e34fb5d98675f754269f44c0354bdde1a4
2021-07-14 10:57:04 +09:00
Treehugger Robot
1308667155 Merge "Support legacy limit reached callback" 2021-06-29 05:02:47 +00:00
Remi NGUYEN VAN
87e88884b3 Support legacy limit reached callback
Add a callback entry for the older notifyLimitReached callback, that is
used on R devices.

Bug: 182962001
Test: atest OffloadControllerTest
Change-Id: Ic3c40eeb72b58ff1514f35be8e030a1dd9ba95d7
2021-06-28 06:01:10 +00:00
Dennis Liao
34db409225 Revert "Add OnSetWarningAndLimit into TestableNetworkStatsProvider"
This reverts commit d44e8af26a04fb0b8d73483d7a777cfa94888809.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_rvc-qpr-dev-plus-aosp&target=test_suites_x86_64&lkgb=7487730&lkbb=7488089&fkbb=7487865, bug b/191937497

Change-Id: I21bfa4c481db4e5e5e038a5dd4de432f879aca57
2021-06-24 06:24:07 +00:00
Junyu Lai
a7ace49440 Add OnSetWarningAndLimit into TestableNetworkStatsProvider
This change also address left comments at ag/15010113.

Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
Bug: 191327585
Merged-In: I100668cc6d4cecbaff29d027d37d313dd48854f3
Change-Id: I100668cc6d4cecbaff29d027d37d313dd48854f3
  (cherry-picked from ag/15061296)
2021-06-24 01:19:25 +00:00
Junyu Lai
8dc6e175cc Merge "Revert "Revert "Allow expect onRequestStatsUpdated with any token""" 2021-06-23 03:48:38 +00:00
Junyu Lai
4046a83b12 Revert "Revert "Allow expect onRequestStatsUpdated with any token""
This reverts commit 886c3f16352f372f8e384c2dafd74c304008af38.

Reason for revert: From result of forrest, it turns out the culprit is not the CL. Hence the revert is not necessary.
See https://buganizer.corp.google.com/issues/191742804#comment10 for more detail.

Change-Id: If8492233c69d7947300f35f764199a7db1bd0045
2021-06-23 00:33:48 +00:00
Roy Want
d1573ed5e5 Merge "Revert "Allow expect onRequestStatsUpdated with any token"" 2021-06-22 22:25:27 +00:00
Roy Want
75b9e6773b Revert "Allow expect onRequestStatsUpdated with any token"
This reverts commit 6b547a5fce031d25f2640f5da373aac8897634a2.

Reason for revert: DroidMonitor: Potential culprit for Bug 191742804 - verifying through Forrest before revert submission. This is part of the standard investigation process: RESULT: Out of the two CL's pointed at by this bug, this CL appeared to be the cause of the failure; submitting revert.

Change-Id: Ia727b13b11e9b863a702f83f68da12bbff3bcf3f
2021-06-22 22:20:02 +00:00
Chiachang Wang
c0786a5ec8 Merge "Add fall back to createTunInterface when running on R" 2021-06-22 12:47:59 +00:00
Chiachang Wang
40803d4701 Add fall back to createTunInterface when running on R
TNM.createTunInterface() takes different parameter from S.
GTS is multi-release, so it should be compatible with S
and before S build. Add sdk version check to support it.

Bug: 186680038
Test: atest GtsNetworkStackHostTestCases:\
      com.google.android.gts.networkstack.NetworkStackHostTest#\
      testNetworkStack
Change-Id: I5a08068db43e507637a53a32c15a5eb453d50c32
2021-06-22 12:32:40 +08:00
Junyu Lai
9856889627 Allow expect onRequestStatsUpdated with any token
Altough token field is not used for now. But by design,
the token will be the version number of networkIdentity mappings
that maintain by the service, which cannot be predicted by the
test. Thus, allow expecting any token is necessary.

Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsManager
Bug: 191327585
Merged-In: Ibf10040a5c10b7b1c7d381c01a071fb157409004
Change-Id: Ibf10040a5c10b7b1c7d381c01a071fb157409004
  (cherry-picked from ag/15010113)
2021-06-22 02:15:29 +00:00
Junyu Lai
d609a8d2ea Merge "Add TestableNetworkOfferCallback" 2021-06-21 10:58:04 +00:00
Aaron Huang
066b779b9e Merge "Supports to add a response for the given headers" 2021-06-21 09:42:33 +00:00
Aaron Huang
860a8ebb6f Supports to add a response for the given headers
Currently TestHttpServer only supports to add a response
for Location header. Make it to add a response for the
given headers so that any additional headers that should
be returned along with the response.

Bug: 181745786
Test: build
Change-Id: I80b2fe43016b9cd12fc3cb95ee76f1ec9568ddfc
2021-06-10 01:55:33 +08:00
Junyu Lai
8377130fc0 Add TestableNetworkOfferCallback
Ignore-AOSP-First: Needs cherry-picks
Test: android.net.NetworkProviderTest on R/S device
Bug: 189074532
Change-Id: Iac7ec1bb4c34b4354f7b43fec86ded68c1a1d0de
2021-06-09 12:41:57 +00:00