diff options
author | xiao yang <yangx.jy@cn.fujitsu.com> | 2018-01-19 13:38:05 +0800 |
---|---|---|
committer | Eryu Guan <eguan@redhat.com> | 2018-01-21 22:10:50 +0800 |
commit | a3b3cf68fb905f0206d347e6d2e000a9f2c6e724 (patch) | |
tree | 3a7b403d75c4fe8885e0105a1d41767994891d71 | |
parent | 21e739820378bccbbb01305f8b59e64d9cd5a52f (diff) | |
download | xfstests-a3b3cf68fb905f0206d347e6d2e000a9f2c6e724.tar.gz |
common: Add _require_no_xfs_bug_on_assert and factor out filter_xfs_dmesg
1) Introduce _require_no_xfs_bug_on_assert helper to check if XFS is
built with CONFIG_XFS_ASSERT_FATAL, and call _require_no_xfs_debug
if bug_on_assert is not available.
2) Apply _require_no_xfs_bug_on_assert in xfs/098 and xfs/115.
3) Move filter_xfs_dmesg from xfs/098 to common/filter, and rename
it as _filter_assert_dmesg.
[eguan: update comment and _notrun message a bit]
Signed-off-by: xiao yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
-rw-r--r-- | common/filter | 11 | ||||
-rw-r--r-- | common/xfs | 22 | ||||
-rwxr-xr-x | tests/xfs/098 | 18 | ||||
-rwxr-xr-x | tests/xfs/115 | 5 |
4 files changed, 41 insertions, 15 deletions
diff --git a/common/filter b/common/filter index 8e1fdb4e50..53874a08f5 100644 --- a/common/filter +++ b/common/filter @@ -570,5 +570,16 @@ _filter_aiodio_dmesg() -e "s#$warn9#Intentional warnings in dio_complete#" } +# We generate assert related WARNINGs on purpose and make sure test doesn't fail +# because of these warnings. This is a helper for _check_dmesg() to filter out +# them. +_filter_assert_dmesg() +{ + local warn1="WARNING:.*fs/xfs/xfs_message\.c:.*asswarn.*" + local warn2="WARNING:.*fs/xfs/xfs_message\.c:.*assfail.*" + sed -e "s#$warn1#Intentional warnings in asswarn#" \ + -e "s#$warn2#Intentional warnings in assfail#" +} + # make sure this script returns success /bin/true diff --git a/common/xfs b/common/xfs index ab58364079..9b20b03807 100644 --- a/common/xfs +++ b/common/xfs @@ -625,6 +625,28 @@ _require_no_xfs_debug() fi } +# Require that assertions will not crash the system. +# +# Assertions would always crash the system if XFS assert fatal was enabled +# (CONFIG_XFS_ASSERT_FATAL=y). If a test is designed to trigger an assertion, +# skip the test on a CONFIG_XFS_ASSERT_FATAL built XFS by default. Note: +# CONFIG_XFS_ASSERT_FATAL can be disabled by setting bug_on_assert to zero if +# we want test to run. +_require_no_xfs_bug_on_assert() +{ + if [ -f /sys/fs/xfs/debug/bug_on_assert ]; then + grep -q "1" /sys/fs/xfs/debug/bug_on_assert && \ + _notrun "test requires XFS bug_on_assert to be off, turn it off to run the test" + else + # Note: Prior to the creation of CONFIG_XFS_ASSERT_FATAL (and + # the sysfs knob bug_on_assert), assertions would always crash + # the system if XFS debug was enabled (CONFIG_XFS_DEBUG=y). If + # a test is designed to trigger an assertion and the test + # designer does not want to hang fstests, skip the test. + _require_no_xfs_debug + fi +} + # Get a metadata field # The first arg is the field name # The rest of the arguments are xfs_db commands to find the metadata. diff --git a/tests/xfs/098 b/tests/xfs/098 index 9bcd94b0c0..24ce1d5d44 100755 --- a/tests/xfs/098 +++ b/tests/xfs/098 @@ -47,6 +47,8 @@ _cleanup() _supported_fs xfs _supported_os Linux +# We corrupt XFS on purpose, and check if assert failures would crash system. +_require_no_xfs_bug_on_assert _require_scratch test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc _require_attrs @@ -56,16 +58,6 @@ test -z "${FUZZ_ARGS}" && FUZZ_ARGS="-n 8 -3" rm -f $seqres.full -# If we corrupt log on a CONFIG_XFS_WARN build, there will be mount related -# WARNINGs in dmesg as expected. We don't want to simply _disable_dmesg_check -# which could miss other potential bugs, so filter out the intentional WARNINGs, -# make sure test doesn't fail because of this warning and fails on other WARNINGs. -filter_xfs_dmesg() -{ - local warn="WARNING:.*fs/xfs/xfs_message\.c:.*asswarn.*" - sed -e "s#$warn#Intentional warnings in asswarn#" -} - TESTDIR="${SCRATCH_MNT}/scratchdir" TESTFILE="${TESTDIR}/testfile" @@ -107,8 +99,10 @@ _scratch_mount 2>/dev/null && _fail "mount should not succeed" echo "+ repair fs" _repair_scratch_fs >> $seqres.full 2>&1 -# mount may trigger related WARNINGs, so filter them. -_check_dmesg filter_xfs_dmesg +# We may trigger assert related WARNINGs if we corrupt log on a +# CONFIG_XFS_WARN or CONFIG_XFS_DEBUG (CONFIG_XFS_ASSERT_FATAL is +# disabled) build, so filter them. +_check_dmesg _filter_assert_dmesg echo "+ mount image (2)" _scratch_mount diff --git a/tests/xfs/115 b/tests/xfs/115 index 0e62628d70..f77d0dd292 100755 --- a/tests/xfs/115 +++ b/tests/xfs/115 @@ -52,9 +52,8 @@ rm -f $seqres.full _supported_fs generic _supported_os Linux _require_scratch_nocheck -# we corrupt XFS on purpose, and debug built XFS would crash due to assert -# failure, so skip if we're testing on a debug built XFS -_require_no_xfs_debug +# We corrupt XFS on purpose, and check if assert failures would crash system. +_require_no_xfs_bug_on_assert _disable_dmesg_check # Make sure we disable finobt if the filesystem supports it, otherwise, just |