Commit Graph

2937 Commits

Author SHA1 Message Date
Nandu Suram
8d88f8bb36 include ats target
fixes: 244138449

include ats target

Change-Id: I462b13a5b1332c8afdf46761f1cbad545e7cf291
2022-09-08 23:00:44 +00:00
Junyu Lai
5e53d5390c Merge "[ST02] Add methods for synthesizing DNS packets" 2022-09-07 02:25:41 +00:00
Chalard Jean
e301436409 Introduce getResIntegerConfig
This is a symmetric to getResBooleanConfig for integers.

Test: new test in this patch
Change-Id: I36cb910acb59c3211ba2c77dd3784fefa93545d9
2022-09-06 11:23:25 +09:00
junyulai
96c4750d59 [ST02] Add methods for synthesizing DNS packets
Bug: 139774492
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.DnsPacketUtilsTest
Change-Id: I0c1547cbc1e7295e9a3dcb0f553065356b05bd7c
2022-09-05 10:16:24 +08:00
Jean Chalard
df8292c805 Merge "Add CollectionUtils.contains with predicate" 2022-09-03 03:27:03 +00:00
Jean Chalard
a804f3fc1e Merge changes I506872f7,I0afb6513
* changes:
  Improve documentation for the concurrent interpreter
  Fix a flake due to uncertainties in time measurement
2022-09-01 03:01:40 +00:00
Chalard Jean
debdc78518 Add CollectionUtils.contains with predicate
Test: included in this patch
Change-Id: Id10c8878a8e7fe59fa2d7858212e4c01d4de1ca4
2022-08-31 15:55:20 +09:00
Motomu Utsumi
3113f36a89 Merge changes from topic "TestBpfMap_implements_IBpfMap"
* changes:
  Add BpfDump#dumpMap
  TestBpfMap implements IBpfMap instead of extends BpfMap
2022-08-31 03:54:28 +00:00
Chalard Jean
9df957f803 Improve documentation for the concurrent interpreter
Test: comment-only change
Change-Id: I506872f7ff83b8c99527ff593eecc8fdc6760b53
2022-08-30 18:32:54 +09:00
Chalard Jean
6f469c8e9d Fix a flake due to uncertainties in time measurement
The concurrent interpreter supports a `time` directive that
lets testers ensure some instruction has taken at least some
amount of time. This is useful when testing that some
callback didn't arrive before it was sent, for example.

Unfortunately, there is some unavoidable uncertainty in how
time is measured. Because the thread that measures time
needs a very small amount of time before it starts measuring
the time taken by its instruction, it is possible that the
time that is intended to be measured actually took X, but
because the measuring thread took Ɛ before it started
measuring time, the measured time is X - Ɛ, which may fail
the test because it didn't take enough time.

Because there is no way at all to know how much time passed
between the measuring thread being woken up and it measuring
start time, it's not possible to fix this as long as the
measure for the minimum time is taken after the wait. So
instead, take the measure before the wait.

It's always technically possible that there is a bug where
the code doesn't take enough time, but the test doesn't
catch it because the device happened to run slowly as it
ran the test (e.g. other stuff running at the same time),
and this patch makes it a little worse – there will be more
true negatives, but this is the only way to ensure no false
positives and it should still catch the "too fast" cases
most of the time.

Now, each thread has its own "blocked" time. It would be
possible to store that time in a local and pass it down to
all instructions, but that would require all instructions
to take the blocked time as an argument, while only the
`time` instruction can have any meaningful use of it.
Therefore, store it in a thread local instead of adding an
argument to all instructions for all interpreters.

Test: atest --iterations 100 'TestableNetworkCallbackTest#testPollForNextCallback'
      ...although I can't get it to fail locally, so the
      proof will be in a dying out of the flakes.
      Also checked that increasing the minimum time on an
      existing test does fail as expected
Bug: 185735163
Change-Id: I0afb651337a8b10a864cc5bc793d65d2ce56ab20
2022-08-30 18:32:52 +09:00
Ryan Prichard
dcaec67bb9 Merge "Switch from std::result_of to std::invoke_result" 2022-08-29 23:11:53 +00:00
Ryan Prichard
8cbe32c501 Switch from std::result_of to std::invoke_result
std::result_of is deprecated in C++17 and removed in C++20.
std::invoke_result is added in C++17.

Upstream libc++ has started removing the declaration of std::result_of
when a new-enough C++ dialect is selected, so switch to the supported
type.

