Commit graph

1180 commits

Author SHA1 Message Date
Elliott Hughes
62e59646f8 Improve diagnostics from the assembler __memset_chk routines.
Change-Id: Ic165043ab8cd5e16866b3e11cfba960514cbdc57
2016-03-01 12:46:47 -08:00
Elliott Hughes
bf97770a86 Rewrite ifaddrs#getifaddrs_INET.
The old implementation was unnecessarily complex, and using the wrong ioctl
for point-to-point destination addresses.

Bug: http://b/27313259
Change-Id: I9cabd17e414ce42b115037a3f828d79843f604f9
2016-02-29 17:58:54 -08:00
Elliott Hughes
7dac8b8aab Fix scope ids for link-local IPv6 addresses from getifaddrs(3).
Bug: http://b/27219454
Change-Id: I7a166ff5553565f7afdab18dd2c703af4d475ab4
2016-02-17 14:38:09 -08:00
Christopher Ferris
60a5f7360e Merge "Add a memcpy(a, a, n) test." 2016-02-13 17:46:28 +00:00
Christopher Ferris
71766c2577 Add a memcpy(a, a, n) test.
clang depends on memcpy where src and dst are the same to actually
work. Even though this is, technically, undefined behavior,
clang is not going to change. Add a test to verify this assumption
holds true for android devices.

Change-Id: Ib575af3c14e705bb62c18fad7d57e1cc0d242899
2016-02-12 18:09:55 -08:00
Christopher Ferris
249fefbda0 Merge "Fix the default alignment of the allocations." 2016-02-13 01:37:06 +00:00
Christopher Ferris
72df6708c8 Fix the default alignment of the allocations.
In order to enforce this constraint:

The pointer returned if the allocation succeeds shall be suitably
aligned so that it may be assigned to a pointer to any type of object
and then used to access such an object in the space allocated.

Force all allocations on 32 bit systems to have 8 byte alignment,
and all allocations on 64 bit systems to have 16 byte alignment.

Add a test to verify that the allocator returns the correct alignments.

