Commit graph android_packages_modules_Co.../tests/native
Message SHA1
KernelUtils.h: isAtLeastKernelVersion(x,y,z) - default 'z' to 0
This seems to be the most common usecase.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2de4d067b2f20680539cbddb31555864bcf957b1

Maciej Żenczykowski   commited 2025-09-12 10:14:12 -07:00
ee24054e2b
BpfMap.h: introduce BpfMapRW
which allows writes, but not deletes.

This is technically what bpf map arrays are capable of.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1f73bea5428c190af17442539c296282ce9e0786

Maciej Żenczykowski   commited 2025-08-09 16:03:46 -07:00
8b96286200
Remove unused libprocessgroup dependency
Test: mmma packages/modules/Connectivity/
Change-Id: Ie4b2ee5834617a126c30322a76b905bf21cab949

T.J. Mercier   commited 2025-01-17 11:20:39 -08:00
b42fdfc285
Fix dependencies on connectivity_native lib
Address the TODO to link against the library directly, and add necessary
test filters to only run the test on the primary ABI (because the
library in the apex has only one variant for primary ABI), and to only
run the test on U+.

Bug: 356022894
Test: atest
Change-Id: Ib52bfc1051059aaf9d14d1f7707864206d0bdcd9

Remi NGUYEN VAN   commited 2024-07-31 00:39:50 +00:00
fba7850552
Use compile_multilib: "both" for MTS
Ensure MTS modules are compiled with both 32 and 64 bit ABI, as MTS
attempts to run both.

Recent changes have started failing tests when one of the ABI is
missing, see change ID: I5310ca67879534cb066dcedf6a9102a39e085faf

Test: atest bpf_existence_test -- --abi armeabi-v7a
Fixes: 352592958
Fixes: 354070942
Change-Id: Iea494323ccc12710bff6d488f2b51b13255d841e

Remi NGUYEN VAN   commited 2024-07-19 19:26:15 +09:00
e93822153f
Add BPF_MAP_LOCKLESS_FOR_TEST hack for root resolver tests
Per commit description of https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/3109108 "Use SingleWriterBpfMap in BpfNetMaps":

- firewall.cpp writes to sConfigurationMap, sUidOwnerMap, and
  sDataSaverEnabledMap, but that code only runs in tests because
  it requires root privileges.

So either those maps need to not use SingleWriterBpfMap
in the BpfNetMaps (which would affect performance),
or we need to prevent the tests from grabbing the locks,
or the tests will (presumably) fail.

This avoids grabbing the locks from the test, even though
this is absolutely terrible and likely breaks things...
But in general the entire firewall.cpp file (and libconnectivity_native_test_utils target) are just one
large modularization violation in need of major escalation...

Test via:
  atest resolv_{gold,stress,integration,unit}_test

Without this patch:
  resolv_gold_test: Passed: 16
  resolv_integration_test: Passed: 53, Failed: 2, Ignored: 118, Assumption Failed: 0 (Completed With ERRORS)
  resolv_stress_test: Passed: 2
  resolv_unit_test: Passed: 124, Failed: 2

  4 tests failed
  --------------
  ResolverMultinetworkTest#DnsWithVpn
  PrivateDns/TransportParameterizedTest#BlockDnsQuery/DoT
  CallbackTest#tagSocketCallback
  ResolvGetAddrInfoTest#InvalidParameters

With this patch:
  resolv_gold_test: Passed: 16
  resolv_integration_test: Passed: 178
  resolv_stress_test: Passed: 2
  resolv_unit_test: Passed: 126

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie97d015ef66c3864a23484e7ed190fe7d091af5c

Maciej Żenczykowski   commited 2024-06-14 17:35:29 -07:00
04fb3862a9
Build mainline tests with static libc++ and version script
Bug: 341216801
Test: bpf_existence_test connectivity_native_test
Change-Id: Ib1ad48902472fcf2fbfad3012426f9fd6a5102f6

Ryan Prichard   commited 2024-05-20 17:00:24 -07:00
3ae062d8d6
eliminate some casts
follow up to http://aosp/2965923 to hopefully eliminate
that class of bug in the future...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie09db001ff15a6b2b15bb1bb0c1ce8228e162337

Maciej Żenczykowski   commited 2024-02-16 18:20:55 +00:00
d7ade39c0c
Merge "Use uint_32 for UidOwnerMatchType" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-02-16 05:26:31 +00:00
17dd9e9fa8
Use uint_32 for UidOwnerMatchType
The enum is already using 12 bits, so using fewer bits loses information.
This is in sync with the UidOwnerValue struct used to contain this data.

Test: atest resolv_integration_test
Test: atest resolv_unit_test