Bug: http://b/175635923
Test: treehugger
Change-Id: Ie2db3e092b4300e20858097ac4e88ebaedc7ae07
2022-08-26 20:31:55 -07:00
Motomu Utsumi
3becbd22dc Add BpfDump#dumpMap
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I7b0a949e667da4120cc20d8587019bfb0f922584
2022-08-25 18:34:22 +09:00
Motomu Utsumi
3d835e9a8e TestBpfMap implements IBpfMap instead of extends BpfMap
Bug: 217624062
Test: m, atest BpfCoordinatorTest BpfNetMapsTest
Change-Id: I41153a569d79031f0841432c6e83bef2170a33e4
2022-08-25 11:01:25 +09:00
Motomu Utsumi
fdfaa30146 Merge "Support StructInetDiagSockId parse" 2022-08-24 11:45:53 +00:00
Jean Chalard
8f31efb89c Merge "Add findFirst and findLast to CollectionsUtils" 2022-08-24 09:51:36 +00:00
Motomu Utsumi
56fa997164 Merge "Add test for StructInetDiagSockId" 2022-08-24 09:39:04 +00:00
Remi NGUYEN VAN
f3a6a1bbdf Merge "Check that cell network is available before tests" 2022-08-24 04:21:22 +00:00
Motomu Utsumi
dfe4251427 Merge "Add fromBase64EncodedString to BpfDump" 2022-08-24 03:16:53 +00:00
Treehugger Robot
3c024b6fcd Merge "RESTRICT AUTOMERGE - [Bluetooth apex] Use new apex name" 2022-08-23 19:04:07 +00:00
Treehugger Robot
eecde2bc87 Merge "Add getter to PerUidCounter" 2022-08-23 18:25:03 +00:00
William Escande
fbe576b383 RESTRICT AUTOMERGE - [Bluetooth apex] Use new apex name
The Bluetooth apex name is now called com.android.btservices

Bug: 243054261
Test: Build
Change-Id: I38caf03e134d9623ee73fa5b7f742d5ebbafeaa1
2022-08-23 17:29:59 +00:00
Motomu Utsumi
556667ef02 Support StructInetDiagSockId parse
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: If42436459874d4c61037a98db18c43b40eb81066
2022-08-23 12:42:12 +09:00
Jean Chalard
f80c3ad69e Merge "Add Function3" 2022-08-23 03:13:12 +00:00
Motomu Utsumi
fbc3280c79 Add test for StructInetDiagSockId
Upcoming CL will modify StructInetDiagSockId.
So, as a preparation, this CL adds test for existing behavior of
StructInetDiagSockId.

Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ef475bec050ba2689a8df6182be36a6fccd9bfb
2022-08-23 11:56:11 +09:00
Cole Faust
acb83d2339 Merge "Add CollectionUtils.indexOfSubArray()" 2022-08-22 22:42:59 +00:00
Cole Faust
ad9456d322 Merge "Fix array-related errorprone warnings" 2022-08-22 04:13:30 +00:00
Remi NGUYEN VAN
da0e172551 Check that cell network is available before tests
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
2022-08-22 11:15:49 +09:00
Cole Faust
0d8bd9005d Add CollectionUtils.indexOfSubArray()
This is useful as an array version of Collections.indexOfSubList().

Bug: 242630963
Test: atest NetworkStaticLibTests
Change-Id: I36724791ceece1348826a51cb2a975e169dfecc6
2022-08-22 09:17:29 +09:00
Motomu Utsumi
4dcf00e78c Add fromBase64EncodedString to BpfDump
EthernetTetheringTest has parseMapKeyValue that decodes the string
encoded by BpfDump#toBase64EncodedString
Upcoming CL also wants to decode the encoded string.
So this CL renames parseMapKeyValue to fromBase64EncodedString and moves
to BpfDump with refactoring

Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ec302aaaa3e8779119cf153567cb032828f5daf
2022-08-18 12:38:24 +09:00
Maciej Żenczykowski
8a8bd3734f create Struct.S32
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7bddfec540ba0f7c9b842d4c5ec0c9402eedc72a
2022-08-17 15:21:25 +00:00
Junyu Lai
c0a6d524eb Add getter to PerUidCounter
This is needed by ConnectivityServiceTest, refer to the
counter part CL in the module git.

This CL also fix guarded by annotation and remove the
increment/decrement method with count methods, which
is not very useful.

Test: TH
Bug: 235771502
Change-Id: Iaab681bf456e14afb4c6ddf700eb3308abead35f
2022-08-17 14:17:42 +08:00
Chalard Jean
cc5f01c610 Add findFirst and findLast to CollectionsUtils
Test: new tests in this patch
Change-Id: Ie13ee7f50832ffec1febe4f4596d0b26e4c4a2f6
2022-08-17 01:44:13 +00:00
Chalard Jean
a19f85124e Add Function3
...and rename ExceptionUtils to FunctionalUtils as the old name
would no longer be appropriate.

