diff --git a/Cargo.toml b/Cargo.toml index b49bee2..dd23e91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,4 +85,8 @@ required-features = ["boxed-scopes"] [[example]] name = "diagnosis" +required-features = ["boxed-scopes"] + +[[example]] +name = "file" required-features = ["boxed-scopes"] \ No newline at end of file diff --git a/examples/file.rs b/examples/file.rs new file mode 100644 index 0000000..9fe5743 --- /dev/null +++ b/examples/file.rs @@ -0,0 +1,45 @@ +// (c) Meta Platforms, Inc. and affiliates. +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +use std::str::FromStr; + +use anyhow::Result; +use futures::FutureExt; + +use ocptv::output as tv; +use tv::{TestResult, TestStatus}; + +async fn run_file_step(step: &tv::StartedTestStep) -> Result { + let uri = tv::Uri::from_str("file:///root/mem_cfg_log").unwrap(); + step.file("mem_cfg_log", uri).await?; + + Ok(TestStatus::Complete) +} + +/// Simple demo with file. +#[tokio::main] +async fn main() -> Result<()> { + let dut = tv::DutInfo::builder("dut0").build(); + + tv::TestRun::builder("simple measurement", "1.0") + .build() + .scope(dut, |r| { + async move { + r.add_step("step0") + .scope(|s| run_file_step(s).boxed()) + .await?; + + Ok(tv::TestRunOutcome { + status: TestStatus::Complete, + result: TestResult::Pass, + }) + } + .boxed() + }) + .await?; + + Ok(()) +}