Add hwpoison-inject load check

Add load checker of hwpoison-inject module for test case
run_hugepage_overcommit.sh.

NOTE: Gong revisits this patch a little bit.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
diff --git a/cases/function/hwpoison/helpers.sh b/cases/function/hwpoison/helpers.sh
index b9ddcbe..1c41912 100644
--- a/cases/function/hwpoison/helpers.sh
+++ b/cases/function/hwpoison/helpers.sh
@@ -3,6 +3,7 @@
 export ROOT=`(cd ../../../; pwd)`
 . $ROOT/lib/functions.sh
 setup_path
+. $ROOT/lib/mce.sh
 
 TMP="../../../work"
 TMP_DIR=${TMP_DIR:-$TMP}
@@ -74,3 +75,18 @@
 	done
 	umount $HT
 }
+
+load_hwpoison_inject() {
+	local path
+
+	check_debugfs
+	path=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/hwpoison
+	if [ ! -d $path ] ; then
+		modprobe hwpoison-inject
+		if [ $? -ne 0 ] ; then
+			die "Failed to load hwpoison-inject module. Abort."
+		else
+			echo "hwpoison-inject module is loaded."
+		fi
+	fi
+}
diff --git a/cases/function/hwpoison/run_hugepage_overcommit.sh b/cases/function/hwpoison/run_hugepage_overcommit.sh
index 51f393e..f01c219 100755
--- a/cases/function/hwpoison/run_hugepage_overcommit.sh
+++ b/cases/function/hwpoison/run_hugepage_overcommit.sh
@@ -4,6 +4,8 @@
 
 . ./helpers.sh
 
+load_hwpoison_inject
+
 # make sure we have no hwpoisoned hugepage before starting this test.
 free_resources > /dev/null