Commit Graph

1238 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
e57ae65216 Remove @Nullable from byte
Primitive types can't be null.

Change-Id: Idc2a30b1faae69213bc3bd7262f72d4ec23e1c40
Test: m
2022-10-31 08:01:30 +00:00
Chiachang Wang
97d0f3a563 Merge "Add debug log in ensureWifiConnected" 2022-10-31 01:38:57 +00:00
chiachangwang
b5e9e3fc2b Add debug log in ensureWifiConnected
It's sometimes not clear that tests call ensureWifiConnected
but no wifi enabled. It's hard to clarify design with wifi
stack, so add the gotten wifi info in the log to help on
debugging.

Bug: 252869312
Test: atest CtsNetTestCases
Change-Id: I3bc74dd38dd5a36a93510fc5d70c0fa00b66e842
2022-10-28 01:13:40 +00:00
Maciej Żenczykowski
4bc5fd7ad3 Merge "trivialize SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED" 2022-10-26 23:08:16 +00:00
Treehugger Robot
9c549c0d53 Merge "Fix errorprone warnings that should be errors" 2022-10-26 21:09:23 +00:00
Maciej Żenczykowski
203d5e0dcd trivialize SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED
Bug: 255652639
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3732bbd7ad9e4e06c914206560268bd1ce8204f4
2022-10-26 03:05:32 +00:00
Paul Hu
281e7a2587 Merge "Add ByteUtils for byte utility functions" 2022-10-26 01:05:55 +00:00
Chris Sabotta
87e48d453e Merge "Bug: b/255652639" 2022-10-25 23:40:44 +00:00
Chris Sabotta
33f1f3f74c Bug: b/255652639
Revert "remove SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED"

This reverts commit 319d8468ad90d33307ce764e7f6130587ce81419.

Reason for revert: Build breakage, (First bad build: 9217822)

Change-Id: I0db2bdb68006f9379bb149f7de9fa81ace501c3d
2022-10-25 23:38:32 +00:00
Maciej Żenczykowski
713c112d23 Merge "remove SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED" 2022-10-25 22:10:11 +00:00
Maciej Żenczykowski
5897a805ea remove SKIP_IF_BPF_SUPPORTED
as this does not appear to be used anywhere anymore

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6905c6fdb4daf48df07e758481368d441637ad13
2022-10-25 09:27:08 +00:00
Maciej Żenczykowski
52605df5fd remove SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED
as this does not appear to be used anywhere anymore

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I95939b0b6c66f41f776ca31ea7178bb30241b81f
2022-10-25 09:24:59 +00:00
Paul Hu
528e675fdd Add ByteUtils for byte utility functions
Bug: 254155029
Test: atest NetworkStaticLibTests
Change-Id: I996ead6f23698313828e844672de5917efdfce69
2022-10-25 05:40:00 +00:00
Chalard Jean
0eac837b01 [CC08] Remove expectCallback*
These methods have been migrated to the shorter and better
provisioned expect<> family of methods.

Test: Builds
Change-Id: I60c77bfeabe373557d61f0f8d0295b385fe5271e
2022-10-24 18:54:46 +09:00
Chalard Jean
6f8bcae7d0 [CC07] Add build tests for expect* versions
Also address some comments left on a previous patchset.

Test: NetworkStaticLibTests
Change-Id: I3ea16bb54aec31ddb0368af980483109a1bdb49b
2022-10-24 18:54:45 +09:00
Jean Chalard
041f81ec85 Merge "[CC06] Move usage of expectCallback* to expect" 2022-10-24 04:22:18 +00:00
Treehugger Robot
9e4d8a3221 Merge "Disallow pre-T use of userspace writable bpf map arrays with more than 1 element." 2022-10-21 03:58:21 +00:00
Chalard Jean
3ad176b03a [CC06] Move usage of expectCallback* to expect
See CC03 (aosp/2255619) for details

Test: NettworkStaticLibTests
Change-Id: Id15560f5744024ff2ac2acbaf4de83818ce6efc5
2022-10-21 11:53:13 +09:00
Jean Chalard
ca89fc43a8 Merge "Increase the timeout for eventuallyExpect" 2022-10-21 02:51:11 +00:00
Maciej Żenczykowski
6f9830c342 Disallow pre-T use of userspace writable bpf map arrays with more than 1 element.
Bug: 254543135
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I11ea5edaebf08f3492ad79f059afa98b50f80df3
2022-10-21 00:04:03 +00:00
Chalard Jean
347dd8ded4 Increase the timeout for eventuallyExpect
Sometimes the tests are run under high load, e.g. immediately
after boot while all apps that listen for the boot completed
broadcast run their listeners. Under these circumstances,
40ms of leeway is tight ; on recent Android devices HZ is
commonly 100 too, meaning a general time unit of 60 will give
a little bit of air.

