summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2016-08-12 15:34:51 -0700
committerMartijn Coenen <maco@google.com>2017-08-09 20:23:22 +0200
commit7060431a6f0eb395bdc32171aecc51c25fbe7dac (patch)
tree492af5404741aabda80cd1329645fd55aea7b113
parent6d5fa9459f3b084ab802f32bb8a490ac0f25f2a4 (diff)
downloadnative-7060431a6f0eb395bdc32171aecc51c25fbe7dac.tar.gz
binder: tests: Check that cookie and binder high bits are zero
Bug 30768347 Test: new test passes Change-Id: I164eaf9186110809b0adf040f40c81d846f75986 Merged-In: I5ab71ed0c613011b52ed59ec9be02c1bf231c38a
-rw-r--r--libs/binder/tests/binderLibTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index 456d20bf7c..935b68e52b 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -45,6 +45,7 @@ enum BinderLibTestTranscationCode {
BINDER_LIB_TEST_ADD_SERVER,
BINDER_LIB_TEST_CALL_BACK,
BINDER_LIB_TEST_NOP_CALL_BACK,
+ BINDER_LIB_TEST_GET_SELF_TRANSACTION,
BINDER_LIB_TEST_GET_ID_TRANSACTION,
BINDER_LIB_TEST_INDIRECT_TRANSACTION,
BINDER_LIB_TEST_SET_ERROR_TRANSACTION,
@@ -670,6 +671,21 @@ TEST_F(BinderLibTest, PromoteRemote) {
EXPECT_GE(ret, 0);
}
+TEST_F(BinderLibTest, CheckHandleZeroBinderHighBitsZeroCookie) {
+ status_t ret;
+ Parcel data, reply;
+
+ ret = m_server->transact(BINDER_LIB_TEST_GET_SELF_TRANSACTION, data, &reply);
+ EXPECT_EQ(NO_ERROR, ret);
+
+ const flat_binder_object *fb = reply.readObject(false);
+ ASSERT_TRUE(fb != NULL);
+ EXPECT_EQ(fb->hdr.type, BINDER_TYPE_HANDLE);
+ EXPECT_EQ(ProcessState::self()->getStrongProxyForHandle(fb->handle), m_server);
+ EXPECT_EQ(fb->cookie, (binder_uintptr_t)0);
+ EXPECT_EQ(fb->binder >> 32, (binder_uintptr_t)0);
+}
+
class BinderLibTestService : public BBinder
{
public:
@@ -771,6 +787,9 @@ class BinderLibTestService : public BBinder
binder->transact(BINDER_LIB_TEST_CALL_BACK, data2, &reply2);
return NO_ERROR;
}
+ case BINDER_LIB_TEST_GET_SELF_TRANSACTION:
+ reply->writeStrongBinder(this);
+ return NO_ERROR;
case BINDER_LIB_TEST_GET_ID_TRANSACTION:
reply->writeInt32(m_id);
return NO_ERROR;