diff options
| author | 2022-08-19 18:08:41 +0000 | |
|---|---|---|
| committer | 2022-08-19 18:08:41 +0000 | |
| commit | 513b631f08d5e51a56564db03b0d081964889fb6 (patch) | |
| tree | 288d9f59835193bd29afe61c34ee9bc8b15bf283 /libs | |
| parent | b31a42460ebb751c5e2154d94efb36acc0027c07 (diff) | |
| parent | e29166dd2cb9c38f4e734f92fb3486b4500371ab (diff) | |
Merge "binderLibTest: filling buffer" am: 184a9c7331 am: 85d28f8f6c am: 9fee4a7147 am: e29166dd2c
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2151721
Change-Id: I01a700785d9062cb694a110d9629f8a824c0817d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index e72f39c24a..5de08bdc00 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -1158,6 +1158,42 @@ TEST_F(BinderLibTest, VectorSent) { EXPECT_EQ(readValue, testValue); } +// see ProcessState.cpp BINDER_VM_SIZE = 1MB. +// This value is not exposed, but some code in the framework relies on being able to use +// buffers near the cap size. +// TODO(b/238777741): why do larger values, like 300K fail sometimes +constexpr size_t kSizeBytesAlmostFull = 100'000; +constexpr size_t kSizeBytesOverFull = 1'050'000; + +TEST_F(BinderLibTest, GargantuanVectorSent) { + sp<IBinder> server = addServer(); + ASSERT_TRUE(server != nullptr); + + for (size_t i = 0; i < 10; i++) { + // a slight variation in size is used to consider certain possible caching implementations + const std::vector<uint64_t> testValue((kSizeBytesAlmostFull + i) / sizeof(uint64_t), 42); + + Parcel data, reply; + data.writeUint64Vector(testValue); + EXPECT_THAT(server->transact(BINDER_LIB_TEST_ECHO_VECTOR, data, &reply), StatusEq(NO_ERROR)) + << i; + std::vector<uint64_t> readValue; + EXPECT_THAT(reply.readUint64Vector(&readValue), StatusEq(OK)); + EXPECT_EQ(readValue, testValue); + } +} + +TEST_F(BinderLibTest, LimitExceededVectorSent) { + sp<IBinder> server = addServer(); + ASSERT_TRUE(server != nullptr); + const std::vector<uint64_t> testValue(kSizeBytesOverFull / sizeof(uint64_t), 42); + + Parcel data, reply; + data.writeUint64Vector(testValue); + EXPECT_THAT(server->transact(BINDER_LIB_TEST_ECHO_VECTOR, data, &reply), + StatusEq(FAILED_TRANSACTION)); +} + TEST_F(BinderLibTest, BufRejected) { Parcel data, reply; uint32_t buf; |