The drawback in this is that the test is less stringent on
TrackRecord, which as a multi-thread primitive should have
really tight tests to make sure that a non-threading primitive
(e.g. a polling implementation) doesn't pass. This patch makes
the testing on that front a little bit less reliable.

Note that this patch won't actually fix all flakes in that it
isn't really possible to guarantee the device will have any
CPU time to run the test at all anyway, but this should make
most failures go away.

Also, the argument for the time unit is never used, and can
be removed ; at least, the possibility of the timeArg() func
not using the same value as the sleep directive is scary, so
that possibility should be removed. If the time unit argument
is ever needed it can be added back, but considering the arg
has been available for years and never used, it's unlikely.

Test: NetworkStaticLibTests
Fixes: 254188131
Change-Id: Ia7a4fe775942484dcd7dc223c7710e82a8329beb
2022-10-20 16:42:16 +09:00
Maciej Żenczykowski
dd3fe1d750 add DEFINE_BPF_MAP_RO for output maps which userspace should never modify
Bug: 254543135
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I94c5e68e8941a264ea3671f75e3ad9c37ded8894
2022-10-20 04:06:37 +00:00
Chalard Jean
f79ca2809a [CC04] Have TestNetworkTracker implement HasNetwork
This already has all necessary methods, it only needs to
declare it implements the interface.

Test: ConnectivityServiceTest
Change-Id: I8de643f2b8de9765c25c3efe934c94549f341a51
2022-10-19 15:46:35 +09:00
Chalard Jean
b7e2284acf [CC03] Replace expectCallback* with expect
"callback" is redundant – it's a TestCallback object and
it takes a type of callback anyway.

"assertNextIs" is shorter than expectCallback, and more
directly explicit than "expect", but it's also 3 words
and very different from previous usage.
Using expect() is a little bit less in-your-face obvious,
but it's simple, familiar, and short.

Test: CtsNetTestCases
      FrameworksNetIntegrationTests
      FrameworksNetTests
      NetworkStackTests
Bug: 157405399
Change-Id: I6c8c85a8be3895dd8f0ef681faa4a8b2b4f2f493
2022-10-18 20:18:46 +09:00
Chalard Jean
70c62e594a [CC01] Remove the confusing pollForNextCallback
In Java, "poll" methods return null when the collection is
empty. Respect this convention.

Bug: 157405399
Test: FrameworksNetTests
Change-Id: I3b17908f9ce1f60b18908605a645da3199c010b9
2022-10-17 14:51:53 +09:00
Cole Faust
f4dd77109e Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I772563b5e54b468a755520d2ed9b78bcb5fc3ad6
2022-10-15 21:33:31 -07:00
Jean Chalard
4152f83b27 Merge "Move bit utility methods to a new BitUtils class." 2022-10-14 04:55:25 +00:00
Chalard Jean
5c6f7809e2 Save one minute in executing NetworkStaticLibTests
The default timeout for expectEventually is 30 seconds, so this
test used to take one minute. With this change, it now only takes
50ms, with virtually no change in safety.

Test: NetworkStaticLibTests
Change-Id: Id8d6a738ea6a70f7d901a7659b2160c2f3d7d2c0
2022-10-13 16:41:29 +09:00
Chalard Jean
cd0fc3d71b Move TestableNetworkCallbackTest to f/l/n
This tests a utility in f/l/n, so it should live together with
it and not in the network stack tests

Test: NetworkStaticLibTests NetworkStackTests
Change-Id: I90d12933e3a82eba4b565022d3df1e7c1d503f56
2022-10-13 16:41:28 +09:00
chiachangwang
8d65699533 Correct failed log in ensureWifiConnected()
The timeout is used in the test should be WIFI_CONNECT_TIMEOUT_MS
but log shows WIFI_CONNECT_INTERVAL_MS instead. The debug log is
confusing. Correct it to right variable.

Test: atest CtsNetTestCases
Change-Id: I4cedaa6e03aea6cc02a07bdbea2f0b1e7f5076e1
2022-10-12 14:14:49 +00:00
Chalard Jean
2ecf120256 Move bit utility methods to a new BitUtils class.
In particular this moves NetworkCapabilies#
appendStringRepresentationOfBitMaskToStringBuilder to this
class. It also moves some other NetworkCapabilitiesUtils
methods that are better homed in this new class.

Test: new test in this patch
Change-Id: I16374d7ca1da92052bb814bde796602d62f5c42e
2022-10-12 20:31:20 +09:00
Maciej Żenczykowski
45b9d2d0f9 Merge "add bpf_for_each_map_elem() helper definition" 2022-10-07 19:45:57 +00:00
Paul Hu
561b97e711 Enlarge the TestableNetworkCallback default timeout
TestableNetworkCallback is using on both unit and cts tests with
same timeout 200ms. For unit tests, most of objects are mock, so
the callback should respond quickly and this interval is fine.
But for cts tests, they are running on the real system and the
callback time will depend on the system which may be over 200 ms
sometimes if the system is busy or has performance problems. So
enlarge the Network Callback default timeout to 500ms that can
reduce the test flake on cts tests. To ensure there is no impact
on no callback check, add the no callback timeout 200ms which is
the same timeout as before.

Bug: 245000567
Test: Run the FrameworksNetTests CtsNetTestCases and check
      no running time increase.
Change-Id: I31f8bc08f65a622f6ab9b6c7f0577f0b107440c1
2022-10-04 07:05:14 +00:00
Maciej Żenczykowski
c5dcf2c8ea add bpf_for_each_map_elem() helper definition
See 5.12+ kernel's include/uapi/linux/bpf.h

(note that since bpf is 64-bit, int and long are the same thing)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib340a619645ad5ab8e41ff76cb7b51671f496bc5
2022-09-27 23:14:51 +00:00
Junyu Lai
e766a09b79 Merge "[ST02] Add methods for synthesizing DNS packets" 2022-09-22 02:39:42 +00:00
Nucca Chen
48a33adc7b Merge changes from topic "test-tethering-icmp"
* changes:
  IpUtils: add ICMP checksum calculation function
  NetworkStackConstants: add ICMP checksum offset constant
2022-09-19 15:53:43 +00:00
Hungming Chen
0aa70a0973 IpUtils: add ICMP checksum calculation function
Bug: 237369591
Test: NetworkStaticLibTests
Change-Id: If45de190872cad588f9b9104828a0d8116fc158b
2022-09-19 15:34:33 +08:00
Hungming Chen
6573c64f39 NetworkStackConstants: add ICMP checksum offset constant
Bug: 237369591
Test: NetworkStaticLibTests
Change-Id: I7175c9ae3c547639fcfe2e252dad591ad2c3ec8a
2022-09-19 15:34:28 +08:00
Junyu Lai
85e24e85b2 [ST02] Add methods for synthesizing DNS packets
This re-submit aosp/1387135 but define TYPE_CNAME locally to
prevent from using non-finalize API.

Bug: 139774492
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.DnsPacketUtilsTest

Change-Id: Ib2e98292be994ca09845c6857b8884f9bcdaba80
2022-09-16 15:40:01 +08:00
Maciej Żenczykowski
1bff3fb28f NetlinkSocketTest.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

(apparently this field is never accessed, as the test only looks at family)

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I879c1637a87587b7bc1c13013ea9c5e655c141eb
2022-09-16 06:37:44 +00:00
Motomu Utsumi
1eb3792251 Add BpfDump#dumpMapStatus
Test: atest NetworkStaticLibTests
Change-Id: I77d397b16380a397573cc528fe7f15f381cda21f
2022-09-12 19:08:31 +09:00
Motomu Utsumi
9f732331a4 Merge "Add idiag_sock_id to InetDiagMessage class" 2022-09-10 02:02:11 +00:00
Anton Hansson
2464a31bf8 Merge "Revert "[ST02] Add methods for synthesizing DNS packets"" 2022-09-09 07:58:06 +00:00
Nandu Suram
8d88f8bb36 include ats target
fixes: 244138449

include ats target

Change-Id: I462b13a5b1332c8afdf46761f1cbad545e7cf291
2022-09-08 23:00:44 +00:00
Remi NGUYEN VAN
f53c488b93 Revert "[ST02] Add methods for synthesizing DNS packets"
Revert "[ST02.1] Add TYPE_CNAME constant to DnsResolver"

Revert submission 1387135-st02

Reason for revert: Usage of TYPE_CNAME in a library shared among
modules does not interact well with current module release process

Reverted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets

Change-Id: I9f8de47c9ba9fb4db7cf3695966f222f68a9a290
2022-09-08 11:01:05 +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
Motomu Utsumi
ea0fcc94ec Add idiag_sock_id to InetDiagMessage class
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I9dc5b1d5b2d3da9ab21ce92b3f88d3f9d4d842f1
2022-09-05 21:59: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