common: add helper function _flakey_drop_and_remount

To avoid having many tests repeating the following pattern:

        _load_flakey_table $FLAKEY_DROP_WRITES
        _unmount_flakey

        _load_flakey_table $FLAKEY_ALLOW_WRITES
        _mount_flakey

add the helper function _flakey_drop_and_remount to remove
the existing duplicated code and serve as a shortcut.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Filipe Manana
2015-11-17 08:41:32 +11:00
committed by Dave Chinner
parent 71f68b47e1
commit 1a22b6820e
23 changed files with 46 additions and 159 deletions
+15
View File
@@ -74,3 +74,18 @@ _load_flakey_table()
$DMSETUP_PROG resume flakey-test
[ $? -ne 0 ] && _fatal "failed to resumeflakey-test"
}
# Silently drop all writes and unmount/remount to simulate a crash/power
# failure.
_flakey_drop_and_remount()
{
_load_flakey_table $FLAKEY_DROP_WRITES
_unmount_flakey
if [ "x$1" = "xyes" ]; then
_check_scratch_fs $FLAKEY_DEV
fi
_load_flakey_table $FLAKEY_ALLOW_WRITES
_mount_flakey
}