History log of /bionic/tests/string_test.cpp
Revision Date Author Comments
61833de613990f2fdaf357bb3d854d72a4980890 31-Jul-2014 Christopher Ferris <cferris@google.com> Fix memchr with a zero length.

The memchr implementation for 64 bit fails if these conditions occur:

- The buffer is 32 byte aligned.
- The buffer contains the character in the first byte.
- The count sent in is zero.

The function should return NULL, but it's not.

Bug: 16676625

(cherry picked from commit e03e1eac0b7682884b6628df1305d34299680cb4)

Change-Id: Ie4cca2c445127a0936ee2b96651a8e7204fbaffd
3a657d01eca1529ba7002cbee44e149988834c9d 27-Jun-2014 Christopher Ferris <cferris@google.com> Add extra strchr testing.

Change-Id: Idd0a779eb3388e402cfcb4e0df40872320f8e155
e5fdaa4f9d102461a4d8a865e6ca84666893b9e7 14-Jun-2014 Dan Albert <danalbert@google.com> Revert "Backing this one out since the counterpart needs to be sent upstream."

This reverts commit a04d2bc28e7d7fcaf34ad71e4a6608a13cf84197.

Change-Id: I1b49165ca5d4bafdba7948818256a6167a363aca
a04d2bc28e7d7fcaf34ad71e4a6608a13cf84197 14-Jun-2014 Dan Albert <danalbert@google.com> Backing this one out since the counterpart needs to be sent upstream.

This reverts commit 5ee320dd35fafc11eaf90c62198e08c6670e35b4.

Change-Id: I1a9c6b06c3aca595f01c629f7649be743dc48e77
5ee320dd35fafc11eaf90c62198e08c6670e35b4 12-Jun-2014 Dan Albert <danalbert@google.com> Hides valloc(3)/pvalloc(3) on LP64.

These were removed from POSIX 2004. Hides the header declarations for all
targets, and hides the symbols for LP64.

Bug: 13935372
Change-Id: Id592f67e9b7051517a05f536e1373b30162e669c
24614b4729a4c8665193f5793b93019b37f779b1 13-Jun-2014 Elliott Hughes <enh@google.com> Remove __memcmp16 from bionic.

Change-Id: I2486d667d96c8900dd368d855f37c1327161efb7
2aca7fe8214d9b4f421499a6f07579c888313649 10-Jun-2014 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Fix memcmp16() test

__memcmp16() should return an integer less than, equal to, or greater than
zero. However the tests looks for a specific value.

Change-Id: I06052f58f9ccc67146a3df9abb349c4bc19f090e
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
fce861498c8c4720c6ad2475a73bb4c3e55d6948 26-May-2014 Varvara Rainchik <varvara.rainchik@intel.com> Fix for slm-tuned memmove (both 32- and 64-bit).

Introduce a test for memmove that catches a fault.
Fix both 32- and 64-bit versions of slm-tuned memmove.

Change-Id: Ib416def2610a0972e32c3b9b6055b54967643dc3
Signed-off-by: Varvara Rainchik <varvara.rainchik@intel.com>
6c80ccdeed9d9b30e961f68229fe8171d79c5d14 12-May-2014 Shu Zhang <chazhang@nvidia.com> denver: optimize memmove

Optimize 32-bit denver memmove with reversal memcpy.

Change-Id: Iaad0a9475248cdd7e4f50d58bea9db1b767abc88
0990d4fda898ada86e557f872f5cb7d16b138e3c 30-Apr-2014 Elliott Hughes <enh@google.com> Make SIGRTMIN hide the real-time signals we use internally.

__SIGRTMIN will continue to tell the truth. This matches glibc's
behavior (as evidenced by the fact that we don't need a special case
in the strsignal test now).

Change-Id: I1abe1681d516577afa8cd39c837ef12467f68dd2
950a58e24d1019eb9d814dbb16f111a6b61e3f23 04-Apr-2014 Christopher Ferris <cferris@google.com> Add stpcpy/stpncpy.

Add tests for the above.

Add the fortify implementations of __stpcpy_chk and __stpncpy_chk.

Modify the strncpy test to cover more cases and use this template for
stpncpy.

Add all of the fortify test cases.

Bug: 13746695
Change-Id: I8c0f0d4991a878b8e8734fff12c8b73b07fdd344
f04935c85e0b466f0d30d2cd4c0fa2fff62e7d6d 21-Dec-2013 Christopher Ferris <cferris@google.com> Make sure that the same tests are on all platforms.

In order to be able to generate a list of tests for cts, the same set of
tests must exist across all platforms. This CL adds empty tests where a
test was conditionally compiled out.

This CL creates a single library libBionicTests that includes all of
the tests found in bionic-unit-tests-static.

Also fix a few missing include files in some test files.

Tested by running and compiling the tests for every platform and
verifying the same number of tests are on each platform.

Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
e5bbb6b6ab662503f06ceb20fa841d2e558d596d 04-Dec-2013 Christopher Ferris <cferris@google.com> Add strcmp/memcmp testing.

Bug: 9797008
Change-Id: I11b1da060d29f7dacbb53f20a3e2082395b5bd8a
b687ad3c3491fffe22507cafc9347e10cbf6bd31 07-Nov-2013 Christopher Ferris <cferris@google.com> Add new tests for memory/string routines.

Create a few generic testing functions to allow any memory/string tests
to be created.

Add alignment tests for memcpy/memset/strcat/strcpy/strlen.

