diff options
author | Elliott Hughes <enh@google.com> | 2014-09-10 17:39:00 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-09-10 20:30:23 -0700 |
commit | 00008263782e484020420c606f7d145fe7d0a4d8 (patch) | |
tree | 54c08439fe7247e27d94a1440348beab0ef8f16a /tests/fcntl_test.cpp | |
parent | 7efad83d430f4d824f2aaa75edea5106f6ff8aae (diff) | |
download | bionic-00008263782e484020420c606f7d145fe7d0a4d8.zip bionic-00008263782e484020420c606f7d145fe7d0a4d8.tar.gz bionic-00008263782e484020420c606f7d145fe7d0a4d8.tar.bz2 |
Add posix_fadvise(3).
Bug: 12449798
Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
Diffstat (limited to 'tests/fcntl_test.cpp')
-rw-r--r-- | tests/fcntl_test.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp index 5f20295..3fd0a8c 100644 --- a/tests/fcntl_test.cpp +++ b/tests/fcntl_test.cpp @@ -70,10 +70,32 @@ TEST(fcntl, creat_creat64) { ASSERT_EQ(ENOENT, errno); } +TEST(fcntl, posix_fadvise) { + TemporaryFile tf; + errno = 0; + + EXPECT_EQ(EBADF, posix_fadvise(-1, 0, 0, POSIX_FADV_NORMAL)); + EXPECT_EQ(0, errno); + + EXPECT_EQ(EBADF, posix_fadvise64(-1, 0, 0, POSIX_FADV_NORMAL)); + EXPECT_EQ(0, errno); + + EXPECT_EQ(EINVAL, posix_fadvise(tf.fd, 0, 0, -1)); + EXPECT_EQ(0, errno); + + EXPECT_EQ(EINVAL, posix_fadvise64(tf.fd, 0, 0, -1)); + EXPECT_EQ(0, errno); + + EXPECT_EQ(0, posix_fadvise(tf.fd, 0, 0, POSIX_FADV_NORMAL)); + EXPECT_EQ(0, posix_fadvise64(tf.fd, 0, 0, POSIX_FADV_NORMAL)); +} + TEST(fcntl, fallocate_EINVAL) { TemporaryFile tf; -#if defined(__BIONIC__) + // fallocate/fallocate64 set errno. + // posix_fallocate/posix_fallocate64 return an errno value. + errno = 0; ASSERT_EQ(-1, fallocate(tf.fd, 0, 0, -1)); ASSERT_EQ(EINVAL, errno); @@ -81,7 +103,6 @@ TEST(fcntl, fallocate_EINVAL) { errno = 0; ASSERT_EQ(-1, fallocate64(tf.fd, 0, 0, -1)); ASSERT_EQ(EINVAL, errno); -#endif errno = 0; ASSERT_EQ(EINVAL, posix_fallocate(tf.fd, 0, -1)); |