aboutsummaryrefslogtreecommitdiffstats
path: root/tests/stdio_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-01-26 14:13:04 -0800
committerElliott Hughes <enh@google.com>2016-01-26 14:45:13 -0800
commit03e65eb03bf0bfaafa797daf91e80e8308968db3 (patch)
tree9f3158666a6a63833a0ae6beb23f3e0979de1fd8 /tests/stdio_test.cpp
parentced73ee45e04a991ce1295a38364568a17884eed (diff)
downloadandroid_bionic-03e65eb03bf0bfaafa797daf91e80e8308968db3.tar.gz
android_bionic-03e65eb03bf0bfaafa797daf91e80e8308968db3.tar.bz2
android_bionic-03e65eb03bf0bfaafa797daf91e80e8308968db3.zip
Implement funopen64.
Bug: http://b/24807045 Change-Id: I161920978161389be34b707cc6ce8e05f760d552
Diffstat (limited to 'tests/stdio_test.cpp')
-rw-r--r--tests/stdio_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 89bf04a8e..7f412c13c 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -1091,6 +1091,41 @@ TEST(STDIO_TEST, fseek_ftell_unseekable) {
ASSERT_EQ(ESPIPE, errno);
fclose(fp);
+#else
+ GTEST_LOG_(INFO) << "glibc uses fopencookie instead.\n";
+#endif
+}
+
+TEST(STDIO_TEST, funopen_EINVAL) {
+#if defined(__BIONIC__)
+ errno = 0;
+ ASSERT_EQ(nullptr, funopen(nullptr, nullptr, nullptr, nullptr, nullptr));
+ ASSERT_EQ(EINVAL, errno);
+#else
+ GTEST_LOG_(INFO) << "glibc uses fopencookie instead.\n";
+#endif
+}
+
+TEST(STDIO_TEST, funopen_seek) {
+#if defined(__BIONIC__)
+ auto read_fn = [](void*, char*, int) { return -1; };
+
+ auto seek_fn = [](void*, fpos_t, int) -> fpos_t { return 0xfedcba12; };
+ auto seek64_fn = [](void*, fpos64_t, int) -> fpos64_t { return 0xfedcba12345678; };
+
+ 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);
+
+ 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);
+#else
+ GTEST_LOG_(INFO) << "glibc uses fopencookie instead.\n";
#endif
}