FS/XFS testing framework
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs
Date: Sun, 29 May 2016 00:42:39 +0800	[thread overview]
Message-ID: <20160528164239.GB5507@dhcp12-143.nay.redhat.com> (raw)
In-Reply-To: <8311236a-820b-473d-7aab-2afa8c24a4af@sandeen.net>

On Fri, May 27, 2016 at 01:27:56PM -0500, Eric Sandeen wrote:
> On 5/27/16 1:05 PM, Eric Sandeen wrote:
> 
> > So maybe something like this (not tested)
> > 
> > + /* Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ENTRY */
> > +_require_fs_sys_fs()
> > +{
> > +        local dev=$1
> > +        local target=$2
> > +        local dname=""
> > +        local tmp_mnt=`mktemp -d`
> > +
> > +        if [ ! -b "$dev" -o -z "$target" ];then
> > +	        echo "Usage: _require_fs_sys_fs <device> <sysfs_path>"
> > +                exit 1
> > +        fi
> > +
> > +        dname=$(basename $(readlink -f $dev))
> > +        _mount -t $FSTYP `_common_dev_mount_options` $dev $tmp_mnt
> > +        if [ ! -e /sys/fs/${FSTYP}/${dname}/$target ];then
> > +                umount $tmp_mnt
> > +                rm -f $tmp_mnt
> > +                _notrun "/sys/fs/${FSTYP}/${dname}/$target: No such file or directory"
> > +        fi
> > +        umount $SCRATCH_MNT
> > +        rm -f $tmp_mnt
> > +}
> > 
> > and it would work for either SCRATCH or TEST?
> 
> I guess nothing guarantees that the device is already mkfs'd, at least
> for scratch, so maybe it also needs to catch a mount failure,
> with a message about "could not mount; mkfs first in your test?"
> or something like that.

Yes, if we don't mkfs in _require_fs_sys_fs(), that means we need the
caller make sure they do that. I will check the mount error likes:

_mount -t $FSTYP `_common_dev_mount_options` $dev $tmp_mnt
if [ $? -ne 0 ];then
	rm -f $tmp_mnt
	_notrun "could not mount; mkfs first in your test?"
elif [ ! -e /sys/fs/${FSTYP}/${dname}/$target ];then
	....
fi

Thanks,
Zorro

> 
> -Eric
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-05-28 16:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 15:21 [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs Zorro Lang
2016-05-27 15:21 ` [PATCH 2/2] xfs/006: new case to test xfs fail_at_unmount error handling Zorro Lang
2016-05-27 18:26   ` Eric Sandeen
2016-05-28 16:56     ` Zorro Lang
2016-05-27 18:05 ` [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs Eric Sandeen
2016-05-27 18:27   ` Eric Sandeen
2016-05-28 16:42     ` Zorro Lang [this message]
2016-05-28 17:54       ` Eric Sandeen
2016-05-28 16:36   ` Zorro Lang
2016-05-28 18:06     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160528164239.GB5507@dhcp12-143.nay.redhat.com \
    --to=zlang@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox