Commit graph

16 commits

Author SHA1 Message Date
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
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
zijunzhao
2572571786 Nullability check for mman module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ib5c4887d89581eaedcf4a3e128811a6a374a8d1b
2023-05-18 19:02:25 +00:00
Elliott Hughes
3d24d2b088 Add memfd_create(2) and mlock2(2).
These are old enough now that the latest devices will have kernels that
support them.

Also add basic doc comments to <sys/mman.h>.

Test: treehugger
Change-Id: I1b5ff5db0b6270f5c374287cac1d6a751a0259f5
2019-08-05 16:31:08 -07:00
Mark Salyzyn
68a3bcc249 bionic tests: switch to using android-base/file.h for TemporaryFile
A matching definition of TemporaryFile exists in libbase now.

Test: compile
Bug: 119313545
Change-Id: I6f84dbf3af9a9c4b270a2532a36c9cb4c0f6bb8f
2018-11-13 10:57:28 -08:00
Yi Kong
32bc0fcf69 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I5b4123bc6709641315120a191e36cc57541349b2
2018-08-02 18:09:44 -07:00
Elliott Hughes
7b0af7ad82 Always log errno when aborting.
(Where errno is relevant.)

Also consistently use -1 as the fd for anonymous mmaps. (It doesn't matter,
but it's more common, and potentially more intention-revealing.)

Bug: http://b/65608572
Test: ran tests
Change-Id: Ie9a207632d8242f42086ba3ca862519014c3c102
2017-09-15 16:18:49 -07:00
Elliott Hughes
4a253496b8 Add a test for a known kernel bug.
Bug: http://b/27265969
Change-Id: I981cb6a91015bd17d362987ed12c8ca638987c5b
2016-07-14 17:07:17 -07:00
Josh Gao
2feb9dde60 Fix test build break.
Change-Id: I73a39c6d4bb9baebbfb5572e9259bcd405116039
2015-11-19 13:44:20 -08:00
Daniel Micay
c22a7de798 extend the PTRDIFF_MAX size check to mremap
This removes another way to obtain objects larger than PTRDIFF_MAX. The
only known remaining hole is now jemalloc's merging of virtual memory
spans.

Technically this could be wrapped in an __LP64__ ifndef since it can't
occur on 64-bit due to the 1:1 split. It doesn't really matter either
way.

Change-Id: Iab2af242b775bc98a59421994d87aca0433215bd
2015-11-19 08:57:47 -05:00
Daniel Micay
4200e260d2 fix the mremap signature
The mremap definition was incorrect (unsigned long instead of int) and
it was missing the optional new_address parameter.

Change-Id: Ib9d0675aaa098c21617cedc9b2b8cf267be3aec4
2015-11-06 13:14:43 -08:00
Yabin Cui
5afae64a1b implement posix_madvise
Bug: 18472477
Change-Id: I8183de6c281acf69ed5f7f88351b056b9827b162
2014-12-04 11:01:28 -08:00
Christopher Ferris
eda26bc1ff Add/Remove mmap tests.
Remove the incorrect tests that use a negative offset for mmap without
a fd.

Add a small set of tests for mmap.

Bug: 15436969

Change-Id: Id537d33cd4cdc26dee6cdfa9bf9cf35754bce335
2014-06-12 13:16:36 -07:00
Elliott Hughes
0e44bc3bae Remove <asm/page.h>.
If we have PAGE_SIZE/PAGESIZE, POSIX says they should be in <limits.h>.

Change-Id: I3c2d574ea2aea81f524874a156361411a4ffa18e
2014-02-24 15:55:31 -08:00
Elliott Hughes
431166d995 Fix 32-bit mmap/mmap64 handling of negative offsets.
We don't actually need to worry about sign extension if we reject
negative values ourselves. Previously it was possible to come up
with negative but aligned values that we would pass to the kernel;
in the case of mmap (as opposed to mmap64) we'd incorrectly turn
those into large positive offsets.

Change-Id: I2aa583e0f892d59bb77429aea8730b72db32dcb0
2014-01-27 16:36:56 -08:00