xref: /aosp_15_r20/external/ltp/tools/insert_kernel_faults.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker#!/bin/sh
2*49cdfc7eSAndroid Build Coastguard Worker################################################################################
3*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
4*49cdfc7eSAndroid Build Coastguard Worker## Copyright (c) International Business Machines  Corp., 2009                 ##
5*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
6*49cdfc7eSAndroid Build Coastguard Worker## This program is free software;  you can redistribute it and/or modify      ##
7*49cdfc7eSAndroid Build Coastguard Worker## it under the terms of the GNU General Public License as published by       ##
8*49cdfc7eSAndroid Build Coastguard Worker## the Free Software Foundation; either version 2 of the License, or          ##
9*49cdfc7eSAndroid Build Coastguard Worker## (at your option) any later version.                                        ##
10*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
11*49cdfc7eSAndroid Build Coastguard Worker## This program is distributed in the hope that it will be useful, but        ##
12*49cdfc7eSAndroid Build Coastguard Worker## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13*49cdfc7eSAndroid Build Coastguard Worker## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
14*49cdfc7eSAndroid Build Coastguard Worker## for more details.                                                          ##
15*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
16*49cdfc7eSAndroid Build Coastguard Worker## You should have received a copy of the GNU General Public License          ##
17*49cdfc7eSAndroid Build Coastguard Worker## along with this program;  if not, write to the Free Software               ##
18*49cdfc7eSAndroid Build Coastguard Worker## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
19*49cdfc7eSAndroid Build Coastguard Worker##                                                                            ##
20*49cdfc7eSAndroid Build Coastguard Worker################################################################################
21*49cdfc7eSAndroid Build Coastguard Worker#									      ##
22*49cdfc7eSAndroid Build Coastguard Worker# File :        insert_kernel_faults.sh					      ##
23*49cdfc7eSAndroid Build Coastguard Worker#									      ##
24*49cdfc7eSAndroid Build Coastguard Worker# Usage:	insert_kernel_faults.sh <fault_percentage>		      ##
25*49cdfc7eSAndroid Build Coastguard Worker#									      ##
26*49cdfc7eSAndroid Build Coastguard Worker# Description:  This is a simple script that inserts faults at various	      ##
27*49cdfc7eSAndroid Build Coastguard Worker#		subsystems of the kernel. Please refer to the ltp/README      ##
28*49cdfc7eSAndroid Build Coastguard Worker#		for the various kernel CONFIG options needed to exploit	      ##
29*49cdfc7eSAndroid Build Coastguard Worker#		all those features					      ##
30*49cdfc7eSAndroid Build Coastguard Worker#									      ##
31*49cdfc7eSAndroid Build Coastguard Worker# Author:	Subrata Modak <[email protected]>		      ##
32*49cdfc7eSAndroid Build Coastguard Worker#									      ##
33*49cdfc7eSAndroid Build Coastguard Worker# History:      Aug 11 2009 - Created - Subrata Modak.			      ##
34*49cdfc7eSAndroid Build Coastguard Worker#		Aug 17 2009 - Changed the debugfs mount point - Subrata Modak.##
35*49cdfc7eSAndroid Build Coastguard Worker################################################################################
36*49cdfc7eSAndroid Build Coastguard Worker
37*49cdfc7eSAndroid Build Coastguard Workerif [ -z "$1" ]
38*49cdfc7eSAndroid Build Coastguard Worker	then
39*49cdfc7eSAndroid Build Coastguard Worker	#Check if Useage has been proper
40*49cdfc7eSAndroid Build Coastguard Worker	echo "Usage: $0 <fault_percentage>"
41*49cdfc7eSAndroid Build Coastguard Worker	exit 1
42*49cdfc7eSAndroid Build Coastguard Workerfi
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard Worker#These are the types of Subsystems where fault will be injected
45*49cdfc7eSAndroid Build Coastguard Worker#Make sure debugfs has been mounted
46*49cdfc7eSAndroid Build Coastguard Workerfor FAILTYPE in fail_io_timeout fail_make_request fail_page_alloc failslab
47*49cdfc7eSAndroid Build Coastguard Workerdo
48*49cdfc7eSAndroid Build Coastguard Worker	echo $1 > /sys/kernel/debug/$FAILTYPE/probability
49*49cdfc7eSAndroid Build Coastguard Worker	echo 100 > /sys/kernel/debug/$FAILTYPE/interval
50*49cdfc7eSAndroid Build Coastguard Worker	echo -1 > /sys/kernel/debug/$FAILTYPE/times
51*49cdfc7eSAndroid Build Coastguard Worker	echo 0 > /sys/kernel/debug/$FAILTYPE/space
52*49cdfc7eSAndroid Build Coastguard Workerdone
53*49cdfc7eSAndroid Build Coastguard Worker
54