Test: FrameworksNetTests
Change-Id: I2affd69fb84d7f250b4a45497eec6c052bf6ec50
2022-08-16 18:53:17 +09:00
Cole Faust
0e5b5d856b Fix array-related errorprone warnings
The ArrayEquals, ArrayHashCode, ArrayToString, and
ArraysAsListPrimitiveArray errorprone findings were
demoted from errors to warnings. Fix existing
occurrences of them so they can be made errors again.

Bug: 242630963
Test: RUN_ERROR_PRONE=true m javac-check
Change-Id: I6132205b0e86e3ec73c78d54ce2a8c334b81c5ed
2022-08-15 18:41:10 -07:00
Xiao Ma
1ccec63237 Merge "Move NetworkMonitorUtils to net-utils-device-common lib." am: 43cfbc9c59
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2154500

Change-Id: I48536961bf5bc62ec006b26f7e73126a316cf2ed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-12 09:24:39 +00:00
Xiao Ma
12c8e96276 Merge "Move NetworkMonitorUtils to net-utils-device-common lib." 2022-08-12 09:06:58 +00:00
Maciej Żenczykowski
beb75c8ffd fix wrong bpf path am: f979c8a094
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2181835

Change-Id: I1804b2f4f5a6dcbbd6949c15b46693f6d580eb96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-11 07:34:08 +00:00
Maciej Żenczykowski
af0ae6785f fix wrong bpf path
(also note the program in p/m/C netd.C is not optional or kernel version dependent)

Bug: 237030932
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia984f6a1ce0ab14a204fe47ec295db1363879b7b
2022-08-10 18:22:40 +00:00
Xiao Ma
1453c7c74a Move NetworkMonitorUtils to net-utils-device-common lib.
Move the NetworkMonitorUtils class from NetworkStack module to
frameworks/libs/net, then we can remove the filegroups defined
in NetworkStack module which are shared with Connectivity module.
Import the net-utils-device-common lib instead.

Update the NetworkMonitorUtils#isValidationRequired() first param type
to make the migration easier, change the NetworkAgentConfigShim type
param to boolean, which can be passed by the caller directly such as in
ConnectivityServiceTest or NetworkMonitor, then we don't need to add
static lib to support NetworkAgentConfigShim, not easy to support.

Bug: 238960524
Test: m
Change-Id: I72dfb5902dea0e7ddb2c33a08f874fe36adcbeec
2022-08-05 14:29:11 +09:00
Lorenzo Colitti
257cac20f8 Randomize the prefix used by RouterAdvertisementResponder. am: 6ab502437e
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2173507

Change-Id: Iae3ccaf7156f3541b8804258d5321fe4f504da4a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-04 06:20:23 +00:00
Lorenzo Colitti
0b3378b7d4 Randomize the prefix used by RouterAdvertisementResponder.
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
2022-08-03 17:24:11 +09:00
Remi NGUYEN VAN
bb4be844f7 Merge "Add CtsNetTestCasesMaxTargetSdk30" am: 5142f27f7a
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2159059

Change-Id: I4c7d1bea6934c0a36f3afc89b325288b4ab318b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 08:41:54 +00:00
Remi NGUYEN VAN
1ea7347343 Merge "Add CtsNetTestCasesMaxTargetSdk30" 2022-07-29 08:09:54 +00:00
Patrick Rohr
a888b572c2 RaResponder: log instead of throw exception am: 12eeb3939b
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2168407

Change-Id: I47b04ff1f405838427b3217ddf83b7e02e86fc85
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 04:02:18 +00:00
Patrick Rohr
41a1ead4c0 PacketResponder: stop should wait for thread to join am: d3f5b7328a
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2168406

Change-Id: Id2fed765d907df481815e7ada133e03ba7c7d3a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 04:02:16 +00:00
Patrick Rohr
4a76563701 RaResponder: log instead of throw exception
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
2022-07-28 15:50:50 -07:00
Patrick Rohr
a5500c6d05 PacketResponder: stop should wait for thread to join
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
2022-07-28 15:50:50 -07:00
Treehugger Robot
ca24b7e0c4 Merge "Add struct Icmpv4Header class to parse icmpv4 header from a packet" am: fe738d1933
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/2164003

Change-Id: I4b3f02f4fc048b430eb2e91f34ad613a5c32dff6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-26 16:03:36 +00:00
Treehugger Robot
7174d9d82c Merge "Add struct Icmpv4Header class to parse icmpv4 header from a packet" 2022-07-26 15:37:58 +00:00