Test all filesystems by default
cover Test all filesystems by default
This series enables testing all filesystems currently supported by the testsuite (ext4, xfs, jfs, vfat) using the [fs_]filesystem subtests without the need to run the tests manually or move to a different filesystem. The filesystems not available on the tested kernel are automatically excluded.
The series also updates dependencies with the packages containing the required mkfs.* programs and fixes the mkfs.* invocation to not get stuck when testing jfs.
Note: The F32 CI will start failing after this and the kernel update patches are merged (the old kernel on the image doesn't have the XFS quota fix). It will be necessary to bump the stable Fedora testing to F33.
Ondrej Mosnacek (3):
README,travis: add e2fsprogs, jfsutils, and dosfstools to deps tests/filesystem: pipe "yes" to mkfs.* to fix jfs test tests/[fs_]filesystem: test all filesystems
README.md | 6 ++++++ tests/Makefile | 8 ++++++-- tests/filesystem/Filesystem.pm | 2 +- tests/filesystem/ext4 | 1 + tests/filesystem/jfs | 1 + tests/filesystem/test | 14 ++++++++++++-- tests/filesystem/vfat | 1 + tests/filesystem/xfs | 1 + tests/fs_filesystem/ext4 | 1 + tests/fs_filesystem/jfs | 1 + tests/fs_filesystem/test | 14 ++++++++++++-- tests/fs_filesystem/vfat | 1 + tests/fs_filesystem/xfs | 1 + travis-ci/run-testsuite.sh | 3 +++ 14 files changed, 48 insertions(+), 7 deletions(-) create mode 120000 tests/filesystem/ext4 create mode 120000 tests/filesystem/jfs create mode 120000 tests/filesystem/vfat create mode 120000 tests/filesystem/xfs create mode 120000 tests/fs_filesystem/ext4 create mode 120000 tests/fs_filesystem/jfs create mode 120000 tests/fs_filesystem/vfat create mode 120000 tests/fs_filesystem/xfs
Signature · 1 line
2.26.2
PATCH 1/3 README,travis: add e2fsprogs, jfsutils, and dosfstools to deps
They are needed for ext4, jfs, and vfat tests, which will become executed by default in an upcoming patch.
--- README.md | 6 ++++++ travis-ci/run-testsuite.sh | 3 +++ 2 files changed, 9 insertions(+)
README.md +6 -0
@@ -58,6 +58,9 @@ similar dependencies): * keyutils-libs-devel _(tools used by the keys tests)_ * kernel-devel _(used by the kernel module tests)_ * quota, xfsprogs-devel and libuuid-devel _(used by the filesystem tests)_ +* e2fsprogs _(used by the ext4 filesystem tests)_ +* jfsutils _(used by the jfs filesystem tests)_ +* dosfstools _(used by the vfat filesystem tests)_ * nftables _(used by inet_socket and sctp tests if ver >= 9.3 for secmark testing )_ On a modern Fedora system you can install these dependencies with the
@@ -81,6 +84,9 @@ following command (NOTE: On Fedora 32 and below you need to remove quota \ xfsprogs-devel \ libuuid-devel \ + e2fsprogs \ + jfsutils \ + dosfstools \ nftables \ kernel-devel-$(uname -r) \ kernel-modules-$(uname -r)
travis-ci/run-testsuite.sh +3 -0
@@ -38,6 +38,9 @@ dnf install -y \ quota \ xfsprogs-devel \ libuuid-devel \ + e2fsprogs \ + jfsutils \ + dosfstools \ kernel-devel-"$(uname -r)" \ kernel-modules-"$(uname -r)"
Signature · 1 line
2.26.2
PATCH 2/3 tests/filesystem: pipe "yes" to mkfs.* to fix jfs test
In reply to Ondrej Mosnacekmkfs.jfs is reluctant to overwrite the device without the user's consent, so shout a stream of y's on it to avoid the test getting stuck. We can't universally pass -q to mkfs.*, because not all mkfs.* tools support it.
--- tests/filesystem/Filesystem.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/filesystem/Filesystem.pm +1 -1
@@ -133,7 +133,7 @@ sub make_fs { attach_dev( $mk_dev, $mk_dir ); print "Make $mk_type filesystem on $mk_dev\n"; - $result = system("mkfs.$mk_type $mk_dev >& /dev/null"); + $result = system("yes | mkfs.$mk_type $mk_dev >& /dev/null"); if ( $result != 0 ) { system("losetup -d $mk_dev 2>/dev/null"); print "mkfs.$mk_type failed to create filesystem on $mk_dev\n";
Signature · 1 line
2.26.2
PATCH 3/3 tests/[fs_]filesystem: test all filesystems
In reply to Ondrej MosnacekRun [fs_]filesystem tests always for all common filesystems (xfs, ext4, jfs, vfat). Use symlinks to achieve this without changing much code while still allowing to run the test script directly (optionally specifying the filesystem type).
--- tests/Makefile | 8 ++++++-- tests/filesystem/ext4 | 1 + tests/filesystem/jfs | 1 + tests/filesystem/test | 14 ++++++++++++-- tests/filesystem/vfat | 1 + tests/filesystem/xfs | 1 + tests/fs_filesystem/ext4 | 1 + tests/fs_filesystem/jfs | 1 + tests/fs_filesystem/test | 14 ++++++++++++-- tests/fs_filesystem/vfat | 1 + tests/fs_filesystem/xfs | 1 + 11 files changed, 38 insertions(+), 6 deletions(-) create mode 120000 tests/filesystem/ext4 create mode 120000 tests/filesystem/jfs create mode 120000 tests/filesystem/vfat create mode 120000 tests/filesystem/xfs create mode 120000 tests/fs_filesystem/ext4 create mode 120000 tests/fs_filesystem/jfs create mode 120000 tests/fs_filesystem/vfat create mode 120000 tests/fs_filesystem/xfs
tests/Makefile +6 -2
@@ -4,6 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux +FILESYSTEMS ?= ext4 xfs jfs vfat export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE
@@ -17,6 +18,9 @@ MOD_POL_VERS := $(shell $(CHECKMODULE) -V |cut -f 2 -d '-') MAX_KERNEL_POLICY := $(shell cat $(SELINUXFS)/policyvers) POL_TYPE := $(shell ./pol_detect $(SELINUXFS)) +# Filter out unavailable filesystems +FILESYSTEMS := $(foreach fs,$(FILESYSTEMS),$(shell modprobe $(fs) && echo $(fs))) + SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \ fdreceive inherit link mkdir msg open ptrace readlink relabel rename \ rxdir sem setattr setnice shm sigkill stat sysctl task_create \
@@ -111,7 +115,7 @@ SUBDIRS += lockdown endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) -SUBDIRS += filesystem +SUBDIRS += $(addprefix filesystem/,$(FILESYSTEMS)) ifeq ($(shell grep -q all_filesystem_perms.*watch $(POLDEV)/include/support/all_perms.spt && echo true),true) export CFLAGS += -DHAVE_FS_WATCH_PERM endif
@@ -119,7 +123,7 @@ endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) ifneq ($(shell ./kvercmp $$(uname -r) 5.2),-1) -SUBDIRS += fs_filesystem +SUBDIRS += $(addprefix fs_filesystem/,$(FILESYSTEMS)) endif endif
tests/filesystem/ext4 new file +1 -0
@@ -0,0 +1 @@ +.
tests/filesystem/jfs new file +1 -0
@@ -0,0 +1 @@ +.
tests/filesystem/test +12 -2
@@ -12,6 +12,17 @@ BEGIN { $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|; + # extract test_name and move up one dir if started from a subdir + $test_name = $basedir; + $test_name =~ s|.*/([^/]*)|$1|; + if ( $test_name eq "fs_filesystem" ) { + $fs_type = " "; + } + else { + $fs_type = $test_name; + $basedir =~ s|(.*)/[^/]*|$1|; + } + # Options: -v Verbose, -e enable udisks(8) daemon, -f filesystem type $v = " "; $disable_udisks = 1;
@@ -20,8 +31,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg;
tests/filesystem/vfat new file +1 -0
@@ -0,0 +1 @@ +.
tests/filesystem/xfs new file +1 -0
@@ -0,0 +1 @@ +.
tests/fs_filesystem/ext4 new file +1 -0
@@ -0,0 +1 @@ +.
tests/fs_filesystem/jfs new file +1 -0
@@ -0,0 +1 @@ +.
tests/fs_filesystem/test +12 -2
@@ -12,6 +12,17 @@ BEGIN { $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|; + # extract test_name and move up one dir if started from a subdir + $test_name = $basedir; + $test_name =~ s|.*/([^/]*)|$1|; + if ( $test_name eq "fs_filesystem" ) { + $fs_type = " "; + } + else { + $fs_type = $test_name; + $basedir =~ s|(.*)/[^/]*|$1|; + } + # Some code in tests/filesystem is reused $filesystem_dir = "$basedir/../filesystem";
@@ -23,8 +34,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg;
tests/fs_filesystem/vfat new file +1 -0
@@ -0,0 +1 @@ +.
tests/fs_filesystem/xfs new file +1 -0
@@ -0,0 +1 @@ +.
Signature · 1 line
2.26.2
Re: [PATCH testsuite 3/3] tests/[fs_]filesystem: test all filesystems
Quoted 5 lines · Ondrej Mosnacek
Run [fs_]filesystem tests always for all common filesystems (xfs, ext4,
jfs, vfat). Use symlinks to achieve this without changing much code while still allowing to run the test script directly (optionally specifying the filesystem type).
These ran okay using 'make test', however when I moved to tests/filesystem and ran ./test the fs_type was .. Also when I moved to filesystems/xfs and ran ./test, the move mount failed because mount does not like sym links and resolves to realpath.
I've had a go at fixing these and I've noted the changes below (please feel free to rework). The fs_filesystem also has the same issues.
Quoted 96 lines
Signed-off-by Ondrej Mosnacek <[email protected]>--- tests/Makefile | 8 ++++++-- tests/filesystem/ext4 | 1 + tests/filesystem/jfs | 1 + tests/filesystem/test | 14 ++++++++++++-- tests/filesystem/vfat | 1 + tests/filesystem/xfs | 1 + tests/fs_filesystem/ext4 | 1 + tests/fs_filesystem/jfs | 1 + tests/fs_filesystem/test | 14 ++++++++++++-- tests/fs_filesystem/vfat | 1 + tests/fs_filesystem/xfs | 1 + 11 files changed, 38 insertions(+), 6 deletions(-) create mode 120000 tests/filesystem/ext4 create mode 120000 tests/filesystem/jfs create mode 120000 tests/filesystem/vfat create mode 120000 tests/filesystem/xfs create mode 120000 tests/fs_filesystem/ext4 create mode 120000 tests/fs_filesystem/jfs create mode 120000 tests/fs_filesystem/vfat create mode 120000 tests/fs_filesystem/xfstests/Makefile +4
-1@@ -4,6 +4,7 @@ SBINDIR ?= $(PREFIX)/sbin POLDEV ?= $(PREFIX)/share/selinux/devel INCLUDEDIR ?= $(PREFIX)/include SELINUXFS ?= /sys/fs/selinux +FILESYSTEMS ?= ext4 xfs jfs vfat export CFLAGS+=-g -O0 -Wall -D_GNU_SOURCE@@ -17,6 +18,9 @@ MOD_POL_VERS := $(shell $(CHECKMODULE) -V |cut -f 2 -d '-') MAX_KERNEL_POLICY := $(shell cat $(SELINUXFS)/policyvers) POL_TYPE := $(shell ./pol_detect $(SELINUXFS)) +# Filter out unavailable filesystems +FILESYSTEMS := $(foreach fs,$(FILESYSTEMS),$(shell modprobe $(fs) && echo $(fs))) + SUBDIRS:= domain_trans entrypoint execshare exectrace
execute_no_trans\
fdreceive inherit link mkdir msg open ptrace readlink relabel
rename \tests/Makefile +1
-1rxdir sem setattr setnice shm sigkill stat sysctl task_create \@@ -111,7 +115,7 @@ SUBDIRS += lockdown endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) -SUBDIRS += filesystem +SUBDIRS += $(addprefix filesystem/,$(FILESYSTEMS)) ifeq ($(shell grep -q all_filesystem_perms.*watch $(POLDEV)/include/support/all_perms.spt && echo true),true)export CFLAGS += -DHAVE_FS_WATCH_PERM
endiftests/Makefile +1
-1@@ -119,7 +123,7 @@ endif ifeq ($(shell grep -q filesystem $(POLDEV)/include/support/all_perms.spt && echo true),true) ifneq ($(shell ./kvercmp $$(uname -r) 5.2),-1) -SUBDIRS += fs_filesystem +SUBDIRS += $(addprefix fs_filesystem/,$(FILESYSTEMS)) endif endiftests/filesystem/ext4 new file +1
-0@@ -0,0 +1 @@ +.tests/filesystem/jfs new file +1
-0@@ -0,0 +1 @@ +.tests/filesystem/test +1
-0@@ -12,6 +12,17 @@ BEGIN { $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|; + # extract test_name and move up one dir if started from a subdir
tests/filesystem/test BEGIN { · line 25
Quoted 10 lines
tests/filesystem/test +10
-0+ $test_name = $basedir; + $test_name =~ s|.*/([^/]*)|$1|; + if ( $test_name eq "fs_filesystem" ) { + $fs_type = " "; + } + else { + $fs_type = $test_name; + $basedir =~ s|(.*)/[^/]*|$1|; + } +
I changed the above to this:
# extract test_name and move up one dir if started from a subdir
$test_name = $basedir;
$test_name =~ s|.*/([^/]*)|$1|;
if ( $test_name eq "." ) {
$cwd = `pwd 2>/dev/null`;
chomp($cwd);
my($d_name) = ($cwd =~ m#/([^/]+)$#);
if ( $d_name eq "filesystem" ) {
$fs_type = " ";
}
else {
$fs_type = $d_name;
}
}
else {
$fs_type = $test_name;
$basedir =~ s|(.*)/[^/]*|$1|;
}Quoted 5 lines
tests/filesystem/test +0
-0# Options: -v Verbose, -e enable udisks(8) daemon, -f filesystemtype
$v = " "; $disable_udisks = 1;
tests/filesystem/test BEGIN { · line 37
Quoted 9 lines
tests/filesystem/test +1
-2@@ -20,8 +31,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg;
Also to fix the move mount sym link problem I changed:
# mount(2) MS_BIND | MS_PRIVATE requires an absolute path to a private mount
# point before MS_MOVE
$cwd = `pwd 2>/dev/null`;
chomp($cwd);
if ( $basedir eq "." ) {
$target = `realpath -e $cwd`;
chomp($target);
$private_path = "$target/mntpoint";
}
else {
$private_path = "$cwd/$basedir/mntpoint";
}The reason the move mount check failed was because I was passing the original sym link paths such as: ..../tests/filesystem/vfat to mount.c that had a compare to check if moved. However it was mounted on the real path (..../tests/filesystem/..) not the sym link.
Quoted 80 lines
tests/filesystem/vfat new file +1
-0@@ -0,0 +1 @@ +.tests/filesystem/xfs new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/ext4 new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/jfs new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/test +12
-2@@ -12,6 +12,17 @@ BEGIN { $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|; + # extract test_name and move up one dir if started from a subdir + $test_name = $basedir; + $test_name =~ s|.*/([^/]*)|$1|; + if ( $test_name eq "fs_filesystem" ) { + $fs_type = " "; + } + else { + $fs_type = $test_name; + $basedir =~ s|(.*)/[^/]*|$1|; + } + # Some code in tests/filesystem is reused $filesystem_dir = "$basedir/../filesystem";@@ -23,8 +34,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg;tests/fs_filesystem/vfat new file +1
-0@@ -0,0 +1 @@ +.tests/fs_filesystem/xfs new file +1
-0@@ -0,0 +1 @@ +.
Re: [PATCH testsuite 3/3] tests/[fs_]filesystem: test all filesystems
Quoted 7 lines · Richard Haines
Quoted 5 lines · Ondrej Mosnacek
Run [fs_]filesystem tests always for all common filesystems (xfs, ext4,
jfs, vfat). Use symlinks to achieve this without changing much code while still allowing to run the test script directly (optionally specifying the filesystem type).
Quoted 7 lines
These ran okay using 'make test', however when I moved to tests/filesystem and ran ./test the
fs_typewas .. Also when I moved to filesystems/xfs and ran ./test, the move mount failed because mount does not like sym links and resolves to realpath.I've had a go at fixing these and I've noted the changes below (please feel free to rework). The
fs_filesystemalso has the same issues.
Heh, I should've tried it before making that claim :)
Quoted 24 lines
Quoted 24 lines
Signed-off-by Ondrej Mosnacek <[email protected]>--- tests/Makefile | 8 ++++++-- tests/filesystem/ext4 | 1 + tests/filesystem/jfs | 1 + tests/filesystem/test | 14 ++++++++++++-- tests/filesystem/vfat | 1 + tests/filesystem/xfs | 1 + tests/fs_filesystem/ext4 | 1 + tests/fs_filesystem/jfs | 1 + tests/fs_filesystem/test | 14 ++++++++++++-- tests/fs_filesystem/vfat | 1 + tests/fs_filesystem/xfs | 1 + 11 files changed, 38 insertions(+), 6 deletions(-) create mode 120000 tests/filesystem/ext4 create mode 120000 tests/filesystem/jfs create mode 120000 tests/filesystem/vfat create mode 120000 tests/filesystem/xfs create mode 120000 tests/fs_filesystem/ext4 create mode 120000 tests/fs_filesystem/jfs create mode 120000 tests/fs_filesystem/vfat create mode 120000 tests/fs_filesystem/xfs
[...]
Quoted 32 lines
Quoted 9 lines
tests/filesystem/test +1
-0@@ -12,6 +12,17 @@ BEGIN { $basedir = $0; $basedir =~ s|(.*)/[^/]*|$1|; + # extract test_name and move up one dir if started from a subdirtests/filesystem/test BEGIN { · line 25
Quoted 10 lines
tests/filesystem/test +10
-0+ $test_name = $basedir; + $test_name =~ s|.*/([^/]*)|$1|; + if ( $test_name eq "fs_filesystem" ) { + $fs_type = " "; + } + else { + $fs_type = $test_name; + $basedir =~ s|(.*)/[^/]*|$1|; + } +I changed the above to this:
# extract test_name and move up one dir if started from a subdir $test_name = $basedir; $test_name =~ s|.*/([^/]*)|$1|; if ( $test_name eq "." ) { $cwd = `pwd 2>/dev/null`; chomp($cwd); my($d_name) = ($cwd =~ m#/([^/]+)$#); if ( $d_name eq "filesystem" ) { $fs_type = " "; }
Quoted 8 lines
else {
$fs_type = $d_name;
}
}
else {
$fs_type = $test_name;
$basedir =~ s|(.*)/[^/]*|$1|;
}Yes, I'll need to use something similar. Thanks!
Quoted 34 lines
Quoted 6 lines
tests/filesystem/test +0
-0# Options: -v Verbose, -e enable udisks(8) daemon, -f filesystemtype
$v = " "; $disable_udisks = 1;tests/filesystem/test BEGIN { · line 37
Quoted 9 lines
tests/filesystem/test +1
-2@@ -20,8 +31,7 @@ BEGIN { $nfs_enabled = 0; $vfat_enabled = 0; - $i = 0; - $fs_type = " "; + $i = 0; foreach $arg (@ARGV) { if ( $arg eq "-v" ) { $v = $arg;Also to fix the move mount sym link problem I changed:
# mount(2)
MS_BIND|MS_PRIVATErequires an absolute path to a private mount# point before MS_MOVE $cwd = `pwd 2>/dev/null`; chomp($cwd); if ( $basedir eq "." ) { $target = `realpath -e $cwd`; chomp($target); $private_path = "$target/mntpoint"; } else { $private_path = "$cwd/$basedir/mntpoint"; }
Quoted 4 lines
The reason the move mount check failed was because I was passing the original sym link paths such as: ..../tests/filesystem/vfat to
mount.cthat had a compare to check if moved. However it was mounted on the real path (..../tests/filesystem/..) not the sym link.
I think I might have a simpler way to solve this... I'll have to try it.
Signature · 3 lines
Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.