Bug: 26739265
Change-Id: I9af53279617408676b94e4ec6481b3ed7ffafc6a
2016-02-12 17:30:30 -08:00
Elliott Hughes
cac2908b08 Fix regerror(..., nullptr, 0).
Found by passing a bad regular expression to the Google benchmark
code (https://github.com/google/benchmark).

Change-Id: I475db71c25706bbf02091b754acabe8254062f3a
2016-02-12 16:00:53 -08:00
Elliott Hughes
884f76e3aa Add tests for zero-sized allocations.
POSIX lets us return null and set errno, but that would be annoying and
surprising.

Bug: http://b/27101951
Change-Id: I320a8a14884abb806a8d30e3e6cf1ede28b49335
2016-02-11 08:45:40 -08:00
Chih-hung Hsieh
4c3cf4ad4d Merge "Enable clang for x86_64 after fp128 fix in clang-2577113." 2016-02-09 01:27:01 +00:00
Chih-Hung Hsieh
63fedd76ad Enable clang for x86_64 after fp128 fix in clang-2577113.
Upstream LLVM fix was included in prebuilt clang-2577113.

BUG: 21899249
Change-Id: Ief3f3e28650c0bbf8749a5e5d26f45c39e15ed62
2016-02-08 17:07:33 -08:00
Elliott Hughes
8200e55d94 Add a test for a possible overflow in *printf.
It turns out we don't have any bugs here, but glibc does. Found while
chasing down a toybox failure I saw on the host, but we may as well
add the test in case we ever screw up here in future.

Change-Id: Ib8dd227ed3b742dc4dab8c09dc08e6ea9a35c807
2016-02-05 21:57:37 -08:00
Elliott Hughes
43f7c87565 Add a test for snprintf on a PTHREAD_STACK_MIN-sized stack.
This is a common thing for people to want to do, snprintf requires
a lot of stack for itself, and PTHREAD_STACK_MIN should be usable
for realistic code.

Change-Id: Ib09cfb4e0beec1c69ee0944c3ea4c5d03a94c491
2016-02-05 11:18:41 -08:00
Elliott Hughes
0c485dae70 Add in6addr_any and in6addr_loopback symbols.
Change-Id: I3a90fa448b6bd43321672ba74b84a4e9e8a67738
2016-02-03 14:13:52 -08:00
Elliott Hughes
5f26c6bc91 Really add adjtimex(2), and add clock_adjtime(2) too.
Change-Id: I81fde2ec9fdf787bb19a784ad13df92d33a4f852
2016-02-03 13:19:10 -08:00
Elliott Hughes
f226ee59e0 Add fopen64/freopen64/tmpfile64 aliases.
Our fopen/freopen/tmpfile are already always O_LARGEFILE, but let's add
the aliases for _LARGEFILE_SOURCE compatibility.

Bug: http://b/24807045
Change-Id: I5d99b3ef3c9f27ce70f13313f6a92e96c7f21f80
2016-02-03 11:24:28 -08:00
Elliott Hughes
a279324094 Merge "Fix ifaddrs#getifaddrs_INET flakiness." 2016-02-03 18:55:20 +00:00
Elliott Hughes
2d5e21f00d Fix ifaddrs#getifaddrs_INET flakiness.
The interface name wasn't being nul-terminated for the ioctl. Also clean up
the code a bit to give more useful diagnostics on failure.

Bug: http://b/26887941
Change-Id: I30c6bdc1a32733971a27ed1fb7db9d8239b6262b
2016-02-03 07:42:33 -08:00
Elliott Hughes
e4fa6e9cc7 Expose ftello64.
Also add the missing test that would have caught this.

Bug: http://b/24807045
Change-Id: I756a4d825595b52396b15898e3f717156fd1ba2f
2016-02-02 22:39:15 -08:00
Dan Albert
f68dcbe093 Fix our fortify tests for global -Werror.
If anyone has a better way of doing this it would be welcome...

Bug: http://b/26936282
Change-Id: I796896866327b4b5b5ee4ec36994fb320993f85d
2016-02-02 17:13:03 -08:00
Elliott Hughes
955426ef79 Fix a sign extension bug in stdio.
This also lets us test the EOVERFLOW behavior, which pointed out that the
fgetpos/fsetpos return on failure has always been wrong...

Bug: http://b/24807045
Change-Id: I35273eb07c8c9155af858adb27569983397580b6
2016-01-26 18:25:52 -08:00
Elliott Hughes
03e65eb03b Implement funopen64.
Bug: http://b/24807045
Change-Id: I161920978161389be34b707cc6ce8e05f760d552
2016-01-26 14:45:13 -08:00
Elliott Hughes
33697a0c43 Factor out the waiting for children in bionic tests.
Change-Id: I4a1e51b6920b33dc892d447f5bd6d10f1cb2704a
2016-01-26 13:13:52 -08:00
Elliott Hughes
94bb0fab93 Merge "Support _FILE_OFFSET_BITS=64 for most of <stdio.h>." 2016-01-26 20:51:59 +00:00
Elliott Hughes
d9bb708575 Merge "Implement POSIX lockf." 2016-01-26 20:45:32 +00:00
Elliott Hughes
5704c423c8 Implement POSIX lockf.
This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.

POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.

Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
2016-01-26 11:09:44 -08:00
Elliott Hughes
9677fab88c Support _FILE_OFFSET_BITS=64 for most of <stdio.h>.
This doesn't address funopen, but does add fgetpos/fsetpos/fseeko/ftello.

Bug: http://b/24807045
Change-Id: Ibff6f00df5fb699c8e8f13b91a75caf024540b73
2016-01-26 09:14:41 -08:00
Yabin Cui
ca48274298 Revert "Revert "Make sem_wait able to return errno EINTR for sdk > 23.""
This reverts commit 6d51085202.
And add missing bionic_sdk_version.h.

Change-Id: I24cc738b1fd1d26234c52afbc787f5b3c4a9c9cb
2016-01-25 17:39:18 -08:00
Dan Albert
6d51085202 Revert "Make sem_wait able to return errno EINTR for sdk > 23."
Broke the build. There's no such file as bionic_sdk_version.h anywhere in the tree.

This reverts commit 892b61d340.

Change-Id: Iec3f4588edfb1d1524bb5f16451fd05dc6ebe44a
2016-01-26 00:20:06 +00:00
Yabin Cui
892b61d340 Make sem_wait able to return errno EINTR for sdk > 23.
Posix standards says sem_wait is interruptible by the delivery
of a signal. To keep compatiblity with old apps, only fix that
in newer sdk versions.

Bug: 26743454

Change-Id: I924cbb436658e3e0f397c922d866ece99b8241a3
2016-01-25 13:44:39 -08:00
Josh Gao
c650447239 Merge "Remove dlmalloc." 2016-01-25 18:42:55 +00:00
Josh Gao
0ac0cee0d1 Remove dlmalloc.
Bug: http://b/17207577
Change-Id: Ie009badca6deb1f91b27a4340b70cdd6bedff893
2016-01-25 10:14:35 -08:00
Elliott Hughes
71288cbfdf Add another stdio test.
This test didn't catch anything, but it does ensure that we exercise
the "lots of files" case.

Bug: http://b/26747402
Change-Id: I6c51c6436029572a49190d509f131eb93b808652
2016-01-22 19:22:44 -08:00
Elliott Hughes
7f54348f30 Loosen up sys_time.gettimeofday.
We've seen it take 1146us on Nexus 9 (which did have exceptionally slow
system calls).

Bug: http://b/26724042
Change-Id: I263b7e1267d58fe4a6528403d03e5b245fdcd528
2016-01-21 16:43:43 -08:00
Elliott Hughes
8d6e19408c Merge "Simplify fseek/ftell." 2016-01-21 18:35:18 +00:00
Elliott Hughes
2704bd1340 Simplify fseek/ftell.
Another step towards _FILE_OFFSET_BITS=64 support.

