On 5/28/16 11:42 AM, Zorro Lang wrote: > 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 Yes, I think this is better. Any test using scratch should mkfs it anyway, and this way the test will not have to perform mkfs twice - once for the _require, and again for the test. Thanks, -Eric > Thanks, > Zorro -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html