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