Skip to content

Commit 44c56d5

Browse files
andy5995claude
andcommitted
test: skip test_media_root.sh if /tmp is not a top-level mount
Containers and macOS often have /tmp on the root filesystem, in which case rmw correctly writes an absolute path (not a topdir relative path). Use 'df -P' to check the mount point; skip silently if /tmp is not its own top-level mount rather than failing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fb943ab commit 44c56d5

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/test_media_root.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@ else
2020
. "${MESON_SOURCE_ROOT}/test/COMMON"
2121
fi
2222

23-
# This test needs a file and waste folder on the same device, but a different
24-
# device than $HOME. Use a hard-link probe to detect this portably: hard links
25-
# only succeed within the same filesystem, so a failure means different devices.
26-
mkdir -p "$RMW_FAKE_HOME"
27-
probe="/tmp/.rmw-media-root-probe"
28-
touch "$probe"
29-
if ln "$probe" "$RMW_FAKE_HOME/.rmw-probe" 2>/dev/null; then
30-
rm -f "$probe" "$RMW_FAKE_HOME/.rmw-probe"
31-
echo "/tmp is on the same device as home; skipping"
23+
# This test requires /tmp to be a top-level mount point on its own device so
24+
# that rmw will write a relative Path in the trashinfo. Skip if that condition
25+
# isn't met (e.g. containers where /tmp is on the root filesystem, or macOS
26+
# where /tmp is a symlink into the root partition).
27+
tmp_mount=$(df -P /tmp 2>/dev/null | awk 'NR==2 {print $NF}')
28+
if [ "$tmp_mount" != "/tmp" ]; then
29+
echo "/tmp is not a top-level mount point (got: ${tmp_mount:-unavailable}); skipping"
3230
exit 0
3331
fi
34-
rm -f "$probe"
3532

3633
# /tmp is on a different device — use it as the simulated media root.
3734
TRASH_DIR="/tmp/.Trash-$(id -u)"
@@ -43,6 +40,7 @@ test_file_path="$TEST_DIR/$test_file"
4340
rm -rf "$TRASH_DIR" "$TEST_DIR"
4441

4542
# Create test config pointing the waste folder to /tmp
43+
mkdir -p "$RMW_FAKE_HOME"
4644
TEST_CONFIG="$RMW_FAKE_HOME/media-root.testrc"
4745
printf 'WASTE = /tmp/.Trash-%s, removable\nexpire_age = 90\n' "$(id -u)" > "$TEST_CONFIG"
4846

0 commit comments

Comments
 (0)