2 # Routines for injecting errors into filesystems
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2016 Oracle. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 # Contact information: Oracle Corporation, 500 Oracle Parkway,
21 # Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
22 #-----------------------------------------------------------------------
25 # Tests whether $FSTYP is one of the filesystems that supports error injection
26 _require_error_injection()
30 grep -q 'debug 1' /proc/fs/xfs/stat || \
31 _notrun "XFS error injection requires CONFIG_XFS_DEBUG"
34 _notrun "Error injection not supported on filesystem type: $FSTYP"
38 # Requires that xfs_io inject command knows about this error type
39 _require_xfs_io_error_injection()
42 _require_error_injection
44 # NOTE: We can't actually test error injection here because xfs
45 # hasn't always range checked the argument to xfs_errortag_add.
46 # We also don't want to trip an error before we're ready to deal
49 $XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \
50 _notrun "XFS error injection $type unknown."
53 # Inject an error into the test fs
58 $XFS_IO_PROG -x -c "inject $type" $TEST_DIR
61 # Inject an error into the scratch fs
62 _scratch_inject_error()
66 $XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT
69 # Unmount and remount the scratch device, dumping the log
70 _scratch_inject_logprint()
74 if test -n "$opts"; then
79 _scratch_mount "$opts"
82 # Unmount and remount the test device, dumping the log
83 _test_inject_logprint()
87 if test -n "$opts"; then