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
We use "mts-networking" and not "mts" so that the tests and test dependencies can be properly included in the automated MTS packaging and release (go/mts-packaging).
Instead of tagging tests "mts", we should use "mts-*" where the suffix is one of https://source.corp.google.com/android/test/mts/tools/build/config.mk;l=19.
Test: built locally and verified contents
Bug: 203466102
Change-Id: I5f9bdaf699cfa2525b33178c0e30a6b794b9d5f5
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
This is useful for some tests that need to make sure a few
things all happen, but some of them may throw an exception.
In vanilla Java you'd say
try {
...
} finally {
try {
...
} finally {
try {
...
} finally {
...
}
}
}
With this patch, you can pass a list of blocks to clean.
Kotlin :
tryTest {
...
} cleanupStep {
...
} cleanupStep {
...
} cleanup {
...
}
Java :
tryAndCleanup(() -> {
...
}, () -> {
...
}, () -> {
...
})
This keeps the semantics of tryTest{} of throwing any
exception that was thrown in tryTest{} and adding the
exception in the cleanup steps as suppressed.
Test: new tests for this
Change-Id: Ie26b802cb4893e13a70646aa0b7887701dee1ec6
This is the same thing try{} does, and allows to lift
return out of tryTest.
This allows syntaxes like :
fun foo() = try {
"Foo";
} cleanup {
doSomeCleanup()
}
}
val network = try {
registerNetworkCallback
callback.getNetwork()
} cleanup {
unregisterNetworkCallback
}
}
Note: bypassing ktlint because of b/185077240
Test: FrameworksNetTests
Change-Id: Ib8f6fde7ccfd62fdcb3c1e3b7b03909ed94d4b23
Non-local returns will prevent the execution of the cleanup{}
block, which is too much of a footgun to allow. See the bug
for details of how it happens.
There doesn't seem to be a way to keep the nice syntax, allow
non-local returns and still guarantee execution of the cleanup
block in all cases. Thus, forbid non-local returns. Users can
still use return@tryTest to accomplish almost the same thing,
and the next patch will also let tryTest{} return its last
evaluated value, fixing remaining cases.
E.g.
tryTest {
foo()
if (condition) return result
bar()
} cleanup {
doCleanup()
}
can always be written
return tryTest {
foo()
if (condition) return@tryTest result
bar()
} cleanup {
doCleanup()
}
...and it's a rare case, so the additional syntax is acceptable.
Test: NetworkStaticLibTests
Bug: 207358921
Change-Id: I40443acf7e4d86813641adc877e27fb2334d0daf
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
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
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
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
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
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
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)
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
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
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
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
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
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
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
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
Add a callback entry for the older notifyLimitReached callback, that is
used on R devices.
Bug: 182962001
Test: atest OffloadControllerTest
Change-Id: Ic3c40eeb72b58ff1514f35be8e030a1dd9ba95d7
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)
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