aboutsummaryrefslogtreecommitdiff
path: root/filesystem
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2023-09-09 11:30:45 -0700
committerEric Biggers <ebiggers@google.com>2023-09-09 11:30:45 -0700
commitb928729b995fbbc007e47ec39a111ef059fcb29c (patch)
treea5b83bbbe5c80d5b6826ca84fce06fb3051b8d7b /filesystem
parente663a3ee2287be77dcd44631b29147a1eddcb4f0 (diff)
mountpoint_test: skip TestLoadSourceDevice if loop0 doesn't exist
Probably resolves https://github.com/google/fscrypt/issues/382
Diffstat (limited to 'filesystem')
-rw-r--r--filesystem/mountpoint_test.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/filesystem/mountpoint_test.go b/filesystem/mountpoint_test.go
index 43b5a0d..f06219c 100644
--- a/filesystem/mountpoint_test.go
+++ b/filesystem/mountpoint_test.go
@@ -17,10 +17,9 @@
* the License.
*/
-// Note: these tests assume the existence of some well-known directories and
-// devices: /mnt, /home, /tmp, and /dev/loop0. This is because the mountpoint
-// loading code only retains mountpoints on valid directories, and only retains
-// device names for valid device nodes.
+// Note: these tests assume the existence of some well-known directories: /mnt,
+// /home, and /tmp. This is because the mountpoint loading code only retains
+// mountpoints on valid directories.
package filesystem
@@ -100,6 +99,11 @@ func TestLoadMountInfoBasic(t *testing.T) {
// Test that Mount.Device is set to the mountpoint's source device if
// applicable, otherwise it is set to the empty string.
func TestLoadSourceDevice(t *testing.T) {
+ // The mountinfo parser ignores devices that don't exist. For the valid
+ // device, try /dev/loop0. If it doesn't exist, skip the test.
+ if _, err := os.Stat("/dev/loop0"); err != nil {
+ t.Skip("/dev/loop0 does not exist, skipping test")
+ }
var mountinfo = `
15 0 7:0 / / rw shared:1 - foo /dev/loop0 rw,data=ordered
31 15 0:27 / /tmp rw,nosuid,nodev shared:17 - tmpfs tmpfs rw