diff options
| author | 2021-01-13 04:47:14 +0000 | |
|---|---|---|
| committer | 2021-01-13 04:47:14 +0000 | |
| commit | 90e39e440f7a72c255a6f4f911d54ee973a208ea (patch) | |
| tree | 60fa1017124f23925342176f1fd81f8619af156b | |
| parent | e6b4397199f35f9dd472e3a7854a967842de68fd (diff) | |
| parent | b049f180279754a54597635395377a23f7317391 (diff) | |
Merge "Fix dumpsys meminfo is not completing in bugreports"
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 2 | ||||
| -rw-r--r-- | cmds/dumpstate/tests/dumpstate_smoke_test.cpp | 45 |
2 files changed, 46 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 59a7d8cd2d..a374c864c5 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1549,7 +1549,7 @@ static void DumpAppInfos(int out_fd = STDOUT_FILENO) { dprintf(out_fd, "========================================================\n"); 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, "== Running Application Providers (non-platform)\n"); diff --git a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp index fe6a34a514..0e366cb638 100644 --- a/cmds/dumpstate/tests/dumpstate_smoke_test.cpp +++ b/cmds/dumpstate/tests/dumpstate_smoke_test.cpp @@ -319,6 +319,16 @@ TEST_F(ZippedBugReportContentsTest, ContainsSomeFileSystemFiles) { */ class BugreportSectionTest : public Test { public: + ZipArchiveHandle handle; + + void SetUp() { + ASSERT_EQ(OpenArchive(ZippedBugreportGenerationTest::getZipFilePath().c_str(), &handle), 0); + } + + void TearDown() { + CloseArchive(handle); + } + static void SetUpTestCase() { ParseSections(ZippedBugreportGenerationTest::getZipFilePath().c_str(), ZippedBugreportGenerationTest::sections.get()); @@ -343,6 +353,19 @@ class BugreportSectionTest : public Test { } 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) { @@ -400,6 +423,28 @@ TEST_F(BugreportSectionTest, DISABLED_WifiSectionGenerated) { 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, §ion_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 { protected: void SetUp() override { |