tracing: Improve error message for clock snapshot test
The test seems to be flaky under some circumstances. This should help
understand what's happening.
Change-Id: I00523a47656d92714aa10a13b70956bdf07a4a94
diff --git a/src/tracing/test/api_integrationtest.cc b/src/tracing/test/api_integrationtest.cc
index ba0d010..b71f0b8 100644
--- a/src/tracing/test/api_integrationtest.cc
+++ b/src/tracing/test/api_integrationtest.cc
@@ -4930,15 +4930,23 @@
// Check that clock snapshots are monotonic and don't contain timestamps from
// trace events with explicit timestamps.
- std::unordered_map<uint64_t, uint64_t> last_clock_ts;
+ struct LastTs {
+ uint64_t ts = 0;
+ uint64_t seq_id = 0;
+ };
+ std::unordered_map<uint64_t, LastTs> last_clock_ts;
for (const auto& packet : trace.packet()) {
if (packet.has_clock_snapshot()) {
for (auto& clock : packet.clock_snapshot().clocks()) {
if (!clock.is_incremental()) {
uint64_t ts = clock.timestamp();
uint64_t id = clock.clock_id();
- EXPECT_LE(last_clock_ts[id], ts);
- last_clock_ts[id] = ts;
+ EXPECT_LE(last_clock_ts[id].ts, ts)
+ << "This sequence:" << packet.trusted_packet_sequence_id()
+ << " prev sequence:" << last_clock_ts[id].seq_id
+ << " clock_id:" << id;
+ last_clock_ts[id].ts = ts;
+ last_clock_ts[id].seq_id = packet.trusted_packet_sequence_id();
}
}