Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34449e45 authored by Arve Hjønnevåg's avatar Arve Hjønnevåg Committed by Android (Google) Code Review
Browse files

Merge changes I5ab71ed0,I0e8803ff

* changes:
  binder: tests: Check that cookie and binder high bits are zero
  binder: tests: Fix warnings
parents dee20e5a 10b69a22
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -44,6 +44,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,
@@ -387,7 +388,7 @@ TEST_F(BinderLibTest, IndirectGetId2)

    ret = reply.readInt32(&count);
    ASSERT_EQ(NO_ERROR, ret);
    EXPECT_EQ(ARRAY_SIZE(serverId), count);
    EXPECT_EQ(ARRAY_SIZE(serverId), (size_t)count);

    for (size_t i = 0; i < (size_t)count; i++) {
        BinderLibTestBundle replyi(&reply);
@@ -437,7 +438,7 @@ TEST_F(BinderLibTest, IndirectGetId3)

    ret = reply.readInt32(&count);
    ASSERT_EQ(NO_ERROR, ret);
    EXPECT_EQ(ARRAY_SIZE(serverId), count);
    EXPECT_EQ(ARRAY_SIZE(serverId), (size_t)count);

    for (size_t i = 0; i < (size_t)count; i++) {
        int32_t counti;
@@ -629,7 +630,7 @@ TEST_F(BinderLibTest, PassFile) {
    }

    ret = read(pipefd[0], buf, sizeof(buf));
    EXPECT_EQ(sizeof(buf), ret);
    EXPECT_EQ(sizeof(buf), (size_t)ret);
    EXPECT_EQ(write_value, buf[0]);

    waitForReadData(pipefd[0], 5000); /* wait for other proccess to close pipe */
@@ -668,6 +669,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->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:
@@ -769,6 +785,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;