History log of /bionic/tests/unistd_test.cpp
Revision Date Author Comments
175dd8ac616f807cebf39917c2652e3fe23c633d 22-Jun-2016 Daniel Xie <dxie@google.com> DO NOT MERGE: push out fix for data dir.

Change-Id: I97ff02676e7f6008c26ddb5c41eb113b4b62280f
45418639d8e8a7a806b9895aa991f1ae0e4e2cd6 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
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
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