summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2021-10-08 20:36:28 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-10-08 20:36:28 +0000
commit14c95f0218fe027e81ae8d780c77c9c18d89de54 (patch)
tree8d1d096629fafcd4f0f80734f0cc21c03c8220dc
parentcfd046033588758691c01aa652a82db24c967845 (diff)
parentf80809bda0f365ea9e42a1622b232accfd1a4d24 (diff)
Merge "binderUnitTests: getOpenAshmemSize"
-rw-r--r--libs/binder/tests/Android.bp1
-rw-r--r--libs/binder/tests/binderParcelUnitTest.cpp18
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());
+ }
+}