summaryrefslogtreecommitdiff
path: root/tests/stdio_test.cpp
AgeCommit message (Collapse)Author
2016-01-19Make FILE*s less usable after fclose(3).Elliott Hughes
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-13Add method to run fortified versions of funcs.Christopher Ferris
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
2015-10-09Fix stdio read after EOF behavior.Elliott Hughes
Bug: https://code.google.com/p/android/issues/detail?id=184847 Change-Id: Ia20ce94007c2a09649f0763b1dc7ba959f2f618d
2015-04-05Add a test for getdelim(3) on a directory.Elliott Hughes
Apparently uClibc has a bug here. We don't, but let's keep it that way. Bug: http://landley.net/notes.html#21-03-2015 Change-Id: If406df963db9bee47921d7a1c116ebcab08d96bf
2015-02-27Fix fread returning bad data.Christopher Ferris
Bug: 19172514 Change-Id: I05016577858a02aca7d14e75e6ec28abc925037c
2015-01-24Fix optimized fread.Elliott Hughes
gcov does writes after reads on the same stream, but the bulk read optimization was clobbering the FILE _flags, causing fwrite to fail. Bug: 19129055 Change-Id: I9650cb7de4bb173a706b502406266ed0d2b654d7
2015-01-22Fix the stdio.fread_EOF test.Elliott Hughes
Another sizeof/strlen screwup caused by trying to be too clever. Use std::string instead. Also fix all the ASSERT_STREQ calls in this file that had the arguments the right^Wwrong way round. If I ever see Kent Beck... Change-Id: I47a1bdfee99cf4e7bed9b398f3158a308fbcf1e8
2015-01-22Fix fread_EOF test name.Elliott Hughes
Change-Id: I53a7f1428fd27c0b2a5c80f2e8af4845d17f5b4b
2015-01-20Optimized fread.Elliott Hughes
This makes us competitive with glibc for fully-buffered and unbuffered reads, except in single-threaded situations where glibc avoids locking, but since we're never really single-threaded anyway, that isn't a priority. Bug: 18593728 Change-Id: Ib776bfba422ccf46209581fc0dc54f3567645b8f
2014-12-20Fix nan output in the printf family.Elliott Hughes
Bug: https://code.google.com/p/android/issues/detail?id=82452 Change-Id: I51f226c8b033de6e81baeea5e6db3de6ed196f73
2014-12-02Avoid pathological behavior in OpenBSD's fread.Elliott Hughes
Bug: https://code.google.com/p/android/issues/detail?id=81155 Bug: 18556607 Change-Id: Idc60976b79610e2202cc42dc393dcb4ca6c42e05
2014-11-07implement missing seekdir and telldirYabin Cui
Bug: 18266863 Change-Id: I189ee949d4f7ccee099f3341e349cd969d25480f
2014-11-03Ensure we initialize stdin/stdout/stderr's recursive mutexes.Elliott Hughes
Bug: 18208568 Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
2014-09-23CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps.Elliott Hughes
Change-Id: I74ea88e0d4973d6ab3c57da7d8bb643c31592b14
2014-08-27call uselocale() before freelocale() to make sure that g_local_key has a ↵Wally Yau
valid locale. For tests that call uselocale(), the locale is stored in the g_userlocale_key thread-specific key. If freelocale() is called later, then g_uselocal_key points to a deleted pointer. CTS eventually calls vfprintf to print the result, which calls MB_CUR_MAX and MB_CUR_MAX accesses the deleted locale stored in g_uselocale_key, causing unpredictable errors. Fixed the tests by calling uselocale() with the old locale before calling freelocale. (cherry-pick of 8a46cf0fcf82b8c76e05be7e066ec854f974603a.) Bug: 17299565 Change-Id: I87efa2a9b16999a11d587f68d3aeedcbe6ac8a2c
2014-08-20Add POSIX-2008 fmemopen, open_memstream, and open_wmemstream.Elliott Hughes
Bug: 17164505 Change-Id: I59e28a08ff8b6ab632230b11a5807cfd5278aeb5
2014-07-30Proper MB_CUR_MAX.Dan Albert
Previously this was hard coded to 4. This is only the case for UTF-8 locales. As a side effect, this properly reports C.UTF-8 as the default locale instead of C. Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
2014-06-11Remove declaration for putw(3)/getw(3).Dan Albert
These were both removed from POSIX 2004, and we don't define an implementation for getw(3). Keep the definition of put(3) on LP32 for binary compatibility. Bug: 13935372 Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
2014-06-05Fix the printf family for non-ASCII.Elliott Hughes
The bug here turned out to be that we hadn't increased the constant corresponding to the maximum number of bytes in a character to match our new implementation, so any character requiring more than a byte in UTF-8 would break our printf family. Bug: 15439554 Change-Id: I693e5e6eb11c640b5886e848502908ec5fff53b1
2014-05-29Fix dprintf test.Christopher Ferris
Change-Id: Ied783d545b6a35a70a158249f3957a9d00971627
2014-05-22Add dprintf testCalin Juravle
Change-Id: I0fe1b4d45c1312cf01deed6ce5db032d5513e908
2014-05-15Document a known test issue in stdio_test.cpp.Calin Juravle
Bug: 13077905 Change-Id: Iab7fc7be0737c732e26cc07ecd7884b3087b51bb
2014-05-14Add tests for fprintf behavior when the underlying fd is bad.Elliott Hughes
Bug: 7229520 Change-Id: Ie878e0c13fdcda7b9131fa56208b84ed88125be7
2014-05-14Add a unit test for already-fixed printf -0.0 formatting.Elliott Hughes
This was fixed by the upgrade to upstream head. Bug: 5084292 Change-Id: Ia3bda1c0bbe38f428e22213b8bdbdf1a16caccf2
2014-05-13Consistently use #if defined(__BIONIC__) in tests.Elliott Hughes
I've also switched some tests to be positive rather than negative, because !defined is slightly harder to reason about and there are only two cases: bionic and glibc. Change-Id: I8d3ac40420ca5aead3e88c69cf293f267273c8ef
2014-05-13Add fpos_t tests.Calin Juravle
Bug: 13077905 Change-Id: I86bb0ee95660f69f9971231c6f828a3a067d1ac8
2014-05-12Fix use-after-free errors in stdio_test.Elliott Hughes
fclose(3) frees the passed-in FILE*. We should close(2) the underlying fd, not fclose(3) the stream, if we want to test what happens with a stream we can't read from. Bug: 14466691 Change-Id: I99fed5904b0266b9c6ae05d0b9cf2e926446c064
2014-05-05Merge "Disable %n in printf and vfwprintf."Elliott Hughes
2014-05-05Disable %n in printf and vfwprintf.Elliott Hughes
Bug: 14492135 Change-Id: If190bede29e5f68a65043ddbe8e878c660933d03
2014-05-05Switch to current upstream OpenBSD wsetup.c.Elliott Hughes
Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
2014-04-17Upgrade to current vfprintf.Elliott Hughes
This gets us various bug fixes and missing C99 functionality. Bug: https://code.google.com/p/android/issues/detail?id=64886 Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
2014-04-16Switch to gdtoa.Elliott Hughes
This gives us a real strtold for LP64 and fixes various LP64 bugs. Bug: 13563801 Change-Id: I277858d718ee746e136b6b6308a495ba50dfa488
2014-04-14Extra tests for printf of NaN and Inf.Elliott Hughes
Change-Id: I61fc655d9777a03aabf38f6ebd047fe275386f05
2014-04-02Fix the printf issue for 64 bits. The following case:Alexander Ivchenko
printf("%1$s %1$s\n", "test"); would print garbage instead of the second "test". The problem is __find_arguments and the patch is a backport of two patches from OpenBSD that fix the issue: Author: tedu <tedu@cvs.openbsd.org> Date: Sat Apr 29 23:00:24 2006 +0000 check mmap for failure. the helper functions using it return -1, but callers do not yet check since printf() for example is not documented to return an error. some formatting cleanups. mostly ok deraadt millert Author: millert <millert@cvs.openbsd.org> Date: Fri May 16 14:28:54 2008 +0000 C99 says that for each va_copy() there must be a matching va_end(). Replace the non-portable hackery in __find_arguments() with a union. From FreeBSD. Change-Id: I6ea392ce6fcf4a319ae6a67ec58cc52fe7cbe534 Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2014-03-17Use the float/double assert macros.Christopher Ferris
The normal ASSERT_EQ macros don't work quite right for float/double values, and result in false failures. Use the correct macros instead. Bug: 13511379 Change-Id: Ic2feee7f3d3569f57b6453b8fa95222846c625cd
2014-03-12Upgrade to current upstream scanf implementation.Elliott Hughes
Also add a basic test. Change-Id: Icc0e68a5716b9579244f6eb8bac1ab5a24eda85a
2014-02-06Make sure that the same tests are on all platforms.Christopher Ferris
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
2013-12-19Don't abort in stdio.getdelim_invalid and stdio.getline_invalid.Elliott Hughes
Change-Id: Ie1aefed732f4bea77887bddd1be9a0578e247aa3
2013-11-15Modify tests for another glibc difference.Christopher Ferris
It turns out that when passing a closed file to getdelim or getline, the functions in glibc will properly return a failure, but errno might not be set. Skip the errno check except on bionic. Change-Id: I8d625f15303d4c2d42e8d28491ea8a368aea4d32
2013-10-29Fix up failing glibc tests.Christopher Ferris
There is a known bug running clone with the CLONE_VM flag, so for host create an empty test. Change the expected output of the stdio test for a glibc difference. Change the pause test to use ScopedSignalHandler to setup/restore the SIGALRM handler. After this, running bionic-unit-tests-glibc passes for all tests. Bug: 11389824 Change-Id: Ib304eae4164115835a54991dfdca5821ecc3db5e
2013-10-18Fix some test assumptions that are wrong for __LP64__.Elliott Hughes
Change-Id: Ic79cd5858ceb611640a76bd03f3da4925d3150d9
2013-10-11Fix clang warnings in bionic.Stephen Hines
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-09-24Add a unit test for %n.Elliott Hughes
Change-Id: I9335e089d66c98d34577f5e1d1a54b8f507b94f6
2013-09-23Fix %hhd formats in the printf family.Elliott Hughes
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-04-11Start moving to current FreeBSD stdio.Elliott Hughes
This only touches the easy stuff. Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
2013-03-08Let bionic use the correct definition of ssize_t.Elliott Hughes
Bug: 8253769 Change-Id: I50c7cc20828fc089b83580e039ce9153a6c5a8cc
2013-03-06Upgrade to current NetBSD popen/pclose.Elliott Hughes
This gets us back to using vfork now our ARM vfork assembler stub is fixed, and adds the missing thread safety for the 'pidlist'. Bug: 5335385 Change-Id: Ib08bfa65b2cb9fa695717aae629ea14816bf988d
2013-02-28Avoid changing the C++ ABI with ssize_t.Elliott Hughes
Bug: 8253769 Change-Id: Ia325003ed6e59da553e2bdde7c43515bc191b8ba
2013-02-19use architecture-specific ssize_t definitionThorsten Glaser
after change 32822 was rejected, this is the more light-weight version of the fix: libc/include/sys/types.h already - via libc/kernel/common/linux/posix_types.h - includes a definition of __kernel_ssize_t from libc/kernel/arch-*/asm/posix_types.h which is architecture-specific, toolchain-agnostic and also gets rid of the gcc -Wformat warning (which it issues correctly, since this i̲s̲ indeed a bug in bionic) Change-Id: Ie4503ab16628bc25815a836d07556f665e9795c7
2013-02-11Fix __pthread_clone on ARM to set errno on failure.Elliott Hughes
MIPS and x86 appear to have been correct already. (Also fix unit tests that ASSERT_EQ with errno so that the arguments are in the retarded junit order.) Bug: 3461078 Change-Id: I2418ea98927b56e15b4ba9cfec97f5e7094c6291