Skip to content

Commit 0f649ac

Browse files
committed
tests-integration: Optimize rebuilds
- Pass `--timestamp` to podman build to squash timestamps in order to gain reproducibilty, working around containers/buildah#5592 - Fix the xattr reading code to correctly skip trailing nils Signed-off-by: Colin Walters <[email protected]>
1 parent 01f8d76 commit 0f649ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests-integration/src/runvm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ fn run_bib(sh: &Shell, cimage: &str, tmpdir: &Utf8Path, diskpath: &Utf8Path) ->
6464
println!("{cimage} digest={digest}");
6565
if diskpath.try_exists()? {
6666
let mut buf = [0u8; 2048];
67-
if rustix::fs::getxattr(diskpath.as_std_path(), IMAGEID_XATTR, &mut buf)
67+
if let Ok(n) = rustix::fs::getxattr(diskpath.as_std_path(), IMAGEID_XATTR, &mut buf)
6868
.context("Reading xattr")
69-
.is_ok()
7069
{
71-
let buf = String::from_utf8_lossy(&buf);
70+
let buf = String::from_utf8_lossy(&buf[0..n]);
7271
if &*buf == digest.as_str() {
7372
println!("Existing disk {diskpath} matches container digest {digest}");
7473
return Ok(());
@@ -142,9 +141,10 @@ pub(crate) fn run(opt: Opt) -> Result<()> {
142141
let testimage = if let Some(i) = testimage.take() {
143142
i
144143
} else {
144+
let source_date_epoch = cmd!(&ctx.sh, "git log -1 --pretty=%ct").read()?;
145145
cmd!(
146146
&ctx.sh,
147-
"podman build --build-arg=variant=tmt -t {TEST_IMAGE} -f hack/Containerfile ."
147+
"podman build --timestamp={source_date_epoch} --build-arg=variant=tmt -t {TEST_IMAGE} -f hack/Containerfile ."
148148
)
149149
.run()?;
150150
TEST_IMAGE.to_string()

0 commit comments

Comments
 (0)