Commit graph android_packages_modules_Co.../staticlibs/testutils
Message SHA1
Make sure no suppressed expression is present when they shouldn't
In fact the test already passes, because addSuppressed contains
an explicit test that if this === argument, then it doesn't add
it. But otherwise that's a bug in tryCleanup

Test: NetworkStaticLibTests
Change-Id: I202790bbe8d82445c5affdd9076561c2c6ea9b59

Chalard Jean   commited 2021-11-24 17:07:28 +09:00
bfbcacef6d
Enable strict_updatability_linting in frameworks/libs/net
Enable the strict_updatability_linting here first as a prior
commit to enable strict_updatability_linting in connectivity
modules.

Bug: 188851968
Test: m lint-check ; atest NetworkStaticLibTests
Change-Id: Idac98a1c85bf5bb86269b1daad2b444cfb58db8a

Chiachang Wang   commited 2021-11-19 15:41:27 +08:00
7068c88921
[LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
Added SPDX-license-identifier-Apache-2.0 to:
  common/testutils/app/connectivitychecker/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I9e25f435ce9835f12a167e6c57e33f6d87c159de

Bob Badour   commited 2021-11-11 10:10:56 -08:00
891a3b9fb7
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
Merge changes from topic "testStatsProvider-cp" am: 8dc319b30f
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1843374

Change-Id: Ifd7c922d474aa701e53bd2393495a4cfaef7ecb6

Junyu Lai   authored and   Automerger Merge Worker   commited 2021-10-05 10:26:39 +00:00
df424c18fa
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

Junyu Lai   commited 2021-10-05 10:14:24 +00:00
749459c3bd
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)

Junyu Lai   commited 2021-10-01 10:13:23 +00:00
16b160bfcb
Merge "Implement DevSdkIgnoreRule with SdkLevel" am: 20bad35bc3
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1827474

Change-Id: I4b6165b1eff5cdc92e69f6ee8574a157d9f8bf7b

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-09-17 10:20:27 +00:00
b999f5fa4b
Merge "Implement DevSdkIgnoreRule with SdkLevel"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-09-17 10:07:32 +00:00
52f1cc6f4f
Add a new utility to improve stack traces from automatic testing am: 6b56526bec
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1821095

Change-Id: I587f022c0a53dc56e654738686e222d384039500

Chalard Jean   authored and   Automerger Merge Worker   commited 2021-09-17 07:59:31 +00:00
63e8809f5b
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

Remi NGUYEN VAN   commited 2021-09-17 16:11:45 +09:00
c2a28e0490
Add a new utility to improve stack traces from automatic testing
A common pattern in tests is to use try-finally to make sure
cleanup is executed. This is necessary in CTS in particular to
make sure the test does not leave the device in a bad state.

The problem with using try-finally in this manner is that any
exception thrown in the finally{} block will override any thrown
in the try{} block. If the exception in finally{} is caused by
the one from try{}, then the stack trace reported by the tools
is the consequence and not the cause, making it difficult to
interpret the stack trace of automated tests.

So today, code has to make sure that either the code in
finally{} can't throw, or can't be affected by any code in
try{}, and both of these are really difficult to ensure in
presence in finally{} of code the tester does not control.

What we'd want ideally is a structure like try-finally, that
guaratees the code in finally{} is executed in all cases,
but that bubbles up the exception from try{} if any, and
will still bubble up any exception from finally{} if the
try{} block hasn't thrown.

That's what this new tool does.

Usage from Kotlin is like try-finally :
tryTest {
  testing code
} cleanup {
  cleanup code
}

Usage from Java can't be made as nice, but it's relatively okay :
testAndCleanup(() -> {
  testing code
}, () -> {
  cleanup code
});

Bugs listed below are some tests that have been affected by
this issue and have unhelpful traces.

Test: new test for this code
Bug: 198586720
Bug: 198998862
Change-Id: I54b30a7d53772feeade99274b6120a79707ad1c9

Chalard Jean   commited 2021-09-17 12:21:09 +09:00
5872cb8dbd
Merge "Add initTestNetwork with a list of LinkAddress" am: e0920f08f2
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1810276

