From 0f649ac9ea09aa75ad225eea938f07854000b365 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 18 Jun 2024 17:43:13 -0400 Subject: [PATCH] tests-integration: Optimize rebuilds - Pass `--timestamp` to podman build to squash timestamps in order to gain reproducibilty, working around https://github.com/containers/buildah/issues/5592 - Fix the xattr reading code to correctly skip trailing nils Signed-off-by: Colin Walters --- tests-integration/src/runvm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests-integration/src/runvm.rs b/tests-integration/src/runvm.rs index deb9686ad..823be9dbd 100644 --- a/tests-integration/src/runvm.rs +++ b/tests-integration/src/runvm.rs @@ -64,11 +64,10 @@ fn run_bib(sh: &Shell, cimage: &str, tmpdir: &Utf8Path, diskpath: &Utf8Path) -> println!("{cimage} digest={digest}"); if diskpath.try_exists()? { let mut buf = [0u8; 2048]; - if rustix::fs::getxattr(diskpath.as_std_path(), IMAGEID_XATTR, &mut buf) + if let Ok(n) = rustix::fs::getxattr(diskpath.as_std_path(), IMAGEID_XATTR, &mut buf) .context("Reading xattr") - .is_ok() { - let buf = String::from_utf8_lossy(&buf); + let buf = String::from_utf8_lossy(&buf[0..n]); if &*buf == digest.as_str() { println!("Existing disk {diskpath} matches container digest {digest}"); return Ok(()); @@ -142,9 +141,10 @@ pub(crate) fn run(opt: Opt) -> Result<()> { let testimage = if let Some(i) = testimage.take() { i } else { + let source_date_epoch = cmd!(&ctx.sh, "git log -1 --pretty=%ct").read()?; cmd!( &ctx.sh, - "podman build --build-arg=variant=tmt -t {TEST_IMAGE} -f hack/Containerfile ." + "podman build --timestamp={source_date_epoch} --build-arg=variant=tmt -t {TEST_IMAGE} -f hack/Containerfile ." ) .run()?; TEST_IMAGE.to_string()