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"
//! 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;
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,
);
// 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
ostree reset testrepo:{testref} {booted_commit}
rpm-ostree cleanup -pbrm
",
- testref = TESTREF,
- booted_commit = booted_commit
+ testref,
+ booted_commit,
)
.with_context(|| {
format!(
bash!(
"ostree remote delete --if-exists testrepo
ostree remote add --set=gpg-verify=false testrepo {url}",
- url = url
+ url
)?;
if firstrun {
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
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]
"
)?;
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(())
}
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()
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(())
}
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;
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(())
}