Commit graph

15 commits

Author SHA1 Message Date
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
Josh Gao
dcc97c0887 Disable fdtrack post-fork.
Also delete some fdsan code that attempts to check for the post-fork
state, but never will, because we update the cached pid upon fork.

Bug: http://b/174542867
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Test: treehugger
Change-Id: I9b748dac9de9b4c741897d93e64d31737e52bf8e
2021-04-07 19:00:45 -07:00
Josh Gao
3de19151e5 Add wrappers for pidfd_{open,getfd,send_signal}.
Bug: http://b/172518739
Test: `/data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter="*pidfd*"` on blueline
Change-Id: Ibae32bbedbcf26535a80a5cbfb55ce180906b610
2021-02-25 13:55:12 -08:00
Elliott Hughes
ba3187f102 Don't dump backtraces while running fdtrack tests.
I'm assuming this was useful while debugging, but isn't needed now.

Bug: http://b/180605583
Test: check logs
Change-Id: I9d5bb8db60e7709a9a52e29469f7fd1d5a9cb085
2021-02-18 17:25:53 -08:00
Treehugger Robot
e3bc50d44f Merge changes If42905f3,Id351a993,I8a082fd0
* changes:
  fdtrack: don't do anything while vforked.
  fdsan: don't do anything when vforked.
  Track whether a thread is currently vforked.
2020-05-12 07:04:58 +00:00
Josh Gao
4129113128 fdtrack: don't do anything while vforked.
Bug: http://b/153926671
Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator
Change-Id: If42905f3d6a76ed70a45e5b9edd029ffd7789045
2020-05-07 20:18:45 -07:00
Josh Gao
9413ae7366 fdtrack: fix accept test, add test for accept4.
accept creates an additional socket behind the scenes to communicate
with netd. Filter out events for temporarily created, but then closed
fds to allow for this.

Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I2168ddc60f307278e3257ffcdf591272d61d45bb
2020-04-30 16:17:04 -07:00
Josh Gao
b107eab5ef fdtrack: add wrapper for socketpair.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I8b25accf00dc01f6fab351f3ba612f6b0ff9d094
2020-04-29 17:21:16 -07:00
Josh Gao
7de412443d fdtrack: add wrapper for eventfd.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I59013f0c4da0debbcc50269c64ae9db0cdc4eaa0
2020-04-29 17:21:16 -07:00
Josh Gao
a38331d833 fdtrack: add wrappers for epoll_create, epoll_create1.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I6c881e5d67596c543526536541d5b8086e21d9e9
2020-04-29 17:21:16 -07:00
Josh Gao
1fad5283a0 fdtrack: add wrappers for pipe, pipe2.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I66826f312a65ab9f1bd8193bf684e330baa952dc
2020-04-29 17:21:16 -07:00
Josh Gao
9d512402d4 fdtrack: add tests for individual wrappers.
Add tests for all of our existing wrappers (with one commented out,
because it's unexpectedly generating multiple events).

Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I552692aef952237c2eee0dabec61b7ea7fd230e3
2020-04-29 17:21:12 -07:00
Josh Gao
7596250722 Move fdtrack APIs to LLNDK.
Test: logcat -c; fdtrack_test; logcat -d
Change-Id: Ib6f75a7c8bbc4d6efa0708dcbbfe4ad3c0641022
2020-01-30 13:55:10 -08:00
Josh Gao
97271920bf Add a tool to track down fd leaks.
Add a hook that's called upon file descriptor creation to libc, and a
library that uses it to capture backtraces for file descriptor creation,
to make it easier to hunt down file descriptor leaks.

Currently, this doesn't capture all of the ways of creating a file
descriptor, but completeness isn't required for this to be useful as
long as leaked file descriptors are created with a function that is
tracked. The primary unhandled case is binder, which receives file
descriptors as a payload in a not-trivially-parsable byte blob, but
there's a chance that the leak we're currently trying to track down
isn't of a file descriptor received over binder, so leave that for
later.

Bug: http://b/140703823
Test: manual
Change-Id: I308a14c2e234cdba4207157b634ab6b8bc539dd9
(cherry picked from commit b7eccd4b15)
2020-01-30 13:55:10 -08:00