diff options
author | Yurii Zubrytskyi <zyy@google.com> | 2019-08-09 15:22:55 -0700 |
---|---|---|
committer | Yurii Zubrytskyi <zyy@google.com> | 2019-08-14 10:04:32 -0700 |
commit | d77c99ebc3d896501531e9522b690c4a0e971aff (patch) | |
tree | 43b57cbe031527095981e3684c20f9a584ad0e42 /base/mapped_file_test.cpp | |
parent | 6ecedd2040d0b8260b83e5d2af99e9db703a7fb6 (diff) |
[base] Make MappedFile work with OS file handles
adb uses its own implementation of Windows HANDLE->int mapping,
and it doesn't play well with _get_osfhandle() function used in
MappedFile::FromFd().
This CL adds another function that accepts raw handle, so adb
can pass it directly
+ make constant functions 'const'
+ make the MappedFile movable, as nothing prevents it from being
one
Test: libbase_test
Change-Id: Ifde4a4094b910e9c7b431126ecf3fef5aa3bb4a6
Diffstat (limited to 'base/mapped_file_test.cpp')
-rw-r--r-- | base/mapped_file_test.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/base/mapped_file_test.cpp b/base/mapped_file_test.cpp index cfde73c74..3629108c9 100644 --- a/base/mapped_file_test.cpp +++ b/base/mapped_file_test.cpp @@ -44,5 +44,8 @@ TEST(mapped_file, zero_length_mapping) { ASSERT_TRUE(tf.fd != -1); auto m = android::base::MappedFile::FromFd(tf.fd, 4096, 0, PROT_READ); - ASSERT_EQ(0u, m->size()); + ASSERT_NE(nullptr, m); + EXPECT_TRUE((bool)*m); + EXPECT_EQ(0u, m->size()); + EXPECT_NE(nullptr, m->data()); } |