Re: [PATCH 2/3] generic: introduce test to test file_getattr/file_setattr syscalls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2025-08-11 08:17:40, Darrick J. Wong wrote:
> On Fri, Aug 08, 2025 at 09:31:57PM +0200, Andrey Albershteyn wrote:
> > Add a test to test basic functionality of file_getattr() and
> > file_setattr() syscalls. Most of the work is done in file_attr
> > utility.
> > 
> > Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx>
> > ---
> >  tests/generic/2000     | 113 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/2000.out |  37 ++++++++++++++++
> >  2 files changed, 150 insertions(+)
> > 
> > diff --git a/tests/generic/2000 b/tests/generic/2000
> > new file mode 100755
> > index 000000000000..b4410628c241
> > --- /dev/null
> > +++ b/tests/generic/2000
> > @@ -0,0 +1,113 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2025 Red Hat Inc.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 2000
> > +#
> > +# Test file_getattr/file_setattr syscalls
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto
> > +
> > +# Import common functions.
> > +# . ./common/filter
> > +
> > +_wants_kernel_commit xxxxxxxxxxx \
> > +	"fs: introduce file_getattr and file_setattr syscalls"
> > +
> > +# Modify as appropriate.
> > +_require_scratch
> > +_require_test_program "af_unix"
> > +_require_test_program "file_attr"
> > +_require_symlinks
> > +_require_mknod
> > +
> > +_scratch_mkfs >>$seqres.full 2>&1
> > +_scratch_mount
> > +
> > +file_attr () {
> > +	$here/src/file_attr $*
> > +}
> > +
> > +create_af_unix () {
> > +	$here/src/af_unix $* || echo af_unix failed
> > +}
> > +
> > +projectdir=$SCRATCH_MNT/prj
> > +
> > +# Create normal files and special files
> > +mkdir $projectdir
> > +mkfifo $projectdir/fifo
> > +mknod $projectdir/chardev c 1 1
> > +mknod $projectdir/blockdev b 1 1
> > +create_af_unix $projectdir/socket
> > +touch $projectdir/foo
> > +ln -s $projectdir/foo $projectdir/symlink
> > +touch $projectdir/bar
> > +ln -s $projectdir/bar $projectdir/broken-symlink
> > +rm -f $projectdir/bar
> > +
> > +echo "Error codes"
> > +# wrong AT_ flags
> > +file_attr --get --invalid-at $projectdir ./foo
> > +file_attr --set --invalid-at $projectdir ./foo
> > +# wrong fsxattr size (too big, too small)
> > +file_attr --get --too-big-arg $projectdir ./foo
> > +file_attr --get --too-small-arg $projectdir ./foo
> > +file_attr --set --too-big-arg $projectdir ./foo
> > +file_attr --set --too-small-arg $projectdir ./foo
> > +# out of fsx_xflags mask
> > +file_attr --set --new-fsx-flag $projectdir ./foo
> > +
> > +echo "Initial attributes state"
> > +file_attr --get $projectdir
> > +file_attr --get $projectdir ./fifo
> > +file_attr --get $projectdir ./chardev
> > +file_attr --get $projectdir ./blockdev
> > +file_attr --get $projectdir ./socket
> > +file_attr --get $projectdir ./foo
> > +file_attr --get $projectdir ./symlink
> > +
> > +echo "Set FS_XFLAG_NODUMP (d)"
> > +file_attr --set --set-nodump $projectdir
> > +file_attr --set --set-nodump $projectdir ./fifo
> > +file_attr --set --set-nodump $projectdir ./chardev
> > +file_attr --set --set-nodump $projectdir ./blockdev
> > +file_attr --set --set-nodump $projectdir ./socket
> > +file_attr --set --set-nodump $projectdir ./foo
> > +file_attr --set --set-nodump $projectdir ./symlink
> > +
> > +echo "Read attributes"
> > +file_attr --get $projectdir
> > +file_attr --get $projectdir ./fifo
> > +file_attr --get $projectdir ./chardev
> > +file_attr --get $projectdir ./blockdev
> > +file_attr --get $projectdir ./socket
> > +file_attr --get $projectdir ./foo
> > +file_attr --get $projectdir ./symlink
> > +
> > +echo "Set attribute on broken link with AT_SYMLINK_NOFOLLOW"
> > +file_attr --set --set-nodump $projectdir ./broken-symlink
> > +file_attr --get $projectdir ./broken-symlink
> > +
> > +file_attr --set --no-follow --set-nodump $projectdir ./broken-symlink
> > +file_attr --get --no-follow $projectdir ./broken-symlink
> > +
> > +cd $SCRATCH_MNT
> > +touch ./foo2
> > +echo "Initial state of foo2"
> > +file_attr --get --at-cwd ./foo2
> > +echo "Set attribute relative to AT_FDCWD"
> > +file_attr --set --at-cwd --set-nodump ./foo2
> > +file_attr --get --at-cwd ./foo2
> > +
> > +echo "Set attribute on AT_FDCWD"
> > +mkdir ./bar
> > +file_attr --get --at-cwd ./bar
> > +cd ./bar
> > +file_attr --set --at-cwd --set-nodump ""
> > +file_attr --get --at-cwd .
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/generic/2000.out b/tests/generic/2000.out
> > new file mode 100644
> > index 000000000000..51b4d84e2bae
> > --- /dev/null
> > +++ b/tests/generic/2000.out
> > @@ -0,0 +1,37 @@
> > +QA output created by 2000
> > +Error codes
> > +Can not get fsxattr on ./foo: Invalid argument
> > +Can not get fsxattr on ./foo: Invalid argument
> > +Can not get fsxattr on ./foo: Argument list too long
> > +Can not get fsxattr on ./foo: Invalid argument
> > +Can not get fsxattr on ./foo: Argument list too long
> > +Can not get fsxattr on ./foo: Invalid argument
> > +Can not set fsxattr on ./foo: Invalid argument
> > +Initial attributes state
> > +----------------- /mnt/scratch/prj 
> 
> Assuming SCRATCH_DIR=/mnt/scratch on your system, please _filter_scratch
> the output.
> 
> (The rest looks reasonable to me.)
> 
> --D
> 

ops, will fix, thanks

-- 
- Andrey





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux