From 71d18daee0f4515bbf412f2a010e048f7311b1cc Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 20 Jun 2024 00:09:04 +0900 Subject: [PATCH] tests: (findmnt) add a case testing -Q option The mostly derrived from "filter" test case. Signed-off-by: Masatake YAMATO --- tests/expected/findmnt/filterQ-options | 31 ++++++++ tests/expected/findmnt/filterQ-options-name | 7 ++ .../expected/findmnt/filterQ-options-nameval | 3 + .../findmnt/filterQ-options-nameval-multi | 3 + .../findmnt/filterQ-options-nameval-neg | 33 ++++++++ tests/expected/findmnt/filterQ-options-neg | 5 ++ tests/expected/findmnt/filterQ-options-no | 5 ++ .../expected/findmnt/filterQ-options-no-multi | 3 + tests/expected/findmnt/filterQ-types | 4 + tests/expected/findmnt/filterQ-types-multi | 5 ++ tests/expected/findmnt/filterQ-types-neg | 31 ++++++++ tests/ts/findmnt/filterQ | 77 +++++++++++++++++++ 12 files changed, 207 insertions(+) create mode 100644 tests/expected/findmnt/filterQ-options create mode 100644 tests/expected/findmnt/filterQ-options-name create mode 100644 tests/expected/findmnt/filterQ-options-nameval create mode 100644 tests/expected/findmnt/filterQ-options-nameval-multi create mode 100644 tests/expected/findmnt/filterQ-options-nameval-neg create mode 100644 tests/expected/findmnt/filterQ-options-neg create mode 100644 tests/expected/findmnt/filterQ-options-no create mode 100644 tests/expected/findmnt/filterQ-options-no-multi create mode 100644 tests/expected/findmnt/filterQ-types create mode 100644 tests/expected/findmnt/filterQ-types-multi create mode 100644 tests/expected/findmnt/filterQ-types-neg create mode 100755 tests/ts/findmnt/filterQ diff --git a/tests/expected/findmnt/filterQ-options b/tests/expected/findmnt/filterQ-options new file mode 100644 index 00000000000..f8aae935ab9 --- /dev/null +++ b/tests/expected/findmnt/filterQ-options @@ -0,0 +1,31 @@ +TARGET SOURCE FSTYPE OPTIONS +/proc /proc proc rw,relatime +/sys /sys sysfs rw,relatime +/dev udev devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755 +/dev/pts devpts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 +/dev/shm tmpfs tmpfs rw,relatime +/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,mode=755 +/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset +/sys/fs/cgroup/ns cgroup cgroup rw,nosuid,nodev,noexec,relatime,ns +/sys/fs/cgroup/cpu cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu +/sys/fs/cgroup/cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuacct +/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory +/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices +/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer +/sys/fs/cgroup/net_cls cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls +/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio +/sys/kernel/security systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/hugepages systemd-1 autofs rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/sys/kernel/debug systemd-1 autofs rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/mqueue systemd-1 autofs rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/bus/usb /proc/bus/usb usbfs rw,relatime +/dev/hugepages hugetlbfs hugetlbfs rw,relatime +/dev/mqueue mqueue mqueue rw,relatime +/proc/sys/fs/binfmt_misc none binfmt_misc rw,relatime +/sys/fs/fuse/connections fusectl fusectl rw,relatime +/home/kzak/.gvfs gvfs-fuse-daemon fuse.gvfs-fuse-daemon rw,nosuid,nodev,relatime,user_id=500,group_id=500 +/var/lib/nfs/rpc_pipefs sunrpc rpc_pipefs rw,relatime +/mnt/sounds //foo.home/bar/ cifs rw,relatime,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-name b/tests/expected/findmnt/filterQ-options-name new file mode 100644 index 00000000000..a3a0ead5887 --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-name @@ -0,0 +1,7 @@ +TARGET SOURCE FSTYPE OPTIONS +/sys/kernel/security systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/hugepages systemd-1 autofs rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/sys/kernel/debug systemd-1 autofs rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/mqueue systemd-1 autofs rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-nameval b/tests/expected/findmnt/filterQ-options-nameval new file mode 100644 index 00000000000..21219c52427 --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-nameval @@ -0,0 +1,3 @@ +TARGET SOURCE FSTYPE OPTIONS +/sys/kernel/security systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-nameval-multi b/tests/expected/findmnt/filterQ-options-nameval-multi new file mode 100644 index 00000000000..f2ab3ce4f0b --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-nameval-multi @@ -0,0 +1,3 @@ +TARGET SOURCE FSTYPE OPTIONS +/dev/pts devpts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-nameval-neg b/tests/expected/findmnt/filterQ-options-nameval-neg new file mode 100644 index 00000000000..bdd21952a67 --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-nameval-neg @@ -0,0 +1,33 @@ +TARGET SOURCE FSTYPE OPTIONS +/proc /proc proc rw,relatime +/sys /sys sysfs rw,relatime +/dev udev devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755 +/dev/pts devpts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 +/dev/shm tmpfs tmpfs rw,relatime +/ /dev/sda4 ext3 rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered +/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,mode=755 +/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset +/sys/fs/cgroup/ns cgroup cgroup rw,nosuid,nodev,noexec,relatime,ns +/sys/fs/cgroup/cpu cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu +/sys/fs/cgroup/cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuacct +/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory +/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices +/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer +/sys/fs/cgroup/net_cls cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls +/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio +/dev/hugepages systemd-1 autofs rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/sys/kernel/debug systemd-1 autofs rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/mqueue systemd-1 autofs rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/bus/usb /proc/bus/usb usbfs rw,relatime +/dev/hugepages hugetlbfs hugetlbfs rw,relatime +/dev/mqueue mqueue mqueue rw,relatime +/boot /dev/sda6 ext3 rw,noatime,errors=continue,barrier=0,data=ordered +/home/kzak /dev/mapper/kzak-home ext4 rw,noatime,barrier=1,data=ordered +/proc/sys/fs/binfmt_misc none binfmt_misc rw,relatime +/sys/fs/fuse/connections fusectl fusectl rw,relatime +/home/kzak/.gvfs gvfs-fuse-daemon fuse.gvfs-fuse-daemon rw,nosuid,nodev,relatime,user_id=500,group_id=500 +/var/lib/nfs/rpc_pipefs sunrpc rpc_pipefs rw,relatime +/mnt/sounds //foo.home/bar/ cifs rw,relatime,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-neg b/tests/expected/findmnt/filterQ-options-neg new file mode 100644 index 00000000000..323d9b2a97d --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-neg @@ -0,0 +1,5 @@ +TARGET SOURCE FSTYPE OPTIONS +/ /dev/sda4 ext3 rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered +/boot /dev/sda6 ext3 rw,noatime,errors=continue,barrier=0,data=ordered +/home/kzak /dev/mapper/kzak-home ext4 rw,noatime,barrier=1,data=ordered +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-no b/tests/expected/findmnt/filterQ-options-no new file mode 100644 index 00000000000..323d9b2a97d --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-no @@ -0,0 +1,5 @@ +TARGET SOURCE FSTYPE OPTIONS +/ /dev/sda4 ext3 rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered +/boot /dev/sda6 ext3 rw,noatime,errors=continue,barrier=0,data=ordered +/home/kzak /dev/mapper/kzak-home ext4 rw,noatime,barrier=1,data=ordered +rc=0 diff --git a/tests/expected/findmnt/filterQ-options-no-multi b/tests/expected/findmnt/filterQ-options-no-multi new file mode 100644 index 00000000000..2d714ae5cda --- /dev/null +++ b/tests/expected/findmnt/filterQ-options-no-multi @@ -0,0 +1,3 @@ +TARGET SOURCE FSTYPE OPTIONS +/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio +rc=0 diff --git a/tests/expected/findmnt/filterQ-types b/tests/expected/findmnt/filterQ-types new file mode 100644 index 00000000000..6a69a66b1fd --- /dev/null +++ b/tests/expected/findmnt/filterQ-types @@ -0,0 +1,4 @@ +TARGET SOURCE FSTYPE OPTIONS +/ /dev/sda4 ext3 rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered +/boot /dev/sda6 ext3 rw,noatime,errors=continue,barrier=0,data=ordered +rc=0 diff --git a/tests/expected/findmnt/filterQ-types-multi b/tests/expected/findmnt/filterQ-types-multi new file mode 100644 index 00000000000..323d9b2a97d --- /dev/null +++ b/tests/expected/findmnt/filterQ-types-multi @@ -0,0 +1,5 @@ +TARGET SOURCE FSTYPE OPTIONS +/ /dev/sda4 ext3 rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered +/boot /dev/sda6 ext3 rw,noatime,errors=continue,barrier=0,data=ordered +/home/kzak /dev/mapper/kzak-home ext4 rw,noatime,barrier=1,data=ordered +rc=0 diff --git a/tests/expected/findmnt/filterQ-types-neg b/tests/expected/findmnt/filterQ-types-neg new file mode 100644 index 00000000000..f8aae935ab9 --- /dev/null +++ b/tests/expected/findmnt/filterQ-types-neg @@ -0,0 +1,31 @@ +TARGET SOURCE FSTYPE OPTIONS +/proc /proc proc rw,relatime +/sys /sys sysfs rw,relatime +/dev udev devtmpfs rw,relatime,size=1983516k,nr_inodes=495879,mode=755 +/dev/pts devpts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 +/dev/shm tmpfs tmpfs rw,relatime +/sys/fs/cgroup tmpfs tmpfs rw,nosuid,nodev,noexec,relatime,mode=755 +/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset +/sys/fs/cgroup/ns cgroup cgroup rw,nosuid,nodev,noexec,relatime,ns +/sys/fs/cgroup/cpu cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu +/sys/fs/cgroup/cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuacct +/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory +/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices +/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer +/sys/fs/cgroup/net_cls cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls +/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio +/sys/kernel/security systemd-1 autofs rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/hugepages systemd-1 autofs rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/sys/kernel/debug systemd-1 autofs rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/dev/mqueue systemd-1 autofs rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct +/proc/bus/usb /proc/bus/usb usbfs rw,relatime +/dev/hugepages hugetlbfs hugetlbfs rw,relatime +/dev/mqueue mqueue mqueue rw,relatime +/proc/sys/fs/binfmt_misc none binfmt_misc rw,relatime +/sys/fs/fuse/connections fusectl fusectl rw,relatime +/home/kzak/.gvfs gvfs-fuse-daemon fuse.gvfs-fuse-daemon rw,nosuid,nodev,relatime,user_id=500,group_id=500 +/var/lib/nfs/rpc_pipefs sunrpc rpc_pipefs rw,relatime +/mnt/sounds //foo.home/bar/ cifs rw,relatime,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344 +rc=0 diff --git a/tests/ts/findmnt/filterQ b/tests/ts/findmnt/filterQ new file mode 100755 index 00000000000..4f5f724c953 --- /dev/null +++ b/tests/ts/findmnt/filterQ @@ -0,0 +1,77 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="filterQ" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_init_subtest "types" +$TS_CMD_FINDMNT -Q 'FSTYPE == "ext3"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "types-multi" +$TS_CMD_FINDMNT -Q 'FSTYPE =~ "ext[34]"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "types-neg" +$TS_CMD_FINDMNT -Q 'FSTYPE !~ "ext[34]"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-name" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval-neg" +$TS_CMD_FINDMNT -Q 'OPTIONS !~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-nameval-multi" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\" && OPTIONS =~ "\" && OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-neg" +$TS_CMD_FINDMNT -Q 'OPTIONS !~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-no" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "options-no-multi" +$TS_CMD_FINDMNT -Q 'OPTIONS =~ "\" && OPTIONS =~ "\" && OPTIONS =~ "\"' --kernel --tab-file "$TS_SELF/files/mountinfo" &> $TS_OUTPUT +echo rc=$? >> $TS_OUTPUT + +ts_finalize