Commit graph

3499 commits

Author SHA1 Message Date
Elliott Hughes
92be5ce73c Merge "Stop defining __STDC_*_MACROS macros." into main am: 78714d102f am: 8f288d8f42
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955173

Change-Id: I61bbc1b46e0e839ae8389d4c6d8af23716d38877
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-08 01:15:20 +00:00
Elliott Hughes
3bb9880a57 Stop defining __STDC_*_MACROS macros.
The libcs we use don't need these any more (if they ever did), and we
were setting these globally in the build system anyway.

Also remove the -D_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS from versioner
which doesn't seem needed any more either.

Test: treehugger
Change-Id: I9fb225b085906a02918c5847401d6c59f7779581
2024-02-07 21:05:44 +00:00
Florian Mayer
79cd8b8519 Merge "[MTE] remap stacks with PROT_MTE when requested by dlopened library" into main am: ba5630cede am: f252b3fda6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2901508

Change-Id: Id912233d287ce492657d5ebca053e5a7995bf113
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-06 17:40:52 +00:00
Florian Mayer
ba5630cede Merge "[MTE] remap stacks with PROT_MTE when requested by dlopened library" into main 2024-02-06 16:16:03 +00:00
Florian Mayer
79c9694c91 [MTE] remap stacks with PROT_MTE when requested by dlopened library
BYPASS_INCLUSIVE_LANGUAGE_REASON="man" refers to manual not person

Bug: 318749472
Test: atest pthread on MTE enabled device
Test: atest memtag_stack_dlopen_test on MTE enabled device
Test: manual with NDK r26b built app with fsanitize=memtag-stack
Change-Id: Iac191c31b87ccbdc6a52c63ddd22e7b440354202
2024-02-05 18:17:24 -08:00
Aditya Choudhary
829c064ccc Merge "Migrate Test Targets to New Android Ownership Model" into main am: d7144fcdf0 am: 72f82334d5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2946528

Change-Id: Ib29cccd2cba3862f451518437b56421ff031c2d1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-04 22:14:00 +00:00
Aditya Choudhary
d9d37c09d8 Migrate Test Targets to New Android Ownership Model
This CL is created as a best effort to migrate test targets to the new Android ownership model.
It is based on historical data from repository history and insights from git blame.
Given the nature of this effort, there may be instances of incorrect attribution. If you find incorrect or unnecessary
attribution in this CL, please create a new CL to fix that.

For detailed guidelines and further information on the migration please refer to the link below,
go/new-android-ownership-model

Bug: 304529413
Test: N/A
Change-Id: Ie36b2a3245d9901323affcc5e51dafbb87af9248
2024-02-02 13:57:12 +00:00
Treehugger Robot
adba83240b Merge "sys_statvfs_test: fix expectation for Linux 6.7." into android13-tests-dev am: 7123abff51
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2928751

Change-Id: I38541b1db092dd37044970a52494dafc5ed6ed26
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-31 19:15:43 +00:00
Treehugger Robot
7123abff51 Merge "sys_statvfs_test: fix expectation for Linux 6.7." into android13-tests-dev 2024-01-31 18:42:56 +00:00
Elliott Hughes
d06a358244 Merge "sys_vfs_test: fix expectation for Linux 6.7." into android13-tests-dev am: fb7d4c4761
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2929452

Change-Id: Ib4321aba8f1be78db8a79e7f858c7813d71ed11f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-31 16:02:50 +00:00
Elliott Hughes
234dc36ac6 sys_statvfs_test: fix expectation for Linux 6.7.
I'd assumed that it was _deliberate_ that filesystems like procfs
reported 0 here, but apparently not. Good news: this makes for a more
worthwhile test than we had previously (at least when run on a 6.7+
kernel).

Bug: http://b/321880382 (for sys_vfs_test)
Bug: http://b/319590754 (for sys_statvfs_test)
Test: treehugger
Change-Id: I0a63faa8ca359592a29d7bca1a40ecd94fd50044
(cherry picked from commit 7506c37386)
2024-01-26 23:45:11 +00:00
Elliott Hughes
6df96da2d4 Merge "sys_vfs_test: fix expectation for Linux 6.7." into main am: 284596e19e am: c10762164b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2928750

Change-Id: I40b63bedec6dc84a11e7df9d879c9e2f8e5b64cc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-26 00:17:13 +00:00
Elliott Hughes
3e7e2251fa sys_vfs_test: fix expectation for Linux 6.7.
I'd assumed that it was _deliberate_ that filesystems like procfs
reported 0 here, but apparently not. Good news: this makes for a more
worthwhile test than we had previously (at least when run on a 6.7+
kernel).

(This is the sys_vfs_test equivalent of the earlier change made to
sys_statvfs_test.)

Bug: http://b/321880382 (for sys_vfs_test)
Bug: http://b/319590754 (for sys_statvfs_test)
Test: treehugger
Change-Id: I3c6f784d1e348bf1be3a102d1dd6336c33d0b2db
(cherry picked from commit 1b48afbc66)
2024-01-25 22:53:16 +00:00
Elliott Hughes
1b48afbc66 sys_vfs_test: fix expectation for Linux 6.7.
I'd assumed that it was _deliberate_ that filesystems like procfs
reported 0 here, but apparently not. Good news: this makes for a more
worthwhile test than we had previously (at least when run on a 6.7+
kernel).

(This is the sys_vfs_test equivalent of the earlier change made to
sys_statvfs_test.)

Bug: http://b/321880382 (for sys_vfs_test)
Bug: http://b/319590754 (for sys_statvfs_test)
Test: treehugger
Change-Id: I3c6f784d1e348bf1be3a102d1dd6336c33d0b2db
2024-01-25 10:12:37 -08:00
Treehugger Robot
5d16f2ebb3 Merge "Disable stack protector test with stack MTE" into main am: e8cfc14651 am: df5a96be4e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2920186

Change-Id: I8d467383c5031e132b5f9b92724c5cf9bded1dd1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-23 10:29:10 +00:00
Treehugger Robot
e8cfc14651 Merge "Disable stack protector test with stack MTE" into main 2024-01-23 09:22:16 +00:00
Mitch Phillips
7ce3ec389b Disable stack protector test with stack MTE
Obviously stack MTE conflates with the stack protector test. It doesn't
conflate with heap MTE (which we're expecting to push more broadly as
part of the -eng build), and so we want to keep this test working under
heap-mte scenarios as well.

Hence, the check-if-stack-variable-is-tagged test, and only under that
case, we skip.

Test: atest bionic-unit-tests on a fullmte device (with stack MTE turned
back on and the new compiler).
Bug: 320448268

Change-Id: I2ecee8a7c46416883235bf5c4ee2de9408047829
2024-01-22 12:40:34 +01:00
Treehugger Robot
1eb127b9ea Merge "bpfmt all the .bp files to silence ayeaye." into main am: 6467c97105 am: 2569eb859b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2918991

Change-Id: I7fc367f7c75495525fba093761c8354f1042a378
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 23:32:41 +00:00
Elliott Hughes
1eacc0edc0 bpfmt all the .bp files to silence ayeaye.
Test: treehugger
Change-Id: I5b7add6f013dcd2d4eee4851b7a2a22310c6d533
2024-01-19 19:05:36 +00:00
Elliott Hughes
7c9c122c4c Revert "[RESTRICT AUTOMERGE] time_test#mktime_EOVERFLOW: allow both Android 14 and 2024Q1 behavior."
This reverts commit 4c5eeb8346 in main,
where we have the newer tzcode and so can pass the stricter test.

Bug: http://b/307680874
Test: treehugger
Change-Id: I28a6f423815655a59fb503230e50a7b618b0349a
2024-01-12 23:49:44 +00:00
Elliott Hughes
1c116ba64a [RESTRICT AUTOMERGE] time_test#mktime_EOVERFLOW: allow both Android 14 and 2024Q1 behavior. am: 4c5eeb8346
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2908740

Change-Id: Ib623cf4b4dda4791b0647b7c6d93543389431e30
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 22:47:23 +00:00
Elliott Hughes
4d04e858c4 Merge "sys_statvfs_test: fix expectation for Linux 6.7." into main am: f71f6cfea7 am: 831d4ae043 am: 02e0d81101
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2907296

Change-Id: Ica376463841d0a72da4999fc6bc585706fae2c74
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-12 21:23:50 +00:00
Elliott Hughes
4c5eeb8346 [RESTRICT AUTOMERGE] time_test#mktime_EOVERFLOW: allow both Android 14 and 2024Q1 behavior.
As long as 2024Q1 is using Android 14's CTS, Android 14's CTS needs to
work with both. That doesn't make much sense for this test of a bug fix,
so just disable it.

Bug: http://b/307680874
Test: treehugger
Change-Id: Ic1bea5d0404c91279a025ac97b521f07e4d2d387
2024-01-12 19:52:55 +00:00
Elliott Hughes
f71f6cfea7 Merge "sys_statvfs_test: fix expectation for Linux 6.7." into main 2024-01-12 17:22:47 +00:00
Elliott Hughes
7506c37386 sys_statvfs_test: fix expectation for Linux 6.7.
I'd assumed that it was _deliberate_ that filesystems like procfs
reported 0 here, but apparently not. Good news: this makes for a more
worthwhile test than we had previously (at least when run on a 6.7+
kernel).

Bug: http://b/319590754
Test: treehugger
Change-Id: I0a63faa8ca359592a29d7bca1a40ecd94fd50044
2024-01-11 20:46:23 +00:00
Ryan Prichard
91091d62b9 Merge "Avoid printing char16_t* and wchar_t to gtest Message" into main am: 45884037fe am: 6282a053b8 am: c9a1198b98
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2902185

Change-Id: Idca843e160e518711ccf9e547f00125dd3cefac4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-11 00:37:56 +00:00
Ryan Prichard
45884037fe Merge "Avoid printing char16_t* and wchar_t to gtest Message" into main 2024-01-10 22:02:02 +00:00
Ryan Prichard
f40f25829e Avoid printing char16_t* and wchar_t to gtest Message
gtest's Message class has a special handler for operator<< of wchar_t*
to convert it to UTF-8, but it doesn't have one for a single wchar_t or
for a char16_t* string. It delegates these to std::stringstream, which
as of a libc++ upgrade, deletes its operator<< for char16_t and
wchar_t. See wg21.link/p1423r3.

Bug: http://b/175635923
Test: m MODULES-IN-bionic
Change-Id: I8307663b72855cfc0b91d7f63993f1f6fe028b8e
2024-01-10 10:30:02 -08:00
Elliott Hughes
74c359277a Merge "[RESTRICT AUTOMERGE] fcntl_F_SETFD test: allow both Android 14 and 2024Q1 behavior." into android14-tests-dev 2024-01-09 14:39:00 +00:00
Elliott Hughes
82decc79bf Merge "[RESTRICT AUTOMERGE] uchar/wchar tests: allow both Android 14 and 2024Q1 behaviors." into android14-tests-dev 2024-01-09 14:38:47 +00:00
Elliott Hughes
7922ce0d0d [RESTRICT AUTOMERGE] fcntl_F_SETFD test: allow both Android 14 and 2024Q1 behavior.
What's important is that we name the flag. It doesn't really matter
whether you have the better message that will be in Android 15. As long
as 2024Q1 is using Android 14's CTS, Android 14's CTS needs to work with
both.

Bug: http://b/307680874
Test: treehugger
Change-Id: I8c50707e1dfd6b40e6ced887ae105508c6339989
2024-01-06 00:28:41 +00:00
Elliott Hughes
30fc7dee98 [RESTRICT AUTOMERGE] uchar/wchar tests: allow both Android 14 and 2024Q1 behaviors.
As long as 2024Q1 is using Android 14's CTS, Android 14's CTS needs
to work with both. That doesn't really seem practical for these tests,
so just disable them.

Bug: http://b/307680874
Test: treehugger
Change-Id: Iab4085ce1be1b0e00a6714eaf3008787e29e7e7b
2024-01-06 00:26:26 +00:00
Elliott Hughes
db123a73ca time.mktime_EOVERFLOW: set an explicit timezone.
Bug: http://b/283397453 (original)
Bug: http://b/307680874 (cherrypick)
Test: export TZ=Asia/Shanghai
Change-Id: Ia03822adad367abf35a0fdf55d7367cd1764fcdd
(cherry picked from commit f52b2165cb)
2024-01-06 00:19:03 +00:00
Dennis Shen
5951b4100c sys_prop: add a flag to enable large sys prop node only for internal
builds

Use a soong config var to control if we should use a large sys prop node
size. Node in prop_area.cpp, the PA_SIZE is controlled by a macro flag.
This macro flag is passed in as a compiler flag which is then added when
the soong configure variable (large_system_property_node) is true.

The sooong configure variable is then backed by a build system flag
defined in build/release/build_flags.scl. The value of this flag is then
determined by different release configurations. Only internal build
release configuration would set this flag to true.

Bug: b/316932568
Change-Id: Ibe2ffda9155246f2217aaa0e7d589ed7effec311
2024-01-05 23:53:47 +00:00
Elliott Hughes
2ddb20d29d Remove a few glibc #if hacks.
We've updated the corresponding glibc headers so we don't need these
hacks any more.

Bug: http://b/318541070
Test: treehugger
Change-Id: Ic1974f30f9edb2589cc93041822706bc89909882
2024-01-04 16:44:57 -08:00
Dennis Shen
c1e79efa0a Merge "Revert "system properties: doubling the shared file size to 256Kb"" into main 2024-01-04 21:24:20 +00:00
Dennis Shen
3d1ce8c831 Revert "system properties: doubling the shared file size to 256Kb"
This reverts commit 46cce48995.

Reason for revert: 

Will put a change behind flags to bump storage to 1Mb for internal build only. AOSP code does not need to be changed. The change will be only made to git_main.

Change-Id: If3484d0e56f4c3d8fc729f55744c2d8ebdd13b11
2024-01-04 14:18:38 +00:00
Elliott Hughes
3ef682790e riscv64: remove some obsolete #if cruft.
We have newer uapi headers now.

Test: treehugger
Change-Id: Ic5d602f3a97a860ee9f1ad5b791b46013f25e743
2024-01-03 12:08:51 -08:00
Dennis Shen
46cce48995 system properties: doubling the shared file size to 256Kb
While aconfig flag storage is being migrated to its own dedicated
storage, we need to provide some relief to the current flag users which
are running into storage capacity limit of system property. Currently
system property by default allocates a file of 128Kb for each storage
node. Bump it to 256Kb for now.

Bug: b/316037066
Change-Id: I8b0b58733f362c3789ec92ae09ee589c7c1b72c6
2023-12-18 14:02:21 +00:00
Andy Hung
46f0ddb29f Merge "bionic: fix pthread_mutex_timedlock for PI mutexes" into main 2023-12-14 17:52:55 +00:00
Andy Hung
5e19b185fd bionic: fix pthread_mutex_timedlock for PI mutexes
FUTEX_LOCK_PI uses CLOCK_REALTIME so adjust clock timebase
accordingly.

FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI, FUTEX_LOCK_PI2
are updated to check the presence of FUTEX_CLOCK_REALTIME flag.

Test: atest bionic-unit-tests
Bug: 312787238
Bug: 315897315
Change-Id: I2d93286cf22d3b3d9f3757d49b46f7ee9ea5490c
2023-12-13 12:10:50 -08:00
Elliott Hughes
00ab1a5f95 Merge "Add a missing strtol() family test and a hex benchmark." into main 2023-12-12 14:27:30 +00:00
Elliott Hughes
4e62055462 Add a missing strtol() family test and a hex benchmark.
Benchmark added to test an optimization I'll send round next, test added
when an even bigger refactoring (as part of a more interesting
optimization) broke strtol() in a way the strtol() tests didn't notice.

Test: treehugger
Change-Id: Ic974900021107938dbbbe98648960adb102d9595
2023-12-11 16:57:03 -08:00
Colin Cross
0ce2dcfad2 Merge "Remove bionic bp2build properties" into main 2023-12-11 23:12:54 +00:00
Juan Yescas
717debf261 Merge "16k: Fix sysconf_SC_ARG_MAX test to support 16k page sizes" into main 2023-12-08 21:01:54 +00:00
Elliott Hughes
4fa4354799 Merge "Remove obsolete workaround." into main 2023-12-08 19:56:42 +00:00
Juan Yescas
2da31cf7b0 16k: Fix sysconf_SC_ARG_MAX test to support 16k page sizes
The sysconf_SC_ARG_MAX test was failing because it didn't
handle the case for 16k. After fixing the test case, it will
handle 4k/16k page sizes and fail when there is another page
size.

Bug: 315174209
Test: atest -c bionic-unit-tests-static
Change-Id: Ie24a79be9d6790a1243be48d39f67acda485c37d
2023-12-08 11:51:39 -08:00
Juan Yescas
837e4d1f52 Merge "16k: Fix pthread tests to support 4k/16k page sizes" into main 2023-12-08 17:50:38 +00:00
Elliott Hughes
5c17d7d092 Remove obsolete workaround.
These were added because the tests wouldn't build without them, but they
do now.

Bug: http://b/132640749
Test: treehugger
Change-Id: Idc0aff08ce461bde5ed2cd816f04dcdef5d7af5d
2023-12-08 09:47:07 -08:00
Elliott Hughes
9cf79d736f Merge "Stop saying -fno-emulated-tls in tests." into main 2023-12-08 17:33:59 +00:00
Yi Kong
066b5d6380 Fix -Winteger-overflow warning
Test: presubmit
Change-Id: If9dee7c85efc3d14805c8e3ab85631223adac5ec
2023-12-08 19:53:31 +09:00
Juan Yescas
65af9a862a 16k: Fix pthread tests to support 4k/16k page sizes
Fix the pthread test cases to support 4k/16k page sizes.

Bug: 315174209
Test: atest -c bionic-unit-tests-static
Change-Id: Ie364e756120c396144f20372cac8239eed6c7bd8
2023-12-07 20:14:26 -08:00
Colin Cross
c03d928b6e Remove bionic bp2build properties
Bug: 315353489
Test: m blueprint_tests
Change-Id: I4b320d88e6b59296e092ee46f56372cc6b85ba21
2023-12-07 16:56:16 -08:00
Elliott Hughes
c7cc6d5902 Stop saying -fno-emulated-tls in tests.
This is now the default.

I've left the fuzzer workaround in for now, but we can come back and see
whether the fuzzer library has actually switched.

Test: treehugger
Change-Id: Ia3a09738396bfe915ceabec4a6019f4cedb0f39c
2023-12-07 16:27:08 -08:00
Evgenii Stepanov
73a867a203 Merge changes from topic "revert-2709995-VVPYYBKIHY" into main
* changes:
  Revert "Linker support for MTE globals."
  Revert "Add a memtag-globals test to bionic"
2023-12-07 01:36:49 +00:00
Treehugger Robot
12c86dabf9 Merge "Extend MemtagNoteTest." into main 2023-12-06 21:44:45 +00:00
Evgenii Stepanov
d957e96b58 Extend MemtagNoteTest.
Calling free() during system property init results in premature
allocator initialization. This has been fixed with a Scudo change in
https://r.android.com/2853684. This patch extends MemtagNoteTest to
verify that there are no stray PROT_MTE mappings when MTE is not
enabled in the binary.

Test: adb shell setprop arm64.memtag.bootctl memtag
      adb reboot
      bionic-unit-tests --gtest_filter=MemtagNoteTest.SEGV/*
Bug: 309698651
Change-Id: I6c7733d8799537d898c97b00d494ce6591cf44d9
2023-12-06 12:53:34 -08:00
Treehugger Robot
cd9814461f Merge "Revert "Disable MTE globals tests under HWASan"" into main 2023-12-06 19:46:44 +00:00
Evgenii Stepanov
d0f4bd5939 Revert "Add a memtag-globals test to bionic"
Revert submission 2709995

Reason for revert: linker crash in soinfo::apply_relr_reloc

Reverted changes: /q/submissionid:2709995

Bug: 314038442
Change-Id: I416bff00ed3d530b3b6257362b2119c358e1d152
2023-12-06 19:01:17 +00:00
Evgenii Stepanov
b9cccdb357 Revert "Disable MTE globals tests under HWASan"
This reverts commit f71ee5adb7.

Reason for revert: linker crash in soinfo::apply_relr_reloc

Bug: 314038442
Change-Id: Ib2415519e37d6b2acb30f50afa6c45391e2a4b70
2023-12-06 18:58:10 +00:00
Elliott Hughes
561e804ffb riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers.
This way, callees don't need to worry about whether or not their
reference to __riscv_hwprobe() has been resolved before their ifunc
resolver is called.

This matches the current glibc proposal from rivos.

Test: treehugger
Change-Id: I0d5244aa837d0d1f0e6bd7d22091dfedb8a55bdb
2023-12-05 16:31:59 -08:00
Mitch Phillips
f71ee5adb7 Disable MTE globals tests under HWASan
Bug: 313613493
Change-Id: Ie15852edc486944a1242dd7741a81e404bdb893f
Test: atest bionic-unit-tests under HWASan
2023-11-28 18:03:28 +00:00
Mitch Phillips
456ce1e7ce Merge changes I2fc4fc9d,Id7b1a925 into main
* changes:
  Add a memtag-globals test to bionic
  Linker support for MTE globals.
2023-11-28 09:31:57 +00:00
Mitch Phillips
057c8ddd71 Add a memtag-globals test to bionic
This test comes in two flavours: a prebuilt, and one from source (which is used
to generate the prebuilt). For now, the in-tree prebuilt compiler isn't
new enough to actually build binaries with proper MTE globals support,
so I've provided prebuilts using a tip-of-tree compiler. Thus, the MTE
globals support in the linker can be experimented on, tested, and
(hopefully) submitted while not being blocked on the toolchain roll.

You can see the binaries have MTE globals by grabbing a tip-of-tree
compiler, and running 'llvm-readelf --memtag <bin>'.

Bug: N/A
Test: atest bionic-unit-tests --test-filter=*Memtag*
Change-Id: I2fc4fc9d1c6ddd16c2204dd728d4ebe463928522
2023-11-20 15:53:14 +01:00
Hans Boehm
71eb46fc00 Better obstruct optimization for ordering test
... to make sure that stores to the same locations are harder to
eliminate.

Also ensure that reader gets a chance to run by sleeping if necessary.

Bug: 308744279
Test: atest stdatomic
Test: Check that we don't usually sleep.
Change-Id: Iddab2a109525f96e065ac8331f227baa08dd8e22
2023-11-14 14:11:25 -08:00
Treehugger Robot
d0f5e4cf8a Merge "sys_msg_test: Fix msgsnd() argument passing" into main 2023-10-31 16:56:08 +00:00
Treehugger Robot
0207a6a186 Merge changes from topic "appcompat_override" into main
* changes:
  Move __system_properties_reload to LIBC from LIBC_PLATFORM
  Write appcompat_override system properties
2023-10-31 02:29:57 +00:00
Christopher Ferris
b4e560ed7c Add android_mallopt M_GET_DECAY_TIME_ENABLED.
The bionic benchmarks set the decay time in various ways, but
don't necessarily restore it properly. Add a new method for
getting the current decay time and then a way to restore it.

Right now the assumption is that the decay time defaults to zero,
but in the near future that assumption might be incorrect. Therefore
using this method will future proof the code.

Bug: 302212507

Test: Unit tests pass for both static and dynamic executables.
Test: Ran bionic benchmarks that were modified.
Change-Id: Ia77ff9ffee3081c5c1c02cb4309880f33b284e82
2023-10-30 15:30:16 -07:00
Kevin Brodsky
3cc6ae0144 sys_msg_test: Fix msgsnd() argument passing
msgsnd() takes the following arguments:
1. msqid: the message queue ID
2. msgp: a pointer to a struct whose first member is the message
   type (long) and the second the message itself (char array).
3. msgsz: the size of the message
4. msgflg: optional flags

sys_msg.smoke does not correctly specify msgsz, as it provides the
size of the whole struct instead of its message (data) member.
sys_msg.msgsnd_failure does not provide a pointer to a full struct
as msgp. In both cases, this results in the kernel reading garbage
on the stack.

Fix both issues by providing the appropriate size and struct
pointer.

Test: run bionic-tests --gtest_filter=sys_msg.*
Change-Id: Iaa005e259d3ecfa28484dd66222ed6c4584ffc08
2023-10-30 09:45:38 +00:00
Elliott Hughes
1b2e844745 Fix riscv64 stpcpy().
We were copying the data fine, but the return value was one vector
length too far (but also not taking into account the actual number of
bytes in the last transfer).

Also move the stpcpy() tests to EXPECT_EQ() so we get all the details
of the failure at once.

Test: treehugger
Change-Id: I76bf02c8a31f40722acb7c9fd8e301d50e405bf8
2023-10-26 17:50:16 -07:00
Nate Myren
0ab0615f8c Move __system_properties_reload to LIBC from LIBC_PLATFORM
The zygote cannot have visiblity to LIBC_PLATFORM methods. Therefore,
move __system_properties_reload to LIBC, and rename it
__system_properties_zygote_reload, and indicate in comments that it
should not be used by non-zygote apps

Bug: 291814949
Test: atest CtsBionicRootTestCases
Change-Id: Iee8fa0c76b740543c05a433393f2f4bef36d6d3d
2023-10-25 17:41:33 -07:00
Treehugger Robot
4cc96c1d1e Merge "Improve comment about glibc behavior difference." into main 2023-10-25 21:25:35 +00:00
Dan Albert
ac243733a5 Improve comment about glibc behavior difference.
I was re-reading this comment and thought I'd gotten my interpretation
backward, but it's actually just very nuanced. Elaborate a bit so I
hopefully don't reinterpret this again in a few more months.

Bug: None
Test: None
Change-Id: I8ca444f2fb143c46e6068f349e9f5eb574fc4b31
2023-10-25 20:31:48 +00:00
Treehugger Robot
7bdcf765fa Merge "<syslog.h>: add facilitynames[] and prioritynames[]." into main 2023-10-24 01:46:46 +00:00
Elliott Hughes
afb8e05eb3 <syslog.h>: add facilitynames[] and prioritynames[].
Test: treehugger
Change-Id: I2a65b3088fe5a28b66e7d1c2a8caa10cb4467202
2023-10-23 17:47:15 -07:00
Kalesh Singh
41c8951c91 bionic: tests: Remove PAGE_SIZE usage
Instead of the hardcoded PAGE_SIZE 4096 macro, use the
real system page-size as queried from the auxillary vector.

Bug: 277272383
Bug: 300367402
Test: atest -c bionic-unit-tests
Change-Id: I2f1ad1b431e36ef45e9f53f713ced6b06e0d4f70
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-10-19 15:49:50 -07:00
Nate Myren
b8c87b14b0 Write appcompat_override system properties
Create a second set of system properties, that can be overlaid over the
real ones if necessary, for appcompat purposes.

Bug: 291814949
Ignore-AOSP-First: Aosp -> internal merge conflict
Test: manual, treehugger, system_properties_test

Change-Id: I541d3658cab7753c16970957c6ab4fc8bd68d8f3
Merged-In: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
2023-10-19 13:35:57 -07:00
Elliott Hughes
b4e2219987 Merge "Clarify the fcntl() "that's not how F_SETFD works" error." into main 2023-10-12 17:51:20 +00:00
Elliott Hughes
25af17c587 Clarify the fcntl() "that's not how F_SETFD works" error.
The first app developer (we know of) that hit this didn't understand
what it was trying to tell them.

Before:
    FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x801

After:
    FORTIFY: fcntl(F_SETFD) only supports FD_CLOEXEC but was passed 0x801

Bug: https://issuetracker.google.com/304348746
Test: treehugger
Change-Id: I8522e851d8f74c91152ebae68b083b5272d49255
2023-10-12 16:04:14 +00:00
Elliott Hughes
76a3ad4e44 Add tests for stdio functions not setting the error indicator.
From https://reviews.llvm.org/D150044#4597254.

Bug: http://b/302742247
Test: treehugger
Change-Id: I001e7a995aabef37bdcdb53791c4af36c77d7b57
2023-10-09 16:50:55 -07:00
Elliott Hughes
b2f2fc8184 Remove unreliable CFI test.
Remove tests of implementation details rather than the CFI
functionality itself. In particular, CFI is designed to protect against
invalid calls to executable code, whereas heap memory is covered by page
protection.

Bug: http://b/298741930
Test: treehugger
Change-Id: Ib7f8af283b4c0001da8fa80a1b281bdc4c50af51
2023-10-06 16:58:12 -07:00
Treehugger Robot
51be22c28d Merge "Consistently use #if defined(__BIONIC__)." into main 2023-09-28 20:17:02 +00:00
Elliott Hughes
fc1b3b8b7e Merge "Use strerrorname_np() in ASSERT_ERRNO()." into main 2023-09-28 20:03:47 +00:00
Elliott Hughes
e7943f8b95 Consistently use #if defined(__BIONIC__).
Test: treehugger
Change-Id: I844b909404532eb9165cba1ed6f237bdd4a46990
2023-09-28 10:47:51 -07:00
Elliott Hughes
11069030d6 Remove an obsolete TODO now we have a new clang.
Test: treehugger
Change-Id: I19751fe73f4cd3400005d0ccad0bccb0a74f6fc8
2023-09-28 08:22:26 -07:00
Elliott Hughes
d2250edc10 Use strerrorname_np() in ASSERT_ERRNO().
Hopefully this is totally unambiguous and non-confusing output:
```
Expected equality of these values:
  Errno(22)
    Which is: EINVAL
  Errno((*__errno()))
    Which is: ENOSYS
```

Test: treehugger
Change-Id: Iefe6a8a6447e76681c18256d2713e2c527081c75
2023-09-28 08:15:36 -07:00
Elliott Hughes
a67fe1b171 Merge "Add strerrordesc_np() and strerrorname_np()." into main 2023-09-27 22:26:37 +00:00
Elliott Hughes
2109f12c3b Add strerrordesc_np() and strerrorname_np().
strerrordesc_np() isn't very useful (being just another name for
strerror()), but strerrorname_np() lets you get "ENOSYS" for ENOSYS,
which will make some of our test assertion messages clearer when we
switch over from strerror().

This also adds `%#m` formatting to all the relevant functions.

Test: treehugger
Change-Id: Icfe07a39a307d591c3f4f2a09d008dc021643062
2023-09-27 11:21:12 -07:00
Elliott Hughes
4ae4be9263 Clean up how we skip tests when a syscall isn't in the kernel.
The close_range() test in particular has been confusing a lot of
partners. I think the sys_epoll_test.cpp idiom is the clearest of the
ones in use, so let's use that everywhere. (I haven't actually touched
the SysV IPC tests, because if we do touch them, _deleting_ them --
since all those syscalls are not allowed on Android -- is probably the
change to be made!)

I'm on the fence about factoring this idiom out into a macro. There
should never be too many of these, and we should probably be removing
them? Is anyone still running the current bionic tests on 4.3 kernels
without membarrier(2), and if they are --- why?!

For now though, I haven't removed any of our existing tests; I've just
moved them over to the sys_epoll_test.cpp style.

Test: treehugger
Change-Id: Ie69a0bb8f416c79957188e187610ff8a3c4d1e8f
2023-09-22 17:15:25 -07:00
Elliott Hughes
95646e6666 Add ASSERT_ERRNO and EXPECT_ERRNO (and use them).
We've talked about this many times in the past, but partners struggle to
understand "expected 38, got 22" in these contexts, and I always have to
go and check the header files just to be sure I'm sure.

I actually think the glibc geterrorname_np() function (which would
return "ENOSYS" rather than "Function not implemented") would be more
helpful, but I'll have to go and implement that first, and then come
back.

Being forced to go through all our errno assertions did also make me
want to use a more consistent style for our ENOSYS assertions in
particular --- there's a particularly readable idiom, and I'll also come
back and move more of those checks to the most readable idiom.

I've added a few missing `errno = 0`s before tests, and removed a few
stray `errno = 0`s from tests that don't actually make assertions about
errno, since I had to look at every single reference to errno anyway.

Test: treehugger
Change-Id: Iba7c56f2adc30288c3e00ade106635e515e88179
2023-09-21 14:15:59 -07:00
Treehugger Robot
d72f4f8770 Merge "Consistent qualifier ordering." into main 2023-09-15 17:19:08 +00:00
Florian Mayer
6b4e6e470e Merge "Remove ASan test" into main 2023-09-14 19:19:01 +00:00
Elliott Hughes
30088848fc Consistent qualifier ordering.
Change our handful of `constexpr static`s to the much more common
`static constexpr`. It's easier to "follow existing style" when there
aren't two existing styles to copy from, and all else being equal,
"majority wins" :-)

Test: treehugger
Change-Id: Ifbf0f62ab84c9450bf9c2e49e96915c126fd20c4
2023-09-14 18:36:55 +00:00
Florian Mayer
12e38c23f1 Remove ASan test
ASan for device side is deprecated.
Bug: 300289881

Change-Id: I492ccbbeae43c84b53e92b062048c56ea974308e
2023-09-13 12:29:32 -07:00
Christopher Ferris
1de7a480bc Disable warning which is not detecting problems.
A clang update enabled -Wreorder-init-list by default. Since it doesn't
provide any benefit to the bionic code, disable the warning.

Test: Builds without warnings.
Change-Id: I5891527ef532b59dc2a02b39a5896112411d21f5
2023-09-12 13:03:02 -07:00
Colin Cross
90eef4250e Merge "Skip sysconf_cache for musl" into main 2023-09-06 17:14:57 +00:00
Elliott Hughes
906d7d41e4 Merge "Add epoll_pwait2()." into main 2023-09-05 21:48:08 +00:00
Colin Cross
cb5d3c1c33 Skip sysconf_cache for musl
Musl doesn't have the _SC_LEVEL?_?CACHE_SIZE sysconf macros.

Bug: 257334542
Test: m USE_HOST_MUSL=true host-native
Change-Id: I42e65daa9169e129059ddde5eee487ea51e6f143
2023-09-05 13:53:11 -07:00
Elliott Hughes
fce8a155df __riscv_hwprobe: don't try to set errno.
When used in an ifunc resolver, errno@plt won't be available. This is
the API the rivos folks contributing to glibc are leaning towards, for
the same reason. Hit by the berberis folks because they don't implement
the syscall so they were trying to set errno to ENOSYS.

Tested by looking at the generated assembler, and also disabling the
vdso (since on actual systems, this will go via the vdso).

Test: treehugger
Change-Id: Ie2779110f141f20efe97cb892fbdefd808b5339b
2023-08-29 15:41:36 -07:00
Elliott Hughes
647472db9b <termios.h>: add two new POSIX functions.
musl already added tcgetwinsize() and tcsetwinsize(), but I didn't
notice.

Trivial single-line inlines added to a header that's already written
that way.

Test: treehugger
Change-Id: Iac95ea6a89f3872025c512f7e61987b81d0aafa7
2023-08-29 09:33:04 -07:00
Elliott Hughes
a71a15fe34 Merge "sysconf(): implement cache queries." into main 2023-08-28 14:48:20 +00:00
Elliott Hughes
02df7388f1 sysconf(): implement cache queries.
This is a bit disappointing. I'd not implemented this in the past
because it wasn't available on all platforms, and -- although the
riscv64 implementation was just a cool optimization -- I thought that
the /sys stuff was actually portable, until I ran it on arm64 hardware.
So here we have getauxval() for riscv64, /sys for x86-64, and our best
guess based on ctr_el0 for arm64.

Bug: http://b/294034962
Test: ran tests on the host, an arm64 device, and riscv64 host and qemu
Change-Id: I420b69b976d30668d4d2ac548c4229e2a4eafb20
2023-08-28 14:48:12 +00:00
Elliott Hughes
bf4d3a95c1 Merge "Add %b/%B to async-safe logging." into main 2023-08-24 14:34:45 +00:00
Elliott Hughes
4c62e59fe6 Add epoll_pwait2().
I've also added doc comments for everything in <sys/epoll.h>.

I've also broken up the old "smoke" test (which was taking 2s on my
riscv64 qemu) to keep the total runtime for all the tests down to 200ms.

Test: treehugger
Change-Id: Icd939af51886fdf21432653a07373c1a0f26e422
2023-08-23 15:59:12 -07:00
Elliott Hughes
f5b4e3ce58 Add %b/%B to async-safe logging.
Missed this when we added the new C23 binary output to the printf()
family.

Also fix %X to use "0X" instead of "0x" and add missing tests.

Test: used by new LD_SHOW_AUXV functionality
Change-Id: I6623b92acec7daf534536697de0f87352a2653ad
2023-08-23 14:08:40 -07:00
Elliott Hughes
620a72252e riscv64: fix ifuncs, improve the ifunc tests.
Talking futher to the person doing the glibc risc-v ifunc work, they
clarified that glibc _is_ passing hwcap as the first argument, and the
null pointer is actually the second argument.

https://sourceware.org/pipermail/libc-alpha/2023-August/150967.html

So since our whole purpose here was source compatibility, let's do what
they're actually doing, and let's add some tests. I've also added a test
that __riscv_hwprobe() works from an ifunc resolver because that's one
place where it might well be used. That said, one other thing that came
out of the discussion is that I actually went away and looked at a
sample of top apps to see how many are using ifuncs currently. The
result? Zero. So although this _might_ be interesting long term
(especially if clang gets riscv64 FMV), I think we've done more than we
need to with riscv64 ifuncs for now!

Test: ran locally, both dynamic and static tests
Change-Id: Ie2044d9f4e47c32c00ad381f045c537f4df38b08
2023-08-21 16:17:35 -07:00
Treehugger Robot
d8708ba8b6 Merge "sys_hwprobe_test.cpp: compare vdso to syscall." into main 2023-08-21 20:47:52 +00:00
Mitch Phillips
f5c9a65046 Move bionic test libraries to a default, for easy consumption in cts.
This list has diverged between cts/ and bionic/. Instead of having to
maintain the list, let's just make cts/ inherit the one from bionic.

Bug: 296832150
Test: atest bionic-unit-tests CtsBionicTestCases
Change-Id: I271668e83aed239107b9129dfb707f03bae47cfa
2023-08-21 13:55:10 +02:00
Elliott Hughes
728aaf6800 sys_hwprobe_test.cpp: compare vdso to syscall.
Also fix a __has_include() that was copy & pasted without modification
from a different test.

Test: treehugger
Change-Id: Iafceb331a95ec788596ffdad60aa2202b692e589
2023-08-14 14:58:33 -07:00
Dan Albert
1982dce568 Merge changes I1a60d6ef,Idabf0107 into main
* changes:
  Fix result for zero-length non-null conversion.
  Fix mismatched return types for surrogate pairs.
2023-08-07 17:55:09 +00:00
Christopher Ferris
636b9b9bf2 Merge "Increase time to set allocation limit." into main 2023-08-04 22:54:05 +00:00
Christopher Ferris
e9ffc52da7 Increase time to set allocation limit.
Under some circumstances, it's possible to fail the enable allocation
limit android_mallopt call. Increase the total allowed time for the
function to complete.

In addition, if the enable fails, allow another limit call to succeed
in the future.

Finally, change the limit test to use _exit instead of exit.

Bug: 291672185

Test: Ran limit test thousands of times.
Test: Forced the limit to fail and verified the second call passes.
Change-Id: I0948e6fd97231a7538b9b82b76f0a207386681b1
2023-08-04 13:10:48 -07:00
Dan Albert
16007d5204 Fix result for zero-length non-null conversion.
Bug: None
Test: deleted the xfail half of the test
Change-Id: I1a60d6ef27ebad14de79ac3bc637a6f2280334d8
2023-08-04 19:48:56 +00:00
Dan Albert
3a8fed1ac3 Fix mismatched return types for surrogate pairs.
We've had these backward all this time. The relevant quote is in a
code comment in the implementation, but the first call after
completely decoding a code point that requires a surrogate pair should
return the number of bytes decoded by the most recent call, and the
second call should return -3 (if only C had given those some named
constants that might have been more obviously wrong).

Bug: https://issuetracker.google.com/289419882
Test: Fixed the test, tests run against glibc and musl to confirm
Change-Id: Idabf01075b1cad35b604ede8d676d6f0b1dc91e6
2023-08-04 19:48:35 +00:00
Dan Albert
9f30c6ba92 Disable 0b parsing test for glibc.
Bug: None
Test: ran on glibc
Change-Id: I390ea20015f94b26ab3cdbeb6ade6cbcfefa7b0a
2023-08-04 19:48:34 +00:00
Dan Albert
a40159fa22 Improve output for failed wcsto* tests.
Bug: None
Test: ran these and finally understood which sub-test was failing
Change-Id: I51c6536eba4b9c82ed4b062b1702128e23cf339c
2023-08-03 21:05:29 +00:00
Dan Albert
9f78c51e03 Add missing setlocale/uselocale for glibc tests.
Bug: None
Test: these
Change-Id: Ifa0a555e3a771b27ba733b1316f7531c7b262f8b
2023-08-03 21:05:29 +00:00
Dan Albert
5325653b0f Fix test for out of range multibyte characters.
Same as in uchar_test.cpp: glibc implements a much older unicode
standard which allows these.

Bug: None
Test: this is a test
Change-Id: Iead5eb01d391be85a7b1a034ea9e7f8828e81cdb
2023-08-03 21:04:31 +00:00
Dan Albert
512469a858 Fix wchar tests for zero length conversions.
Same as the previous change for the uchar tests: the tests are wrong
to match bionic's wrong implementation. Fix the test to encode the bug
for now while I get the tests into good shape, then I'll be back to
fix the bugs and remove the test differences.

Bug: None
Test: this is a test
Change-Id: I1123660994f755f8bac1f2656f6890d5a43310b3
2023-08-03 20:03:28 +00:00
Dan Albert
686e67d077 Fix wcsto*_l tests for glibc.
glibc immediately dereferences the locale passed to all wcsto*_l
functions, even if it won't be used, and even if it's
LC_GLOBAL_LOCALE, which isn't a pointer to valid memory.

Bug: None
Test: this is the test
Change-Id: Ia307cbd6a5c5b4b904c978a03e6d06c1cef6ceed
2023-08-03 19:59:11 +00:00
Tomasz Wasilczyk
704e4e6936 Define gettid symbol when testing on glibc < 2.30
Bug: 289414897
Test: it builds
Change-Id: Ic44514953f34096e8a681ef2587439953096ba53
2023-08-03 07:19:17 -07:00
Florian Mayer
8a2f0358ed Merge "Don't assume size of functions." into main 2023-07-29 01:48:02 +00:00
Florian Mayer
8fc5ab4f72 Don't assume size of functions.
Bug: 293532332
Change-Id: I93a8c5380b17b77ff85f4027b48ea5318a03e9e3
2023-07-28 15:51:38 -07:00
Elliott Hughes
f3d6b44e2b riscv64: add <sys/hwprobe.h>.
This is source compatible with the current proposal for glibc.

Bug: https://github.com/google/android-riscv64/issues/27
Test: treehugger
Change-Id: I428777e4eac1fe643d442a93a4b3ad1fdf0ffd97
2023-07-28 09:29:06 -07:00
Christopher Ferris
15c22cdee0 No tombstones under normal bionic unit tests run.
Change a test to use a signal that does not trigger a tombstone.

Also changed the gwp_asan_integration.DISABLED_assert_gwp_asan_enabled
test to inherit from the SilentDeathTest to prevent tombstones
being generated.

Test: Ran tests and no tombstones generated.
Change-Id: I0f104704829dde692aa515a63dea1c6971278c29
2023-07-24 17:51:41 -07:00
Christopher Ferris
c833fabed7 Mark death tests properly.
A few death tests are not set to silence tombstones, so fix
all of those occurrences.

Test: Ran all death tests and no tombstones generated.
Change-Id: If2b54b1a3432edbd54076439d40527d966607f70
2023-07-24 14:31:15 -07:00
Christopher Ferris
1b61cbf604 Merge "Fix potential flakiness in android_mallopt test." into main 2023-07-22 03:28:39 +00:00
Christopher Ferris
fe13041d22 Fix potential flakiness in android_mallopt test.
The set_allocation_limit_multiple_threads test could fail every
once in a while. So rewrite slightly so that the tests wait until
all of the threads are running before letting them start.

I also refactored the code to use std::thread instead of the raw
pthread functions.

Bug: 291672185

Test: Ran the test thousdands of times.
Change-Id: Ia0bdef93d58e0ff8266e551ed4a32e14ff829581
2023-07-21 13:42:09 -07:00
Dan Albert
09d3b5065d Disable uchar.start_state test for musl.
These all appear to be either musl bugs or underspecified corners of
the C standard, so rather than verify the musl behavior I've just
disabled the body of the test for musl.

Now that this is skipped, all the uchar tests are passing for bionic,
glibc, and musl.

Bug: None
Test: None
Change-Id: Icf88ef42e9b750ab45ba76bf8112967b00e72a9f
2023-07-20 22:09:30 +00:00
Dan Albert
a0d0e350a5 Add missing setlocale calls in tests.
Doesn't do anything for bionic (which is why this has gone unnoticed),
but it does change the locale for glibc and musl. After this patch,
all these tests pass on glibc. musl is still failing in
uchar.start_state, which I haven't finished investigating.

This should probably be a test fixture so it's harder to forget, but
there are a handful of tests here which don't call setlocale until
part way through the tests, and I'm not certain if that was attempting
to test some non-obvious behavior, or if that was just an accident. I
don't want to change that test behavior before understanding it
better, so this will do for now.

Bug: None
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: Ib781a41893f021e336e67281070932f41f792318
2023-07-20 17:15:59 +00:00
Treehugger Robot
a8a9c09e0f Merge "Fix another over-long UTF-8 sequence test." into main 2023-07-20 17:03:04 +00:00
Treehugger Robot
876f3668ac Merge changes I0845fdee,I879de1e8 into main
* changes:
  Fix mbrtoc16 reserved range test for musl.
  Fix surrogate pair deocding for musl/glibc.
2023-07-20 17:03:03 +00:00
Elliott Hughes
ab9028c8ba Merge "De-pessimize SigSetConverter usage." into main 2023-07-20 16:03:27 +00:00
Dan Albert
f5b8c7dcf4 Fix another over-long UTF-8 sequence test.
This one forgot to set its locale, so it was passing on glibc (because
the sequence here wasn't valid in its default locale) and failing on
musl, both for the wrong reasons.

Bug: None
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: Ic6bcd1836ba23c7010e2cde673a3beca73778021
2023-07-19 21:54:09 +00:00
Dan Albert
ef8e1581ce Fix mbrtoc16 reserved range test for musl.
Musl was treating 0xf0 as a valid character in its default locale. I
didn't dig into whether that was a musl bug or whether it was actually
translating whatever extended ASCII character that was into the
correct code point (tbh I don't know what the rule there is either).

Bug: None
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: I0845fdee9a016ad67ccff3716129ff29f83a63d7
2023-07-19 21:54:09 +00:00
Dan Albert
78da292886 Invert over-long UTF-8 bool for readability.
Also actually assign a bool to it. I'd originally written a #define
and apparently forgot to fix the value. I'm a bit surprised that clang
didn't complain.

Bug: None
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: Iac46bc9c48fd70853d5c447e812e25e617281d2b
2023-07-19 21:54:09 +00:00
Dan Albert
1e8e0c1f03 Fix surrogate pair deocding for musl/glibc.
Bug: https://issuetracker.google.com/289419882
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: I879de1e88d27b28f3c4892ab1b00bd942a32383e
2023-07-19 21:54:09 +00:00
Dan Albert
b9bc50910e Add musl handling in run-on-host.sh.
Bug: None
Test: ./tests/run-on-host.sh glibc
Test: ./tests/run-on-host.sh musl
Change-Id: I4f85310750402e1187358aeb4a585f26092b97ac
2023-07-19 21:53:11 +00:00
Elliott Hughes
215baed16f De-pessimize SigSetConverter usage.
While looking at the disassembly for the epoll stuff I noticed that this
expands to quite a lot of code that the compiler can't optimize out for
LP64 (because it doesn't know that the "copy the argument into a local
and then use the local" bit isn't important).

There are two obvious options here. Something like this:
```
  int signalfd64(int fd, const sigset64_t* mask, int flags) {
    return __signalfd4(fd, mask, sizeof(*mask), flags);
  }

  int signalfd(int fd, const sigset_t* mask, int flags) {
  #if defined(__LP64__)
    return signalfd64(fd, mask, flags);
  #else
    SigSetConverter set = {.sigset = *mask};
    return signalfd64(fd, &set.sigset64, flags);
  #endif
  }
```
Or something like this:
```
  int signalfd64(int fd, const sigset64_t* mask, int flags) {
    return __signalfd4(fd, mask, sizeof(*mask), flags);
  }

  #if defined(__LP64__)
  __strong_alias(signalfd, signalfd64);
  #else
  int signalfd(int fd, const sigset_t* mask, int flags) {
    SigSetConverter set = {};
    set.sigset = *mask;
    return signalfd64(fd, &set.sigset64, flags);
  }
  #endif
```
The former is slightly more verbose, but seems a bit more obvious, so I
initially went with that. (The former is more verbose in the generated
code too, given that the latter expands to _no_ code, just another symbol
pointing to the same code address.)

Having done that, I realized that slight changes to the interface would
let clang optimize away most/all of the overhead for LP64 with the only
preprocessor hackery being in SigSetConverter itself.

I also pulled out the legacy bsd `int` conversions since they're only
used in two (secret!) functions, so it's clearer to just have a separate
union for them. While doing so, I suppressed those functions for
riscv64, since there's no reason to keep carrying that mistake forward.

posix_spawn() is another simple case that doesn't actually benefit from
SigSetConverter, so I've given that its own anonymous union too.

Test: treehugger
Change-Id: Iaf67486da40d40fc53ec69717c3492ab7ab81ad6
2023-07-19 12:20:07 -07:00
Dan Albert
9a9bbe5fc6 Fix uchar.mbrtoc16_zero_len for glibc and musl.
Bug: None
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Change-Id: Ia7dd2dedd39ac287350bab42493e886939556111
2023-07-19 18:04:10 +00:00
Dan Albert
9fa76f1374 Fix mbrtoc32 tests for out of range code points.
Same as the earlier fix for mbrtoc16. Other implementations support
the older RFC, bionic supports the new one.

Bug: None
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Change-Id: I9e85a9ae53aaaa112a76665063acd2bd856b26cf
2023-07-19 17:59:29 +00:00
Dan Albert
0b8fbdf4b3 Fix mbrtoc32 test for musl and glibc.
glibc and musl both interpreted the spec differently than we did
(better, imo) for the return value of a zero-length conversion. Fix
the test to handle that.

Also converted the test from ASSERT to EXPECT to reduce the number of
builds needed to find failures.

Bug: None
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Change-Id: Id74364040ce3b0e21bacd78f70467053cc8a6058
2023-07-19 17:59:27 +00:00
Dan Albert
d0b8d3c901 Merge "Fix 5-byte mbrtoc16 test for glibc/musl." into main 2023-07-18 22:25:11 +00:00
Dan Albert
1252ab04c3 Fix 5-byte mbrtoc16 test for glibc/musl.
Also split that case out into a separate test to avoid complicating
the test for the common cases.

Bug: None
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.mbrtoc16"
Change-Id: If7e50f659ad99ee9bab8847fc7320c7bbd629c5d
2023-07-17 23:52:02 +00:00
Elliott Hughes
74d9765be9 Add __riscv_flush_icache() to <sys/cachectl.h>.
The obsolete mips header rides again!

The most interesting part of this change is that I've removed the hack
that meant that all system call wrappers starting with `__` defaulted to
being hidden symbols. That's no longer useful given our linker scripts,
and it actively got in the way here because the public libc symbol
actually starts with `__` in glibc, and it would be weird and annoying
for developers if we chose a different name.

Test: strace
Change-Id: I230479787895e8e34f566ade36346a8241eea998
2023-07-12 16:30:55 -07:00
Treehugger Robot
cfb9030ff0 Merge "Add a test for a recent POSIX change." 2023-06-26 22:51:13 +00:00
Elliott Hughes
e18c1fa371 Add a test for a recent POSIX change.
No code change required.

Bug: https://austingroupbugs.net/view.php?id=1647
Test: treehugger
Change-Id: I411a009bccafb4e2738f22199c64d8fe7dc105e3
2023-06-26 13:12:57 -07:00
Florian Mayer
bdc192cf4b Simplify MemtagNoteTests
It's easier to just disable hwasan than to handle it in the test.

Change-Id: I511c63ae8916e03d33984a749f279fabbd0a75e3
2023-06-23 13:21:19 -07:00
Treehugger Robot
8d21eac241 Merge "Format parameter for MemtagNoteTest" 2023-06-23 19:29:04 +00:00
Florian Mayer
ab9c6b1c6a Format parameter for MemtagNoteTest
Test: atest bionic-unit-tests
Change-Id: I8b8e6fb0146f600431cbf043cf212a69ecf6b648
2023-06-23 08:34:11 -07:00