tests: Check the immutable bit
See https://bugzilla.redhat.com/show_bug.cgi?id=1867601 We really want an upstream test for this, even if (to my knowledge) nothing is running ostree's upstream CI on !x86_64.
This commit is contained in:
parent
c61ff03304
commit
cc1b70d921
|
|
@ -31,3 +31,10 @@ fn test_sysroot_ro() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[itest]
|
||||||
|
fn test_immutable_bit() -> Result<()> {
|
||||||
|
// https://bugzilla.redhat.com/show_bug.cgi?id=1867601
|
||||||
|
cmd_has_output(commandspec::sh_command!("lsattr -d /").unwrap(), "-i-")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,20 @@ pub(crate) fn cmd_fails_with<C: BorrowMut<Command>>(mut c: C, pat: &str) -> Resu
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Run command and assert that its stdout contains pat
|
||||||
|
pub(crate) fn cmd_has_output<C: BorrowMut<Command>>(mut c: C, pat: &str) -> Result<()> {
|
||||||
|
let c = c.borrow_mut();
|
||||||
|
let o = c.output()?;
|
||||||
|
if !o.status.success() {
|
||||||
|
bail!("Command {:?} failed", c);
|
||||||
|
}
|
||||||
|
if !twoway::find_bytes(&o.stdout, pat.as_bytes()).is_some() {
|
||||||
|
dbg!(String::from_utf8_lossy(&o.stdout));
|
||||||
|
bail!("Command {:?} stdout did not match: {}", c, pat);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn write_file<P: AsRef<Path>>(p: P, buf: &str) -> Result<()> {
|
pub(crate) fn write_file<P: AsRef<Path>>(p: P, buf: &str) -> Result<()> {
|
||||||
let p = p.as_ref();
|
let p = p.as_ref();
|
||||||
let mut f = File::create(p)?;
|
let mut f = File::create(p)?;
|
||||||
|
|
@ -219,6 +233,15 @@ mod tests {
|
||||||
cmd_fails_with(oops(), "nomatch").expect_err("nomatch");
|
cmd_fails_with(oops(), "nomatch").expect_err("nomatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_output() -> Result<()> {
|
||||||
|
cmd_has_output(Command::new("true"), "")?;
|
||||||
|
assert!(cmd_has_output(Command::new("true"), "foo").is_err());
|
||||||
|
cmd_has_output(commandspec::sh_command!("echo foobarbaz; echo fooblahbaz").unwrap(), "blah")?;
|
||||||
|
assert!(cmd_has_output(commandspec::sh_command!("echo foobarbaz").unwrap(), "blah").is_err());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_validate_authz() -> Result<()> {
|
fn test_validate_authz() -> Result<()> {
|
||||||
assert!(validate_authz("Basic Zm9vdXNlcjpiYXJwdw==".as_bytes())?);
|
assert!(validate_authz("Basic Zm9vdXNlcjpiYXJwdw==".as_bytes())?);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue