Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs. Signed-off-by: Jan Tulak <jtulak@xxxxxxxxxx> --- UPDATE: * Use tmp file instead of scratch - we are using -N flag, so it doesn't really matter. * Make both _requires to use the same function for testing, so if it is ever changed, the change will be reflected in both. --- common/rc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common/rc b/common/rc index 0c68e4f..c66d31d 100644 --- a/common/rc +++ b/common/rc @@ -3843,6 +3843,39 @@ _get_fs_sysfs_attr() cat /sys/fs/${FSTYP}/${dname}/${attr} } +# Skip if we are running an older binary without the stricter input checks. +# Make multiple checks to be sure that there is no regression on the one +# selected feature check, which would skew the result. +# +# At first, make a common function that runs the tests and returns +# number of failed cases. +mkfs_validation_check() +{ + local cmd="$MKFS_XFS_PROG -f -N -d file,name=/tmp/foo,size=$((1024 * 1024 * 1024))" + $cmd -s size=2s >/dev/null 2>&1 + local sum=$? + $cmd -l version=2,su=$((256 * 1024 + 4096)) >/dev/null 2>&1 + sum=`expr $sum + $?` + return $sum +} +# Skip the test if all calls passed - mkfs accepts invalid input +_require_xfs_mkfs_validation() +{ + mkfs_validation_check + if [ "$?" -eq 0 ]; then + _notrun "Requires newer mkfs with stricter input checks: the oldest supported version of xfsprogs is 4.7." + fi +} + +# The oposite of _require_xfs_mkfs_validation. +_require_xfs_mkfs_without_validation() +{ + mkfs_validation_check + if [ "$?" -ne 0 ]; then + _notrun "Requires older mkfs without strict input checks: the last supported version of xfsprogs is 4.5." + fi +} + init_rc ################################################################################ -- 2.5.5 -- 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