summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-05-19 18:17:31 -0700
committerDan Albert <danalbert@google.com>2015-06-01 11:28:13 -0700
commit5f3e19dbbeb851fff5cf7f9869d344feca479413 (patch)
treef83802769593c7d7a534d51ad3dcfddb71557d40 /tests
parentca10ac6dd45f73752e8822fee606d83116a5721a (diff)
downloadbionic-5f3e19dbbeb851fff5cf7f9869d344feca479413.zip
bionic-5f3e19dbbeb851fff5cf7f9869d344feca479413.tar.gz
bionic-5f3e19dbbeb851fff5cf7f9869d344feca479413.tar.bz2
Fix error handling for negative size in ftruncate.
Bug: 21309901 Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0 (cherry picked from commit c05554ec5c9aff5e0f1e83de9bb62c3569eecca2)
Diffstat (limited to 'tests')
-rw-r--r--tests/unistd_test.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unistd_test.cpp b/tests/unistd_test.cpp
index f54a461..a21578a 100644
--- a/tests/unistd_test.cpp
+++ b/tests/unistd_test.cpp
@@ -176,6 +176,15 @@ TEST(unistd, ftruncate64) {
ASSERT_EQ(123, sb.st_size);
}
+TEST(unistd, ftruncate_negative) {
+ TemporaryFile tf;
+ errno = 0;
+ int rc = ftruncate(tf.fd, -123);
+ int err = errno;
+ ASSERT_EQ(-1, rc);
+ ASSERT_EQ(EINVAL, err);
+}
+
static bool g_pause_test_flag = false;
static void PauseTestSignalHandler(int) {
g_pause_test_flag = true;