Change-Id: I4334c9b01ca1ddf0ce640f1272c6d67f3f6f6020

Mark Chien   authored and   Automerger Merge Worker   commited 2021-08-31 08:42:21 +00:00
5c934df677
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

markchien   authored and   Mark Chien   commited 2021-08-31 07:42:45 +00:00
14f746c07a
Merge "Merge sc-dev-plus-aosp-without-vendor@7634622" into stage-aosp-master
Xin Li   authored and   Android (Google) Code Review   commited 2021-08-17 18:14:27 +00:00
ff5da50661
Add the ConnectivityModuleTest annotation
The annotation will be used to mark tests cases that are part of MTS
modules used by multiple modules, to indicate that the test case should
only be run if the MTS suite should cover an updated Connectivity
(tethering) module.

This allows tests to verify new behavior in the Connectivity module,
without failing if that module is not updated.

Bug: 196755836
Test: mts-tradefed run mts-network with exclude-annotation in the config
Change-Id: I05d2200c7ab68042e4e48029e045f164c26b8037

Remi NGUYEN VAN   commited 2021-08-16 18:09:41 +09:00
843740592c
Append link-layer address parameter in makeNewNeighborMessage. am: e26cd34b8a am: e65d03c433
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1788967

Change-Id: I27c720422d9dce022639dd1ca8463076fc22f135

Xiao Ma   authored and   Automerger Merge Worker   commited 2021-08-06 16:47:42 +00:00
8580cd8785
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

Xiao Ma   commited 2021-08-06 13:36:07 +00:00
da2904c7d1
Migrate netlink-client to net-utils-device-common-netlink. am: a5abbe6529 am: 3818589c93
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1755889

Change-Id: Ia1a45efa17b46d2787e7385d6fb3e1e4648060fa

Xiao Ma   authored and   Automerger Merge Worker   commited 2021-08-04 07:56:23 +00:00
049b884c90
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

Xiao Ma   commited 2021-07-29 03:52:09 +00:00
57b3442c65
Merge "Add assertNoCallbackThat" am: 5d39cb6ea7 am: 302ee01797
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1765527

Change-Id: Ia6dfe0d043a30df97b6bf3ae696503305e5e491f

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-07-16 12:55:14 +00:00
65c85f368e
Merge "Add assertNoCallbackThat"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-16 12:29:03 +00:00
5fa15e6098
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

Chiachang Wang   commited 2021-07-16 12:19:39 +08:00
cdf45529ad
Merge "Add filterable, sortable to DevSdkIgnoreRunner" am: c0e59172d3 am: b2e757353a
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1754040

Change-Id: Iffb8ca12a771d658a1b5cb98989ab61a8d9ce778

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2021-07-15 09:01:58 +00:00
49ca421baa
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

Remi NGUYEN VAN   commited 2021-07-14 10:57:04 +09:00
a7702b6379
Merge "Support legacy limit reached callback" am: 38e6f064fb am: 54f6b13dfd
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1748173

Change-Id: Idfbe0ee1e4969572766db13db41c6ef668767f52

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-06-29 05:24:11 +00:00
1c5e60835f
Merge "Support legacy limit reached callback"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-29 05:02:47 +00:00
1308667155
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

Remi NGUYEN VAN   commited 2021-06-28 06:01:10 +00:00
87e88884b3
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

Dennis Liao   commited 2021-06-24 06:24:07 +00:00
34db409225
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)

Junyu Lai   commited 2021-06-24 01:19:25 +00:00
a7ace49440
Merge "Add OnSetWarningAndLimit into TestableNetworkStatsProvider" into sc-dev
Junyu Lai   authored and   Android (Google) Code Review   commited 2021-06-23 20:32:02 +00:00
1f29499c64
Merge "Revert "Revert "Allow expect onRequestStatsUpdated with any token"""
Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-23 03:48:38 +00:00
8dc6e175cc
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
Original-Change: https://android-review.googlesource.com/1742033
Merged-In: I5a08068db43e507637a53a32c15a5eb453d50c32
Change-Id: I5a08068db43e507637a53a32c15a5eb453d50c32