Bug: http://b/24807045
Change-Id: I00b83c81a7b108176c4d9437bc32611f73b7e967
2016-01-21 10:34:35 -08:00
Christopher Ferris
be4f7429ca Merge "Remove dependency on zipalign." 2016-01-21 18:31:12 +00:00
Dimitry Ivanov
3e3b992469 Merge "Do not unmap reserved region on dlclose" 2016-01-21 05:30:31 +00:00
Dimitry Ivanov
f45b0e9ede Do not unmap reserved region on dlclose
dlclose used to unmap the part of the reserved region
for ANDROID_DLEXT_RESERVED_ADDRESS that was neccessary
to map PT_LOAD segments. With this change dlclose
replaces mapped PT_LOAD segments with a PROT_NONE,
MAP_ANONYMOUS | MAP_NORESERVE.

Previously caller was unmapping the reserved region after
the failed dlclose which led to race condition when someone
else reused the region freed by dlclose but before the unmap
by the chromium code.

Bug: http://code.google.com/p/chromium/issues/detail?id=568880
Change-Id: I0f5eaa2bf6641f83dde469b631c518482acc59a2
2016-01-20 20:57:47 -08:00
Christopher Ferris
c0ffceccf9 Remove dependency on zipalign.
Roll our own version of zipalign so that we can break the dependency
on the build tools zipalign. This breaks the transitive dependency
on androidfw so that building bionic unit tests in brillo works again.

Also modify the DlExtTest.ExtInfoUseFdWithOffset test so it dynamically
gets the offset of the shared library inside of the zip instead of
hard-coding the value.

Bug: 25446938
Change-Id: Idfb5d3089960a94eefa2c76e03da1ad2f4d7fb2f
2016-01-20 19:56:53 -08:00
Elliott Hughes
923f165b29 Make FILE*s less usable after fclose(3).
BSD doesn't invalidate the fd stored in struct FILE, which can make
it possible (via fileno(3), for example), to perform operations on
an fd you didn't intend to (rather than just failing with EBADF).

Fixing this makes the code slightly simpler anyway, and might help
catch bad code before it ships.

Bug: http://stackoverflow.com/questions/10816837/fclose-works-differently-on-android-and-linux
Change-Id: I9db74584038229499197a2695c70b58ed0372a87
2016-01-19 15:46:05 -08:00
Elliott Hughes
89f4e09d8d Merge "Implement if_nameindex(3)/if_freenameindex(3)." 2016-01-19 17:24:16 +00:00
Elliott Hughes
ed57b98758 Implement if_nameindex(3)/if_freenameindex(3).
This is just a subset of the recently-implemented getifaddrs(3), though if
we want to handle interfaces (such as "rmnet_*") that don't have an address,
we need to either expose ifaddrs_storage and keep track of which interfaces
we've already seen (which is pretty messy), or refactor the netlink code so
we can reuse it and just extract the information we need for if_nameindex(3).
This patch goes the latter route.

Also clean up if_nametoindex(3) and if_indextoname(3).

Change-Id: I5ffc5df0bab62286cdda2e7af06f032c767119a8
2016-01-18 12:07:38 -08:00
Yi Kong
a6c25829f1 Merge "Add more tests for getifaddrs(3)" 2016-01-17 22:48:36 +00:00
Christopher Ferris
e8efb96b9d Add comment for [p]select_smoke tests STDIN issue.
Change-Id: I59cde8b5aaac3e27419ca86d16f85e5af568acf9
2016-01-14 11:12:38 -08:00
Yi Kong
64b481c29b Add more tests for getifaddrs(3)
This adds the following two checks:

* getifaddrs sees the same list of interfaces as /sys/class/net.
* IPv4 addresses we get from netdevice(7) agrees with results from
  getifaddrs.

Change-Id: I2f6d79d0b5cde6d98a0f671d1623b6b2bc75b60f
2016-01-14 15:39:26 +00:00
Christopher Ferris
dd926b57a0 Fix select failures when STDIN is ready.
The select_smoke and pselect_smoke test can fail if STDIN has data ready
to be read. The easiest way to see the failure is to type on the command
line while running the tests.

To avoid this, allow the return value to be 2 or 3 and check which fds
are ready to be read.

Change-Id: Iafba332c5f3ed1943e3d34501f123dd45f06a8c4
2016-01-13 22:38:09 -08:00
Dan Albert
323900cd7d Merge "Escape failure messages in XML test output." 2016-01-14 06:12:32 +00:00
Dan Albert
09a99641ec Escape failure messages in XML test output.
The gtest XML format requires escaped HTML characters in the test
results.

Change-Id: Ieb9519a55cb52093dfb10a88e883b569bc372cdb
2016-01-13 21:48:56 -08:00
Christopher Ferris
13f26a7b2b Add method to run fortified versions of funcs.
Add a way to turn fortify off for the files that test fortify functions.

This method involves simply compiling the same file with fortify off and
changing the test name slightly.

It's not very pretty, and it assumes that only these few files test
functions that can be fortified.

Bug: 15195631
Change-Id: Iba9db1d508b7d28a1d6968019cb70fe08864827b
2016-01-13 17:13:21 -08:00