Commit graph

166 commits

Author SHA1 Message Date
Elliott Hughes
27586ebe1a Fix utime/utimes when passed a NULL pointer.
Bug: 11383777
Change-Id: If944a42f3adfa8a6ce91c167c249e009ed63300a
2013-10-28 13:21:06 -07:00
Christopher Ferris
b38e4d536f Update running bionic unit tests on host.
Add a bionic-unit-tests-glibc-run target to run the glibc bionic unit tests.

Modify the bionic-unit-tests-run-on-host to make sure that the /system/bin
directory is created properly.

Also remove the EXTERNAL_STORAGE variable which isn't used any more.

Bug: 11234772
Change-Id: I9aea501d05700b29e938f672474d550b1872a78b
2013-10-25 10:23:12 -07:00
Elliott Hughes
11952073af Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.
(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
2013-10-24 15:48:32 -07:00
Elliott Hughes
f8fcfbc85a Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
2013-10-22 16:31:01 -07:00
Elliott Hughes
594b1a4af2 Make sure we have a mkfifo symbol.
Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
2013-10-22 12:03:19 -07:00
Elliott Hughes
3d305f1d62 Fix statvfs tests for the host.
Using /proc seems like a better idea because it's more similar across devices.
I've switched to ensuring we check the initial and final elements in the struct
too, so we have more reason to believe the whole struct is converted correctly.

Change-Id: Ia23403369485747c1452292f6c9df2bb233c04fb
2013-10-21 19:27:19 -07:00
Elliott Hughes
e4375196d6 Fix the system property tests to use $ANDROID_DATA.
This lets them work on the host.

Change-Id: I771ccc67652ae37451b45859c7831116cd830086
2013-10-21 17:40:15 -07:00
Elliott Hughes
53bfdae4ff Fix the x86_64 clone implementation.
Change-Id: Ia75f46dcb4d3222049e9a6a6fabc2b17223b47f7
2013-10-18 19:39:09 -07:00
Elliott Hughes
0c40152767 Fix the time unit tests for systems with 64-bit time_t.
Change-Id: I29df50b25d022c1c00906e71b612defa58e46e81
2013-10-18 16:21:54 -07:00
Pavel Chupin
17558dec7f x86_64: Fix bionic tests build-and-run
Change-Id: Iab48362893a212afbcbc362fdfaff5bfa5b55259
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-18 15:04:19 -07:00
Elliott Hughes
925753aa11 Fix some test assumptions that are wrong for __LP64__.
Change-Id: Ic79cd5858ceb611640a76bd03f3da4925d3150d9
2013-10-18 13:17:18 -07:00
Elliott Hughes
c7e9b23317 Fix sigaction(3) for 64-bit.
Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
2013-10-17 11:36:55 -07:00
Elliott Hughes
40d105ccb3 Switch sigpending over to rt_sigpending.
Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
2013-10-16 14:07:01 -07:00
Elliott Hughes
1f5af926fa Fix sigsuspend to use rt_sigsuspend on all platforms.
Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
2013-10-15 18:15:19 -07:00
Elliott Hughes
19e62325c2 Clean up the sigprocmask/pthread_sigmask implementation.
Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

Also, let's test the return side of these calls, not just the
setting.

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
2013-10-15 11:23:57 -07:00
Stephen Hines
abeafbd6d5 Merge "Wrap sprintf()/snprintf() macros to prevent expansion errors." 2013-10-11 23:28:32 +00:00
Stephen Hines
6c7b3cb056 Fix clang warnings in bionic.
This fixes a few diverse issues that clang warns on in bionic. First,
it specifies the appropriate converted types for format specifiers.
The "h" and "hh" modifiers specify that the user is passing a short or
char respectively. We were passing int deliberately in both cases and
relying on the compiler to implicitly downcast to the smaller type.
We also remove the non-standard "d" suffix from our double-precision
floating point constant. This is an extension for gcc that clang does
not implement. The third fix is to mark the c1 variable as unused,
since it truly is neither read nor written.

Change-Id: I4793352b9d3e58f1f4cac9e7581ef4b2a70b43c7
2013-10-11 16:20:08 -07:00
Stephen Hines
6e38072add Wrap sprintf()/snprintf() macros to prevent expansion errors.
Previously, FORTIFY_SOURCE used single macros to define these standard
functions for use with clang. This can cause conflicts with other macros used
to call these functions, particularly when those macros expand the number of
arguments to the function. This change wraps our macro definitions, so that
expansion properly takes place for programmer arguments first.

Change-Id: I55929b1fd2a643b9d14a17631c4bcab3b0b712cf
2013-10-11 12:14:49 -07:00
Nick Kralevich
b036b5ca36 FORTIFY_SOURCE: fortify read()
Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
2013-10-09 20:17:03 -07:00
Nick Kralevich
8d25327639 Revert "FORTIFY_SOURCE: fortify read()"
This change reverts
* fb3f956d07.
* 65c99de2cb

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
2013-10-09 16:46:25 -07:00
Nick Kralevich
65c99de2cb FORTIFY_SOURCE: fortify read()
Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2013-10-09 13:44:38 -07:00
Nick Kralevich
7943df62f7 Check memory size on FD_* functions
Make sure the buffer we're dealing with has enough room.
Might as well check for memory issues while we're here,
even though I don't imagine they'll happen in practice.

Change-Id: I0ae1f0f06aca9ceb91e58c70183bb14e275b92b5
2013-10-03 15:45:10 -07:00
Elliott Hughes
5b9310e502 Fix 32-bit issues in tests, and add a trivial test for the FD_* macros.
Change-Id: Ia3f21ce1f0ed9236527fe44d36ccb7de6bf63113
2013-10-02 16:59:05 -07:00
Nick Kralevich
90201d5eca FORTIFY_SOURCE: Add __FD_* checks
Add FORTIFY_SOURCE checks for the following macros:

* FD_CLR
* FD_ISSET
* FD_SET

Bug: 11047121
Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
2013-10-02 16:11:30 -07:00
Nick Kralevich
b91791d71c Use alloc_size attribute on *alloc functions
malloc and family were not declared with __attribute__((alloc_size)).
This was (sometimes) preventing FORTIFY_SOURCE related functions
from knowing the size of the buffer it's dealing with, inhibiting
FORTIFY_SOURCE protections.

Add __attribute__((alloc_size))

Information about the alloc_size attribute can be found
at http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Change-Id: Ia2f0a445f0170a7325f69259b5e7fb35a9f14921
2013-10-02 14:14:40 -07:00
Nick Kralevich
8427b7450f Merge "libc: fortify recvfrom()" 2013-09-27 16:05:44 +00:00
Elliott Hughes
7248a2d4d0 Add a unit test for %n.
Change-Id: I9335e089d66c98d34577f5e1d1a54b8f507b94f6
2013-09-24 18:01:33 -07:00
Nick Kralevich
60f4f9a5b9 libc: fortify recvfrom()
Fortify calls to recv() and recvfrom().

We use __bos0 to match glibc's behavior, and because I haven't
tested using __bos.

Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
2013-09-24 16:45:01 -07:00
Elliott Hughes
1d13c64d78 Fix %hhd formats in the printf family.
Found by adapting the simple unit tests for libc logging to test
snprintf too. Fix taken from upstream OpenBSD without updating
the rest of stdio.

Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
2013-09-23 16:02:39 -07:00
Christopher Ferris
16e185c908 __memcpy_chk: Fix signed cmp of unsigned values.
I accidentally did a signed comparison of the size_t values passed in
for three of the _chk functions. Changing them to unsigned compares.

Add three new tests to verify this failure is fixed.

Bug: 10691831

Merge from internal master.

(cherry-picked from 883ef2499c)

Change-Id: Id9a96b549435f5d9b61dc132cf1082e0e30889f5
2013-09-20 20:12:09 -07:00
Elliott Hughes
b4f7616fd6 Ensure we have the off64_t variant of every function that takes an off_t.
Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
2013-09-19 16:27:24 -07:00
Elliott Hughes
e60c4f0a6c Fix host tests that need the shell.
By making the /system/bin/sh available.

Change-Id: I99200c1ddc922a2f6b5cea8ff2da98aedbe70e7b
2013-09-19 11:28:20 -07:00
Pavel Chupin
f22fb68751 Add bionic-unit-tests-run-on-host special target
Allows running the tests linked with bionic .so on the host if host and
target are compatible. See more comments and usage limitation inlined.

make bionic-unit-tests-run-on-host should do build and run.

Change-Id: I5946fa72e009d324baa9da18f460294b3c1a615e
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-09-18 19:09:24 -07:00
Christopher Ferris
8240bed918 Move stack unwinding test into library.
Bug: 8291716
Change-Id: Ia270f074b574a8fe86b5ad435bdef80999c64295
2013-08-29 14:00:25 -07:00
Nick Kralevich
93501d3ab8 FORTIFY_SOURCE: introduce __strncpy_chk2
This change detects programs reading beyond the end of "src" when
calling strncpy.

Change-Id: Ie1b42de923385d62552b22c27b2d4713ab77ee03
2013-08-28 12:39:06 -07:00
Christopher Ferris
5227bb363d Change hard-coded directory.
The tests are using /data/data which is not accessible to a non-root
user. Change this to /data/local/tmp which is accessible to all users.

Bug: 8291716

Change-Id: I66476bbbaf5d1dc0c103863abf9219405f06a85b
2013-08-27 17:22:34 -07:00
Christopher Ferris
153d92765b Create bionic unit test library for use with CTS.
Bug: 8291716

Change-Id: I46b749348456fae7892eecca6b44aef51a0e4747
2013-08-27 14:35:56 -07:00
Elliott Hughes
7843d44a59 Work around tzcode's reliance on signed overflow.
I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929
Change-Id: I36bf3fcf11f5ac9b88137597bac3487a7bb81b0f
2013-08-22 12:21:18 -07:00
Christopher Ferris
c8039337e3 Merge "Change hard-coded temporary directory." 2013-08-16 03:13:42 +00:00
Jeff Hao
9b06cc3c1b Fix pthread_getcpuclockid.
clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183
Change-Id: Iabe643d7d46110bb311a0367aa0fc737f653208e
2013-08-15 15:34:22 -07:00
Christopher Ferris
bd6dc6a886 Change hard-coded temporary directory.
The properties tests creates a temporary directory in /data/nativetest,
but this directory might not exist in all circumstances.
Change this to create the temporary directory in /data/local/tmp.

Change-Id: I812d3e24fcd084c5d74055c9faa95b1656f255bc
2013-08-15 12:54:40 -07:00
Elliott Hughes
d0be7c8f9a Add futimens.
Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
2013-08-08 17:13:33 -07:00
Alexander Ivchenko
baa91f4f89 Add ssse3 implementation of __memcmp16.
__memcmp16 was missing in x86. Also added C-version for backward
compatibility. Added bionic test for __memcmp16 and for wmemcmp.

Change-Id: I33718441e7ee343cdb021d91dbeaf9ce2d4d7eb4
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2013-08-02 17:57:23 -07:00
Elliott Hughes
b95cf0d23a Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.
pthread_getattr_np was reporting the values supplied to us, not the values we
actually used, which is kinda the whole point of pthread_getattr_np.

pthread_attr_setguardsize and pthread_attr_setstacksize were reporting EINVAL
for any size that wasn't a multiple of the system page size. This is
unnecessary. We can just round like POSIX suggests and glibc already does.

Also improve the error reporting for pthread_create failures.

Change-Id: I7ebc518628a8a1161ec72e111def911d500bba71
2013-07-15 14:51:07 -07:00
Elliott Hughes
ee178bfb79 Add a trivial gmtime(3) test.
Change-Id: I849f200a455cd6971646fa45766ab22ba19fb866
2013-07-12 11:25:20 -07:00
Elliott Hughes
06040fd75c Add <sys/statvfs.h>.
Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
2013-07-09 13:25:03 -07:00
Elliott Hughes
74f0833df6 Fix inttypes.h PRI?PTR and SCN?PTR macros.
Our intptr_t and uintptr_t aren't "long". Add a compilation test so we remember
to fix this to cope with 32- and 64-bit later.

Bug: http://code.google.com/p/android/issues/detail?id=57218
Change-Id: I2f816d339edb4f7d57e4418b818fb4c602093f38
2013-07-02 15:35:27 -07:00
Nick Kralevich
a6cde39276 More FORTIFY_SOURCE functions under clang
* bzero
* umask
* strlcat

Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
2013-06-29 08:16:22 -07:00
Nick Kralevich
5bcf39842e Reorganize FORTIFY_SOURCE tests.
Get rid of a lot of the duplication in the various FORTIFY_SOURCE
tests. Instead, we build 4 separate static libraries, with
4 different compile time options, and link them into the final test
binary.

Change-Id: Idb0b7cccc8dd837adb037bf4ddfe8942ae138230
2013-06-28 11:54:29 -07:00
Nick Kralevich
c8ae8bd941 stdio.h: enable vs?printf clang FORTIFY_SOURCE
Enable FORTIFY_SOURCE protections under clang for the following
functions:

  * vsprintf
  * vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
2013-06-27 09:17:48 -07:00