Lines Matching +full:local +full:- +full:dir
17 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #set -x
33 local cmd=$@
35 if [ $DEBUG -eq 0 ]; then
45 local cmd=$@
47 if [ $DEBUG -eq 0 ]; then
62 [ $DEBUG -ne 1 ] && return
63 _print -en "\\033[0;33m" # set font color as yellow
66 _print -en "\\033[0;39m" # restore font color to normal
71 _print -en "\\033[0;33m" # set font color as yellow
74 _print -en "\\033[0;39m" # restore font color to normal
79 _print -n "$*" > $g_tty
80 _print -en "\\033[0;32m" # set font color as green
81 _print -e "\t [start]" > $g_tty
82 echo -e "$* \t [start]" >> $g_logfile
83 _print -en "\\033[0;39m" # restore font color to normal
88 _print -n "$*" > $g_tty
89 _print -en "\\033[0;32m" # set font color as green
90 _print -e "\t [done]" > $g_tty
91 echo -e "$* \t [done]" >> $g_logfile
92 _print -en "\\033[0;39m" # restore font color to normal
97 _print -en "\\033[0;31m" # set font color as red
105 _print -en "\\033[0;39m" # restore font color to normal
116 _print -en "\\033[0;31m" # set font color as red
121 echo "Try \`./hwposion -h\` for more information." > $g_tty
126 _print -en "\\033[0;39m" # restore font color to normal
132 _print -en "\\033[0;34m" # set font color as blue
133 _print -e "$*" > $g_tty
134 echo -e "$*" >> $g_result
135 echo -e "$*" >> $g_logfile
136 _print -en "\\033[0;39m" # restore font color to normal
141 local maxmem=0
142 local lowmem_s=0
143 local lowmem_e=0
144 local highmem_s=0
145 local highmem_e=0
146 local tmp=
150 …tmp=`cat /proc/iomem | grep "System RAM" | grep 100000- | awk -F "-" '{print $2}' | awk '{print $…
157 …tmp=`cat /proc/iomem | grep "System RAM" | grep 100000000- | awk -F "-" '{print $2}' | awk '{prin…
158 if [ -n "$tmp" ]; then
171 local dev_major=
172 local dev_minor=
173 local rc=0
175 if [ $g_soft_offline -eq 1 ]; then
176 …[ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-…
179 if [ $g_madvise -eq 1 ]; then
180 …[ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-…
181 # to avoid unexpected page-state changing in background while testing.
187 dev_major=0x`/usr/bin/stat --format=%t $g_dev` > /dev/null 2>&1
188 [ $? -ne 0 ] && rc=1
189 dev_minor=0x`/usr/bin/stat --format=%T $g_dev` > /dev/null 2>&1
190 [ $? -ne 0 ] && rc=1
191 [ $rc -eq 1 ] && invalid "invalid device: no inode # can be found"
192 echo $dev_major > $g_debugfs/hwpoison/corrupt-filter-dev-major
193 echo $dev_minor > $g_debugfs/hwpoison/corrupt-filter-dev-minor
194 …[ $g_pgtype = "all" -a -f "$g_debugfs/hwpoison/corrupt-filter-flags-mask" ] && echo 0 > $g_debugfs…
195 …[ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $g_debugfs/hwpoison/corrupt-filter-…
201 local mkfs="mkfs.$g_fstype"
202 local mkfs_opts="-q"
203 local mount_opts
206 [ $g_fstype = ocfs2 ] && mkfs_opts="$mkfs_opts -M local"
207 [ $g_fstype = cifs ] && mount_opts="-o password="""
208 mkdir -p $g_testdir || err "cannot mkdir $g_testdir"
209 if [ $g_nomkfs -eq 0 -a $g_netfs -eq 0 ]; then
211 if [ $g_force -eq 0 -a $g_fstype != "ocfs2" ]; then
212 echo -n "test will format $g_dev to $g_fstype, continue [y/n]? "
214 [ $in = 'y' -o $in = "yes" -o $in = 'Y' ] || err "$mkfs on $g_dev is cancelled"
216 begin "-- $mkfs $g_dev"
217 if [ $g_fstype = "vfat" -o $g_fstype = "msdos" -o $g_fstype = "btrfs" ]; then
220 mkfs_opts="-f"
222 [ $g_fstype = ocfs2 ] && echo -n "test will format $g_dev to $g_fstype, continue [y/n]? "
224 end "-- $mkfs $g_dev"
226 if [ $g_netfs -eq 0 ]; then
227 …silent_exec mount -t $g_fstype $g_dev $g_testdir || err "cannot mount $g_fstype fs: $g_dev to $g_t…
229 …silent_exec mount -t $g_fstype $mount_opts $g_netdev $g_testdir || err "cannot mount $g_fstype $mo…
236 g_debugfs=`mount | grep debugfs | cut -d ' ' -f3`
237 [ -z "$g_tty" ] && invalid "$g_tty does not exist"
238 if [ $g_test -eq 0 ]; then
239 if [ $g_fstype = "nfs" -o $g_fstype = "cifs" ]; then
241 [ -z $g_netdev ] && invalid "net device is not specified"
243 [ -z "$g_dev" ] && invalid "device is not specified"
244 [ -b $g_dev ] || invalid "invalid device: $g_dev"
245 if [ $g_netfs -eq 0 ]; then
251 [ -d $g_bindir ] || invalid "no bin subdir there"
252 if [ $g_madvise -eq 0 -o $g_recycle -ne 0 ]; then
257 if [ $g_pfninj -eq 1 ]; then
258 if [ $g_soft_offline -eq 1 ]; then
259 … [ -f $g_sysfs_mem/soft_offline_page ] || invalid "pls. ensure soft_offline_page is enabled"
263 if [ $? -eq 0 ]; then
264 [ -d $g_debugfs/hwpoison/ ] || modprobe hwpoison_inject
265 [ $? -eq 0 ] || invalid "module hwpoison_inject isn't supported ?"
269 [ $g_recycle -ne 0 ] && {
270 …[ -f $g_debugfs/hwpoison/unpoison-pfn ] || invalid "pls. insmod hwpoison_inject module with unpois…
272 if [ $g_apei -eq 1 ]; then
275 if [ $? -eq 0 ]; then
276 [ -d $g_debugfs/apei/einj ] || modprobe einj
277 [ $? -eq 0 ] || invalid "module apei_inj isn't supported ?"
280 [ -d $g_ltproot -a -f $g_ltppan ] || invalid "no ltp-pan on the machine: $g_ltppan"
281 if [ $g_runltp -eq 1 ]; then
282 [ -d $g_ltproot -a -f $g_ltproot/runltp ] || invalid "no runltp on the machine"
284 [ $g_duration -eq 0 ] && invalid "test duration is set as 0 second"
289 mkdir -p $g_resultdir
290 rm -rf $g_logdir
291 mkdir -p $g_logdir
294 [ $g_test -eq 0 ] && clear > $g_tty
301 mkdir -p $g_casedir
306 [ $g_test -eq 0 ] && setup_fs
313 local ltp_failed=$g_logdir/ltp/ltp_failed
314 local ltp_log=$g_logdir/ltp/ltp_log
315 local ltp_output=$g_logdir/ltp/ltp_output
316 local ltp_tmp=$g_testdir/ltp_tmp
319 mkdir -p $g_logdir/ltp
320 echo -n "" > $ltp_failed
321 echo -n "" > $ltp_log
322 echo -n "" > $ltp_output
323 mkdir -p $ltp_tmp
324 …ilent_exec_background $g_ltproot/runltp -d $ltp_tmp -l $ltp_log -o $ltp_output -r $g_ltproot -t ${…
331 local num=0;
332 local ltp_failed=$g_logdir/ltp/ltp_failed
333 local ltp_output=$g_logdir/ltp/ltp_output
335 [ -f $ltp_failed ] || {
336 result "\tltp -- error: no ltp result there"
341 num=`wc -l $ltp_failed | awk '{print $1}'`
342 if [ $num -ne 0 ]; then
343 result "\tltp -- $num case(s) failed"
347 result "\tltp -- all tests pass"
354 local dir=$g_logdir/fs_metadata
355 local result=$dir/fs_metadata.result
356 local log=$dir/fs_metadata.log
357 local pan_log=$dir/pan_log
358 local pan_output=$dir/pan_output
359 local pan_zoo=$dir/pan_zoo
360 local pan_failed=$dir/pan_failed
361 local tmp=$g_testdir/fs_metadata
362 local threads=
363 local node_number=5
364 local tree_depth=6
366 if [ $g_children -eq 0 ]; then
371 [ $threads -gt 10 ] && threads=10 && node_number=6
372 [ $threads -eq 0 ] && threads=1
375 mkdir -p $dir
376 echo -n "" > $pan_failed
377 echo -n "" > $pan_log
378 echo -n "" > $pan_output
379 echo -n "" > $pan_zoo
381 silent_exec_background rm -rf $tmp
382 mkdir -p $tmp || err "cannot create dir: $tmp"
384 …echo "fs_metadata fs-metadata.sh $tree_depth $node_number $threads $g_duration $result $tmp $log" …
385 …dbp "g_ltppan -n fs_metadata -a $pan_zoo -f $g_casedir/fs_metadata -o $pan_output -l $pan_log -C $…
386 …silent_exec_background $g_ltppan -n fs_metadata -a $pan_zoo -f $g_casedir/fs_metadata -o $pan_outp…
395 local fail_num=0;
396 local pass_num=0;
397 local dir=$g_logdir/fs_metadata
398 local result=$dir/fs_metadata.result
399 local log=$dir/fs_metadata.log
401 [ -f $result ] || {
402 result "\tfs_metadata -- error: no result there"
407 fail_num=`grep FAIL $result | awk -F : '{print $NF}'`
408 pass_num=`grep PASS $result | awk -F : '{print $NF}'`
409 [ -z "$fail_num" ] && fail_num=0 && pass_num=0
410 if [ $fail_num -ne 0 ]; then
411 result "\tfs_metadata -- $fail_num tests failed, $pass_num tests pass."
415 if [ $pass_num -eq 0 ]; then
416 result "\tfs_metadata -- no test finished"
420 result "\tfs_metadata -- all $pass_num tests got pass"
433 # $g_ltppan -n fs_specific -a $g_logdir/fs_specific -f $g_casedir/fs_specific -t ${g_duration}s &
439 local dir=$g_logdir/page_poisoning
440 local pan_failed=$dir/pan_failed
441 local pan_log=$dir/pan_log
442 local pan_output=$dir/pan_output
443 local tmp=$g_testdir/page_poisoning
444 local pan_zoo=$dir/pan_zoo
445 local result=$dir/page_poisoning.result
446 local log=$dir/page_poisoning.log
447 local opts=
449 begin "-- launch page_poisoning test"
450 mkdir -p $dir
451 echo -n "" > $pan_failed
452 echo -n "" > $pan_log
453 echo -n "" > $pan_output
454 echo -n "" > $pan_zoo
455 echo -n "" > $log
456 echo -n "" > $result
457 mkdir -p $tmp || err "cannot create dir: $tmp"
459 [ $g_children -ne 0 ] && opts="-i $g_children"
461 echo "page_poisoning page-poisoning -l $log -r $result -t $tmp $opts" > $g_casedir/page_poisoning
462 …dbp "$g_ltppan -n page_poisoning -a $pan_zoo -f $g_casedir/page_poisoning -t ${g_duration}s -o $pa…
463 …ec_background $g_ltppan -n page_poisoning -a $pan_zoo -f $g_casedir/page_poisoning -t ${g_duration…
465 end "-- launch page_poisoning test (pid: $g_pid_madv)"
470 local fail_num=0
471 local pass_num=0
472 local dir=$g_logdir/page_poisoning
473 local result=$dir/page_poisoning.result
474 local log=$dir/page_poisoning.log
476 [ -f $result ] || {
477 result "\tpage_poisoning -- error: no result file there"
482 fail_num=`grep FAILED $result | wc -l | awk '{print $1}'`
483 pass_num=`grep PASS $result | wc -l | awk '{print $1}'`
484 if [ $fail_num -ne 0 ]; then
485 result "\tpage_poisoning -- $fail_num tests failed, $pass_num tests pass."
489 if [ $pass_num -eq 0 ]; then
490 result "\tpage_poisoning -- no case finished"
494 result "\tpage_poisoning -- all $pass_num tests got pass"
510 local pg=$1
512 echo $pg > $g_debugfs/hwpoison/unpoison-pfn
513 dbp "echo $pg > $g_debugfs/hwpoison/unpoison-pfn"
518 local pg_list=
519 local pg=0
520 local pfn=0
521 local cur=
522 local i=0
523 local inj=_pfn_unpoison
525 pg_list=`$g_pagetool -NLrb hwpoison | grep -v offset | cut -f1`
534 local cur=
535 local rest=0
536 local percent=0
537 local next=0
538 local msg="hwpoison page error injection"
540 [ $g_soft_offline -eq 1 ] && msg="page soft offline"
543 [ "$cur" -ge "$g_time_e" ] && return
544 rest=`expr $g_time_e - $cur`
545 let "percent= ($g_duration - $rest) * 100 / $g_duration"
546 [ $percent -eq 0 ] && return
547 if [ $g_recycle -ne 0 ]; then
548 let "g_last=(($percent-$g_percent)*$g_duration)+$g_last"
549 [ $g_last -ge $g_recycle ] && {
554 [ $percent -gt 10 ] && let "next= $percent - 10"
555 [ $g_percent -ne 0 -a $g_percent -gt $next ] && return
562 local pfn=$1
564 echo $pfn > $g_debugfs/hwpoison/corrupt-pfn
565 dbp "echo $pfn > $g_debugfs/hwpoison/corrupt-pfn"
570 local pfn=$1
571 local i
572 local j
573 local paddr
584 local pg_list=
585 local pg=0
586 local pfn=0
587 local cur=
588 local i=0
589 local inj=_pfn_hwpoison
591 [ $g_soft_offline -eq 1 ] && inj=_pfn_soft_offline
594 while [ "$pfn" -lt "$g_maxpfn" ]
599 [ $pfn -gt $g_lowmem_e ] && pfn=$g_highmem_s
600 [ $pfn -gt $g_highmem_e ] && break
602 if [ $i -eq $g_progress ]; then
604 [ "$cur" -ge "$g_time_e" ] && break
610 …silent_exec $g_pagetool -Nrb $g_pgtype || err "unsupported pagetype, pls. refer to command: $g_pag…
611 pg_list=`$g_pagetool -NLrb $g_pgtype | grep -v offset | cut -f1`
616 if [ $i -eq $g_progress ]; then
618 [ "$cur" -ge "$g_time_e" ] && break
628 local pfn=`printf "%x" $1`
629 local type=$2
648 local pg_list=
649 local pg=
650 local cur=
651 local i=0
653 pg_list=`$g_pagetool -NLrb $g_pgtype | grep -v offset | cut -f1`
658 if [ $i -eq $g_progress ]; then
660 [ "$cur" -ge "$g_time_e" ] && break
671 local cur=
672 local i=0
673 local msg="hwpoison page error injection"
674 local MSG="inject HWPOISON error to pages"
676 if [ $g_soft_offline -eq 1 ]; then
680 if [ $g_madvise -eq 1 ]; then
689 if [ $g_madvise -eq 1 ]; then
696 while [ "$cur" -lt "$g_time_e" ]
698 if [ $g_madvise -eq 0 ]; then
700 [ $g_apei -eq 1 ] && apei_inj
701 [ $g_pfninj -eq 1 ] && pfn_inj
703 if [ $i -eq $g_progress ]; then
715 if [ $g_madvise -eq 1 ]; then
724 local dir=$g_logdir/fsck
725 local result=$dir/fsck.result
726 local log=$dir/fsck.log
734 local dir=$g_logdir/fsck
735 local result=$dir/fsck.result
736 local log=$dir/fsck.log
744 local dir=$g_logdir/fsck
745 local result=$dir/fsck.result
746 local log=$dir/fsck.log
747 local fsck=fsck.$g_fstype
748 local opts=""
750 mkdir -p $dir
751 echo -n "" > $log
752 echo -n "" > $result
757 opts="-y"
765 silent_exec umount -f $g_dev || sleep $g_interval
767 if [ $? -eq 0 ]; then
774 silent_exec mount -t $g_fstype $g_dev $g_testdir || {
784 local dir=$g_logdir/fsck
785 local result=$dir/fsck.result
786 local log=$dir/fsck.log
787 local fail_num=0;
788 local pass_num=0;
789 [ -f $result ] || {
790 result "\tfsck.$g_fstype -- no result found"
796 fail_num=`grep FAILED $result | wc -l | awk '{print $1}'`
797 pass_num=`grep PASS $result | wc -l | awk '{print $1}'`
798 if [ $fail_num -ne 0 ]; then
799 result "\tfsck.$g_fstype -- failed"
803 if [ $pass_num -eq 0 ]; then
804 result "\tfsck.$g_fstype -- not executed"
808 result "\tfsck.$g_fstype -- fsck on $g_dev got pass"
815 begin "-- collecting test result"
818 if [ $g_madvise -eq 1 ]; then
822 [ $g_runltp -eq 1 ] && ltp_result
824 [ $g_netfs -eq 0 -a $g_test -eq 0 ] && fsck_result
826 result "totally $g_failed task-groups report failures"
828 end "-- collecting test result"
833 echo "Usage: ./hwpoison.sh -d /dev/device [-options] [arguments]"
836 echo -e "\t-c console\t: target tty console to print test log"
837 echo -e "\t-d device\t: target block device to run test on"
838 echo -e "\t-f fstype\t: filesystem type to be tested"
839 echo -e "\t-i interval\t: sleep interval (default is $g_interval seconds)"
840 echo -e "\t-l logfile\t: log file"
841 echo -e "\t-n netdev\t: target network disk to run test on"
842 echo -e "\t-o ltproot\t: ltp root directory (default is $g_ltproot/)"
843 echo -e "\t-p pagetype\t: page type to inject error "
844 echo -e "\t-r result\t: result file"
845 echo -e "\t-s pagesize\t: page size on the system (default is $g_pgsize bytes)"
846 echo -e "\t-t duration\t: test duration time (default is $g_duration seconds)"
847 echo -e "\t-A \t\t: use APEI to inject error"
848 echo -e "\t-C children\t: process num of workloads"
849 echo -e "\t-F \t\t: execute as force mode, no interaction with user"
850 echo -e "\t-L \t\t: run ltp in background"
851 echo -e "\t-M \t\t: run page_poisoning test thru madvise syscall"
852 echo -e "\t-N \t\t: do not mkfs target block device"
853 echo -e "\t-R recyle\t: automatically unpoison pages after running recyle seconds"
854 echo -e "\t-S \t\t: test soft page offline"
855 echo -e "\t-T \t\t: test mode, run test in local dir other than on target device"
856 echo -e "\t-V \t\t: verbose mode, show debug info"
857 echo -e "\t-h \t\t: print this page"
859 echo -e "device:"
860 echo -e "\tthis is a mandatory argument. typically, it's a disk partition."
861 echo -e "\tall temporary files will be created on this device."
862 echo -e "\terror injector will just inject errors to the pages associated"
863 echo -e "\twith this device (except for the testing thru madvise syscall)."
865 echo -e "pagetype:"
866 echo -e "\tdefault page type:"
867 echo -e "\t $g_pgtype"
868 echo -e "\tfor more details, pls. try \`page-types -h\`."
869 echo -e "\tsee the definition of \"bits-spec\"."
871 echo -e "console:"
872 echo -e "\ttest can print output to the console you specified."
873 echo -e "\te.g. '-c /dev/tty1'"
887 begin "-- cleaning up remaining tasks in background"
888 if [ -n "$g_pid_madv" ]; then
890 [ $? -eq 0 ] && {
891 kill -15 $g_pid_madv > /dev/null 2>&1
895 if [ -n "$g_pid_fsmeta" ]; then
897 [ $? -eq 0 ] && {
898 kill -15 $g_pid_fsmeta > /dev/null 2>&1
902 if [ -n "$g_pid_ltp" ]; then
904 [ $? -eq 0 ] && {
905 kill -15 $g_pid_ltp > /dev/null 2>&1
909 end "-- cleaning up remaining tasks in background"
919 if [ $g_netfs -eq 0 ]; then
920 df | grep $g_dev > /dev/null 2>&1 && silent_exec umount -f $g_dev
922 df | grep $g_netdev > /dev/null 2>&1 && silent_exec umount -f $g_netdev
924 if [ $g_madvise -eq 1 ]; then
933 if [ $g_failed -ne 0 ]; then
943 if [ $g_test -eq 1 ]; then
944 [ $g_apei -eq 1 ] && g_apei=0
945 if [ $g_madvise -eq 1 ]; then
952 # for non-test mode, apei injector is 1st priority.
953 if [ $g_apei -eq 1 ]; then
958 if [ $g_madvise -eq 1 ]; then
976 g_ltppan="$g_ltproot/pan/ltp-pan"
977 g_pagetool="page-types"
1032 g_ltppan="$g_ltproot/pan/ltp-pan";;
1056 if [ $g_madvise -eq 0 ]; then
1057 [ $g_runltp -eq 1 ] && run_ltp
1061 [ $g_netfs -eq 0 -a $g_test -eq 0 ] && run_fsck