Bug: 325150155
Change-Id: Ide0ccea9614cda803b3700a0cc22977e9608209e

Suprabh Shukla   commited 2024-02-15 12:54:48 -08:00
c806db20f7
libconnectivity_native_test_utils: limit visibility
Bug: 324338494
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ied391f3366c87ffb1010ec6e5ece6604a72a7c9b

Maciej Żenczykowski   commited 2024-02-08 04:41:38 +00:00
8e110739c0
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
connectivity_native_test: fix skip message typo
(and adjust indents to be saner)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2e52131fa51782dc89ddbfda4c9239a142376c56

Maciej Żenczykowski   commited 2024-01-18 18:53:32 +00:00
254b52c0eb
Update to fmtlib 10.1.1
fmtlib 10+ removes the automatic formatting
of enum classes to the underlying class, requesting
that a custom formatter be provided for the type.

Normally fmt::underlying could be used to convert
the enum value to its backing type, but this change
automerges to udc-mainline-prod where the helper does
not exist.

Bug: 310046696
Test: m
Change-Id: I62f3a66dd2f8e3d288dc4c0298d4f3bfa57a6a71

Henri Chataing   commited 2023-11-10 01:53:03 +00:00
9007cca051
[Test] Fix DNS resolver MTS failures
In MTS, test infra installs only the DNS resolver module without
installing tethering module. The test utils should not assume the BPF
maps defined in tethering will be in the device.

Bug: 309164580
Test: atest
resolv_integration_test:ResolverTest#BlockDnsQueryWithUidRule

Change-Id: I2c7349a11c9b413c129c93d236c8280588097cf7

Ken Chen   commited 2023-11-04 16:10:34 +08:00
90e009be6c
Add Data Saver utils in Firewall test helper class
Resolv_integration_test needs the function to toggle Data Saver settings
in BPF map.

Bug: 288340533
Test: atest resolv_integration_test
Change-Id: I1725d3c8c6fc641b855c935d7289a99f78dd5933

Ken Chen   commited 2023-11-01 06:23:09 +08:00
5b144a1061
Move OWNER reference master=>main.
BUG=b/291759353

Change-Id: Iad1bae21b54ae1ed192960da9fd8b831709a2f87

Sam Saccone   commited 2023-07-18 17:12:49 +00:00
fbfe27b641
Set test component in common OWNERS
Move the test component configuration from subdirectories
to the common OWNERS file. This ensures that all test directories
like unit/ that did not have the component set are covered.

Bug: 288137916
Change-Id: I48fbe846309cace41588c5ff3dfd46e878c38576
Test: TH

Remi NGUYEN VAN   commited 2023-06-21 02:54:13 +00:00
64020abf11
wire bpf_base_test into netd_updatable_unit_test
The 3 pre-existing //system/netd tests are:
  TEST_F(BpfBasicTest, TestCgroupMounted)
  TEST_F(BpfBasicTest, TestTagSocket)
  TEST_F(BpfBasicTest, TestCloseSocketWithoutUntag)
which are directly related to BpfHandler.cpp implementation,
as it implements:
  Status BpfHandler::init(const char* cg2_path)
  BpfHandler::tagSocket()
  BpfHandler::untagSocket()

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c01ae90904faaea54b427495c7a5deab8b1b900

Maciej Żenczykowski   commited 2022-12-20 00:41:05 +00:00
70d30ec49d
Merge "remove TestTrafficControllerSetUp & TestSocketFilterSetUp"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-12-19 18:46:08 +00:00
9aa2315be1
remove TestTrafficControllerSetUp & TestSocketFilterSetUp
This is (as yet) dead code copied over from //system/netd,
but not yet plumbed into any p/m/C Android.bp file/test.

Update the bpf_shared.h include to netd.h now that that has been
renamed, see:
  https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/2335387

MTS test bpf_existence_test.cpp already does a better job
of testing for bpf program/map existence, see
  MAINLINE_FOR_T_PLUS
  MAINLINE_FOR_T_4_14_PLUS

Test: N/A, this file is not yet compiled
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2ccfd86e352118f6f76e91ec20e10a9285414490

Maciej Żenczykowski   commited 2022-12-18 20:30:32 +00:00
3b67343ddb
rename bpf_shared.h to netd.h
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2e1569c8d70e98f9a3fdbab41fd2ba7f7b84dd37

Maciej Żenczykowski   commited 2022-12-18 20:02:52 +00:00
513474c1a7
copy in bpf_base_test.cpp from system/netd
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1bf320f838c7cc203dd72bc5b48aee92288bbb81

