From 88e8b671ce03135b30411a129664f9ac46e24adb Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 18 May 2023 08:14:50 -0400 Subject: [PATCH] tests: A bit more xshell porting Part of https://github.com/ostreedev/ostree/issues/2857 --- tests/inst/src/destructive.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/inst/src/destructive.rs b/tests/inst/src/destructive.rs index d0c9c9dc..4382c84b 100644 --- a/tests/inst/src/destructive.rs +++ b/tests/inst/src/destructive.rs @@ -32,6 +32,7 @@ use std::path::Path; use std::time; use strum::IntoEnumIterator; use strum_macros::EnumIter; +use xshell::cmd; use crate::test::*; @@ -349,6 +350,7 @@ fn impl_transaction_test>( tdata: &TransactionalTestInfo, mark: Option, ) -> Result<()> { + let sh = xshell::Shell::new()?; let polite_strategies = PoliteInterruptStrategy::iter().collect::>(); let force_strategies = ForceInterruptStrategy::iter().collect::>(); @@ -397,8 +399,8 @@ fn impl_transaction_test>( // then we'll exit implicitly via the reboot, and reenter the function // above. loop { - // Make sure previously failed services (if any) can run. - bash!("systemctl reset-failed || true")?; + // Make sure previously failed services (if any) can run. Ignore errors here though. + let _ = cmd!(sh, "systemctl reset-failed").run()?; // Save the previous strategy as a string so we can use it in error // messages below let prev_strategy_str = format!("{:?}", live_strategy); @@ -421,10 +423,8 @@ fn impl_transaction_test>( // If we've reached our target iterations, exit the test successfully if mark.iter == ITERATIONS { // TODO also add ostree admin fsck to check the deployment directories - bash!( - "echo Performing final validation... - ostree fsck" - )?; + println!("Performing final validation..."); + cmd!(sh, "ostree fsck").run()?; return Ok(()); } let mut rng = rand::thread_rng(); @@ -541,6 +541,7 @@ fn impl_transaction_test>( } pub(crate) fn itest_transactionality() -> Result<()> { + let sh = xshell::Shell::new()?; testinit()?; let mark = get_reboot_mark()?; let cancellable = Some(gio::Cancellable::new()); @@ -572,19 +573,20 @@ pub(crate) fn itest_transactionality() -> Result<()> { }; with_webserver_in(&srvrepo, &webserver_opts, move |addr| { let url = format!("http://{addr}"); - bash!( - "ostree remote delete --if-exists testrepo - ostree remote add --set=gpg-verify=false testrepo ${url}", - url - )?; + cmd!(sh, "ostree remote delete --if-exists testrepo").run()?; + cmd!( + sh, + "ostree remote add --set=gpg-verify=false testrepo {url}" + ) + .run()?; if firstrun { // Also disable zincati because we don't want automatic updates // in our reboots, and it currently fails to start. The less // we have in each reboot, the faster reboots are. - bash!("systemctl disable --now zincati")?; + cmd!(sh, "systemctl disable --now zincati").run()?; // And prepare for updates - bash!("rpm-ostree cleanup -pr")?; + cmd!(sh, "rpm-ostree cleanup -pr").run()?; generate_update(&commit)?; // Directly set the origin, so that we're not dependent on the pending deployment. // FIXME: make this saner -- 2.30.2