Fix statsd_test TestOnDumpReportEraseData

After erasing the statsd data, allow statsd to have an empty report, or
even a report with a non-empty metrics wrapper, as long as it doesn't
have any of the former count metrics in it.

Bug: 77909781
Test: make -j8 statsd_test && adb sync data && adb shell data/nativetest64/statsd_test/statsd_test
Change-Id: I525c61aea97a185df8916e4c1b4c4118493ed780
This commit is contained in:
Bookatz
2018-12-18 10:07:56 -08:00
parent 67fb3ca965
commit ea20bffedc

View File

@@ -279,7 +279,10 @@ TEST(StatsLogProcessorTest, TestOnDumpReportEraseData) {
// Dump report again. There should be no data since we erased it.
processor->onDumpReport(cfgKey, 5, true, true /* DO erase data. */, ADB_DUMP, &bytes);
output.ParseFromArray(bytes.data(), bytes.size());
bool noData = (output.reports_size() == 0) || (output.reports(0).metrics_size() == 0);
// We don't care whether statsd has a report, as long as it has no count metrics in it.
bool noData = output.reports_size() == 0
|| output.reports(0).metrics_size() == 0
|| output.reports(0).metrics(0).count_metrics().data_size() == 0;
EXPECT_TRUE(noData);
}