Chiachang Wang   commited 2021-06-23 00:54:52 +00:00
7dc43667f0
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

Junyu Lai   commited 2021-06-23 00:33:48 +00:00
4046a83b12
Merge "Revert "Allow expect onRequestStatsUpdated with any token""
Roy Want   authored and   Gerrit Code Review   commited 2021-06-22 22:25:27 +00:00
d1573ed5e5
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

Roy Want   commited 2021-06-22 22:20:02 +00:00
75b9e6773b
Merge "Add fall back to createTunInterface when running on R"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-06-22 12:47:59 +00:00
c0786a5ec8
Add OnSetWarningAndLimit into TestableNetworkStatsProvider
This change also address left comments at ag/15010113.

Ignore-AOSP-First: Counter part CL is not in aosp.
Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsProvider
Bug: 191327585
Change-Id: I100668cc6d4cecbaff29d027d37d313dd48854f3

Junyu Lai   commited 2021-06-22 08:25:06 +00:00
03f8890ec8
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

Chiachang Wang   commited 2021-06-22 12:32:40 +08:00
40803d4701
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
Original-Change: https://android-review.googlesource.com/1724310
Merged-In: I80b2fe43016b9cd12fc3cb95ee76f1ec9568ddfc
Change-Id: I80b2fe43016b9cd12fc3cb95ee76f1ec9568ddfc

Aaron Huang   commited 2021-06-22 02:47:13 +00:00
c73b6391dd
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)

Junyu Lai   commited 2021-06-22 02:15:29 +00:00
9856889627
Merge "Add TestableNetworkOfferCallback" into sc-dev
Junyu Lai   authored and   Android (Google) Code Review   commited 2021-06-21 16:27:24 +00:00
72c4ea0947
Merge "Allow expect onRequestStatsUpdated with any token" into sc-dev
Junyu Lai   authored and   Android (Google) Code Review   commited 2021-06-21 14:58:20 +00:00
971619faaa
Add TestableNetworkOfferCallback
Ignore-AOSP-First: Needs cherry-picks
Test: android.net.NetworkProviderTest on R/S device
Bug: 189074532
Original-Change: https://android-review.googlesource.com/1731491
Merged-In: Iac7ec1bb4c34b4354f7b43fec86ded68c1a1d0de
Change-Id: Iac7ec1bb4c34b4354f7b43fec86ded68c1a1d0de

Junyu Lai   commited 2021-06-21 14:20:00 +00:00
be5fe44c0b
Merge "Add TestableNetworkOfferCallback"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-21 10:58:04 +00:00
d609a8d2ea
Merge "Supports to add a response for the given headers"
Aaron Huang   authored and   Gerrit Code Review   commited 2021-06-21 09:42:33 +00:00
066b779b9e
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.

Ignore-AOSP-First: Counter part CL is not available in aosp.
Test: m gts && atest \
      GtsNetworkStackHostTestCases:NetworkStatsHostTest#testNetworkStatsManager
Bug: 191327585
Change-Id: Ibf10040a5c10b7b1c7d381c01a071fb157409004

Junyu Lai   commited 2021-06-17 08:53:09 +00:00
2713cdf321
Update TestNetworkTracker tearDown()
Update to TestNetworkTracker tearDown() to call
TestNetworkManager to tear down the current test network.

Bug: 176496580
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Original-Change: https://android-review.googlesource.com/1663785
Merged-In: I5ba142f601f3942d6e6ec4106fc0e70012b42a49
Change-Id: I5ba142f601f3942d6e6ec4106fc0e70012b42a49

Lorenzo Colitti   authored and   James Mattis   commited 2021-06-16 03:56:37 +00:00
bb6441aa07
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

Aaron Huang   commited 2021-06-10 01:55:33 +08:00
860a8ebb6f
Add TestableNetworkOfferCallback
Ignore-AOSP-First: Needs cherry-picks
Test: android.net.NetworkProviderTest on R/S device
Bug: 189074532
Change-Id: Iac7ec1bb4c34b4354f7b43fec86ded68c1a1d0de

Junyu Lai   commited 2021-06-09 12:41:57 +00:00
8377130fc0