diff options
author | 2021-10-07 18:09:20 -0700 | |
---|---|---|
committer | 2021-10-07 18:30:37 -0700 | |
commit | f80809bda0f365ea9e42a1622b232accfd1a4d24 (patch) | |
tree | 8d1d096629fafcd4f0f80734f0cc21c03c8220dc | |
parent | cfd046033588758691c01aa652a82db24c967845 (diff) |
binderUnitTests: getOpenAshmemSize
In preparation for changing the implementation of this API, it has no
tests!
Bug: 195752513
Test: binderUnitTest
Change-Id: I4207f636b61dabbc81c5e188aa5cde0d5d1ba6ee
-rw-r--r-- | libs/binder/tests/Android.bp | 1 | ||||
-rw-r--r-- | libs/binder/tests/binderParcelUnitTest.cpp | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp index 680f0edd51..86da5887a8 100644 --- a/libs/binder/tests/Android.bp +++ b/libs/binder/tests/Android.bp @@ -87,6 +87,7 @@ cc_test { srcs: ["binderParcelUnitTest.cpp", "binderBinderUnitTest.cpp"], shared_libs: [ "libbinder", + "libcutils", "libutils", ], test_suites: ["general-tests"], diff --git a/libs/binder/tests/binderParcelUnitTest.cpp b/libs/binder/tests/binderParcelUnitTest.cpp index 841d47b264..4950b23858 100644 --- a/libs/binder/tests/binderParcelUnitTest.cpp +++ b/libs/binder/tests/binderParcelUnitTest.cpp @@ -14,8 +14,9 @@ * limitations under the License. */ -#include <binder/Parcel.h> #include <binder/IPCThreadState.h> +#include <binder/Parcel.h> +#include <cutils/ashmem.h> #include <gtest/gtest.h> using android::IPCThreadState; @@ -146,3 +147,18 @@ TEST_READ_WRITE_INVERSE(char16_t, Char, {u'a', u'\0'}); TEST_READ_WRITE_INVERSE(int8_t, Byte, {-1, 0, 1}); TEST_READ_WRITE_INVERSE(String8, String8, {String8(), String8("a"), String8("asdf")}); TEST_READ_WRITE_INVERSE(String16, String16, {String16(), String16("a"), String16("asdf")}); + +TEST(Parcel, GetOpenAshmemSize) { + constexpr size_t kSize = 1024; + constexpr size_t kCount = 3; + + Parcel p; + + for (size_t i = 0; i < kCount; i++) { + int fd = ashmem_create_region("test-getOpenAshmemSize", kSize); + ASSERT_GE(fd, 0); + ASSERT_EQ(OK, p.writeFileDescriptor(fd, true /* take ownership */)); + + ASSERT_EQ((kSize * (i + 1)), p.getOpenAshmemSize()); + } +} |