History log of /bionic/tests/unistd_test.cpp
Revision Date Author Comments
a7f12944d4154a445ee774683e27447d609de540 15-Dec-2017 Elliott Hughes <enh@google.com> A few more trivial tests.

Based on gaps in the list of functions not referenced by the test
executable.

Bug: N/A
Test: ran tests
Change-Id: I73c238e7cf360f94670c7cd13eb954341c940b7b
baed51ee3a13dae4b87b11870bdf7f10bdc9efc1 16-Nov-2017 Elliott Hughes <enh@google.com> Change ARG_MAX/_SC_ARG_MAX back to a constant.

As per the lkml thread https://lkml.org/lkml/2017/11/1/946.

Bug: http://b/65818597
Test: ran tests
Change-Id: I7a0610e6903e6761f2b31416e2f5017bd7a60659
cf3a3e67742ac2a46414531202bb13bf871395ab 23-Oct-2017 Elliott Hughes <enh@google.com> Fix unistd.sysconf test.

A previous change added new assertions about these, but didn't remove
these old now-invalid assertions.

Bug: http://b/68133223
Test: ran tests
Change-Id: Ib6ce6e5f7abe143f2c871e074e7fd51faaf452ac
4d215aad85cd9cba3e815eafb8c56eb5218eafb1 19-Oct-2017 Elliott Hughes <enh@google.com> Add POSIX fexecve.

I'm skeptical about the usefulness of this, but it's in POSIX, it's
in glibc (but not iOS), and it is used in some internal source (test
runners and container code).

Bug: N/A
Test: ran tests
Change-Id: I92c5398f2a679b21a33fba92bc8e67e3ae2eb76f
fa386e0d1eb52478f11b7232d280919245c1616c 18-Oct-2017 Elliott Hughes <enh@google.com> Add POSIX swab.

Surprisingly to me, there are actual uses of `swab` in the codebases
I have available to search, including one with a #ifndef __ANDROID__
around it.

Bug: N/A
Test: ran tests
Change-Id: Ic91b78ae22bb65c346cb46dd38916f48d979abe0
19d768598205d915a856ec8f8bf6f996dc6fa83a 18-Oct-2017 Elliott Hughes <enh@google.com> More <limits.h> fixes.

Went through the POSIX spec for the _POSIX* and _XOPEN* constants.

Bug: http://b/32776472
Test: ran tests
Change-Id: I389100dbc7de354eae9056e44b0a7fa8c37374e3
14e3ff9f09fdd52db43628ccd6f39a6d3fb41740 07-Oct-2017 Elliott Hughes <enh@google.com> Implement <spawn.h>.

As described here:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html

And here:

http://man7.org/linux/man-pages/man3/posix_spawn.3.html

Bug: N/A (but mentioned in my inbox since 2013)
Test: ran tests
Change-Id: I0b27b2919b660779e3bd8a25fb429527c16dc621
aaf83e8051abf9a68e9deee589b18f0ecdf1b266 06-Oct-2017 Elliott Hughes <enh@google.com> More POSIX limits cleanup.

http://man7.org/linux/man-pages/man7/posixoptions.7.html is a very useful
quick reference to what these are supposed to mean.

Bug: http://b/32776472
Test: ran tests
Change-Id: Icea6812d6075e663885844d7424aa6cf73d6284a
3a8f75d8b052611c08ef17ecf625b8021f4e0229 05-Oct-2017 Elliott Hughes <enh@google.com> POSIX clock cleanup.

The newest of these clocks was added in Linux 2.6.12, so no need for runtime
checks.

Add CTS tests that we can actually use the various clocks.

Bug: http://b/67458266
Test: ran tests
Change-Id: I3cfd7982043d6f8d4ebdc2b29e8722334f443ce5
5a7c950909b28c22653f1e72a9559d9316b93f0f 04-Oct-2017 Elliott Hughes <enh@google.com> Sync internal and external master.

Not sure how this managed to cling on in AOSP master, but all the other
mentions of this constant in AOSP master are already expecting the new
value anyway.

Bug: N/A
Test: ran tests
Change-Id: I8b6b4b320eeb1c4cea1c06bea4c1e8e314ee344d
896362eb0e82bcde71c137c925eae9e0882acb91 25-Aug-2017 Elliott Hughes <enh@google.com> Add syncfs(2).

GMM calls this system call directly at the moment. That's silly.

Bug: http://b/36405699
Test: ran tests
Change-Id: I1e14c0e5ce0bc2aa888d884845ac30dc20f13cd5
68ab54444a2da7e11cdd3c35a87a72430f4051ac 29-Jul-2017 Elliott Hughes <enh@google.com> Fix the sysconf _SC_2_VERSION test.

