diff options
author | Elliott Hughes <enh@google.com> | 2016-01-26 18:25:52 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2016-01-26 18:25:52 -0800 |
commit | 955426ef79ae635b74ff917c2b9ebc1a24c6a3ef (patch) | |
tree | 76d5403eaa41b9a00aa4447ae5700eb77170310f /tests/stdio_test.cpp | |
parent | 194860a9e638b1d093857f08b8fad37c9ec0e113 (diff) |
Fix a sign extension bug in stdio.
This also lets us test the EOVERFLOW behavior, which pointed out that the
fgetpos/fsetpos return on failure has always been wrong...
Bug: http://b/24807045
Change-Id: I35273eb07c8c9155af858adb27569983397580b6
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r-- | tests/stdio_test.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp index 7f412c13c..b6f652688 100644 --- a/tests/stdio_test.cpp +++ b/tests/stdio_test.cpp @@ -1116,14 +1116,19 @@ TEST(STDIO_TEST, funopen_seek) { FILE* fp = funopen(nullptr, read_fn, nullptr, seek_fn, nullptr); ASSERT_TRUE(fp != nullptr); fpos_t pos; - ASSERT_EQ(0, fgetpos(fp, &pos)); - ASSERT_EQ(0xfedcba12LL, pos); +#if defined(__LP64__) + EXPECT_EQ(0, fgetpos(fp, &pos)) << strerror(errno); + EXPECT_EQ(0xfedcba12LL, pos); +#else + EXPECT_EQ(-1, fgetpos(fp, &pos)) << strerror(errno); + EXPECT_EQ(EOVERFLOW, errno); +#endif FILE* fp64 = funopen64(nullptr, read_fn, nullptr, seek64_fn, nullptr); ASSERT_TRUE(fp64 != nullptr); fpos64_t pos64; - ASSERT_EQ(0, fgetpos64(fp64, &pos64)); - ASSERT_EQ(0xfedcba12345678, pos64); + EXPECT_EQ(0, fgetpos64(fp64, &pos64)) << strerror(errno); + EXPECT_EQ(0xfedcba12345678, pos64); #else GTEST_LOG_(INFO) << "glibc uses fopencookie instead.\n"; #endif |