fuchsia_fuzzctl_test/
input.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use anyhow::{Context as _, Result};
6use std::fs;
7use std::path::Path;
8
9/// Verifies that the input was actually written and matches its expected contents.
10pub fn verify_saved<P: AsRef<Path>>(saved: P, data: &[u8]) -> Result<()> {
11    let saved = saved.as_ref();
12    let actual =
13        fs::read(saved).with_context(|| format!("failed to read '{}'", saved.to_string_lossy()))?;
14    assert_eq!(actual, data);
15    Ok(())
16}