blob: 63d63031db5c7cd7915e10fb56af045ea00b3753 [file] [log] [blame] [edit]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use diagnostics_reader::{tree_assertion, ArchiveReader, Inspect};
use fuchsia_async as fasync;
use fuchsia_component::client;
use fuchsia_zircon::DurationNum;
const RETRY_DELAY_MS: i64 = 300;
#[fuchsia::test]
async fn log_attribution() {
let _dir =
client::open_childs_exposed_directory("log-stats", None).await.expect("child is running");
// We expect two logs from log-stats itself:
// - INFO: Maintaining.
// - INFO: Failed to open component map file ...
let assertion = tree_assertion!(root: contains {
info_logs: 2u64,
logsink_logs: 2u64,
total_logs: 2u64,
by_component: {
"fuchsia-pkg://fuchsia.com/log-stats-tests#meta/log-stats.cm": contains {
info_logs: 2u64,
total_logs: 2u64,
}
},
});
let reader = ArchiveReader::new().add_selector("log-stats:root");
loop {
let hierarchy = reader
.snapshot::<Inspect>()
.await
.expect("got results")
.into_iter()
.next()
.unwrap()
.payload
.unwrap();
if assertion.run(&hierarchy).is_ok() {
break;
}
fasync::Timer::new(fasync::Time::after(RETRY_DELAY_MS.millis())).await;
}
}