Commit graph android_packages_modules_Co.../tests
Message SHA1
Move battery unplug command to the beginning of the test
The test failed because the test generated traffic
before the unplug command really done.

The unplug command will eventually have onBattery changed
to true. If the traffic is generated before onBattery changed
to true, then the cellular stats won't be updated. And then,
when BatteryStatsService schedules a sync task to update the
stats which will get no delta because the stats on cellular
has already added to mLastModemNetworkStats. Thus, the test
will finally get failed.

Currently, the battery unplug command is executed after connecting
to cellular network and making sure wifi is disconnected which may
trigger battery stats service schedules sync tasks. If there are
too many tasks need to run, then change onBattery to true would
be later. Thus, move the unplug command to the beginning of the
test and add "dumpsys batterystats --write" which will wait for the
worker to finish the task before continuing. Thus, it can make sure
the batterystats are synced.

Also, the stats will be reset when the devices are unplugging after
the battery was last full or the level is 100, or have gone through
a significant charge. So, enable no-auto-reset to avoid the stats
getting reset during the test.

Bug: 192808200
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I08b38d9955c8cbb2d680e268c29368a4c0a7d144

Aaron Huang   commited 2021-07-21 02:14:03 +08:00
a3debae1eb
Merge "Specify which callback is unexpected in tests"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-07-20 01:20:16 +00:00
5251171b75
Merge "Deflake test to ensure system default network as expected"
Chiachang Wang   authored and   Gerrit Code Review   commited 2021-07-20 01:20:07 +00:00
575fa2f103
Merge "Fix a flake with mocking."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-19 12:16:18 +00:00
527f040944
Specify which callback is unexpected in tests
Tests may be flaky due to the usage for assertNoCallback().
The method expects no any callback received. Based on the usage,
tests expect to not to receive certain callback, such as
onAvailable(). The network may update its linkproperties during
the test and trigger onLinkPropertiesChanged(). These callbacks
are ignorable in the tests. They should not fail the tests.

Replace the assertNoCallback to new assertNoCallbackThat with
callback type specified to deflake tests.

Bug: 192239030
Test: atest android.net.cts.ConnectivityManagerTest\
      --iterations 20
Change-Id: I1643c1ff15215c07e174dbcb664cfac2a38d5840

Chiachang Wang   commited 2021-07-19 18:41:53 +08:00
6c80c3806d
Deflake test to ensure system default network as expected
CtsNetUtils.toggleWifi() expects to receive a CONNECTIVITY_ACTION
broadcast after disconnecting from wifi if wifi is enabled.
The wifi may be connected but not validated since wifi just
turns back to connected from the previous test. In this case,
the system default netwok will not be wifi, so there is no
CONNECTIVITY_ACTION broadcast after disconnecting wifi. It
should ensure the wifi is system default network first before
proceeding with other verifications.

Bug: 192213759
Test: atest CtsNetTestCases --iterations 20
Change-Id: I82f0634883362e35b88854aae28e61b75a3cd7cc

Chiachang Wang   commited 2021-07-19 18:38:31 +08:00
ac059de6ad
Merge changes from topic "sdk_int_cp"
* changes:
  Fix testSocketKeepaliveLimitTelephony on R
  Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-19 09:47:21 +00:00
800eff01d0
Merge "Wait for next network in waitForAvailable"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-19 09:47:12 +00:00
e9f65535e0
Merge "Skip BatteryStatsManagerTest on Q"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-19 09:11:54 +00:00
e2067816e9
No-op cleanup
Test: atest ConnectivityServiceTest
Change-Id: Ic07c94785d97bd654ffce960e8bc2652c2dbc3d6

Chalard Jean   commited 2021-07-16 12:02:22 +09:00
6d8f2fbf99
Merge "Fix jarjar-related failures in coverage tests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-15 05:19:18 +00:00
e9f7f1e3d4
Use TRANSPORT_USB from the SDK
Stop using the stopgap TRANSPORT_USB from NetworkCapabilitiesUtil, which
is being removed.

Bug: 184158327
Test: atest NetworkCapabilitiesTest
Change-Id: I6bbb35d39ff67d6f53b389689dc9f1067e64f962

Remi NGUYEN VAN   commited 2021-07-14 16:35:11 +09:00
732584bcb8
Ignore checking TRANSPORT_USB when Android version is older than S
There is a new transport type - TRANSPORT_USB(8) in Android S,
so when the test tries to add this new transport type in older
Android version, it cannot pass the transport type validation and
make test fail.

(clean cherry-pick of change in downstream branch history)
Original change ID before project move:
I38816173b04ea198d99f64f45e9271ac2641e4ac

Bug: 184158327
Test: run CtsNetTestCasesLatestSdk on Android R & Q
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ib0368241771d287c09c0e4463f91122533f85a27

lucaslin   authored and   Remi NGUYEN VAN   commited 2021-07-14 16:28:58 +09:00
eadb0add66
Fix jarjar-related failures in coverage tests
Instead of jarjaring the whole com.android.internal.util package, apply
the jarjar rules per-class. Jarjaring the whole package causes problems
in tests, as for example ConnectivityServiceTest depends on Vpn that
uses other internal utils as hidden API, and these should not be
jarjared.

Also avoid jarjaring INetdUnsolicitedEventListener which is used by
NetdEventListenerServiceTest, and ensure KeepalivePacketDataUtilTest
expects the right package name in toString.

Generally the problems appear because ConnectivityCoverageTests also
includes tests for classes that are not part of the connectivity module,
and use hidden APIs that refer to classes that should not be jarjared.
Some of the tests could be excluded from the coverage suite instead, but
keeping them is helpful for future modularization efforts.

Test: Build service-connectivity, dexdump classes and verify jarjared
      atest ConnectivityCoverageTests
Change-Id: Id6b7e6833d49fa03d9442d7c1c3e4dc16fb48dfc

Remi NGUYEN VAN   commited 2021-07-14 15:22:56 +09:00
ed8efa75b4
Skip BatteryStatsManagerTest on Q
BatteryStatsManager did not exist on Q, so it cannot and should not be
tested there.

Bug: 193586822
Test: atest CtsNetTestCasesLatestSdk on Q
Change-Id: Ia9bef7c3438c25e1a4cb403b27cb0084bbd4f824

Remi NGUYEN VAN   commited 2021-07-14 12:06:51 +09:00
4ba3adc4e5
Wait for next network in waitForAvailable
Tests using CtsNetUtils.TestNetworkCallback would generally assume that
waitForAvailable would return a non-null Network if onAvailable was
called after it was registered. However this is not true if a network
was available, then lost before waitForAvailable is called. This
can typically happen if wifi was disconnected just before calling
ensureWifiConnected (so wifi is being toggled).

In case onUnavailable was called, always wait for the next onAvailable
callback, so that waitForAvailable always waits for a network to be
available. So:

Old behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> returns null immediately
 5) onAvailable called -> unused

New behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> blocks
 5) onAvailable called -> waitForAvailable returns the network

Bug: 190913510
Test: atest CtsNetTestCases
Change-Id: I6bde82ad787371ecffd6caa950b52d90a29ab20b

Remi NGUYEN VAN   commited 2021-07-14 10:08:45 +09:00
30311abb87
Merge "Jarjar all classes in service-connectivity"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-12 23:29:25 +00:00
23c627b090
Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0

Remi NGUYEN VAN   commited 2021-07-12 19:33:33 +09:00
0755183fae
Fix a flake with mocking.
The hypothesis here is that some other thread is using
the mock between the call to when() and the call to
.thenReturn() a few lines above the failure. It's not
clear this is really the reason, but using this syntax
is safer anyway, so whether it fixes the issue or not
this is a good change.

Test: m FrameworksNetTests
Change-Id: I501d2ec8e794c67a53d7c84e290e4cc63481472d

Chalard Jean   commited 2021-07-12 15:30:21 +09:00
6519c179bd
Merge "Remove hidden ArrayUtils usage in test"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-12 02:21:12 +00:00
946da61e70
Remove hidden ArrayUtils usage in test
Internal utils are generally jarjared by connectivity jarjar rules, but
ArrayUtils is not actually statically linked into the tests, so this
makes the ConnectivityCoverageTests fail. FrameworksNetTests has been
fine because it does not use jarjar, but does not exercise updated code
because of that.

Remove usage of the hidden utility, as there are reasonable alternatives
with non-hidden APIs that avoid other breakages long-term.

Bug: 187935317
Test: atest ConnectivityCoverageTests:ConnectivityServiceTest
Change-Id: I8ed85b941c3d1028771a5ac33196b1509a95789d

Remi NGUYEN VAN   commited 2021-07-09 18:52:51 +09:00
61cc1ac9bd
Merge "Add new network capabilities to support automotive head unit via USB"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-09 04:38:10 +00:00
8890ead0e0
Merge "Remove exclusivity restriction of multiple preferences"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-07-08 03:50:34 +00:00
278b92f6a0
Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411

lucaslin   authored and   Remi NGUYEN VAN   commited 2021-07-08 09:44:39 +09:00
6f77442d76
Merge "Ensure wifi reconnects before waiting for metered"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-08 00:40:37 +00:00
14f0d14c14
Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
(cherry-pick from ag/14731887)
Merged-In: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

