Message ID | 5e081252abdcf7253ad83d2b5eda49a8818305ad.1743996408.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fstests: btrfs: add test case to validate sysfs input arguments | expand |
On Mon, Apr 07, 2025 at 11:48:16AM +0800, Anand Jain wrote: > Ensure logs don’t write to a `.full` file when `_set_fs_sysfs_attr()` > is called during setup (before a testcase) in XFS due to unset seqres. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > common/rc | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/common/rc b/common/rc > index e89eee5de840..ca1d13ca1f0b 100644 > --- a/common/rc > +++ b/common/rc > @@ -5201,6 +5201,13 @@ _set_fs_sysfs_attr() > local attr=$1 > shift > local content="$*" > + local logfile="/dev/null" If we're not actually running a test, should the error output go to $check.full instead? --D > + > + # This function may be called outside a testcase during setup, > + # so seqres might not be set. > + if [[ -v seqres ]]; then > + logfile="$seqres.full" > + fi > > if [ ! -b "$dev" -o -z "$attr" -o -z "$content" ];then > _fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>" > @@ -5208,8 +5215,8 @@ _set_fs_sysfs_attr() > > local dname=$(_fs_sysfs_dname $dev) > > - echo "echo '$content' 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $seqres.full > - echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $seqres.full > + echo "echo '$content' 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $logfile > + echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $logfile > } > > # Print the content of /sys/fs/$FSTYP/$DEV/$ATTR > -- > 2.47.0 > >
diff --git a/common/rc b/common/rc index e89eee5de840..ca1d13ca1f0b 100644 --- a/common/rc +++ b/common/rc @@ -5201,6 +5201,13 @@ _set_fs_sysfs_attr() local attr=$1 shift local content="$*" + local logfile="/dev/null" + + # This function may be called outside a testcase during setup, + # so seqres might not be set. + if [[ -v seqres ]]; then + logfile="$seqres.full" + fi if [ ! -b "$dev" -o -z "$attr" -o -z "$content" ];then _fail "Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>" @@ -5208,8 +5215,8 @@ _set_fs_sysfs_attr() local dname=$(_fs_sysfs_dname $dev) - echo "echo '$content' 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $seqres.full - echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $seqres.full + echo "echo '$content' 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr}" >> $logfile + echo "$content" 2>&1 > /sys/fs/${FSTYP}/${dname}/${attr} | tee -a $logfile } # Print the content of /sys/fs/$FSTYP/$DEV/$ATTR
Ensure logs don’t write to a `.full` file when `_set_fs_sysfs_attr()` is called during setup (before a testcase) in XFS due to unset seqres. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- common/rc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)