Not sure how this ended up broken. Too many branches!

Bug: http://b/64565873
Test: ran tests

(cherry picked from commit 6c135f4c41c0fafcf270aea5202adc6e68e04b76)

Change-Id: Ie7078541d2a75fb2fbcf03e78a49707307b674c0
6c135f4c41c0fafcf270aea5202adc6e68e04b76 29-Jul-2017 Elliott Hughes <enh@google.com> Fix the sysconf _SC_2_VERSION test.

Not sure how this ended up broken. Too many branches!

Bug: N/A
Test: ran tests
Change-Id: Ieef1e8170c9aaf139d9e0664475ccb08b8fcdeba
06bd5862b18e0b750a709f7f8a1d277f1f6d0c99 29-Jul-2017 Elliott Hughes <enh@google.com> POSIX getlogin_r/LOGIN_NAME_MAX/TTY_NAME_MAX.

Bug: N/A
Test: ran tests
Change-Id: I97c8ecc82fb09c3fa4bb5e6f000d46f04f3d1702
55daf8a600ed8119753f4e4250aed6b6f18add9c 18-Jul-2017 Elliott Hughes <enh@google.com> Remove weaker _POSIX_THREAD_PROCESS_SHARED test.

This branch (master, which will be o-mr1) already has a stronger test
than this one (which was added for o-dr, which doesn't have its own API
level).

Bug: http://b/62424597
Test: ran tests
Change-Id: Icfb7b50fa3c5b6d256d378add12c854a899a1c92
7b41aaf3d5515eba8b37a7368dfa57a655f1472e 13-Jul-2017 Elliott Hughes <enh@google.com> Loosen _POSIX_THREAD_PROCESS_SHARED test.

Bug: http://b/62424597
Test: bionic unistd.sysconf test
Change-Id: I4adb6d227f761360e9d3fe084a45c386bc6944da
a35293534f1aa481cc299b1c092e6619806e17f7 13-Jul-2017 Elliott Hughes <enh@google.com> Fix unistd._POSIX_macros_smoke test.

We now claim _POSIX2_VERSION, but the test wasn't updated.

Bug: N/A
Test: ran tests
Change-Id: Idb3369b3df4b964f585597f0d37962ae619322d2
468c8086e6f28b9342d3f89ed89f185ab5bb775a 20-May-2017 Elliott Hughes <enh@google.com> Fix _POSIX_THREAD_PROCESS_SHARED.

We've had pthread_*_setpshared for long enough that there are no
__INTRODUCED_IN guards.

Found because fio's configure script was confused by this.

Bug: N/A
Test: ran tests
Change-Id: I07b4d937741e4dcd7e615f2371b17c827341917a
98f016f4c1b9cbec76f80c802bd5594bec76263e 06-Apr-2017 Tom Cherry <tomcherry@google.com> Move scopeguard into android::base

Test: boot bullhead, bionic unit tests
Change-Id: I223249684867655ecb53713b10da41d3014f96ae
b8ab61804cec48e4ca585f4508fb1b7c6c5a04c5 06-Apr-2017 Tom Cherry <tomcherry@google.com> Move scopeguard into android::base

Test: boot bullhead, bionic unit tests
Change-Id: I223249684867655ecb53713b10da41d3014f96ae
30a36273ab761fb07892f7816b4873b6c48a0cea 23-Feb-2017 Elliott Hughes <enh@google.com> Cope with argv[0] being null in the dynamic linker.

Somewhat unsurprisingly, very few commands are happy to be run like this,
in particular multiplexed commands like toybox. But that's no reason for
the linker to get in the way too.

Bug: http://b/33276926
Test: new test
Change-Id: I6dd71ea0183f4da83571039c2198ebb6ed38520e
68ecec1965dcec08c7df3f0224d69604c683cd6c 31-Jan-2017 Evgenii Stepanov <eugenis@google.com> Fix CFI initialization crash on x86.

Third try.

Bug: 34752378
Test: bionic tests
Change-Id: I247c127489a8ee38404e104f28d916a704e35f36
beb3eb1790dffc6e2f57a670aec89364944f66c4 01-Feb-2017 Evgenii Stepanov <eugenis@google.com> Revert "Fix CFI initialization crash on x86."

Breaks aosp-master/sdk.

This reverts commit 4ccd4317f9301ec9b32aa0d3317a0439b994d7bf.
4ccd4317f9301ec9b32aa0d3317a0439b994d7bf 31-Jan-2017 Evgenii Stepanov <eugenis@google.com> Fix CFI initialization crash on x86.