Add an overread test for memcpy/strcat/strcpy/strlen. This test attempts
to verify that the functions do not read past the end of their buffers
(src buffer in the case of src/dst functions).

Bug: 9797008

Change-Id: Ib3223ca1b99e729ae8229adc2d03f4dc3103d97c
baa91f4f8974b6e9a81fa3aa49f051b3bf823653 26-Jun-2013 Alexander Ivchenko <alexander.ivchenko@intel.com> 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>
13476deec46d7ba101c1f76b8ddcaab9d0b96b84 03-Jun-2013 Nick Kralevich <nnk@google.com> Add tests for __strcpy_chk()

Change-Id: I5675d04fcd471732c1b87b83879a54fbcd27762e
cf870199d576bdfc339b7fb016c9f6fe7f2c87ed 31-May-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: strcat / strncat optimize

__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
4f40e511b0612ea099ab5b0843977fe7a49372fd 20-Apr-2013 Nick Kralevich <nnk@google.com> libc: cleanup strchr

Move strchr to a .cpp file, and change to bionic directory.

Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97
1aae9bd170883805f2e7975cd3dbd2502b083cc1 29-Apr-2013 Nick Kralevich <nnk@google.com> strncpy: implement _FORTIFY_SOURCE=2

Add support for fortify source level 2 to strncpy.
This will enable detection of more areas where strncpy
is used inappropriately. For example, this would have detected
bug 8727221.

Move the fortify_source tests out of string_test.cpp, and
put it into fortify1_test.cpp.

Create a new fortify2_test.cpp file, which copies all
the tests in fortify1_test.cpp, and adds fortify_source level
2 specific tests.

Change-Id: Ica0fba531cc7d0609e4f23b8176739b13f7f7a83
a44e9afdd16105d6f36319cb538666d9cc78435a 18-Jan-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: optimize

Don't do the fortify_source checks if we can determine, at
compile time, that the provided operation is safe.

This avoids silliness like calling fortify source on things like:

size_t len = strlen("asdf");
printf("%d\n", len);

and allows the compiler to optimize this code to:

printf("%d\n", 4);

Defer to gcc's builtin functions instead of pointing our code
to the libc implementation.

Change-Id: I5e1dcb61946461c4afaaaa983e39f07c7a0df0ae
606058933c5129cb1026960ea67624b9426c610f 15-Jan-2013 Nick Kralevich <nnk@google.com> fix strerror_r test

e6e60065ff093ff8c859ab146cf543531cb1967c modified strerror_r to
treat errno as signed. However, the change to the test code
modified the "strerror" test, not the "strerror_r" test.

Make the same change for the strerror_r code.

Change-Id: Ia236a53df5745935e229a4446a74da8bed0cfd7b
dcab1b2c76a498c56bc00024613386de8b4b2aae 11-Jan-2013 Nick Kralevich <nnk@google.com> Add stack canaries / strcpy tests.

Add a test to ensure that stack canaries are working
correctly. Since stack canaries aren't normally generated
on non-string functions, we have to enable stack-protector-all.

Add a test to ensure that an out of bounds strcpy generates
a runtime failure.

Change-Id: Id0d3e59fc4b9602da019e4d35c5c653e1a57fae4
e6e60065ff093ff8c859ab146cf543531cb1967c 11-Jan-2013 Elliott Hughes <enh@google.com> glibc 2.15 treats errno as signed in strerror(3).

And the only reason I hadn't done that in bionic is because I wanted to behave
the same as glibc.

Change-Id: I2cf1bf0aac82a748cd6305a2cabbac0790058570
036154b0c2d64d618aded8674f2e13cbbb2867e2 05-Oct-2012 Anna Tikhonova <anna.tikhonova@intel.com> Tests for string routines.

Change-Id: I24068a228f59df1c3b758c5b2026a09720490616
Signed-off-by: Anna Tikhonova <anna.tikhonova@intel.com>
ad88a0863110798cef5169dcf917e18b967a7cf6 25-Oct-2012 Elliott Hughes <enh@google.com> Per-thread -fstack-protector guards for x86.

Based on a pair of patches from Intel:

https://android-review.googlesource.com/#/c/43909/
https://android-review.googlesource.com/#/c/44903/

For x86, this patch supports _both_ the global that ARM/MIPS use
and the per-thread TLS entry (%gs:20) that GCC uses by default. This
lets us support binaries built with any x86 toolchain (right now,
the NDK is emitting x86 code that uses the global).

I've also extended the original tests to cover ARM/MIPS too, and
be a little more thorough for x86.

Change-Id: I02f279a80c6b626aecad449771dec91df235ad01
5419b9474753d25dff947c7740532f86d130c0be 17-Oct-2012 Elliott Hughes <enh@google.com> Make dlerror(3) thread-safe.

I gave up trying to use the usual thread-local buffer idiom; calls to
calloc(3) and free(3) from any of the "dl" functions -- which live in
the dynamic linker -- end up resolving to the dynamic linker's stubs.
I tried to work around that, but was just making things more complicated.
This alternative costs us a well-known TLS slot (instead of the
dynamically-allocated TLS slot we'd have used otherwise, so no difference
there), plus an extra buffer inside every pthread_internal_t.

Bug: 5404023
Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
b5f053b5a7deb084e7a052d527e0aa41339ae05c 08-Sep-2012 Irina Tirdea <irina.tirdea@intel.com> Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).

Change-Id: I426109db25e907980d6cb3a7a695796e45783b78