11import os .path
2+ import platform
23import pytest
34from fileformats .core .fs_mount_identifier import FsMountIdentifier
45from fileformats .generic import File
3334gvfsd-fuse on /run/user/1002/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1002,group_id=1002)
3435""" ,
3536 0 ,
36- [],
37+ [
38+ ("/sys/fs/cgroup/cpu,cpuacct" , "cgroup" ),
39+ ("/sys/firmware/efi/efivars" , "efivarfs" ),
40+ ("/proc/sys/fs/binfmt_misc" , "autofs" ),
41+ ("/sys/fs/fuse/connections" , "fusectl" ),
42+ ("/sys/fs/cgroup/systemd" , "cgroup" ),
43+ ("/sys/fs/cgroup/freezer" , "cgroup" ),
44+ ("/sys/fs/cgroup/cpuset" , "cgroup" ),
45+ ("/sys/kernel/security" , "securityfs" ),
46+ ("/var/lib/docker/aufs" , "ext4" ),
47+ ("/sys/fs/cgroup/pids" , "cgroup" ),
48+ ("/run/user/1002/gvfs" , "fuse.gvfsd-fuse" ),
49+ ("/sys/kernel/debug" , "debugfs" ),
50+ ("/sys/fs/cgroup" , "tmpfs" ),
51+ ("/sys/fs/pstore" , "pstore" ),
52+ ("/dev/hugepages" , "hugetlbfs" ),
53+ ("/dev/mqueue" , "mqueue" ),
54+ ("/boot/efi" , "vfat" ),
55+ ("/dev/pts" , "devpts" ),
56+ ("/dev/shm" , "tmpfs" ),
57+ ("/proc" , "proc" ),
58+ ("/sys" , "sysfs" ),
59+ ("/dev" , "devtmpfs" ),
60+ ("/run" , "tmpfs" ),
61+ ("/" , "ext4" ),
62+ ],
3763 ),
3864 # OS X, no CIFS
3965 (
5379/dev/disk1s3 on /Volumes/Boot OS X (hfs, local, journaled, nobrowse)
5480""" ,
5581 0 ,
56- [],
82+ [
83+ ("/Volumes/MyBookData" , "hfs" ),
84+ ("/Volumes/AFNI_SHARE" , "nfs" ),
85+ ("/Volumes/Boot OS X" , "hfs" ),
86+ ("/Volumes/INCOMING" , "nfs" ),
87+ ("/Volumes/raid.bot" , "nfs" ),
88+ ("/Volumes/raid.top" , "autofs" ),
89+ ("/Network/Servers" , "autofs" ),
90+ ("/Volumes/safni" , "autofs" ),
91+ ("/Volumes/afni" , "nfs" ),
92+ ("/Volumes/afni" , "nfs" ),
93+ ("/home" , "autofs" ),
94+ ("/dev" , "devfs" ),
95+ ("/net" , "autofs" ),
96+ ("/" , "hfs" ),
97+ ],
5798 ),
5899 # Non-zero exit code
59100 ("" , 1 , []),
85126gvfsd-fuse on /run/user/1002/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1002,group_id=1002)
86127""" ,
87128 0 ,
88- [],
129+ [
130+ ("/sys/fs/cgroup/cpu,cpuacct" , "cgroup" ),
131+ ("/sys/firmware/efi/efivars" , "efivarfs" ),
132+ ("/proc/sys/fs/binfmt_misc" , "autofs" ),
133+ ("/sys/fs/fuse/connections" , "fusectl" ),
134+ ("/sys/fs/cgroup/systemd" , "cgroup" ),
135+ ("/sys/fs/cgroup/freezer" , "cgroup" ),
136+ ("/sys/fs/cgroup/cpuset" , "cgroup" ),
137+ ("/sys/kernel/security" , "securityfs" ),
138+ ("/var/lib/docker/aufs" , "ext4" ),
139+ ("/sys/fs/cgroup/pids" , "cgroup" ),
140+ ("/run/user/1002/gvfs" , "fuse.gvfsd-fuse" ),
141+ ("/sys/kernel/debug" , "debugfs" ),
142+ ("/sys/fs/cgroup" , "tmpfs" ),
143+ ("/sys/fs/pstore" , "pstore" ),
144+ ("/dev/hugepages" , "hugetlbfs" ),
145+ ("/dev/mqueue" , "mqueue" ),
146+ ("/boot/efi" , "vfat" ),
147+ ("/dev/pts" , "devpts" ),
148+ ("/dev/shm" , "tmpfs" ),
149+ ("/proc" , "proc" ),
150+ ("/sys" , "sysfs" ),
151+ ("/dev" , "devtmpfs" ),
152+ ("/run" , "tmpfs" ),
153+ ("/" , "ext4" ),
154+ ],
89155 ),
90156 # Variant of OS X example with CIFS added manually
91157 (
98164elros:/volume2/AFNI_SHARE on /Volumes/AFNI_SHARE (nfs)
99165""" ,
100166 0 ,
101- [("/Volumes/afni/fraid" , "nfs" ), ("/Volumes/afni" , "cifs" )],
167+ [
168+ ("/Volumes/afni/fraid" , "nfs" ),
169+ ("/Volumes/AFNI_SHARE" , "nfs" ),
170+ ("/Volumes/INCOMING" , "nfs" ),
171+ ("/Volumes/raid.bot" , "nfs" ),
172+ ("/Volumes/afni" , "cifs" ),
173+ ("/dev" , "devfs" ),
174+ ("/" , "hfs" ),
175+ ],
102176 ),
103177 # From Windows: docker run --rm -it -v C:\:/data busybox mount
104178 (
140214tmpfs on /sys/firmware type tmpfs (ro,relatime)
141215""" ,
142216 0 ,
143- [("/data" , "cifs" )],
217+ [
218+ ("/sys/fs/cgroup/perf_event" , "cgroup" ),
219+ ("/sys/fs/cgroup/net_prio" , "cgroup" ),
220+ ("/sys/fs/cgroup/cpuacct" , "cgroup" ),
221+ ("/sys/fs/cgroup/devices" , "cgroup" ),
222+ ("/sys/fs/cgroup/freezer" , "cgroup" ),
223+ ("/sys/fs/cgroup/net_cls" , "cgroup" ),
224+ ("/sys/fs/cgroup/hugetlb" , "cgroup" ),
225+ ("/sys/fs/cgroup/systemd" , "cgroup" ),
226+ ("/sys/fs/cgroup/cpuset" , "cgroup" ),
227+ ("/sys/fs/cgroup/memory" , "cgroup" ),
228+ ("/sys/fs/cgroup/blkio" , "cgroup" ),
229+ ("/sys/fs/cgroup/pids" , "cgroup" ),
230+ ("/proc/sysrq-trigger" , "proc" ),
231+ ("/sys/fs/cgroup/cpu" , "cgroup" ),
232+ ("/proc/sched_debug" , "tmpfs" ),
233+ ("/etc/resolv.conf" , "ext4" ),
234+ ("/proc/timer_list" , "tmpfs" ),
235+ ("/sys/fs/cgroup" , "tmpfs" ),
236+ ("/etc/hostname" , "ext4" ),
237+ ("/sys/firmware" , "tmpfs" ),
238+ ("/dev/console" , "devpts" ),
239+ ("/dev/mqueue" , "mqueue" ),
240+ ("/proc/kcore" , "tmpfs" ),
241+ ("/etc/hosts" , "ext4" ),
242+ ("/proc/scsi" , "tmpfs" ),
243+ ("/proc/bus" , "proc" ),
244+ ("/proc/irq" , "proc" ),
245+ ("/proc/sys" , "proc" ),
246+ ("/dev/pts" , "devpts" ),
247+ ("/dev/shm" , "tmpfs" ),
248+ ("/proc/fs" , "proc" ),
249+ ("/proc" , "proc" ),
250+ ("/data" , "cifs" ),
251+ ("/dev" , "tmpfs" ),
252+ ("/sys" , "sysfs" ),
253+ ("/" , "overlay" ),
254+ ],
144255 ),
145256 # From @yarikoptic - added blank lines to test for resilience
146257 (
153264
154265""" ,
155266 0 ,
156- [],
267+ [
268+ ("/dev/ptmx" , "devpts" ),
269+ ("/dev/shm" , "tmpfs" ),
270+ ("/dev/pts" , "devpts" ),
271+ ("/proc" , "proc" ),
272+ ("/sys" , "sysfs" ),
273+ ],
157274 ),
158275)
159276
@@ -163,27 +280,24 @@ def test_parse_mount_table(output, exit_code, expected):
163280 assert FsMountIdentifier .parse_mount_table (exit_code , output ) == expected
164281
165282
166- def test_cifs_check ():
167- assert isinstance (FsMountIdentifier .get_mount_table (), list )
168- assert isinstance (FsMountIdentifier .on_cifs ("/" ), bool )
169- fake_table = [("/scratch/tmp" , "ext4" ), ("/scratch" , "cifs" )]
283+ @pytest .mark .skipif (
284+ platform .system () == "Windows" , reason = "Windows does not have mount table"
285+ )
286+ def test_mount_check ():
287+ fake_table = [("/" , "ext4" ), ("/scratch/tmp" , "ext4" ), ("/scratch" , "cifs" )]
170288 cifs_targets = [
171- ("/scratch/tmp/x/y" , False ),
172- ("/scratch/tmp/x" , False ),
173- ("/scratch/x/y" , True ),
174- ("/scratch/x" , True ),
175- ("/x/y" , False ),
176- ("/x" , False ),
177- ("/" , False ),
289+ ("/scratch/tmp/x/y" , True ),
290+ ("/scratch/tmp/x" , True ),
291+ ("/scratch/x/y" , False ),
292+ ("/scratch/x" , False ),
293+ ("/x/y" , True ),
294+ ("/x" , True ),
295+ ("/" , True ),
178296 ]
179297
180- with FsMountIdentifier .patch_table ([]):
181- for target , _ in cifs_targets :
182- assert FsMountIdentifier .on_cifs (target ) is False
183-
184298 with FsMountIdentifier .patch_table (fake_table ):
185299 for target , expected in cifs_targets :
186- assert FsMountIdentifier .on_cifs (target ) is expected
300+ assert FsMountIdentifier .symlinks_supported (target ) is expected
187301
188302
189303def test_copy_constraints (tmp_path ):
@@ -242,3 +356,18 @@ def test_copy_constraints(tmp_path):
242356 assert (
243357 os .stat (ext4_file ).st_ino != os .stat (ext4_file_on_cifs ).st_ino
244358 ) # Not hardlink
359+
360+
361+ def test_generate_mount_table ():
362+ mount_table = FsMountIdentifier .get_mount_table ()
363+ assert isinstance (mount_table , list )
364+ # We can't test the actual mount table, but we can test that the function actually
365+ # runs and returns at least one mount/drive
366+ assert mount_table
367+
368+
369+ @pytest .mark .skipif (
370+ platform .system () == "Windows" , reason = "Windows does not have mount table"
371+ )
372+ def test_symlink_supported ():
373+ assert isinstance (FsMountIdentifier .symlinks_supported ("/" ), bool )
0 commit comments