mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-09 01:18:35 +03:00
tests/inst: Update to published sh-inline crate
And I made a few more API tweaks, such as supporting `Path` objects directly and also not needing e.g. `commit = commit`, see -cfa7c71126
-679bce4cc7
This commit is contained in:
parent
27413afbff
commit
ef55c2c981
@ -14,8 +14,7 @@ structopt = "0.3"
|
||||
serde = "1.0.111"
|
||||
serde_derive = "1.0.111"
|
||||
serde_json = "1.0"
|
||||
# To be published on crates.io soon
|
||||
sh-inline = { git = "https://github.com/cgwalters/rust-sh-inline" }
|
||||
sh-inline = "0.1.0"
|
||||
anyhow = "1.0"
|
||||
tempfile = "3.1.0"
|
||||
glib = "0.10"
|
||||
|
@ -20,10 +20,10 @@
|
||||
//! AUTOPKGTEST_REBOOT_MARK.
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use sh_inline::bash;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::Rng;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sh_inline::bash;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
@ -305,10 +305,7 @@ fn parse_and_validate_reboot_mark<M: AsRef<str>>(
|
||||
fn validate_pending_commit(pending_commit: &str, commitstates: &CommitStates) -> Result<()> {
|
||||
if pending_commit != commitstates.target {
|
||||
bash!("rpm-ostree status -v")?;
|
||||
bash!(
|
||||
"ostree show {pending_commit}",
|
||||
pending_commit = pending_commit
|
||||
)?;
|
||||
bash!("ostree show {pending_commit}", pending_commit)?;
|
||||
anyhow::bail!(
|
||||
"Expected target commit={} but pending={} ({:?})",
|
||||
commitstates.target,
|
||||
@ -455,6 +452,7 @@ fn impl_transaction_test<M: AsRef<str>>(
|
||||
);
|
||||
// Reset the target ref to booted, and perform a cleanup
|
||||
// to ensure we're re-downloading objects each time
|
||||
let testref = TESTREF;
|
||||
bash!(
|
||||
"
|
||||
systemctl stop rpm-ostreed
|
||||
@ -462,8 +460,8 @@ fn impl_transaction_test<M: AsRef<str>>(
|
||||
ostree reset testrepo:{testref} {booted_commit}
|
||||
rpm-ostree cleanup -pbrm
|
||||
",
|
||||
testref = TESTREF,
|
||||
booted_commit = booted_commit
|
||||
testref,
|
||||
booted_commit,
|
||||
)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
@ -569,7 +567,7 @@ fn transactionality() -> Result<()> {
|
||||
bash!(
|
||||
"ostree remote delete --if-exists testrepo
|
||||
ostree remote add --set=gpg-verify=false testrepo {url}",
|
||||
url = url
|
||||
url
|
||||
)?;
|
||||
|
||||
if firstrun {
|
||||
@ -582,16 +580,18 @@ fn transactionality() -> Result<()> {
|
||||
generate_update(&commit)?;
|
||||
// Directly set the origin, so that we're not dependent on the pending deployment.
|
||||
// FIXME: make this saner
|
||||
let origref = ORIGREF;
|
||||
let testref = TESTREF;
|
||||
bash!(
|
||||
"
|
||||
ostree admin set-origin testrepo {url} {testref}
|
||||
ostree refs --create testrepo:{testref} {commit}
|
||||
ostree refs --create={origref} {commit}
|
||||
",
|
||||
url = url,
|
||||
origref = ORIGREF,
|
||||
testref = TESTREF,
|
||||
commit = commit
|
||||
url,
|
||||
origref,
|
||||
testref,
|
||||
commit
|
||||
)?;
|
||||
// We gather a single "cycle time" at start as a way of gauging how
|
||||
// long an upgrade should take, so we know when to interrupt. This
|
||||
|
@ -5,7 +5,7 @@ use std::path::Path;
|
||||
|
||||
use crate::test::*;
|
||||
use anyhow::{Context, Result};
|
||||
use sh_inline::{bash_command, bash};
|
||||
use sh_inline::{bash, bash_command};
|
||||
use with_procspawn_tempdir::with_procspawn_tempdir;
|
||||
|
||||
#[itest]
|
||||
@ -45,9 +45,7 @@ fn test_mtime() -> Result<()> {
|
||||
"
|
||||
)?;
|
||||
let ts = Path::new("repo").metadata()?.modified().unwrap();
|
||||
bash!(
|
||||
r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"#
|
||||
)?;
|
||||
bash!(r#"ostree --repo=repo commit -b test -s "bump mtime" --tree=dir=tmproot >/dev/null"#)?;
|
||||
assert_ne!(ts, Path::new("repo").metadata()?.modified().unwrap());
|
||||
Ok(())
|
||||
}
|
||||
@ -88,8 +86,8 @@ fn test_pull_basicauth() -> Result<()> {
|
||||
ostree --repo=repo remote add --set=gpg-verify=false origin-badauth {unauthuri}
|
||||
ostree --repo=repo remote add --set=gpg-verify=false origin-goodauth {authuri}
|
||||
"#,
|
||||
osroot = osroot.to_str(),
|
||||
serverrepo = serverrepo.to_str(),
|
||||
osroot = osroot,
|
||||
serverrepo = serverrepo,
|
||||
baseuri = baseuri.to_string(),
|
||||
unauthuri = unauthuri.to_string(),
|
||||
authuri = authuri.to_string()
|
||||
|
@ -237,8 +237,13 @@ mod tests {
|
||||
fn test_output() -> Result<()> {
|
||||
cmd_has_output(Command::new("true"), "")?;
|
||||
assert!(cmd_has_output(Command::new("true"), "foo").is_err());
|
||||
cmd_has_output(sh_inline::bash_command!("echo foobarbaz; echo fooblahbaz").unwrap(), "blah")?;
|
||||
assert!(cmd_has_output(sh_inline::bash_command!("echo foobarbaz").unwrap(), "blah").is_err());
|
||||
cmd_has_output(
|
||||
sh_inline::bash_command!("echo foobarbaz; echo fooblahbaz").unwrap(),
|
||||
"blah",
|
||||
)?;
|
||||
assert!(
|
||||
cmd_has_output(sh_inline::bash_command!("echo foobarbaz").unwrap(), "blah").is_err()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::{Context, Result};
|
||||
use sh_inline::bash;
|
||||
use openat_ext::{FileExt, OpenatDirExt};
|
||||
use rand::Rng;
|
||||
use sh_inline::bash;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::os::unix::fs::FileExt as UnixFileExt;
|
||||
@ -141,8 +141,8 @@ pub(crate) fn update_os_tree<P: AsRef<Path>>(
|
||||
assert!(mutated > 0);
|
||||
println!("Mutated ELF files: {}", mutated);
|
||||
bash!("ostree --repo={repo} commit --consume -b {ostref} --base={ostref} --tree=dir={tempdir} --owner-uid 0 --owner-gid 0 --selinux-policy-from-base --link-checkout-speedup --no-bindings --no-xattrs",
|
||||
repo = repo_path.to_str().unwrap(),
|
||||
repo = repo_path,
|
||||
ostref = ostref,
|
||||
tempdir = tempdir.path().to_str().unwrap()).context("Failed to commit updated content")?;
|
||||
tempdir = tempdir.path()).context("Failed to commit updated content")?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user