From a7b4eb7d261255d70d90047ae34e8eea849053f2 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 9 Oct 2018 13:06:00 +0200 Subject: virfiletst: Test virFileIsSharedFS Introduce some basic test cases for virFileIsSharedFS(). More will be added later. In order to achieve desired result, mocks for setmntent() and statfs() need to be invented because the first thing that virFileIsSharedFS() does is calling the latter. If it finds a FUSE mount it'll call the former. The mock might look a bit complicated, but in fact it's quite simple. The test sets LIBVIRT_MTAB env variable to hold the absolute path to a file containing mount table. Then, statfs() returns matching FS it finds, and setmntent() is there just to replace /proc/mounts with the file the test wants to load. Adding this test also exposed a bug we have - because we assume the given path points to a file we cut off what we assume is a file name to obtain directory path and only then we call statfs(). This is buggy because the passed path could be already a mount point. Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- tests/virfiledata/mounts3.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/virfiledata/mounts3.txt (limited to 'tests/virfiledata') diff --git a/tests/virfiledata/mounts3.txt b/tests/virfiledata/mounts3.txt new file mode 100644 index 0000000000..226f67dc00 --- /dev/null +++ b/tests/virfiledata/mounts3.txt @@ -0,0 +1,33 @@ +/dev/root / xfs rw,noatime,attr2,inode64,noquota 0 0 +proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 +tmpfs /run tmpfs rw,nodev,relatime,size=3281436k,mode=755 0 0 +sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 +dev /dev devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=4093060,mode=755 0 0 +securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 +debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0 +mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0 +configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0 +devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 +fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0 +shm /dev/shm tmpfs rw,nosuid,nodev,noexec,relatime 0 0 +cgroup_root /sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755 0 0 +openrc /sys/fs/cgroup/openrc cgroup rw,nosuid,nodev,noexec,relatime,release_agent=/lib/rc/sh/cgroup-release-agent.sh,name=openrc 0 0 +none /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0 +cpuset /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 +cpu /sys/fs/cgroup/cpu cgroup rw,nosuid,nodev,noexec,relatime,cpu 0 0 +cpuacct /sys/fs/cgroup/cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpuacct 0 0 +blkio /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 +memory /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 +devices /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 +freezer /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 +net_cls /sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0 +perf_event /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0 +net_prio /sys/fs/cgroup/net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_prio 0 0 +hugetlb /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0 +pids /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0 +rdma /sys/fs/cgroup/rdma cgroup rw,nosuid,nodev,noexec,relatime,rdma 0 0 +binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0 +hugetlbfs /hugepages2M hugetlbfs rw,relatime,mode=1777,pagesize=2M 0 0 +none /run/user/1000 tmpfs rw,relatime,mode=700,uid=1000 0 0 +host:/nfs /nfs nfs4 rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp6,timeo=600,retrans=2,sec=sys,clientaddr=::,local_lock=none,addr=:: 0 0 +dev /nfs/blah devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=4093060,mode=755 0 0 -- cgit v1.2.1