Second try.

Bug: 34752378
Test: bionic tests
Change-Id: I0a7453154671918b2e6e72f0bb9074c29ceb0f34
6fcd7a7d28aa6be42bbc99070c93d4d16b56ab57 31-Jan-2017 Alex Cheung <alexcheung@google.com> Revert "Fix CFI initialization crash on x86."

This reverts commit be46d3871c91902504e5ec4c7f575c86f647aafc.

Reverting due to broken build:

https://android-build.googleplex.com/builds/branch-dashboard/aosp-master?build_id=3687823

Change-Id: I30968398edd9a094fce878839ba0a002ed487a77
be46d3871c91902504e5ec4c7f575c86f647aafc 27-Jan-2017 Evgenii Stepanov <eugenis@google.com> Fix CFI initialization crash on x86.

Bug: 34752378
Test: bionic tests
Change-Id: If8e33f76a1a2d83356d818fed506ea624f579860
5965bf09d4da45a86c4fbedc2ee33be0b0eb97bb 02-Dec-2016 Elliott Hughes <enh@google.com> Fix unistd.execvpe_ENOEXEC and unistd.execvpe_failure.

These passed when run directly (as root) but failed in CTS' more restricted
environment.

Bug: http://b/33270012
Test: ran CTS tests
Change-Id: Iccb407769fe356c30d52a0a99fff11862134a250
fb5b9bb3bb60b28619708f59c0e140db961f903d 23-Nov-2016 Yabin Cui <yabinc@google.com> Remove CLONE_NEWNS for gettid and getpid cache tests.

Using CLONE_NEWNS flag is not related to the tests, and it make
the tests unavailable in cts tests. So remove the flag.

Bug: http://b/33089743
Test: run CtsBionicTestCases --gtest_filter=unistd*.
Change-Id: I4bda39c6a0c41c9973d275202a3a7f7a1e9bbba3
e462117087b5fa34ec6c1ca22c84b2a34b9ab95c 03-Nov-2016 Robert Sesek <rsesek@google.com> Set __get_thread()->tid as part of clone().

This was previously done only in fork() and pthread_create(), but this left raw
clone() with an invalid cached tid. Since the tid is used for pthread routines,
this led to unstable behavior after clone().

Test: ltp clone01 (see bug for more)
Test: mmma bionic/tests
Test: bionic-unit-tests-static --gtest_filter=*fork*:*clone*

Bug: 32612735
Bug: 32305649
Change-Id: I30eae5a8024b4c5da65476fcadfe14c6db35bb79
a4edf7a57cf818d19546c86b74146335468ea53f 25-Oct-2016 Robert Sesek <rsesek@google.com> Fix gettid() after clone().

The tid is cached in the pthread_internal_t and is properly re-set after fork()
and pthread_create(). But after a plain clone() the value is stale from the
parent.

Test: mmma bionic/tests
Test: bionic-unit-tests-static --gtest_filter=*fork*:*clone*
Test: m checkbuild tests
Test: angler boots

Bug: 32305649
Change-Id: I026d416d1537484cd3e05c8493a35e5ed2acc8ed
73c44a4738fdb615eaede1d0ab21fc3de59105ab 19-Oct-2016 Elliott Hughes <enh@google.com> Fix our _POSIX_* macros to declare barriers and spin locks.

We have these now.

Test: ran tests
Change-Id: Ie7b479061ecec19c8b35ea81e04debfd8323d94a
63615066d9f0b0b1c653c91a9b305e6c292c835a 26-Aug-2016 Elliott Hughes <enh@google.com> Fix execvp/execvpe behavior with absolute paths and ENOEXEC.

Bug: http://b/31091962
Change-Id: Id0b3d41868f5e3ed1ccf618bfefb46609367bc9a
3c1159024c5ca3e85d4fd076f39712da4b27ed34 25-Aug-2016 Elliott Hughes <enh@google.com> 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
1b40aafe3f192f0fdccc04e75cc48b0ed74bc23e 18-Aug-2016 Elliott Hughes <enh@google.com> Rewrite the exec family.

* Removes duplication.
* Removes fixed PATH_MAX limit.
* Adds basic tests.

Bug: http://b/30032507
Change-Id: I4087a9de3e53884ac3297ebafbec4e6f8a9871b6
38dba2e7e16028cdede8f48c58d18e79491f8ed9 11-Aug-2016 Elliott Hughes <enh@google.com> 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
7292725bcd291bda814554fcb9d7c026619c0e49 27-Jul-2016 Elliott Hughes <enh@google.com> Admit that we don't actually support thread priority inheritance.