paulhu   commited 2021-07-07 23:06:43 +08:00
aa0743d7c4
Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-07 03:53:17 +00:00
1d2ad89424
Merge "Fix flake in testMobileDataAlwaysOn"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-07 03:52:38 +00:00
02ea3f55c1
Merge changes I99ce72bd,I5a11a802
* changes:
  Add retries for WifiManager#connect
  Use WifiManager.connect to reconnect wifi

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-07 03:07:21 +00:00
527ffb6f0c
Merge "Use Netd new added/removed uid range methods"
Paul Hu   authored and   Gerrit Code Review   commited 2021-07-07 03:07:10 +00:00
51bfbbfb1b
Use Netd new added/removed uid range methods
Replace network[Add|Remove]UidRanges to
network[Add|Remove]UidRangesParcel. The new methods are passing
NativeUidRangeConfig which contains priority value for each uid
range rules.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
(cherry-pick from ag/14911836)
Merged-In: I08bbdbcb8450b08e6208fa730137348550f9e3d2

Change-Id: I08bbdbcb8450b08e6208fa730137348550f9e3d2

paulhu   authored and   Paul Hu   commited 2021-07-07 03:06:32 +00:00
0e79d95332
Ensure wifi reconnects before waiting for metered
testGetMultipathPreference assumes that wifi will auto-reconnect after
changing its metered status, but this is not necessarily the case if the
BSSID has been blocklisted after it failed validating too many times.

Call ensureWifiConnected to force wifi to reconnect before waiting for
it to become metered.

Bug: 190913510
Test: atest ConnectivityManagerTest
Change-Id: Iafe9837b97e4d654bb0f3962d48a94c1f31bbebc

Remi NGUYEN VAN   commited 2021-07-07 10:55:39 +09:00
c6be26e0ef
remove obsolete/no-op NativeQtaguidTest
qtaguid is long dead - test is thus a no-op

New test logs:
  Running Tests...

  x86 CtsNativeNetTestCases
  -------------------------
  CtsNativeNetTestCases (1 Test)
  [1/1] BpfTest#bpfStructSizeTest: PASSED (0ms)

  Summary
  -------
  x86 CtsNativeNetTestCases: Passed: 1, Failed: 0, Ignored: 0, Assumption Failed: 0,

  All tests passed!

Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9ff784dbfda0ce981904d53eacb7bc831cbe81da

Maciej Å»enczykowski   commited 2021-07-06 22:15:44 +00:00
2aabf4138e
add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes
This test is required to ensure that the system is compatible
with future updates of the tethering mainline module, which
updates BPF .o files on device.

This test must already be passing on OEM devices because otherwise
the offload.o program in the Tethering mainline module would bootloop
the device.

Bug: 190519702
Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibaedb8fcb28591ffba1506514f2305d55712a26b

Maciej Å»enczykowski   commited 2021-07-06 02:50:47 -07:00
bbc4ea32bc
Add retries for WifiManager#connect
Connect can error with BUSY if the framework is busy when connect is
called. Add retries so that if this happens, the connection can succeed
after the framework stops being busy.

Also log the level of scan results when several configurations are
available, and clarify the legacy broadcast assert.

Bug: 188077861
Test: atest CtsNetTestCases
Change-Id: I99ce72bd2604489cb419ea9984643b6985728461

Remi NGUYEN VAN   commited 2021-07-06 17:53:48 +09:00
00407b0c1b
Fix flake in testMobileDataAlwaysOn
The internal structure backing getAllNetworks is updated after
invoking lost callbacks, so the test needs to wait for the handler
to be idle before calling getAllNetworks.

Also avoid assertions in finally clauses, as it causes confusing
error messages.

Bug: 185081944
Change-Id: I8ad5ab45a3e65b0031672e6f594b1a6d6ad5abcb
Test: atest ConnectivityServiceTest

Remi NGUYEN VAN   commited 2021-07-06 06:09:17 +00:00
e687d5844e
Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported
The test relied on waitForIdle to ensure diagnostics callbacks were called,
but as this may require several iterations in the handler queue, this makes
the test unreliable.

Use mockito timeouts on the verify() calls instead.

Bug: 192651465
Change-Id: Iae1704af7ae3649eae301c6aee223ac753629d55
Test: atest ConnectivityServiceTest

