On Sat, Oct 31, 2020 at 7:05 PM Richard Haines <richard_c_haines@xxxxxxxxxxxxxx> wrote: > On Sat, 2020-10-31 at 12:56 +0100, Ondrej Mosnacek wrote: > > 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. Heh, I should've tried it before making that claim :) > > > > Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx> > > --- > > 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 > > [...] > > diff --git a/tests/filesystem/test b/tests/filesystem/test > > index 7d4654d..6b37b76 100755 > > --- a/tests/filesystem/test > > +++ b/tests/filesystem/test > > @@ -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|; > > + } > > + > > 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|; > } Yes, I'll need to use something similar. Thanks! > > > # 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; > > > > 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. I think I might have a simpler way to solve this... I'll have to try it. -- Ondrej Mosnacek Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.