Loading cmds/dumpstate/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,8 @@ cc_test { "tests/dumpstate_smoke_test.cpp", ], static_libs: ["libgmock"], test_config: "dumpstate_smoke_test.xml", test_suites: ["device-tests"], } Loading cmds/dumpstate/TEST_MAPPING +3 −0 Original line number Diff line number Diff line { "presubmit": [ // TODO(159590499) add BugreportManagerTestCases { "name": "dumpstate_smoke_test" }, { "name": "dumpstate_test" } Loading cmds/dumpstate/dumpstate_smoke_test.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2020 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 dumpstate_smoke_test"> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-native" /> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="dumpstate_smoke_test->/data/local/tmp/dumpstate_smoke_test" /> </target_preparer> <test class="com.android.tradefed.testtype.GTest" > <option name="native-test-device-path" value="/data/local/tmp" /> <option name="module-name" value="dumpstate_smoke_test" /> <option name="native-test-timeout" value="600000" /> </test> </configuration> cmds/dumpstate/tests/dumpstate_smoke_test.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -209,13 +209,12 @@ class ZippedBugreportGenerationTest : public Test { static std::shared_ptr<std::vector<SectionInfo>> sections; static Dumpstate& ds; static std::chrono::milliseconds duration; static void SetUpTestCase() { static void GenerateBugreport() { // clang-format off char* argv[] = { (char*)"dumpstate", (char*)"-d", (char*)"-z", (char*)"-B" (char*)"-z" }; // clang-format on sp<DumpstateListener> listener(new DumpstateListener(dup(fileno(stdout)), sections)); Loading @@ -236,20 +235,20 @@ Dumpstate& ZippedBugreportGenerationTest::ds = Dumpstate::GetInstance(); std::chrono::milliseconds ZippedBugreportGenerationTest::duration = 0s; TEST_F(ZippedBugreportGenerationTest, IsGeneratedWithoutErrors) { GenerateBugreport(); EXPECT_EQ(access(getZipFilePath().c_str(), F_OK), 0); } TEST_F(ZippedBugreportGenerationTest, Is3MBto30MBinSize) { TEST_F(ZippedBugreportGenerationTest, Is3MBMBinSize) { struct stat st; EXPECT_EQ(stat(getZipFilePath().c_str(), &st), 0); EXPECT_GE(st.st_size, 3000000 /* 3MB */); EXPECT_LE(st.st_size, 30000000 /* 30MB */); } TEST_F(ZippedBugreportGenerationTest, TakesBetween30And150Seconds) { TEST_F(ZippedBugreportGenerationTest, TakesBetween30And300Seconds) { EXPECT_GE(duration, 30s) << "Expected completion in more than 30s. Actual time " << duration.count() << " s."; EXPECT_LE(duration, 150s) << "Expected completion in less than 150s. Actual time " EXPECT_LE(duration, 300s) << "Expected completion in less than 300s. Actual time " << duration.count() << " s."; } Loading @@ -266,7 +265,8 @@ class ZippedBugReportContentsTest : public Test { CloseArchive(handle); } void FileExists(const char* filename, uint32_t minsize, uint32_t maxsize) { void FileExists(const char* filename, uint32_t minsize, uint32_t maxsize = std::numeric_limits<uint32_t>::max()) { ZipEntry entry; GetEntry(handle, filename, &entry); EXPECT_GT(entry.uncompressed_length, minsize); Loading @@ -285,7 +285,7 @@ TEST_F(ZippedBugReportContentsTest, ContainsMainEntry) { main_entry.uncompressed_length); // contains main entry file FileExists(bugreport_txt_name.c_str(), 1000000U, 50000000U); FileExists(bugreport_txt_name.c_str(), 1000000U); } TEST_F(ZippedBugReportContentsTest, ContainsVersion) { Loading @@ -301,8 +301,9 @@ TEST_F(ZippedBugReportContentsTest, ContainsVersion) { } TEST_F(ZippedBugReportContentsTest, ContainsBoardSpecificFiles) { FileExists("dumpstate_board.bin", 1000000U, 80000000U); FileExists("dumpstate_board.txt", 100000U, 1000000U); // TODO(b/160109027): cf_x86_phone-userdebug does not dump them. // FileExists("dumpstate_board.bin", 1000000U, 80000000U); // FileExists("dumpstate_board.txt", 100000U, 1000000U); } TEST_F(ZippedBugReportContentsTest, ContainsProtoFile) { Loading Loading
cmds/dumpstate/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,8 @@ cc_test { "tests/dumpstate_smoke_test.cpp", ], static_libs: ["libgmock"], test_config: "dumpstate_smoke_test.xml", test_suites: ["device-tests"], } Loading
cmds/dumpstate/TEST_MAPPING +3 −0 Original line number Diff line number Diff line { "presubmit": [ // TODO(159590499) add BugreportManagerTestCases { "name": "dumpstate_smoke_test" }, { "name": "dumpstate_test" } Loading
cmds/dumpstate/dumpstate_smoke_test.xml 0 → 100644 +31 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2020 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 dumpstate_smoke_test"> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-native" /> <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="dumpstate_smoke_test->/data/local/tmp/dumpstate_smoke_test" /> </target_preparer> <test class="com.android.tradefed.testtype.GTest" > <option name="native-test-device-path" value="/data/local/tmp" /> <option name="module-name" value="dumpstate_smoke_test" /> <option name="native-test-timeout" value="600000" /> </test> </configuration>
cmds/dumpstate/tests/dumpstate_smoke_test.cpp +12 −11 Original line number Diff line number Diff line Loading @@ -209,13 +209,12 @@ class ZippedBugreportGenerationTest : public Test { static std::shared_ptr<std::vector<SectionInfo>> sections; static Dumpstate& ds; static std::chrono::milliseconds duration; static void SetUpTestCase() { static void GenerateBugreport() { // clang-format off char* argv[] = { (char*)"dumpstate", (char*)"-d", (char*)"-z", (char*)"-B" (char*)"-z" }; // clang-format on sp<DumpstateListener> listener(new DumpstateListener(dup(fileno(stdout)), sections)); Loading @@ -236,20 +235,20 @@ Dumpstate& ZippedBugreportGenerationTest::ds = Dumpstate::GetInstance(); std::chrono::milliseconds ZippedBugreportGenerationTest::duration = 0s; TEST_F(ZippedBugreportGenerationTest, IsGeneratedWithoutErrors) { GenerateBugreport(); EXPECT_EQ(access(getZipFilePath().c_str(), F_OK), 0); } TEST_F(ZippedBugreportGenerationTest, Is3MBto30MBinSize) { TEST_F(ZippedBugreportGenerationTest, Is3MBMBinSize) { struct stat st; EXPECT_EQ(stat(getZipFilePath().c_str(), &st), 0); EXPECT_GE(st.st_size, 3000000 /* 3MB */); EXPECT_LE(st.st_size, 30000000 /* 30MB */); } TEST_F(ZippedBugreportGenerationTest, TakesBetween30And150Seconds) { TEST_F(ZippedBugreportGenerationTest, TakesBetween30And300Seconds) { EXPECT_GE(duration, 30s) << "Expected completion in more than 30s. Actual time " << duration.count() << " s."; EXPECT_LE(duration, 150s) << "Expected completion in less than 150s. Actual time " EXPECT_LE(duration, 300s) << "Expected completion in less than 300s. Actual time " << duration.count() << " s."; } Loading @@ -266,7 +265,8 @@ class ZippedBugReportContentsTest : public Test { CloseArchive(handle); } void FileExists(const char* filename, uint32_t minsize, uint32_t maxsize) { void FileExists(const char* filename, uint32_t minsize, uint32_t maxsize = std::numeric_limits<uint32_t>::max()) { ZipEntry entry; GetEntry(handle, filename, &entry); EXPECT_GT(entry.uncompressed_length, minsize); Loading @@ -285,7 +285,7 @@ TEST_F(ZippedBugReportContentsTest, ContainsMainEntry) { main_entry.uncompressed_length); // contains main entry file FileExists(bugreport_txt_name.c_str(), 1000000U, 50000000U); FileExists(bugreport_txt_name.c_str(), 1000000U); } TEST_F(ZippedBugReportContentsTest, ContainsVersion) { Loading @@ -301,8 +301,9 @@ TEST_F(ZippedBugReportContentsTest, ContainsVersion) { } TEST_F(ZippedBugReportContentsTest, ContainsBoardSpecificFiles) { FileExists("dumpstate_board.bin", 1000000U, 80000000U); FileExists("dumpstate_board.txt", 100000U, 1000000U); // TODO(b/160109027): cf_x86_phone-userdebug does not dump them. // FileExists("dumpstate_board.bin", 1000000U, 80000000U); // FileExists("dumpstate_board.txt", 100000U, 1000000U); } TEST_F(ZippedBugReportContentsTest, ContainsProtoFile) { Loading