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

Commit ef4d8edc authored by Yifan Hong's avatar Yifan Hong Committed by Automerger Merge Worker
Browse files

Merge "lshal: add test for large debug string." am: bc1cec09 am: ff24cfa4 am: 0c401248

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1833038

Change-Id: I4f6cf565efe2b03998a5c51a86e138ad4d20e86c
parents b5049126 0c401248
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -22,9 +22,10 @@
#include <thread>
#include <thread>
#include <vector>
#include <vector>


#include <gtest/gtest.h>
#include <android-base/parseint.h>
#include <gmock/gmock.h>
#include <android/hardware/tests/inheritance/1.0/IChild.h>
#include <android/hardware/tests/inheritance/1.0/IChild.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <vintf/parse_xml.h>
#include <vintf/parse_xml.h>


@@ -77,6 +78,13 @@ struct Child : android::hardware::tests::inheritance::V1_0::IChild {
            content += "\n";
            content += "\n";
            content += option.c_str();
            content += option.c_str();
        }
        }
        if (options.size() > 0) {
            uint64_t len;
            if (android::base::ParseUint(options[0], &len)) {
                content += "\n";
                content += std::string(len, 'X');
            }
        }
        ssize_t written = write(fd, content.c_str(), content.size());
        ssize_t written = write(fd, content.c_str(), content.size());
        if (written != (ssize_t)content.size()) {
        if (written != (ssize_t)content.size()) {
            LOG(WARNING) << "SERVER(Child) debug writes " << written << " bytes < "
            LOG(WARNING) << "SERVER(Child) debug writes " << written << " bytes < "
@@ -189,6 +197,16 @@ TEST_F(DebugTest, Debug3) {
    EXPECT_THAT(err.str(), HasSubstr("does not exist"));
    EXPECT_THAT(err.str(), HasSubstr("does not exist"));
}
}


TEST_F(DebugTest, DebugLarge) {
    EXPECT_EQ(0u, callMain(lshal, {
        "lshal", "debug", "android.hardware.tests.inheritance@1.0::IChild/default", "10000"
    }));
    EXPECT_THAT(out.str(),
                StrEq("android.hardware.tests.inheritance@1.0::IChild\n10000\n" +
                      std::string(10000, 'X')));
    EXPECT_THAT(err.str(), IsEmpty());
}

TEST_F(DebugTest, DebugParent) {
TEST_F(DebugTest, DebugParent) {
    EXPECT_EQ(0u, callMain(lshal, {
    EXPECT_EQ(0u, callMain(lshal, {
        "lshal", "debug", "android.hardware.tests.inheritance@1.0::IParent", "calling parent"
        "lshal", "debug", "android.hardware.tests.inheritance@1.0::IParent", "calling parent"