Commit graph

1325 commits

Author SHA1 Message Date
Josh Gao
b36efa4343 Fix instances of '#if __LP64__'.
Triggers -Wundef, which is on in -Weverything.

Bug: http://b/31496165
Change-Id: Ib06107073f7dd1d584c19c222d0430da9d35630b
2016-09-15 14:21:28 -07:00
Kenny Root
f0cccdbe19 Fix memory leak in test util
This shows up when you're doing make HOST_SANITIZE=address

Test: mmma bionic && out/host/linux-x86/bin/bionic_tests_zipalign (compare before and after)
Change-Id: Ia94790496327f3818d5fdb7b5ad07e14e60bcae1
2016-09-14 17:24:37 -07:00
Treehugger Robot
0f81dd3548 Merge "Move test libraries under /data/nativetests" 2016-09-09 18:58:34 +00:00
Elliott Hughes
7f0849fd11 Fix sscanf/wcstod parsing of NaNs.
The parsefloat routines -- which let us pass NaNs and infinities on to
strto(f|d|ld) -- come from NetBSD.

Also fix LP64's strtold to return a NaN, and fix all the architectures
to return quiet NaNs.

Also fix wcstof/wcstod/wcstold to use parsefloat so they support hex
floats.

Lots of new tests.

Bug: http://b/31101647
Change-Id: Id7d46ac2d8acb8770b5e8c445e87cfabfde6f111
2016-09-07 15:01:54 -07:00
Elliott Hughes
47126edb90 Fix time.mktime_EOVERFLOW for LP32.
Times before 1901-12-13 *underflow* on LP32, making the year 1900 a bad
choice for success case.

Bug: http://b/31305222
Change-Id: I20d4885c80b57707225580db044abc8948a55fdc
2016-09-06 13:34:15 -07:00
Dimitry Ivanov
a36e59bb99 Move test libraries under /data/nativetests
Move libraries used in bionic-unit-tests out of system partition to
/data/nativetests../bionic-loader-test-libs

Bug: http://b/22182538
Test: build bionic and run bionic-unit-tests
Change-Id: I170177bef782839d0b4970ae4418bf54d0a77836
2016-09-02 14:27:47 -07:00
Treehugger Robot
dd14725eeb Merge "cc_test_library now creates shared libraries too" 2016-09-01 01:27:01 +00:00
Dan Willemsen
4156770d84 cc_test_library now creates shared libraries too
Make these compile as static libraries by properly declaring their
dependencies.

I turned off the shared version of libBionicTests because it produces
this linker warning (treated as error):

external/libcxx/include/sstream:859: warning: relocation refers to
discarded section

Change-Id: I2e1448b47a441b273d208ebd068d0d22e340a0ff
2016-08-31 16:35:01 -07:00
Elliott Hughes
a456fae45f List failing tests last, to reduce the amount of scrolling.
On actual devices, we have a lot of slow tests. Warnings about those
cause cause the failed tests to scroll off the display.

Also replace the made-up word "warnline".

Change-Id: I6b579521a21b56da8a1add08cd34888fc902646e
2016-08-31 14:49:32 -07:00
Treehugger Robot
6d7a1eec4c Merge "Remove $(module)_install_to_out_data flag from test makefile" 2016-08-30 21:16:33 +00:00
Elliott Hughes
af730e63a3 Merge "Fix SysV IPC test failures on Android devices." 2016-08-30 19:35:04 +00:00
Dimitry Ivanov
b16e443239 Remove $(module)_install_to_out_data flag from test makefile
Use non-empty $(module)_install_to_out_data_dir as indication
of custom target dir for a library.

Bug: http://b/22182538
Test: build and run bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Ibfc87f45084a6fe2f487ca1b17a7625a8d8ec707
2016-08-30 11:38:43 -07:00
Alex Vakulenko
e9014474c9 Fix pty.bug_28979140 test in Bionic
The test relies on the fact/assumes that CPU 0 is available to the
test process. This is not necessarily the case. Instead of allocating
CPU 0 to the main thread, find the first available CPU and use that
instead.

BUG=b/29991929
TEST=All Bionic unit tests pass

(cherrypick of 766275e7f697c30164678e1fed55b2a2fcbf8546.)

Change-Id: I36b311cdba57112d663d652757fd5114183fc780
2016-08-27 09:12:31 -07:00
Elliott Hughes
40bae4fc89 Fix SysV IPC test failures on Android devices.
SysV IPC has been compiled out of all our kernels.

Change-Id: I1294459697ed7dff4f21af5c7b04c8b3d3649329
2016-08-26 19:23:39 -07:00
Elliott Hughes
63615066d9 Fix execvp/execvpe behavior with absolute paths and ENOEXEC.
Bug: http://b/31091962
Change-Id: Id0b3d41868f5e3ed1ccf618bfefb46609367bc9a
2016-08-25 17:40:27 -07:00
Elliott Hughes
3c1159024c Fix execvpe ENOEXEC behavior.
The special case for absolute paths wasn't handling ENOEXEC.

