diff options
author | Chen Gong <gong.chen@linux.intel.com> | 2009-12-19 12:34:11 +0800 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2009-12-21 11:54:11 +0100 |
commit | 8a1fd3bef82d7f9b58d9e9809c45e47658e77132 (patch) | |
tree | 3c66d0694aecfce367f308e045b6a396cac62fae | |
parent | c65ef7d07f95bc23a7ebb62f9e2a4d0da053127c (diff) | |
download | mce-test-8a1fd3bef82d7f9b58d9e9809c45e47658e77132.tar.gz |
some codes cleanup
1. more graceful output in the check_debugfs
2. eliminate trivial usage of parameter "debugfs" in hwpoison.sh
3. add some additional checks before driver kicks off, if not so,
one maybe meets such info "Failed: MCE log is different from input",
in fact it is only because module mce_inject isn't be inserted.
Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r-- | doc/howto.txt | 2 | ||||
-rwxr-xr-x | drivers/kdump/driver.sh | 8 | ||||
-rwxr-xr-x | drivers/simple/driver.sh | 8 | ||||
-rw-r--r-- | lib/mce.sh | 4 | ||||
-rwxr-xr-x | stress/hwpoison.sh | 41 |
5 files changed, 41 insertions, 22 deletions
diff --git a/doc/howto.txt b/doc/howto.txt index 776912c..418e728 100644 --- a/doc/howto.txt +++ b/doc/howto.txt @@ -26,7 +26,7 @@ guide and how to add new test cases into test suite. CONFIG_X86_MCE=y CONFIG_X86_MCE_INTEL=y - CONFIG_X86_MCE_INJECT=y + CONFIG_X86_MCE_INJECT=y or CONFIG_X86_MCE_INJECT=m - Get mcelog git version from git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git. diff --git a/drivers/kdump/driver.sh b/drivers/kdump/driver.sh index 9a6ab0a..f865b5c 100755 --- a/drivers/kdump/driver.sh +++ b/drivers/kdump/driver.sh @@ -232,6 +232,14 @@ if [ ! -f $WDIR/stamps/setupped ]; then exit -1 fi +#if mce_inject is a module, it is ensured to have been loaded +modinfo mce_inject > /dev/null 2>&1 +if [ $? -eq 0 ]; then + lsmod | grep mce_inject > /dev/null 2>&1 + [ $? -eq 0 ] || modprobe mce_inject + [ $? -eq 0 ] || die "module mce_inject isn't supported ?" +fi + for case_sh in ${CASES}; do for this_case in $($CDIR/$case_sh enumerate); do export this_case diff --git a/drivers/simple/driver.sh b/drivers/simple/driver.sh index d7250c0..b590d87 100755 --- a/drivers/simple/driver.sh +++ b/drivers/simple/driver.sh @@ -65,6 +65,14 @@ test_all() fi fi + #if mce_inject is a module, it is ensured to have been loaded + modinfo mce_inject > /dev/null 2>&1 + if [ $? -eq 0 ]; then + lsmod | grep mce_inject > /dev/null 2>&1 + [ $? -eq 0 ] || modprobe mce_inject + [ $? -eq 0 ] || die "module mce_inject isn't supported ?" + fi + for case_sh in $CASES; do for this_case in $($CDIR/$case_sh enumerate); do set_fake_panic 1 @@ -300,9 +300,9 @@ get_tolerant() check_debugfs() { - mount|grep debugfs + mount|grep debugfs > /dev/null 2>&1 [ ! $? -eq 0 ] && mount -t debugfs none /sys/kernel/debug - mount|grep debugfs + mount|grep debugfs > /dev/null 2>&1 [ ! $? -eq 0 ] && die "Kernel without debugfs support ?" } diff --git a/stress/hwpoison.sh b/stress/hwpoison.sh index 7836b60..50828fc 100755 --- a/stress/hwpoison.sh +++ b/stress/hwpoison.sh @@ -21,6 +21,10 @@ # #set -x +sd=$(dirname "$0") +export ROOT=`(cd $sd/..; pwd)` + +. $ROOT/lib/mce.sh DEBUG=0 @@ -157,16 +161,15 @@ setup_meminfo() setup_errinj() { - local debugfs="/sys/kernel/debug" local dev_major= local dev_minor= local rc=0 if [ $g_madvise -eq 1 ]; then - [ -f "$debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $debugfs/hwpoison/corrupt-filter-enable + [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-enable return else - [ -f "$debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $debugfs/hwpoison/corrupt-filter-enable + [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $g_debugfs/hwpoison/corrupt-filter-enable fi if [ $g_netfs -eq 0 ]; then dev_major=0x`/usr/bin/stat --format=%t $g_dev` > /dev/null 2>&1 @@ -178,10 +181,10 @@ setup_errinj() dev_major=0 dev_minor=0 fi - echo $dev_major > $debugfs/hwpoison/corrupt-filter-dev-major - echo $dev_minor > $debugfs/hwpoison/corrupt-filter-dev-minor - [ $g_pgtype = "all" -a -f "$debugfs/hwpoison/corrupt-filter-flags-mask" ] && echo 0 > $debugfs/hwpoison/corrupt-filter-flags-mask - [ -f "$debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $debugfs/hwpoison/corrupt-filter-enable + echo $dev_major > $g_debugfs/hwpoison/corrupt-filter-dev-major + echo $dev_minor > $g_debugfs/hwpoison/corrupt-filter-dev-minor + [ $g_pgtype = "all" -a -f "$g_debugfs/hwpoison/corrupt-filter-flags-mask" ] && echo 0 > $g_debugfs/hwpoison/corrupt-filter-flags-mask + [ -f "$g_debugfs/hwpoison/corrupt-filter-enable" ] && echo 1 > $g_debugfs/hwpoison/corrupt-filter-enable return } @@ -208,9 +211,8 @@ setup_fs() check_env() { - local debugfs="/sys/kernel/debug" - - silent_exec mount -t debugfs null $debugfs + check_debugfs + g_debugfs=`mount | grep debugfs | cut -d ' ' -f3` [ -z "$g_tty" ] && invalid "$g_tty does not exist" [ -z "$g_dev" ] && invalid "device is not specified" if [ $g_fstype = "nfs" -o $g_fstype = "cifs" ]; then @@ -226,10 +228,12 @@ check_env() dbp "Found the tool: $g_pagetool" fi if [ $g_pfninj -eq 1 ]; then - [ -d $debugfs/hwpoison/ ] || invalid "pls. insmod hwpoison_inject module" + [ -d $g_debugfs/hwpoison/ ] || modprobe hwpoison_inject + [ $? -eq 0 ] || die "module hwpoison_inject isn't supported ?" fi if [ $g_apei -eq 1 ]; then - [ -d $debugfs/apei/ ] || invalid "pls. insmod apei_inj module" + [ -d $g_debugfs/apei/ ] || modprobe einj + [ $? -eq 0 ] || die "module apei_inj isn't supported ?" fi [ -d $g_ltproot -a -f $g_ltppan ] || invalid "no ltp-pan on the machine: $g_ltppan" if [ $g_runltp -eq 1 ]; then @@ -466,13 +470,12 @@ _pfn_inj() { local pg=$1 - echo $pg > $debugfs/hwpoison/corrupt-pfn - dbp "echo $pg > $debugfs/hwpoison/corrupt-pfn" + echo $pg > $g_debugfs/hwpoison/corrupt-pfn + dbp "echo $pg > $g_debugfs/hwpoison/corrupt-pfn" } pfn_inj() { - local debugfs="/sys/kernel/debug" local pg_list= local pg=0 local pfn=0 @@ -518,9 +521,9 @@ _apei_inj() local pfn=`printf "%x" $1` local type=$2 - echo $type > $debugfs/apei/einj/error_type - echo "0x${pfn}000" > $debugfs/apei/err_inj/error_address - echo "1" > $debugfs/apei/einj/error_inject + echo $type > $g_debugfs/apei/einj/error_type + echo "0x${pfn}000" > $g_debugfs/apei/err_inj/error_address + echo "1" > $g_debugfs/apei/einj/error_inject } apei_ewb_ucr() @@ -535,7 +538,6 @@ apei_mem_ucr() apei_inj() { - local debugfs="/sys/kernel/debug" local pg_list= local pg= local cur= @@ -808,6 +810,7 @@ select_injector() } g_dev= +g_debugfs= g_testdir="/hwpoison" g_fstype=ext3 g_netfs=0 |