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

Commit bd972092 authored by Rhed Jao's avatar Rhed Jao Committed by Automerger Merge Worker
Browse files

Merge "Fix dumpsys meminfo is not completing in bugreports" am: 90e39e44

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id9c359f9ba58d12b91c478372c5231a25cdaae67
parents 8bcd8db9 90e39e44
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1549,7 +1549,7 @@ static void DumpAppInfos(int out_fd = STDOUT_FILENO) {
    dprintf(out_fd, "========================================================\n");
    dprintf(out_fd, "========================================================\n");


    RunDumpsys("APP PROVIDERS PLATFORM", {"activity", "provider", "all-platform"},
    RunDumpsys("APP PROVIDERS PLATFORM", {"activity", "provider", "all-platform"},
            DUMPSYS_COMPONENTS_OPTIONS, out_fd);
            DUMPSYS_COMPONENTS_OPTIONS, 0, out_fd);


    dprintf(out_fd, "========================================================\n");
    dprintf(out_fd, "========================================================\n");
    dprintf(out_fd, "== Running Application Providers (non-platform)\n");
    dprintf(out_fd, "== Running Application Providers (non-platform)\n");
+45 −0
Original line number Original line Diff line number Diff line
@@ -319,6 +319,16 @@ TEST_F(ZippedBugReportContentsTest, ContainsSomeFileSystemFiles) {
 */
 */
class BugreportSectionTest : public Test {
class BugreportSectionTest : public Test {
  public:
  public:
    ZipArchiveHandle handle;

    void SetUp() {
        ASSERT_EQ(OpenArchive(ZippedBugreportGenerationTest::getZipFilePath().c_str(), &handle), 0);
    }

    void TearDown() {
        CloseArchive(handle);
    }

    static void SetUpTestCase() {
    static void SetUpTestCase() {
        ParseSections(ZippedBugreportGenerationTest::getZipFilePath().c_str(),
        ParseSections(ZippedBugreportGenerationTest::getZipFilePath().c_str(),
                      ZippedBugreportGenerationTest::sections.get());
                      ZippedBugreportGenerationTest::sections.get());
@@ -343,6 +353,19 @@ class BugreportSectionTest : public Test {
        }
        }
        FAIL() << sectionName << " not found.";
        FAIL() << sectionName << " not found.";
    }
    }

    /**
     * Whether or not the content of the section is injected by other commands.
     */
    bool IsContentInjectedByOthers(const std::string& line) {
        // Command header such as `------ APP ACTIVITIES (/system/bin/dumpsys activity -v) ------`.
        static const std::regex kCommandHeader = std::regex{"------ .+ \\(.+\\) ------"};
        std::smatch match;
        if (std::regex_match(line, match, kCommandHeader)) {
          return true;
        }
        return false;
    }
};
};


TEST_F(BugreportSectionTest, Atleast3CriticalDumpsysSectionsGenerated) {
TEST_F(BugreportSectionTest, Atleast3CriticalDumpsysSectionsGenerated) {
@@ -400,6 +423,28 @@ TEST_F(BugreportSectionTest, DISABLED_WifiSectionGenerated) {
    SectionExists("wifi", /* bytes= */ 100000);
    SectionExists("wifi", /* bytes= */ 100000);
}
}


TEST_F(BugreportSectionTest, NoInjectedContentByOtherCommand) {
    // Extract the main entry to a temp file
    TemporaryFile tmp_binary;
    ASSERT_NE(-1, tmp_binary.fd);
    ExtractBugreport(&handle, tmp_binary.fd);

    // Read line by line and identify sections
    std::ifstream ifs(tmp_binary.path, std::ifstream::in);
    std::string line;
    std::string current_section_name;
    while (std::getline(ifs, line)) {
        std::string section_name;
        if (IsSectionStart(line, &section_name)) {
            current_section_name = section_name;
        } else if (IsSectionEnd(line)) {
            current_section_name = "";
        } else if (!current_section_name.empty()) {
            EXPECT_FALSE(IsContentInjectedByOthers(line));
        }
    }
}

class DumpstateBinderTest : public Test {
class DumpstateBinderTest : public Test {
  protected:
  protected:
    void SetUp() override {
    void SetUp() override {