Remi NGUYEN VAN   commited 2021-07-06 06:05:38 +00:00
1f210f792a
Use WifiManager.connect to reconnect wifi
Address a TODO to use WifiManager#connect to reconnect wifi, instead of
WifiManager#reconnect. #connect also clears the BSSID denylist; that
list has caused flakyness due to tests that cause the network not to
validate such as captive portal or invalid private DNS behavior tests,
causing wifi to ignore the access point in reconnect attempts.

Bug: 188077861
Test: atest CtsNetTestCasesLatestSdk

Change-Id: I5a11a802db8a4881c161e6038c1c183d2ac23a05

Remi NGUYEN VAN   commited 2021-07-06 11:30:51 +09:00
3676ffb9af
Merge "Consider NetworkOffer is unneeded if it cannot satisfy the request"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-07-05 08:57:07 +00:00
b028fc7cf1
Fix testSocketKeepaliveLimitTelephony on R
DEVICE_INITIAL_SDK_INT does not exist in older SDKs: use the pre-rename
field, FIRST_SDK_INT instead.

Fixes: 185731191
Test: atest ConnectivityManagerTest#testSocketKeepaliveLimitTelephony
Change-Id: I1fbc0f714d539a664c053cb9cf1f86c3e651c5a2
Merged-In: I1fbc0f714d539a664c053cb9cf1f86c3e651c5a2

Remi NGUYEN VAN   commited 2021-07-05 14:18:27 +09:00
aeb54b3cf8
Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
Replace all FIRST_SDK_INT usage in Connectivity because it has
been renamed to DEVICE_INITIAL_SDK_INT.

Bug: 184735771
Test: m CtsNetTestCases
Merged-In: I2f155592b08cdbf259a00b035cacb37ca9847e72
(clean cherry-pick)

Change-Id: I2f155592b08cdbf259a00b035cacb37ca9847e72

paulhu   authored and   Remi NGUYEN VAN   commited 2021-07-05 14:18:26 +09:00
bee1c6d9cd
Merge "Move BitUtils, RingBuffer test to coretests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-07-05 05:05:34 +00:00
6be4ebcb0a
Merge "Add tests for in-kernel VPN/VCN dataplane"
Benedict Wong   authored and   Gerrit Code Review   commited 2021-07-02 18:42:15 +00:00
64619cabc1
Merge "Listen EXTERNAL_APPLICATIONS_AVAILABLE intent"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-02 16:56:12 +00:00
321558ffe8
Listen EXTERNAL_APPLICATIONS_AVAILABLE intent
- Some applications are installed on external storage and they
  are unavailable until exernal storage installed them
  completely. And their permission need update after becoming
  available. Thus, listen EXTERNAL_APPLICATIONS_AVAILABLE intent
  and update those package whose is listed in chaged package
  list.
- Remove user argument on buildPackageInfo() because the uid on
  ApplicationInfo is based uid.

Bug: 145234989
Test: atest FrameworksNetTests
Merged-In: Ia11ca4a7ba6fc1b87c27c0c40e36c91d9cdb322a

Change-Id: Ia11ca4a7ba6fc1b87c27c0c40e36c91d9cdb322a

paulhu   commited 2021-07-02 22:35:26 +08:00
8a4ce40acb
Merge "Force only system uid can set uids allowed on restricted networks"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-02 13:52:50 +00:00
47202851ec
Merge "Allow non-VPNs to have underlying networks."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-07-02 13:28:01 +00:00
5903d5646c
Force only system uid can set uids allowed on restricted networks
- Check whether calling UID/PID is system_server.
- For CTS test, enforce NETWORK_SETTINGS permission otherwise if
  it's a debug build.

Bug: 175199465
Test: atest FrameworksNetTests
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestrictedNetworks
Merged-In: I175a831671d3e52460d28203b09f6c0dda56b61c

Change-Id: I175a831671d3e52460d28203b09f6c0dda56b61c

paulhu   commited 2021-07-02 20:04:50 +08:00
92f128c51c
Allow non-VPNs to have underlying networks.
Certain network types, like the VCN, have underlying
networks for the purpose of data usage, but do not want to
propagate the underlying network capabilities.

Allow these networks to set underlying networks, but continue
not to propagate the capabilities.

Bug: 190620024
Test: new unit test
Change-Id: I53d6080f48707ff3c37fbfbef534284ba77a7432

Lorenzo Colitti   commited 2021-07-02 18:48:25 +09:00
bd079455f1
Add tests for in-kernel VPN/VCN dataplane
This change adds relevant tests for the migrateTun functionality in
NetworkStats.

Bug: 190620024
Test: atest NetworkStatsTest
Change-Id: I33f14f2d0f71013a594fd4c8c3914a590d30ea06

Benedict Wong   commited 2021-07-02 00:39:32 -07:00
1117e853f9