Bug: https://code.google.com/p/android/issues/detail?id=218323
Change-Id: I6c69b0fbb8414e7cc2deeb8be50b6af4830ed55e
175dd8ac616f807cebf39917c2652e3fe23c633d 22-Jun-2016 Daniel Xie <dxie@google.com> DO NOT MERGE: push out fix for data dir.

Change-Id: I97ff02676e7f6008c26ddb5c41eb113b4b62280f
a948a4e050883801ad8f7c72e8ef33c776850329 21-May-2016 Christopher Ferris <cferris@google.com> Change use of /data to /data/local/tmp.

The unistd fsync/fdatasync were changed to use /data from /.
Unfortunately, this directory is unreadable unless you are root, so
change this path to /data/local/tmp.

Bug: 28885777
(cherry picked from commit 7e53843f7b4c061920d1742c8e70a50509d83a53)

Change-Id: I14514e985af8039ab63ac2bcf890f8d04dd82ccb
2e6e99128acead0b8a996e9775dc157988946d92 11-May-2016 Shuhei Takahashi <nya@google.com> Run fsync tests on mutable filesystem.

The purpose of those tests is to ensure fsync succeeds for
directories. However, they try to call fsync for / (the root
filesystem) that is usually mounted read-only, which does not
make sense because the whole point of fsync is to flush
uncommitted changes to the filesystem.

In fact, some well-known read-only filesystems (e.g. squashfs)
does not support fsync, so these tests fail if we use such
filesystems as the root filesystem.

This patch changes the tests to call fsync against /data
instead. /data is a user data partition and should be always
mounted read-write.

Bug: 28681455

(cherry picked from commit cfa3262ce46fdec81cb011ec78273df68c325c9c)

Change-Id: I3e50f7b6ef07e96138711eef1f678f90cc9eb632
7e53843f7b4c061920d1742c8e70a50509d83a53 21-May-2016 Christopher Ferris <cferris@google.com> Change use of /data to /data/local/tmp.

The unistd fsync/fdatasync were changed to use /data from /.
Unfortunately, this directory is unreadable unless you are root, so
change this path to /data/local/tmp.

Bug: 28885777
Change-Id: Ia88da7a05c8f1b05fbd45ef2e8c55ba0c3368164
1944780b62f84acb660f46c8ae37e10928de8dab 22-May-2014 Christopher Ferris <cferris@google.com> Fix overflow testing in sbrk.

Modify the overflow testing for sbrk.

Bug: 15188366
Bug: 28740702

(cherry picked from commit 738b0cc5e95a9a650e9621603f4dd8dd16b07568)

Change-Id: Id79a2314d86333d689b291bc32e513664df7e058
f36b5088a32775c44661fb6b348ed0b6b3b67e65 26-Apr-2014 Elliott Hughes <enh@google.com> Fix brk/sbrk error checking.

Note that the kernel returns the current break on error or if the requested
break is smaller than the minimum break, or the new break. I don't know where
we got the idea that the kernel could return -1.

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Bug: 28740702

(cherry picked from commit 533dde4dbf87d6615952be3654fc74e5ff2e1003)

Change-Id: Ied16987756a501acf292368a14e3727ad631efa5
cfa3262ce46fdec81cb011ec78273df68c325c9c 11-May-2016 Shuhei Takahashi <nya@google.com> Run fsync tests on mutable filesystem.

The purpose of those tests is to ensure fsync succeeds for
directories. However, they try to call fsync for / (the root
filesystem) that is usually mounted read-only, which does not
make sense because the whole point of fsync is to flush
uncommitted changes to the filesystem.

In fact, some well-known read-only filesystems (e.g. squashfs)
does not support fsync, so these tests fail if we use such
filesystems as the root filesystem.

This patch changes the tests to call fsync against /data
instead. /data is a user data partition and should be always
mounted read-write.

Bug: 28681455
Change-Id: I9314dad6f8d54c66401714af0f66e782ebd8e319
126ab128824ce98fbc79ce0f19149407bcb82390 31-Dec-2015 Daniel Micay <danielmicay@gmail.com> tests: allow brk to fail with ENOMEM

Any caller of brk needs to handle failure by falling back to mmap as
there's no guarantee that other mappings are not placed above the brk
heap. Since jemalloc starts with mmap in the first place and dlmalloc
knows how to fall back to mmap, it's already a legacy API in Android.

