diff options
author | Yabin Cui <yabinc@google.com> | 2015-10-06 15:10:05 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-10-06 16:15:30 -0700 |
commit | 6dfef255b8fa77e3b5c0a69b7f276ea8e25e22cd (patch) | |
tree | 5b2a9edc9c7f62a035eed4baec6c48221b56ac38 /adb/adb_utils_test.cpp | |
parent | d1f8e4dc9af2b309351bab70dc5eb5a10d939223 (diff) |
adb: keep file flags in fdevent_install.
Bug: 24615098
Change-Id: Ia791ecbe612f09aca3bbd5787513f121fae54da5
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r-- | adb/adb_utils_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp index 17c8d0a1cd..4a2787a529 100644 --- a/adb/adb_utils_test.cpp +++ b/adb/adb_utils_test.cpp @@ -202,3 +202,19 @@ TEST(adb_utils, mkdirs) { ASSERT_EQ(0, chdir(td.path)) << strerror(errno); test_mkdirs(std::string("relative/subrel/file")); } + +#if !defined(_WIN32) +TEST(adb_utils, set_file_block_mode) { + int fd = adb_open("/dev/null", O_RDWR | O_APPEND); + ASSERT_GE(fd, 0); + int flags = fcntl(fd, F_GETFL, 0); + ASSERT_EQ(O_RDWR | O_APPEND, (flags & (O_RDWR | O_APPEND))); + ASSERT_TRUE(set_file_block_mode(fd, false)); + int new_flags = fcntl(fd, F_GETFL, 0); + ASSERT_EQ(flags | O_NONBLOCK, new_flags); + ASSERT_TRUE(set_file_block_mode(fd, true)); + new_flags = fcntl(fd, F_GETFL, 0); + ASSERT_EQ(flags, new_flags); + ASSERT_EQ(0, adb_close(fd)); +} +#endif |