From e2f2ac6cb7ee24cade096cae32c52428b01408f9 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 6 May 2025 20:41:36 +0100 Subject: [PATCH] Fix test_canonicalize_rootfs Signed-off-by: Stepan Koltsov --- src/runtime/mod.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index 5c1eeb0fef..b99bdc306c 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -277,7 +277,16 @@ mod tests { fn test_canonicalize_rootfs() { let rootfs_name = "rootfs"; let bundle = tempfile::tempdir().expect("failed to create tmp test bundle dir"); - let rootfs_absolute_path = bundle.path().join(rootfs_name); + + // On macOS, `$TMPDIR` may not point to canonicalized path. + // ``` + // $ echo $TMPDIR; realpath $TMPDIR + // /var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T/ + // /private/var/folders/_h/j_17023n23s3_50cq_gwhrrc0000gq/T + // ``` + let bundle = fs::canonicalize(bundle.path()).expect("failed to canonicalize bundle"); + + let rootfs_absolute_path = bundle.join(rootfs_name); assert!( rootfs_absolute_path.is_absolute(), "rootfs path is not absolute path" @@ -295,7 +304,7 @@ mod tests { .build() .unwrap(); - spec.canonicalize_rootfs(bundle.path()) + spec.canonicalize_rootfs(&bundle) .expect("failed to canonicalize rootfs"); assert_eq!( @@ -310,7 +319,7 @@ mod tests { .build() .unwrap(); - spec.canonicalize_rootfs(bundle.path()) + spec.canonicalize_rootfs(&bundle) .expect("failed to canonicalize rootfs"); assert_eq!(