Forcing it to succeed rules out stronger ASLR implementations where the
brk heap might not have any room to grow. It's also valid for the brk
implementation to simply return -1 with errno set to ENOMEM in every
case and that's a good way of finding anything relying on it. It would
make sense for it to be an optional kernel feature.

The brk heap is also not guaranteed to be initially page aligned. PaX
ASLR randomizes the internal bits. It was only mentioned in a comment to
explain the design of the test though.

Bug: 24233096
Change-Id: I16e9bc8677e796c73915b830b99b0ce39c02b31d
e2faf07d659b1c824002e50b9cdfa9caae62a31b 03-Mar-2016 Greg Hackmann <ghackmann@google.com> Add {get,set}domainname(2)

{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
33697a0c43c48e15c3bcf018138b9b837d0099cd 26-Jan-2016 Elliott Hughes <enh@google.com> Factor out the waiting for children in bionic tests.

Change-Id: I4a1e51b6920b33dc892d447f5bd6d10f1cb2704a
5704c423c81790195161c1757ae79da188590c51 26-Jan-2016 Elliott Hughes <enh@google.com> Implement POSIX lockf.

This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.

POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.

Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
13f26a7b2bff5ed88b925b7206256e07596f3626 13-Jan-2016 Christopher Ferris <cferris@google.com> Add method to run fortified versions of funcs.

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
939a7e01197858fdb8463bb5a8284ba501a3e882 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename from base/ to android-base/.

Change-Id: I0a4592945400b1fa6892bf7c1fa8659fd711efa3
0b2acdfcc99ecf3ff36fc6337e14b171170f38cf 03-Oct-2015 Elliott Hughes <enh@google.com> Use const auto& in for loops.

Change-Id: Ic437c59797ee4e7dc38291da35c72d827bc89c8d
cb6f599c44b144db26c13507dbd89805b8fe03be 30-Sep-2015 Yabin Cui <yabinc@google.com> Fix the way to count online cpus.

Read /proc/stat to count online cpus is not correct for all android
kernels. Change to reading /sys/devices/system/cpu/online instead.

Bug: 24376925
Change-Id: I3785a6c7aa15a467022a9a261b457194d688fb38
5891abdc66aa9578395bc8b8e5740f629a2694b7 08-Aug-2015 Elliott Hughes <enh@google.com> Invalidate cached pid in vfork.

Bug: http://b/23008979
Change-Id: I1dd900ac988cdbe10aad3abc53240c5d352891d5
189394b885e4b11e9f009fd2e434e6dc6696277b 25-Jul-2015 Elliott Hughes <enh@google.com> Use AT_PAGESZ for sysconf(_SC_PAGE_SIZE).

Bug: http://b/18342333
Change-Id: Id12ed4e85a0f35d7d27202f7792df42a65a74b4e
c5e02eeb353c3cdd357413f563701d5018fc76a5 01-Jun-2015 Dan Albert <danalbert@google.com> Cleanup ftruncate negative test.

Addresses post-submit comments from
I54692ab8105dd09db6af7a2c0894a17bdd118aa0.

Bug: http://b/21309901
Change-Id: Ie19ee8cdcc4055a65fe7dfc103156e54eafe8977
(cherry picked from commit 9d476a02e9a14e847669a6683c585028175aa322)
9d476a02e9a14e847669a6683c585028175aa322 01-Jun-2015 Dan Albert <danalbert@google.com> Cleanup ftruncate negative test.

Addresses post-submit comments from
I54692ab8105dd09db6af7a2c0894a17bdd118aa0.

Bug: http://b/21309901
Change-Id: Ie19ee8cdcc4055a65fe7dfc103156e54eafe8977
5f3e19dbbeb851fff5cf7f9869d344feca479413 20-May-2015 Dan Albert <danalbert@google.com> Fix error handling for negative size in ftruncate.

Bug: 21309901
Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0
(cherry picked from commit c05554ec5c9aff5e0f1e83de9bb62c3569eecca2)
c05554ec5c9aff5e0f1e83de9bb62c3569eecca2 20-May-2015 Dan Albert <danalbert@google.com> Fix error handling for negative size in ftruncate.

Bug: 21309901
Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0
be52e658171edf6651895c40d1563289bafa52f7 24-Feb-2015 Elliott Hughes <enh@google.com> Fix dup2 in the case where the two fds are equal.

dup3's behavior differs from dup2 in this case, so we need to paper
over that in the C library.

Change-Id: I313cd6f226db5e237f61866f324c5ecdd12bf762
6c238f2926e69a950f0671ae5519584c20d84196 12-Dec-2014 Yabin Cui <yabinc@google.com> Fix pthread key num calculation.

Bug: 18723085
Change-Id: Iba2c834b350e4cdba0b2d771b221560a3e5df952
725756045e03ea6f7ef00d02e883ef2914d06dde 08-Dec-2014 Yabin Cui <yabinc@google.com> Change _POSIX_CPUTIME macro to make it compitable with glibc.

Change-Id: I7a8dbb74bd622693c9fef60bd779687207517b7d
634816055f51c536d24dea30dfe930b7fe2fa603 02-Dec-2014 Yabin Cui <yabinc@google.com> support _POSIX_REALTIME_SIGNALS

Bug: 18489947
Change-Id: I2e834d68bc10ca5fc7ebde047b517a3074179475
5afae64a1bac56638c6348f0c8f5e9d61b654029 26-Nov-2014 Yabin Cui <yabinc@google.com> implement posix_madvise

Bug: 18472477
Change-Id: I8183de6c281acf69ed5f7f88351b056b9827b162
d5c652756bb1a52959cd5c62447b62462f90f983 26-Nov-2014 Yabin Cui <yabinc@google.com> support _POSIX_CPUTIME

Bug: 18490039
Change-Id: I01fa83b48e1b908de1f227b6e4f98e280bcd50ee
1c19194c9d2518dbe86973cd313a277ecb70d75c 20-Nov-2014 Yabin Cui <yabinc@google.com> flesh out sysconf(3) and the _POSIX_* constants

Bug: 17571891
Change-Id: I81036615486bde65969ae5662587fcc88348474e
bc6447673fba0b38d948dcd627ab6744395c771a 25-Sep-2014 Derek Xue <derek.xue@linaro.org> bionic/test: migrate sysconf tests from system/extras to bionic/tests

The old test are implemented in file:
system/extras/tests/bionic/libc/other/test_sysconf.c
This change is to migrate them to bionic/tests with the gtest format.

and since the sysconf is defined in unistd.h, will put the test under
bionic/tests/unistd_test.cpp file as unistd.syscon test

Change-Id: Ie519147c1c86a6c4cefa8c88b18bf58bdfbffbdb
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
b5e581abfe28de8ed6c8c8af1c265bb4e36f97bb 08-Nov-2014 Yabin Cui <yabinc@google.com> Increase support of pathconf options.

Bug: 18206366
Change-Id: Ie770e49f5af3631eb9fbd2cd5174edf004c81e00
fb50057138ef37232dc67c8559fd26719ee26021 13-Nov-2014 Elliott Hughes <enh@google.com> Fix glibc 2.15 build.

glibc 2.15 has prlimit64, has an unsetenv that's declared nonnull,
and hasn't fixed the problems we were having trying to use the
POSIX strerror_r in C++ code.

Change-Id: I834356a385e5ae55500bd86781691b6c1c9c8300
2f954bab2d524f6afed8a443c2a7ee32876db0fa 30-Oct-2014 Yongqin Liu <yongqin.liu@linaro.org> gethostname.c: change to report ENAMETOOLONG error when buflen is less

change to behaviour the same as glibc for the check about buflen

Change-Id: I98265a8fe441df6fed2527686f89b087364ca53d
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
d94e7f0f1d95e0da73fca8d591fdb56b69d82653 25-Sep-2014 Derek Xue <derek.xue@linaro.org> bionic tests: migrate gethostname test to unistd_test.cpp from system/extras

The old tests are implemented in file
system/extras/tests/bionic/libc/common/test_gethostname.c
Here migrate the test to the tests/unistd_test.cpp file and
add some more checks

Change-Id: Iab1e3da873bb333d1ddefc03108d536933792db2
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
b86a4c7f651ab347611847e4f5a1a50d6ee1827b 08-Nov-2014 Elliott Hughes <enh@google.com> Add sethostname(2).

Not very useful, but helps building stuff like toybox out of the box.

Change-Id: I110e39030452bd093a84278e019c5752d293718d
9df70403d95f5cfe6824e38a9a6c35f9b9bbc76a 06-Nov-2014 Yabin Cui <yabinc@google.com> make all bionic death tests not dumpable

Bug: 18067305

Change-Id: Ia1ecacf47eddecc9bc58aaac779e0c218f463179
60452a211c19e8cd09d4111fa733c64ecd1200f0 22-Sep-2014 Elliott Hughes <enh@google.com> Unit test for abort(3).

Change-Id: I021604b977572801f228a193741624df26e76d72
2b3b2ecee8df54a25e9f5e0968761dbac4761e6c 22-Aug-2014 Elliott Hughes <enh@google.com> Fix unistd.getpid_caching_and_clone.

This test only works if you're root (strictly: if you have permission to
CLONE_NEWNS), so it's useful to us when we're doing ad hoc testing (since
that's usually done as root), but it's not useful as part of CTS or when
running the tests on the host.

(cherry-pick of 84d0683a824fa02dbaa6d1b56a79223804b54e80.)

Bug: 16705621
Bug: 17170200
Change-Id: Ia92c871b15f7e45fc174bb59bc95540fd00ae745
84d0683a824fa02dbaa6d1b56a79223804b54e80 22-Aug-2014 Elliott Hughes <enh@google.com> Fix unistd.getpid_caching_and_clone.

This test only works if you're root (strictly: if you have permission to
CLONE_NEWNS), so it's useful to us when we're doing ad hoc testing (since
that's usually done as root), but it's not useful as part of CTS or when
running the tests on the host.

Bug: 16705621
Bug: 17170200
Change-Id: Ia92c871b15f7e45fc174bb59bc95540fd00ae745
78e4f8fed2c162f8ada55180e48487ef2180cf93 28-Jul-2014 Elliott Hughes <enh@google.com> syscall(3)'s return type should be long.

This doesn't require us to change any of the syscall implementations
because (a) the LP32 ones have sizeof(int) == sizeof(long) anyway,
which is how we never noticed this bug before and (b) the LP64 ones
all use a 64-bit register for the result (and for the syscall number
too).

Bug: https://code.google.com/p/android/issues/detail?id=73952
Bug: 16568314

(cherry picked from commit 21972b61ec0572395c5684eebc6cc7b3a4c9e3be)

Change-Id: Ifbc424be29e5650ec72a24df25dd35f24fdd5b3c
21972b61ec0572395c5684eebc6cc7b3a4c9e3be 28-Jul-2014 Elliott Hughes <enh@google.com> syscall(3)'s return type should be long.

This doesn't require us to change any of the syscall implementations
because (a) the LP32 ones have sizeof(int) == sizeof(long) anyway,
which is how we never noticed this bug before and (b) the LP64 ones
all use a 64-bit register for the result (and for the syscall number
too).

Bug: https://code.google.com/p/android/issues/detail?id=73952
Change-Id: I9866c3579a7a94de27bfbe80ad7a822c3183c7fb
fa9e16efaf0e885f6044e725eb759ef6de10f7ef 24-Jun-2014 Elliott Hughes <enh@google.com> Fix getpid caching across a clone.

If you make clone, fork, or vfork system calls directly, you're still
on your own, but we now do the right thing for the clone wrapper.
With this implementation, children lose the getpid caching, but we've
no reason to think that that covers any significant use cases.

Bug: 15387103
Change-Id: Icfab6b63c708fea830960742ec92aeba8ce7680d
7086ad6919feb2415c6027163f5c63323bcca27c 20-Jun-2014 Elliott Hughes <enh@google.com> Cache getpid.

In practice, with this implementation we never need to make a system call.
We get the main thread's tid (which is the same as our pid) back from
the set_tid_address system call we have to make during initialization.
A new pthread will have the same pid as its parent, and a fork child's
main (and only) thread will have a pid equal to its tid, which we get for
free from the kernel before clone returns.

The only time we'd actually have to make a getpid system call now is if
we take a signal during fork and the signal handler calls getpid. (That,
or we call getpid in the dynamic linker while it's still dealing with its
own relocations and hasn't even set up the main thread yet.)

Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
738b0cc5e95a9a650e9621603f4dd8dd16b07568 22-May-2014 Christopher Ferris <cferris@google.com> Fix overflow testing in sbrk.

Modify the overflow testing for sbrk.

Bug: 15188366

Change-Id: Ia83f85f7c1789454d872279bd41f38f1ce6b8a34
1728b2396591853345507a063ed6075dfd251706 14-May-2014 Elliott Hughes <enh@google.com> Switch to g_ for globals.

That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
063525c61d24776094d76971f33920e2a2079530 13-May-2014 Elliott Hughes <enh@google.com> Consistently use #if defined(__BIONIC__) in tests.

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
a62a28d1d9c8df7cb77e4bca19814922729b5291 07-May-2014 Elliott Hughes <enh@google.com> Add basic tests for fsync/fdatasync.

Bug: 14613980
Change-Id: Ie8002c2a1abae07295b7bdb33772764767c03d37
3d7a0d9b08ecab054b2dff8332507644de3690b0 29-Apr-2014 Elliott Hughes <enh@google.com> Switch to the OpenBSD wcsto* functions.

This replaces a partial set of non-functional functions with a complete
set of functions, all of which actually work.

This requires us to implement mbsnrtowcs and wcsnrtombs which completes
the set of what we need for libc++.

The mbsnrtowcs is basically a copy & paste of wcsnrtombs, but I'm going
to go straight to looking at using the OpenBSD UTF-8 implementation rather
than keep polishing our home-grown turd.

(This patch also opportunistically switches us over to upstream btowc,
mbrlen, and wctob, since they're all trivially expressed in terms of
other functions.)

Change-Id: I0f81443840de0f1aa73b96f0b51988976793a323
533dde4dbf87d6615952be3654fc74e5ff2e1003 26-Apr-2014 Elliott Hughes <enh@google.com> Fix brk/sbrk error checking.

Note that the kernel returns the current break on error or if the requested
break is smaller than the minimum break, or the new break. I don't know where
we got the idea that the kernel could return -1.

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Change-Id: I0fd6b8b14ddf1ae82935c0c3fc610da5cc74932e
cbf6df0459f05e180d1c50b3f5b36cdd483193c6 17-Sep-2013 Grigoriy Kraynov <grigoriy.kraynov@intel.com> Tests for environment variables utility functions

This is the first patch from the new set of tests for Bionic standard functions.

Change-Id: Ie568788a24832394e597ad33f44a5c71cb33b51f
Signed-off-by: Grigoriy Kraynov <grigoriy.kraynov@intel.com>
764a99361130dceda62bbc4f8780bbf395dbc424 09-Apr-2014 Elliott Hughes <enh@google.com> Fix build: include what you use.

Change-Id: I12b2d5e434ad3ed38d4451bd470673781e6ca8fe
9f525644df99cb2f7f81a23ca23840f0a8f82275 09-Apr-2014 Elliott Hughes <enh@google.com> Implement _Exit(3).

Change-Id: Ida6ac844cc87d38c9645b197dd8188bb73e27dbe
aedb00d04eb7f0b20b6abde702ba94a46577ca68 03-Mar-2014 Elliott Hughes <enh@google.com> Switch to upstream alarm(3).

The only way the setitimer call can fail is if the unsigned number of seconds is
too large to fit in the kernel's signed number of seconds. If you schedule a
68-year alarm, glibc will fail by returning 0 and BSD will fail by returning -1.

Change-Id: Ic3721b01428f5402d99f31fd7f2ba2cc58805607
915fefb62e1beed3da26fe299a8141645733a925 18-Feb-2014 Elliott Hughes <enh@google.com> Fix x86 build.

Change-Id: Iee6e5884288f7da6c955694cfe32fecfd9c9e263
3d19a8319b9c27af8aa5cfbf495da0fe7fa62d3e 15-Feb-2014 Colin Cross <ccross@android.com> bionic: fix __set_errno for arm64 syscalls that return a 64-bit value

bionic/libc/arch-arm64/syscalls/read.S ends with:
b.hi __set_errno
ret
END(read)

If __set_errno returns int, it will set w0 to 0xFFFFFFFF, which means
x0 is 0x00000000FFFFFFFF. When interpreted as a ssize_t that is
INT_MAX, not -1.

Change __set_errno to return long, which will cause x0 to be set instead
of w0.

Change-Id: I9f9ea0f2995928d2ea240eb2ff7758ecdf0ff412
13613137bc4266656bffce464e525eb9ae6371f0 28-Oct-2013 Christopher Ferris <cferris@google.com> Fix up failing glibc tests.

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
11952073af22568bba0b661f7a9d4402c443a888 25-Oct-2013 Elliott Hughes <enh@google.com> Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.

(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
b4f7616fd618875768b8fffc122b58bdb84a9969 20-Sep-2013 Elliott Hughes <enh@google.com> Ensure we have the off64_t variant of every function that takes an off_t.

Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
428f5567be25b8090e3dd72e2d3d337c305b514e 06-Feb-2013 Elliott Hughes <enh@google.com> Remove bogus extra alignment from sbrk.

Bug: https://code.google.com/p/android/issues/detail?id=37349
Change-Id: I970c7b6be7bb7fbe6bbbe2c332f05816aeb0e09f
a55f63083fb16b2595f517a3260083e5f8cddd02 02-Jan-2013 Elliott Hughes <enh@google.com> Define _POSIX_MONOTONIC_CLOCK and implement sysconf(_SC_MONOTONIC_CLOCK).

Bug: http://code.google.com/p/android/issues/detail?id=39680
Change-Id: I11cf10a66f9d305868a725f04f581099fb88bbfc