summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Check memory size on FD_* functionsNick Kralevich2013-10-031-0/+14
| | | | | | | | 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
* Fix 32-bit issues in tests, and add a trivial test for the FD_* macros.Elliott Hughes2013-10-024-5/+50
| | | | Change-Id: Ia3f21ce1f0ed9236527fe44d36ccb7de6bf63113
* FORTIFY_SOURCE: Add __FD_* checksNick Kralevich2013-10-021-0/+7
| | | | | | | | | | | Add FORTIFY_SOURCE checks for the following macros: * FD_CLR * FD_ISSET * FD_SET Bug: 11047121 Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
* Use alloc_size attribute on *alloc functionsNick Kralevich2013-10-021-0/+14
| | | | | | | | | | | | | | 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
* Merge "libc: fortify recvfrom()"Nick Kralevich2013-09-271-0/+8
|\
| * libc: fortify recvfrom()Nick Kralevich2013-09-241-0/+8
| | | | | | | | | | | | | | | | | | 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
* | Add a unit test for %n.Elliott Hughes2013-09-241-0/+12
|/ | | | Change-Id: I9335e089d66c98d34577f5e1d1a54b8f507b94f6
* Fix %hhd formats in the printf family.Elliott Hughes2013-09-231-0/+127
| | | | | | | | 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
* __memcpy_chk: Fix signed cmp of unsigned values.Christopher Ferris2013-09-201-0/+55
| | | | | | | | | | | | | | | 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 883ef2499c2ff76605f73b1240f719ca6282e554) Change-Id: Id9a96b549435f5d9b61dc132cf1082e0e30889f5
* Ensure we have the off64_t variant of every function that takes an off_t.Elliott Hughes2013-09-194-0/+144
| | | | Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
* Fix host tests that need the shell.Elliott Hughes2013-09-191-0/+1
| | | | | | By making the /system/bin/sh available. Change-Id: I99200c1ddc922a2f6b5cea8ff2da98aedbe70e7b
* Add bionic-unit-tests-run-on-host special targetPavel Chupin2013-09-181-0/+21
| | | | | | | | | | 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>
* Move stack unwinding test into library.Christopher Ferris2013-08-291-4/+14
| | | | | Bug: 8291716 Change-Id: Ia270f074b574a8fe86b5ad435bdef80999c64295
* FORTIFY_SOURCE: introduce __strncpy_chk2Nick Kralevich2013-08-281-0/+60
| | | | | | | This change detects programs reading beyond the end of "src" when calling strncpy. Change-Id: Ie1b42de923385d62552b22c27b2d4713ab77ee03
* Change hard-coded directory.Christopher Ferris2013-08-271-2/+2
| | | | | | | | | 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
* Create bionic unit test library for use with CTS.Christopher Ferris2013-08-271-3/+16
| | | | | | Bug: 8291716 Change-Id: I46b749348456fae7892eecca6b44aef51a0e4747
* Work around tzcode's reliance on signed overflow.Elliott Hughes2013-08-221-0/+13
| | | | | | | | 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
* Merge "Change hard-coded temporary directory."Christopher Ferris2013-08-162-4/+4
|\
| * Change hard-coded temporary directory.Christopher Ferris2013-08-152-4/+4
| | | | | | | | | | | | | | | | 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
* | Fix pthread_getcpuclockid.Jeff Hao2013-08-152-1/+11
|/ | | | | | | | clock_gettime was returning EINVAL for the values produced by pthread_getcpuclockid. Bug: 10346183 Change-Id: Iabe643d7d46110bb311a0367aa0fc737f653208e
* Add futimens.Elliott Hughes2013-08-082-0/+54
| | | | | Bug: 10239370 Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
* Add ssse3 implementation of __memcmp16.Alexander Ivchenko2013-08-021-23/+77
| | | | | | | | __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>
* Fix pthread_getattr_np, pthread_attr_setguardsize, and ↵Elliott Hughes2013-07-151-0/+93
| | | | | | | | | | | | | | | 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
* Add a trivial gmtime(3) test.Elliott Hughes2013-07-121-0/+12
| | | | Change-Id: I849f200a455cd6971646fa45766ab22ba19fb866
* Add <sys/statvfs.h>.Elliott Hughes2013-07-092-0/+72
| | | | | Bug: 2512019 Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
* Fix inttypes.h PRI?PTR and SCN?PTR macros.Elliott Hughes2013-07-022-0/+45
| | | | | | | | 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
* More FORTIFY_SOURCE functions under clangNick Kralevich2013-06-291-0/+48
| | | | | | | | * bzero * umask * strlcat Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
* Reorganize FORTIFY_SOURCE tests.Nick Kralevich2013-06-285-1049/+306
| | | | | | | | | 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
* stdio.h: enable vs?printf clang FORTIFY_SOURCENick Kralevich2013-06-274-0/+219
| | | | | | | | | | | | Enable FORTIFY_SOURCE protections under clang for the following functions: * vsprintf * vsnprintf and add unittests. Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
* Kernel dso support for 'dl_iterate_phdr' functionSergey Melnikov2013-06-253-1/+121
| | | | | | | | | | Kernel provides virtual DSO for stack unwinding/exception handlind info for signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function for additional DWARF info gathering from DSOs. Patch enables virtual DSO enumeration via dl_iterate_phdr function. Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com> Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102
* libc: enable FORTIFY_SOURCE snprintf under clangNick Kralevich2013-06-254-0/+44
| | | | Change-Id: I8b8059782a720104722b0841994b38f873ed02aa
* bionic: revert to a single (larger) property areaGreg Hackmann2013-06-242-18/+10
| | | | | | | | | | | | | | | | d329697 is too complicated. Change the multiple property pages back to a single 128K property area that's mapped in entirely at initialization (the memory will not get allocated until the pages are touched). d329697 has other changes useful for testing (moving property area initialization inside bionic and adding __system_property_set_filename) so undo the change manually rather than with git revert. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 5f05348c18286a2cea46eae8acf94ed5b7932fac) Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
* bionic: make property area expandableGreg Hackmann2013-06-242-27/+105
| | | | | | | | | | | | | | | | | The property area is initially one 4K region, automatically expanding as needed up to 64 regions. To avoid duplicating code, __system_property_area_init() now allocates and initializes the first region (previously it was allocated in init's init_property_area() and initialized in bionic). For testing purposes, __system_property_set_filename() may be used to override the file used to map in regions. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit d32969701be070c0161c2643ee3c3df16066bbb8) Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
* libc: enable sprintf FORTIFY_SOURCE under clangNick Kralevich2013-06-244-0/+47
| | | | | | | clang doesn't support __builtin_va_arg_pack(), so we have to use #define instead. Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
* libc: enable FORTIFY_SOURCE clang strlcpyNick Kralevich2013-06-203-0/+40
| | | | Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
* Merge "Fix FORTIFY_SOURCE unittests."Nick Kralevich2013-06-192-4/+12
|\
| * Fix FORTIFY_SOURCE unittests.Nick Kralevich2013-06-192-4/+12
| | | | | | | | | | | | The compiler is too damn smart. Change-Id: Ibef3ef41ec99f8cd9c06f1dbca535819f9a08197
* | bionic: add __system_property_foreachGreg Hackmann2013-06-181-0/+19
|/ | | | | | | | | | | | find_nth() will be inefficient on a trie. Since find_nth() is only used internally and only for enumerating properties, we can add a foreach() function to do this directly. Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit 577418403d68e663fb33c7b0c8a90d862d9c00cf) Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
* Merge "libc: add limited FORTIFY_SOURCE support for clang"Nick Kralevich2013-06-185-0/+545
|\
| * libc: add limited FORTIFY_SOURCE support for clangNick Kralevich2013-06-185-0/+545
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all FORTIFY_SOURCE support when compiling under clang. At the time, we didn't have proper test cases, and couldn't easily create targeted clang tests. This change re-enables FORTIFY_SOURCE support under clang for a limited set of functions, where we have explicit unittests available. The functions are: * memcpy * memmove * strcpy * strncpy * strcat * strncat * memset * strlen (with modifications) * strchr (with modifications) * strrchr (with modifications) It may be possible, in the future, to enable other functions. However, I need to write unittests first. For strlen, strchr, and strrchr, clang unconditionally calls the fortified version of the relevant function. If it doesn't know the size of the buffer it's dealing with, it passes in ((size_t) -1), which is the largest possible size_t. I added two new clang specific unittest files, primarily copied from fortify?_test.cpp. I've also rebuild the entire system with these changes, and didn't observe any obvious problems. Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
* | bionic: fix deleting property arrays in property benchmarkColin Cross2013-06-181-4/+4
| | | | | | | | | | | | Use delete[] to delete arrays allocated with new [] Change-Id: Icc2a6b23df09049c008f7f1f50ed93a277174308
* | bionic: change properties benchmarks to read a single propertyColin Cross2013-06-181-6/+6
|/ | | | | | | | | | The properties benchmarks were reading n properties from a property area with n properties in it, which was making it hard to compare the time between runs of different sizes. Change the benchmark to read a random property per iteration so the numbers between runs are comparable. Change-Id: Ib1648ce0948d9038fce76d209608427376cfb8da
* bionic: add tests for propertiesColin Cross2013-06-173-0/+347
| | | | | | (cherry picked from commit 37d9f75dde881a0ba1c1b3253b1be19d4096963d) Change-Id: Iac00ce10a4272032a1cbdbc4204277d6876e3365
* Handles spurious wake-ups in pthread_join()msg5552013-06-121-0/+22
| | | | | | | | | | | | | | | | | | | Removed 'join_count' from pthread_internal_t and switched to using the flag PTHREAD_ATTR_FLAG_JOINED to indicate if a thread is being joined. Combined with a switch to a while loop in pthread_join, this fixes spurious wake-ups but prevents a thread from being joined multiple times. This is fine for two reasons: 1) The pthread_join specification allows for undefined behavior when multiple threads try to join a single thread. 2) There is no thread safe way to allow multiple threads to join a single thread with the pthread interface. The second thread calling pthread_join could be pre-empted until the thread is destroyed and its handle reused for a different thread. Therefore multi-join is always an error. Bug: https://code.google.com/p/android/issues/detail?id=52255 Change-Id: I8b6784d47620ffdcdbfb14524e7402e21d46c5f7
* fix unittests.Nick Kralevich2013-06-113-35/+35
| | | | | | | | | | 7e6ce1a3c52d8533fed92c143419fedb0c93988a fixed abort() to raise SIGABRT rather than causing SIGSEGV. However, the unittests were not updated. Fix unittests. Change-Id: I73db194127b9b9e9440358aa94273863765a736b
* Implement malloc_usable_size for debug impls.Christopher Ferris2013-06-072-0/+236
| | | | | | | | | | | | | | | | | | | | | | | | | | - Implemented chk_memalign. - Fixed a few bugs in leak_memalign. - Implemented {leak,fill,check,qemu}_malloc_usable_size. - Make malloc_usable_size update at run time. - Add malloc_test.cpp as a small set of tests for the malloc debug routines. - Fix the qemu routines since it's been broken since it moved to C++. - Add support for the %u format to the out_vformat in libc_logging.cpp. This is used by the emulator code. Tested using the bionic-unit-tests with setprop libc.debug.malloc set to 1, 5, and 10. I tested as much as possible on the emulator, but tracing doesn't appear to be working properly. Bug: 6143477 Merge change from internal master. (cherry-picked from commit 3d594c258045783fc9e1956ce7a4d91e302f011e) Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb
* Add tests for __strcpy_chk()Nick Kralevich2013-06-043-0/+136
| | | | Change-Id: I5675d04fcd471732c1b87b83879a54fbcd27762e
* FORTIFY_SOURCE: strcat / strncat optimizeNick Kralevich2013-05-313-0/+312
| | | | | | | | | | | | | | | | __strcat_chk and __strncat_chk are slightly inefficient, because they end up traversing over the same memory region two times. This change optimizes __strcat_chk / __strncat_chk so they only access the memory once. Although I haven't benchmarked these changes, it should improve the performance of these functions. __strlen_chk - expose this function, even if -D_FORTIFY_SOURCE isn't defined. This is needed to compile libc itself without -D_FORTIFY_SOURCE. Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
* Add strncpy FORTIFY_SOURCE tests.Nick Kralevich2013-05-302-0/+48
| | | | Change-Id: Id108b1d72b44d7e5fb911268e80bbdf896808f60
* libc: cleanup strchrNick Kralevich2013-05-022-0/+16
| | | | | | Move strchr to a .cpp file, and change to bionic directory. Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97