// SPDX-License-Identifier: Apache-2.0
use process_control::{ChildExt, Output, Timeout};
use std::io::Write;
use std::path::Path;
use std::process::{Command, Stdio};
use std::time::Duration;
pub const CRATE: &str = env!("CARGO_MANIFEST_DIR");
pub const KEEP_BIN: &str = env!("CARGO_BIN_EXE_enarx");
pub const OUT_DIR: &str = env!("OUT_DIR");
pub const TEST_BINS_OUT: &str = "bin";
pub const TIMEOUT_SECS: u64 = 30;
pub const MAX_ASSERT_ELEMENTS: usize = 100;
pub fn assert_eq_slices(expected_output: &[u8], output: &[u8], what: &str) {
let max_len = usize::min(output.len(), expected_output.len());
let max_len = max_len.min(MAX_ASSERT_ELEMENTS);
assert_eq!(
output[..max_len],
expected_output[..max_len],
"Expected contents of {} differs",
what
);
assert_eq!(
output.len(),
expected_output.len(),
"Expected length of {} differs",
what
);
assert_eq!(
output, expected_output,
"Expected contents of {} differs",
what
);
}
/// Returns a handle to a child process through which output (stdout, stderr) can
/// be accessed.
pub fn keepldr_exec<'a>(bin: &str, input: impl Into