Also add more extensive tests for execvpe.

Also switch to manually doing the fork in ExecTestHelper::Run because
ASSERT_EXIT doesn't actually return, meaning we were only running the
first part of each test.

Bug: http://b/31073104
Change-Id: I7a4640afc6d290c51ba2e66fc1b9bb6b0fc174f7
2016-08-24 22:56:52 -07:00
Treehugger Robot
fac56897f8 Merge "Rewrite the exec family." 2016-08-24 21:21:43 +00:00
Elliott Hughes
1b40aafe3f Rewrite the exec family.
* Removes duplication.
* Removes fixed PATH_MAX limit.
* Adds basic tests.

Bug: http://b/30032507
Change-Id: I4087a9de3e53884ac3297ebafbec4e6f8a9871b6
2016-08-24 13:03:04 -07:00
Elliott Hughes
7d4e28a486 Merge "Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>." 2016-08-18 23:58:43 +00:00
Elliott Hughes
7c59f3f6f3 Flesh out <sys/msg.h>, <sys/sem.h>, <sys/shm.h>.
Also fix <sys/ipc.h>.

Not useful except to systems/bringup folks for testing. Trivial tests
added, and double-checked under strace to see that things look right.

x86 -- which works differently to everything else -- tested on the host.

Bug: http://b/27952303
Change-Id: I328534e994ae9e90755f545478fba03038c0bb94
2016-08-18 15:23:38 -07:00
Dimitry Ivanov
fc9958ce76 Merge "[mips] Add missing linker shdr tests" 2016-08-17 18:29:52 +00:00
Treehugger Robot
ce8a5b4b9d Merge "Fix memmem behavior with empty needles." 2016-08-16 20:56:54 +00:00
Elliott Hughes
cae33ade6c Fix memmem behavior with empty needles.
Change-Id: I8b893d80c27b548652d843af9520d7adc8ba8902
2016-08-16 12:28:58 -07:00
Nikola Veljkovic
44a654446e [mips] Add missing linker shdr tests
Test: bionic-unit-tests for mips, mips64.
Change-Id: I8ed5f03df8d129e74fa04be2b203bd113a381888
2016-08-16 18:52:06 +00:00
Treehugger Robot
3b2d331e77 Merge "linker: add test for zeroed out shdr_table_" 2016-08-15 23:23:26 +00:00
Treehugger Robot
4154b77285 Merge "linker: add test for zero shdr offset" 2016-08-15 22:01:30 +00:00
Dimitry Ivanov
559583469c linker: add test for zeroed out shdr_table_
Bug: http://b/30795430
Change-Id: I86b658d01b64670d3e702ddb1d3f9db4f75d784f
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 14:06:04 -07:00
Treehugger Robot
63ccb1bdac Merge "[MIPS] Fix bionic test build" 2016-08-15 21:00:47 +00:00
Dimitry Ivanov
4623044517 linker: add test for zero shdr offset
Bug: http://b/30795430
Change-Id: I03853257c4b632ad9daaf1e90f9620678397cff0
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 13:42:47 -07:00
Treehugger Robot
228e747b6c Merge "Fix mktime's errno behavior." 2016-08-15 20:06:57 +00:00
Lazar Trsic
293d5132d0 [MIPS] Fix bionic test build
Group of libtest_invalid* libraries does not exists for mips architecture,
so disable relevant tests.

Change-Id: I3a4fef94933eb33654c4274aa249ea5d61d6cf9b
2016-08-15 12:48:20 -07:00
Dimitry Ivanov
8bdf70e6e4 linker: add test for empty shdr table
Bug: http://b/30795430
Change-Id: Id839c22f88276f31e0615bc2a67d75e27a9aa7c6
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-15 11:30:45 -07:00
Dimitry Ivanov
c9a95613a9 linker: add test for zero shstrndx
Bug: http://b/30166532
Bug: http://b/30795430
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: I4cec73635cf403df9dd60b9a294d2298bb0abe3d
2016-08-15 10:29:50 -07:00
Dimitry Ivanov
0deb70cd04 Merge changes Ibcefd6d9,I249c0815,If59cb6da
* changes:
  Remove some duplication in the makefile
  linker: add test for zero e_shentsize
  Add test for misaligned section header
2016-08-13 03:42:15 +00:00
Dimitry Ivanov
ff25581083 Remove some duplication in the makefile
Bug: http://b/30795430
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: Ibcefd6d913abafe0b202a83399db72050510cd5d
2016-08-12 16:55:17 -07:00
Elliott Hughes
f8ebaa4985 Fix mktime's errno behavior.
Don't touch errno on success, do set it to EOVERFLOW (the only allowed errno
value according to POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/mktime.html)
on failure.

Bug: http://b/30477946
Change-Id: Ia915c7b9c3bfcd2f9025530cf5b068fe4dd4fd9e
2016-08-12 16:28:36 -07:00
Dimitry Ivanov
cb86c3128f linker: add test for zero e_shentsize
Bug: http://b/30166532
Bug: http://b/30795430
Change-Id: I249c081563f0ca7bcc799d8445a53683616eaa4e
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
2016-08-12 15:28:42 -07:00
Dimitry Ivanov
972e3d0787 Add test for misaligned section header
Make sure linker does not crash when dlopening
elf-file with odd section header offset.

Bug: http://b/30795430
Bug: http://b/30687964
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: If59cb6da85b8752a69dc5687de85f9a9b74c92b4
2016-08-12 14:48:15 -07:00
Elliott Hughes
51b3b44585 Merge "Fix sysconf(_SC_ARG_MAX)." 2016-08-12 19:53:46 +00:00
Dimitry Ivanov
e8087022c1 Merge "linker: disallow W + E PT_LOAD segments" 2016-08-12 17:55:36 +00:00
Treehugger Robot
b17d845d9b Merge "Use sysinfo(2) to implement more of <sys/sysinfo.h>." 2016-08-12 17:07:41 +00:00
Dimitry Ivanov
9700babc05 linker: disallow W + E PT_LOAD segments
No mapped segment from the elf file can be writable and
executable at the same time. This commit adds a check
for malformed PT_LOAD segments in the elf-files.

Bug: http://b/30146890
Test: run bionic-unit-tests --gtest_filter=dlfcn.*
Change-Id: Ia23acbe5a48780b65d7e4a50bbe024cd528079f4
2016-08-11 17:24:47 -07:00
Elliott Hughes
c508de0e41 Use sysinfo(2) to implement more of <sys/sysinfo.h>.
We already had implementations of some of the functions, and I didn't
bother rewriting them when we added sysinfo(2). Ross Anderson said in
https://www.lightbluetouchpaper.org/2016/07/29/yet-another-android-side-channel/
that we should "simply disable access to all procfs files", which made
me curious how many places we use /proc in bionic. This is the one that's
obviously unnecessary. The others I'm not aware of alternative APIs for.

Change-Id: Ia64f36b76f29a7a1dd67845270a5472e121aae10
2016-08-11 14:51:31 -07:00
Elliott Hughes
38dba2e7e1 Fix sysconf(_SC_ARG_MAX).
ARG_MAX hasn't been a constant since Linux 2.6.23.

Bug: http://lists.landley.net/pipermail/toybox-landley.net/2016-August/008592.html
Change-Id: I1eddb562751604c75b89fa610d79be0655c53693
Test: ran the bionic tests on device and against glibc
2016-08-10 15:51:06 -07:00
Elliott Hughes
fb3873d4db Fortify vsnprintf in more cases.
Bug: http://b/30445072
Change-Id: I1893890f0e3b56533eef053eda1bd96a0b9a5119
2016-08-10 11:50:12 -07:00
Elliott Hughes
d1f25a7eb1 Reimplement remove(3) without the lstat(2).
This assumes that it's more likely we're unlinking a file than a directory,
though even if that's not true, as long as a failed unlink(2) is cheaper
than a successful lstat(2) -- which seems likely since there's no data to
copy -- we still win.

Change-Id: I0210e9cd3d31b8cf1813c55c810262ef327382ed
2016-08-05 15:53:03 -07:00
Elliott Hughes
70715da453 More stdio one-liners.
This actually turns up a bug in fmemopen, so I guess that's what I'll
look at next...

Change-Id: I2971ecd1b5a3a3c7f43c22d985f88e389af89e97
2016-08-01 18:06:38 -07:00
Elliott Hughes
0a610d00fe Upgrade to tzcode-2016f.
No significant changes other than a default implementation of strftime_l.

Change-Id: I6edd2c03e5e7559f012c0c87d43f7109d641d3ca
2016-07-29 14:04:17 -07:00
Elliott Hughes
7292725bcd Admit that we don't actually support thread priority inheritance.
Bug: https://code.google.com/p/android/issues/detail?id=218323
Change-Id: I6c69b0fbb8414e7cc2deeb8be50b6af4830ed55e
2016-07-27 14:05:10 -07:00
Elliott Hughes
f6495c78a8 Stop #define'ing __func__ and __restrict.
__STDC_VERSION__ isn't defined for __cplusplus, so we've been removing
such checks. Some got missed.

Stop defining __func__ and just use the __PRETTY_FUNCTION__ GCC extension
in <assert.h>. Also fix the #if there so that C++ gets __assert2 rather
than __assert, and rewrite the cast to work with -I rather than -isystem.

Also remove __restrict and just always use the __restrict GCC extension.

Add a trivial test for <assert.h>.

Bug: http://b/30353757
Change-Id: Ie49bb417976293d3a9692b516e28fe3c0ae0a6d9
Test: ran bionic unit tests.
2016-07-25 11:13:47 -07:00