Maciej Żenczykowski   commited 2022-12-15 22:16:09 +00:00
438e4a8526
Add libconnectivity_native
The library provides an interface to interface with the
ConnectivityNative service, and implement port blocking APIs.

Bug: 179733303
Test: atest connectivity_native_test
Change-Id: Iad1c84b5eeab835aca14a2db72a900e099aa3c1c

Remi NGUYEN VAN   authored and   Tyler Wear   commited 2022-11-03 21:01:26 -07:00
fb70eba6bf
[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity
Added SPDX-license-identifier-Apache-2.0 to:
  tests/native/utilities/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: Ic5fd53821753249f6331d482d253e825e338f74e

Bob Badour   commited 2022-08-04 12:11:35 -07:00
a186cbc446
Add libconnectivity_native_test_utils
The utility currently contains a firewall class that is used by DNS
resolver tests to block DNS packets.

Bug: 227159929
Test: atest resolv_integration_test
Change-Id: I5c5bc0b263a677f57cd63f002057ff0812f15e64

Ken Chen   commited 2022-07-29 03:53:24 +08:00
c52cbe0cf8
Move connectivity_native_test to a sub folder
Move sources of connectivity_native_test to a dedicated folder so that
other native tests or utilities can be added to p/m/c/tests/native/ as
well.

Bug: 227159929
Test: atest connectivity_native_test
Change-Id: I97217fbb03b26ed79f1f34932b92c4227a1ece4d

Ken Chen   commited 2022-07-28 14:41:23 +08:00
ef50ab1473
Merge "Revert "connectivity_native_test: remove retries""
Steven Moreland   authored and   Gerrit Code Review   commited 2022-06-22 20:32:25 +00:00
749fd994f8
Revert "connectivity_native_test: remove retries"
This reverts commit ccde0db174.

Reason for revert: fails in mainline prod branch

Change-Id: Id26c44b9e9c68a259d3c82d67a5f4cea27569432

Steven Moreland   commited 2022-06-22 20:27:15 +00:00
5d0843b7f2
Merge "connectivity_native_test: remove retries"
Steven Moreland   authored and   Gerrit Code Review   commited 2022-06-21 23:03:09 +00:00
e1ae9fd469
connectivity_native_test: remove retries
Retries needed due to bug.

Bug: 235006086
Test: connectivity_native_test
Change-Id: Idcc83e52b91416f61de040d910440800772341e7

Steven Moreland   commited 2022-06-07 17:28:53 +00:00
ccde0db174
Add traffic_controller, networkstats, netd_updatable tests to MTS.
In order to get counted by mts code coverage, these native tests need to
be run as part of mts.

Bug: 233904825
Test: m mts && mts-tradefed run mts-tethering-coverage
Change-Id: I79313197b146c7043ffb5e164faa46c2e16dd1d2

Ken Chen   commited 2022-05-27 15:00:18 +00:00
b9266bf507
Merge "ConnectivityNativeBinderTest: Check Kernel Version"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-04-21 00:00:14 +00:00
76ff404153
ConnectivityNativeBinderTest: Check Kernel Version
Check kernel version in patch before running test case
to make sure that 5.4 kernel is used which is what the
bpf prog uses.

Bug: 229692536
Test: atest ConnectivityNativeBinderTest

Change-Id: I3bf8d3ce6c6a64236da2e4f039fb13a98231fae0

Tyler Wear   commited 2022-04-19 18:01:17 -07:00
4e7acedf15
Merge "Disable R+ tests on Q"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-04-13 03:22:21 +00:00
f7ab422491
[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity
Added SPDX-license-identifier-Apache-2.0 to:
  tests/native/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I0f883fa9c9d922766976c939565c6b368629915d

Bob Badour   commited 2022-04-07 10:36:04 -07:00
03465246f6
Disable R+ tests on Q
Add Sdk30ModuleController to ConnectivityCoverageTests and
connectivity_native_test, as they cover code in the Tethering module,
which is R+.

Test: atest ConnectivityCoverageTests connectivity_native_test
Change-Id: Ida573d4e231bf29989f699a9fef77d3a677425c8

Remi NGUYEN VAN   commited 2022-04-07 17:01:13 +09:00
bef435bf9b
add OWNERS for connectivity_native_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibb7bcf272a2ff258d2518b60589ecb8e16823777

Maciej Żenczykowski   commited 2022-04-06 23:25:10 +00:00
189577cd8b
Vendor AIDL interface for port blocking via eBPF
New Connectivity Service exposed to vendor for
restricting certain ports for use only in vendor.

Bug: 179733303

Change-Id: Iad9aff6924498ede5a08cfa5482082f094c0a90b

Tyler Wear   commited 2022-03-25 09:14:48 -07:00
b37f551287