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

Commit 16d89b53 authored by Kalesh Singh's avatar Kalesh Singh Committed by Automerger Merge Worker
Browse files

Merge changes I6c321260,I85d828a1 into main am: d0abe34c am: f7d34b98 am:...

Merge changes I6c321260,I85d828a1 into main am: d0abe34c am: f7d34b98 am: 0a948daf am: 3b29d130 am: 7c82de05

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2704206



Change-Id: I2eafea8b15dc3978aae4c51b1cb827d8e3c9a131
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a39603dd 7c82de05
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ cc_test {
        "libgmock",
    ],

    test_suites: [
        "general-tests",
    ],

    proto: {
        type: "full",
    },

libs/protoutil/AndroidTest.xml

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<configuration description="Config for libprotoutil_test">
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push" value="libprotoutil_test->/data/nativetest/libprotoutil_test" />
    </target_preparer>
    <option name="test-suite-tag" value="apct" />
    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/nativetest" />
        <option name="module-name" value="libprotoutil_test" />
    </test>
</configuration>
+12 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "libprotoutil_test"
    }
  ],
  "hwasan-postsubmit": [
    {
      "name": "libprotoutil_test"
    }
  ]
}
+4 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>

#include <android/util/EncodedBuffer.h>
#include <android/util/protobuf.h>
@@ -25,7 +26,8 @@
namespace android {
namespace util {

const size_t BUFFER_SIZE = 8 * 1024; // 8 KB
constexpr size_t BUFFER_SIZE = 8 * 1024; // 8 KB
const size_t kPageSize = getpagesize();

EncodedBuffer::Pointer::Pointer() : Pointer(BUFFER_SIZE)
{
@@ -92,7 +94,7 @@ EncodedBuffer::EncodedBuffer(size_t chunkSize)
{
    // Align chunkSize to memory page size
    chunkSize = chunkSize == 0 ? BUFFER_SIZE : chunkSize;
    mChunkSize = (chunkSize / PAGE_SIZE + ((chunkSize % PAGE_SIZE == 0) ? 0 : 1)) * PAGE_SIZE;
    mChunkSize = (chunkSize + (kPageSize - 1)) & ~(kPageSize - 1);
    mWp = Pointer(mChunkSize);
    mEp = Pointer(mChunkSize);
}
+11 −7
Original line number Diff line number Diff line
@@ -15,12 +15,16 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <unistd.h>

using namespace android::util;
using android::sp;

constexpr size_t TEST_CHUNK_SIZE = 16UL;
constexpr size_t TEST_CHUNK_HALF_SIZE = TEST_CHUNK_SIZE / 2;
constexpr size_t TEST_CHUNK_3X_SIZE = 3 * TEST_CHUNK_SIZE;
constexpr size_t __TEST_CHUNK_SIZE = 16UL;
const size_t kPageSize = getpagesize();
const size_t TEST_CHUNK_SIZE = (__TEST_CHUNK_SIZE + (kPageSize - 1)) & ~(kPageSize - 1);
const size_t TEST_CHUNK_HALF_SIZE = TEST_CHUNK_SIZE / 2;
const size_t TEST_CHUNK_3X_SIZE = 3 * TEST_CHUNK_SIZE;

static void expectPointer(EncodedBuffer::Pointer* p, size_t pos) {
    EXPECT_EQ(p->pos(), pos);
@@ -34,13 +38,13 @@ TEST(EncodedBufferTest, WriteSimple) {
    expectPointer(buffer->wp(), 0);
    EXPECT_EQ(buffer->currentToWrite(), TEST_CHUNK_SIZE);
    for (size_t i = 0; i < TEST_CHUNK_HALF_SIZE; i++) {
        buffer->writeRawByte(50 + i);
        buffer->writeRawByte(static_cast<uint8_t>(50 + i));
    }
    EXPECT_EQ(buffer->size(), TEST_CHUNK_HALF_SIZE);
    expectPointer(buffer->wp(), TEST_CHUNK_HALF_SIZE);
    EXPECT_EQ(buffer->currentToWrite(), TEST_CHUNK_HALF_SIZE);
    for (size_t i = 0; i < TEST_CHUNK_SIZE; i++) {
        buffer->writeRawByte(80 + i);
        buffer->writeRawByte(static_cast<uint8_t>(80 + i));
    }
    EXPECT_EQ(buffer->size(), TEST_CHUNK_SIZE + TEST_CHUNK_HALF_SIZE);
    expectPointer(buffer->wp(), TEST_CHUNK_SIZE + TEST_CHUNK_HALF_SIZE);
@@ -49,10 +53,10 @@ TEST(EncodedBufferTest, WriteSimple) {
    // verifies the buffer's data
    expectPointer(buffer->ep(), 0);
    for (size_t i = 0; i < TEST_CHUNK_HALF_SIZE; i++) {
        EXPECT_EQ(buffer->readRawByte(), 50 + i);
        EXPECT_EQ(buffer->readRawByte(), static_cast<uint8_t>(50 + i));
    }
    for (size_t i = 0; i < TEST_CHUNK_SIZE; i++) {
        EXPECT_EQ(buffer->readRawByte(), 80 + i);
        EXPECT_EQ(buffer->readRawByte(), static_cast<uint8_t>(80 + i));
    }

    // clears the buffer