Skip to content

test: fix bind mount test to work without /dev/shm mounted - #139

Merged
KrzysztofMolon merged 1 commit into
mainfrom
fix-bind-mount-test
Jul 20, 2026
Merged

test: fix bind mount test to work without /dev/shm mounted#139
KrzysztofMolon merged 1 commit into
mainfrom
fix-bind-mount-test

Conversation

@KrzysztofMolon

@KrzysztofMolon KrzysztofMolon commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the two fragile /proc/mounts-based bind mount assertions with a single stat -c %d device number comparison
  • The old tests parsed /proc/mounts entries with sed — /proc/mounts does not distinguish bind mounts from their source, making the comparison unreliable
  • The new test compares device numbers via stat, which works regardless of whether /dev/shm is a separate tmpfs mountpoint or just a subdirectory of /dev
  • This fixes test failures in environments (e.g. barney) where /dev/shm is not mounted as its own filesystem

Investigation

The old test failed in barney because /dev/shm is not a separate mount — it's a subdirectory of the /dev tmpfs. We investigated two approaches:

  • mountinfo (device ID column 3): works when /dev/shm is a mountpoint, but fails when it's a subdirectory because it has no entry in mountinfo
  • stat -c %d (device number): works in both cases — stat reports the device of the filesystem the path lives on

Tested in both GitHub CI (Docker, /dev/shm = separate tmpfs) and barney (no /dev/shm mount).

Supersedes #137 (reverted in #138). Suggested by @Snaipe.

Test plan

  • GitHub CI passes
  • barney.ci/bst passes without mount -t tmpfs tmpfs /dev/shm

@KrzysztofMolon
KrzysztofMolon force-pushed the fix-bind-mount-test branch 2 times, most recently from 78a67aa to 61ab9db Compare July 16, 2026 10:53
@KrzysztofMolon KrzysztofMolon changed the title test: use /proc/self/mountinfo for bind mount assertion test: fix bind mount test to work without /dev/shm mounted Jul 16, 2026
@KrzysztofMolon
KrzysztofMolon requested a review from Snaipe July 16, 2026 11:06
Replace the two /proc/mounts-based bind mount assertions with
stat-based device number comparisons. The old tests parsed /proc/mounts
entries with sed, which is fragile: /proc/mounts does not distinguish
bind mounts from their source mount.

The new tests use stat -c %d to compare device numbers:
- bind mount: verify /dev/shm and /mnt share the same device
- tmpfs mount: verify /dev/shm and /mnt have different devices

This works regardless of whether /dev/shm is a separate tmpfs
mountpoint or just a subdirectory of /dev.
@KrzysztofMolon
KrzysztofMolon merged commit f50ca0a into main Jul 20, 2026
8 of 9 checks passed
@KrzysztofMolon
KrzysztofMolon deleted the fix-bind-mount-test branch July 20, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants