aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2013-02-06 02:24:57 -0500
committerChen Gong <gong.chen@linux.intel.com>2013-02-06 02:29:54 -0500
commit604eaac573ee5095080f62bf4a020c1dbd182577 (patch)
treeafff7db4075e3c8feecfd95b9be075030b7ef23c
parent8765dc6a73b9ebf5c14a5abf0c15c485d3bce06f (diff)
downloadmce-test-604eaac573ee5095080f62bf4a020c1dbd182577.tar.gz
Clean up hwpoison functional tests
Code displacement: - moved common code into helper.sh to avoid duplicates, - merged run-huge-test.sh into run_hugepage.sh and run-transhuge-test.sh into run_thp.sh. Minor improvements: - added sysctl vm.memory_failure_early_kill=0 in the setup of each testcase (some testcases change this global parameter, so it's safe to reset it to 0 to avoid interference between testcases), - added freeing resources (shmems, semaphores) and unpoisoning in the cleanup of each testcase, - added counter check ("HardwareCorrupted:" in /proc/meminfo) Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
-rw-r--r--cases/function/hwpoison/helpers.sh69
-rwxr-xr-xcases/function/hwpoison/run-huge-test.sh167
-rwxr-xr-xcases/function/hwpoison/run-transhuge-test.sh100
-rwxr-xr-xcases/function/hwpoison/run_hard.sh50
-rwxr-xr-xcases/function/hwpoison/run_hugepage.sh134
-rwxr-xr-xcases/function/hwpoison/run_soft.sh27
-rwxr-xr-xcases/function/hwpoison/run_thp.sh108
7 files changed, 341 insertions, 314 deletions
diff --git a/cases/function/hwpoison/helpers.sh b/cases/function/hwpoison/helpers.sh
new file mode 100644
index 0000000..7b241c8
--- /dev/null
+++ b/cases/function/hwpoison/helpers.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+export ROOT=`(cd ../../../; pwd)`
+. $ROOT/lib/functions.sh
+setup_path
+
+executed_testcase=0
+failed_testcase=0
+
+sysctl -q vm.memory_failure_early_kill=0
+
+run_test() {
+ [ $# -ne 2 ] && echo "$FUNCNAME: Invalid argument" >&2 && exit 1
+ local tp="$1"
+ local expect="$2"
+ local result=
+
+ executed_testcase=$[executed_testcase+1]
+ eval $tp
+ [ $? -eq 0 ] && result=success || result=failure
+ if [ "$result" = "$expect" ] ; then
+ echo "PASS: $tp"
+ else
+ failed_testcase=$[failed_testcase+1]
+ if [ "$result" = "failure" ] ; then
+ echo "FAIL: $tp returned with failure."
+ else
+ echo "FAIL: $tp returned with unexpected success."
+ fi
+ fi
+}
+
+free_resources() {
+ # free IPC semaphores used by thugetlb.c
+ ipcs -s | grep $USER | cut -f2 -d' ' | xargs ipcrm sem > /dev/null 2>&1
+ # remove remaining hugepages on shmem
+ ipcs -m | sed -n '4,$p' | cut -f2 -d' ' | xargs ipcrm shm > /dev/null 2>&1
+
+ echo "Unpoisoning."
+ # unpoison hugepages first to avoid needless unpoisoning for tail pages.
+ page-types -b hwpoison,huge,compound_head=hwpoison,huge,compound_head -x -N
+ page-types -b hwpoison -x -Nl > tmp.hwpoisonlist
+ if [ $(grep "^HardwareCorrupted:" /proc/meminfo | awk '{print $2}') -ne 0 ] ; then
+ echo "WARNING: hwpoison page counter is broken."
+ grep "^HardwareCorrupted:" /proc/meminfo
+ fi
+}
+
+show_summary() {
+ echo ""
+ echo -n " Num of Executed Test Case: $executed_testcase"
+ echo -e " Num of Failed Case: $failed_testcase"
+ echo ""
+}
+
+mount_hugetlbfs() {
+ HT=$TMP_DIR/hugepage
+ mkdir -p $HT
+ mount -t hugetlbfs none $HT
+ sysctl -q vm.nr_hugepages=500
+}
+
+unmount_hugetlbfs() {
+ sysctl -q vm.nr_hugepages=0
+ for mountpoint in $(grep hugetlbfs /proc/mounts | cut -f2 -d' ') ; do
+ rm -rf $mountpoint/*
+ done
+ umount $HT
+}
diff --git a/cases/function/hwpoison/run-huge-test.sh b/cases/function/hwpoison/run-huge-test.sh
deleted file mode 100755
index f5347f1..0000000
--- a/cases/function/hwpoison/run-huge-test.sh
+++ /dev/null
@@ -1,167 +0,0 @@
-#!/bin/bash
-#
-# Test program for memory error handling for hugepages
-# Usage: ./run-huge-test.sh hugetlbfs_directory
-# Author: Naoya Horiguchi
-
-usage()
-{
- echo "Usage: run-huge-test.sh hugetlbfs_directory" && exit 0
-}
-
-htdir=$1
-[ $# -ne 1 ] && usage
-[ ! -d $htdir ] && usage
-
-rm -rf $htdir/test*
-echo 1000 > /proc/sys/vm/nr_hugepages
-
-num=0
-
-exec_testcase() {
- error=0
- echo "TestCase $@"
- hpage_size=$1
- hpage_target=$2
- num=$7
-
- if [ "$3" = "head" ] ; then
- hpage_target_offset=0
- elif [ "$3" = "tail" ] ; then
- hpage_target_offset=1
- else
- error=1
- fi
- hpage_target=$((hpage_target * 512 + hpage_target_offset))
-
- if [ "$4" = "early" ] ; then
- process_type="-e"
- elif [ "$4" = "late_touch" ] ; then
- process_type=""
- elif [ "$4" = "late_avoid" ] ; then
- process_type="-a"
- else
- error=1
- fi
-
- if [ "$5" = "anonymous" ] ; then
- file_type="-A"
- elif [ "$5" = "file" ] ; then
- file_type="-f $num"
- elif [ "$5" = "shm" ] ; then
- file_type="-S"
- else
- error=1
- fi
-
- if [ "$6" = "fork_shared" ] ; then
- share_type="-F"
- elif [ "$6" = "fork_private_nocow" ] ; then
- share_type="-Fp"
- elif [ "$6" = "fork_private_cow" ] ; then
- share_type="-Fpc"
- else
- error=1
- fi
-
- command="./thugetlb -x -m $hpage_size -o $hpage_target $process_type $file_type $share_type $htdir &"
- echo $command
- eval $command
- wait $!
- echo ""
-
- return 0
-}
-
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "early" "anonymous" "fork_private_cow" $num
-
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_touch" "anonymous" "fork_private_cow" $num
-
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "head" "late_avoid" "anonymous" "fork_private_cow" $num
-
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "early" "anonymous" "fork_private_cow" $num
-
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_touch" "anonymous" "fork_private_cow" $num
-
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "file" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "file" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "file" "fork_private_cow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "shm" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_shared" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_private_nocow" $num
-num=$((num+1))
-exec_testcase 2 1 "tail" "late_avoid" "anonymous" "fork_private_cow" $num
-
-# free IPC semaphores used by thugetlb.c
-ipcs -s|grep $USER|cut -f2 -d' '|xargs ipcrm sem
diff --git a/cases/function/hwpoison/run-transhuge-test.sh b/cases/function/hwpoison/run-transhuge-test.sh
deleted file mode 100755
index efa82b9..0000000
--- a/cases/function/hwpoison/run-transhuge-test.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-#
-# run-transhuge-test.sh:
-# Script for hwpoison test of THP(Transparent Huge Page).
-#
-#
-
-ROOT=`(cd ../../../; pwd)`
-
-. $ROOT/lib/functions.sh
-setup_path
-
-THP_POISON_PRO="ttranshuge"
-
-THP_SYS_PATH="/sys/kernel/mm/transparent_hugepage"
-THP_SYS_ENABLED_FILE="$THP_SYS_PATH/enabled"
-
-executed_testcase=0
-failed_testcase=0
-
-error()
-{
- echo "$1" && exit 1
-}
-
-env_check()
-{
- which $THP_POISON_PRO > /dev/null 2>&1
- [ $? -ne 0 ] && error "Please make sure there is file $THP_POISON_PRO."
-
- if [ ! -d $THP_SYS_PATH ] ; then
- error "THP(Transparent Huge Page) may be not supported by kernel."
- fi
-
- thp_enabled="$(cat $THP_SYS_ENABLED_FILE | awk '{print $3}')"
- if [ "$thp_enabled" == "[never]" ] ; then
- error "THP(Transparent Huge Page) is disabled now."
- fi
-}
-
-result_check()
-{
- if [ "$1" != "0" ] ; then
- failed_testcase=`expr $failed_testcase + 1`
- fi
-}
-
-exec_testcase()
-{
- if [ "$1" = "head" ] ; then
- page_position_in_thp=0
- elif [ "$1" = "tail" ] ; then
- page_position_in_thp=1
- else
- error "Which page do you want to poison?"
- fi
-
- if [ "$2" = "early" ] ; then
- process_type="--early-kill"
- elif [ "$2" = "late_touch" ] ; then
- process_type=""
- elif [ "$2" = "late_avoid" ] ; then
- process_type="--avoid-touch"
- else
- error "No such process type."
- fi
-
- executed_testcase=`expr $executed_testcase + 1`
-
- echo "------------------ Case $executed_testcase --------------------"
-
- command="$THP_POISON_PRO $process_type --offset $page_position_in_thp"
- echo $command
- eval $command
- result_check $?
-
- echo -e "\n"
-}
-
-# Environment Check for Test.
-env_check
-
-# Execute Test Cases from Here.
-echo "============= HWPoison Test of Transparent Huge Page ================="
-
-exec_testcase "head" "early"
-
-exec_testcase "head" "late_touch"
-
-exec_testcase "head" "late_avoid"
-
-exec_testcase "tail" "early"
-
-exec_testcase "tail" "late_touch"
-
-exec_testcase "tail" "late_avoid"
-
-echo "======================================================================="
-echo -n " Num of Executed Test Case: $executed_testcase"
-echo -e " Num of Failed Case: $failed_testcase\n"
diff --git a/cases/function/hwpoison/run_hard.sh b/cases/function/hwpoison/run_hard.sh
index 8bc0803..781814a 100755
--- a/cases/function/hwpoison/run_hard.sh
+++ b/cases/function/hwpoison/run_hard.sh
@@ -1,5 +1,9 @@
#!/bin/bash
+pushd `dirname $0` > /dev/null
+
+. ./helpers.sh
+
cat <<-EOF
***************************************************************************
@@ -11,32 +15,28 @@ This test is hard mode of HWPoison functional test.
EOF
-echo 0 > $TMP_DIR/error.$$
+echo "------------------------------------------------------------------------"
+echo "Running tsimpleinj (simple hard offline test)"
+run_test ./tkillpoison failure
-pushd `dirname $0` > /dev/null
+echo "------------------------------------------------------------------------"
+echo "Running tsimpleinj (simple hard offline test)"
+run_test ./tsimpleinj success
+
+echo "------------------------------------------------------------------------"
+echo "Running tinjpage (hard offline test on various types of pages)"
+mount_hugetlbfs
+run_test ./tinjpage success
+unmount_hugetlbfs
+
+echo "------------------------------------------------------------------------"
+echo "Running tprctl (hard offline test with various prctl settings)"
+run_test ./tprctl success
+
+free_resources
+
+show_summary
-HT=$TMP_DIR/hugepage
-mkdir -p $HT
-mount -t hugetlbfs none $HT
-
-./tinjpage
-./tsimpleinj
-if ! ./tkillpoison
-then
- echo "killed as expected"
-else
- echo "didn't get killed"
- echo 1 > $TMP_DIR/error.$$
-fi
-./tprctl
-
-umount $HT
popd > /dev/null
-grep -q "1" $TMP_DIR/error.$$
-if [ $? -eq 0 ]
-then
- exit 1
-else
- exit 0
-fi
+exit $failed_testcase
diff --git a/cases/function/hwpoison/run_hugepage.sh b/cases/function/hwpoison/run_hugepage.sh
index 4c97236..3952975 100755
--- a/cases/function/hwpoison/run_hugepage.sh
+++ b/cases/function/hwpoison/run_hugepage.sh
@@ -1,4 +1,77 @@
#!/bin/bash
+#
+# run_hugepage.sh:
+# Test program for memory error handling for hugepages
+# Author: Naoya Horiguchi
+
+pushd `dirname $0` > /dev/null
+
+. ./helpers.sh
+
+mount_hugetlbfs
+
+exec_testcase() {
+ echo "-------------------------------------"
+ echo "TestCase $@"
+ local hpage_size=2
+ local hpage_target=1
+ local hpage_target_offset=
+ local process_type=
+ local file_type=
+ local share_type=
+ executed_testcase=$[executed_testcase+1]
+
+ case "$1" in
+ head) hpage_target_offset=0 ;;
+ tail) hpage_target_offset=1 ;;
+ *) echo "Invalid argument" >&2 && exit 1 ;;
+ esac
+ hpage_target=$((hpage_target * 512 + hpage_target_offset))
+
+ case "$2" in
+ early) process_type="-e" ;;
+ late_touch) process_type="" ;;
+ late_avoid) process_type="-a" ;;
+ *) echo "Invalid argument" >&2 && exit 1 ;;
+ esac
+
+ case "$3" in
+ anonymous) file_type="-A" ;;
+ file) file_type="-f $executed_testcase" ;;
+ shm) file_type="-S" ;;
+ *) echo "Invalid argument" >&2 && exit 1 ;;
+ esac
+
+ case "$4" in
+ fork_shared) share_type="-F" ;;
+ fork_private_nocow) share_type="-Fp" ;;
+ fork_private_cow) share_type="-Fpc" ;;
+ *) echo "Invalid argument" >&2 && exit 1 ;;
+ esac
+
+ local command="./thugetlb -x -m $hpage_size -o $hpage_target $process_type $file_type $share_type $HT"
+ echo $command
+ eval $command
+ if [ $? -ne 0 ] ; then
+ echo "thugetlb was killed."
+ if [ "$5" = killed ] ; then
+ echo "PASS"
+ else
+ echo "FAIL"
+ failed_testcase=$[failed_testcase+1]
+ fi
+ else
+ echo "thugetlb exited normally."
+ if [ "$5" = killed ] ; then
+ echo "FAIL"
+ failed_testcase=$[failed_testcase+1]
+ else
+ echo "PASS"
+ fi
+ fi
+
+ return 0
+}
cat <<-EOF
@@ -11,11 +84,60 @@ This is the functional test for huge page support of HWPoison.
EOF
-pushd `dirname $0` > /dev/null
+exec_testcase head early file fork_shared killed
+exec_testcase head early file fork_private_nocow killed
+exec_testcase head early file fork_private_cow killed
+exec_testcase head early shm fork_shared killed
+exec_testcase head early anonymous fork_shared killed
+exec_testcase head early anonymous fork_private_nocow killed
+exec_testcase head early anonymous fork_private_cow killed
+
+exec_testcase head late_touch file fork_shared killed
+exec_testcase head late_touch file fork_private_nocow killed
+exec_testcase head late_touch file fork_private_cow killed
+exec_testcase head late_touch shm fork_shared killed
+exec_testcase head late_touch anonymous fork_shared killed
+exec_testcase head late_touch anonymous fork_private_nocow killed
+exec_testcase head late_touch anonymous fork_private_cow killed
+
+exec_testcase head late_avoid file fork_shared notkilled
+exec_testcase head late_avoid file fork_private_nocow notkilled
+exec_testcase head late_avoid file fork_private_cow notkilled
+exec_testcase head late_avoid shm fork_shared notkilled
+exec_testcase head late_avoid anonymous fork_shared notkilled
+exec_testcase head late_avoid anonymous fork_private_nocow notkilled
+exec_testcase head late_avoid anonymous fork_private_cow notkilled
+
+exec_testcase tail early file fork_shared killed
+exec_testcase tail early file fork_private_nocow killed
+exec_testcase tail early file fork_private_cow killed
+exec_testcase tail early shm fork_shared killed
+exec_testcase tail early anonymous fork_shared killed
+exec_testcase tail early anonymous fork_private_nocow killed
+exec_testcase tail early anonymous fork_private_cow killed
+
+exec_testcase tail late_touch file fork_shared killed
+exec_testcase tail late_touch file fork_private_nocow killed
+exec_testcase tail late_touch file fork_private_cow killed
+exec_testcase tail late_touch shm fork_shared killed
+exec_testcase tail late_touch anonymous fork_shared killed
+exec_testcase tail late_touch anonymous fork_private_nocow killed
+exec_testcase tail late_touch anonymous fork_private_cow killed
+
+exec_testcase tail late_avoid file fork_shared notkilled
+exec_testcase tail late_avoid file fork_private_nocow notkilled
+exec_testcase tail late_avoid file fork_private_cow notkilled
+exec_testcase tail late_avoid shm fork_shared notkilled
+exec_testcase tail late_avoid anonymous fork_shared notkilled
+exec_testcase tail late_avoid anonymous fork_private_nocow notkilled
+exec_testcase tail late_avoid anonymous fork_private_cow notkilled
+
+unmount_hugetlbfs
+
+free_resources
+
+show_summary
-HT=$TMP_DIR/hugepage
-mkdir -p $HT
-mount -t hugetlbfs none $HT
-./run-huge-test.sh $HT
-umount $HT
popd > /dev/null
+
+exit $failed_testcase
diff --git a/cases/function/hwpoison/run_soft.sh b/cases/function/hwpoison/run_soft.sh
index ff19a20..309d8c7 100755
--- a/cases/function/hwpoison/run_soft.sh
+++ b/cases/function/hwpoison/run_soft.sh
@@ -1,5 +1,9 @@
#!/bin/bash
+pushd `dirname $0` > /dev/null
+
+. ./helpers.sh
+
cat <<-EOF
***************************************************************************
@@ -11,11 +15,24 @@ This test is soft mode of HWPoison functional test.
EOF
-pushd `dirname $0` > /dev/null
+echo "------------------------------------------------------------------------"
+echo "Running tsoft (simple soft offline test)"
+run_test ./tsoft success
-./tsoft
-./tsoftinj
-echo "Running soft offline for 60 seconds"
-./random_offline -t 60
+echo "------------------------------------------------------------------------"
+echo "Running tsoftinj (soft offline test on various types of pages)"
+mount_hugetlbfs
+run_test ./tsoftinj success
+unmount_hugetlbfs
+
+echo "------------------------------------------------------------------------"
+echo "Running random_offline (random soft offline test for 60 seconds)"
+run_test "./random_offline -t 60" sucess
+
+free_resources
+
+show_summary
popd > /dev/null
+
+exit $failed_testcase
diff --git a/cases/function/hwpoison/run_thp.sh b/cases/function/hwpoison/run_thp.sh
index bbc7942..1a967a3 100755
--- a/cases/function/hwpoison/run_thp.sh
+++ b/cases/function/hwpoison/run_thp.sh
@@ -1,5 +1,82 @@
#!/bin/bash
+#
+# run_thp.sh:
+# Script for hwpoison test of THP(Transparent Huge Page).
+#
+#
+pushd `dirname $0` > /dev/null
+
+. ./helpers.sh
+
+THP_POISON_PRO="ttranshuge"
+
+THP_SYS_PATH="/sys/kernel/mm/transparent_hugepage"
+THP_SYS_ENABLED_FILE="$THP_SYS_PATH/enabled"
+
+error()
+{
+ echo "$1" && exit 1
+}
+
+env_check()
+{
+ which $THP_POISON_PRO > /dev/null 2>&1
+ [ $? -ne 0 ] && error "Please make sure there is file $THP_POISON_PRO."
+
+ if [ ! -d $THP_SYS_PATH ] ; then
+ error "THP(Transparent Huge Page) may be not supported by kernel."
+ fi
+
+ thp_enabled="$(cat $THP_SYS_ENABLED_FILE | awk '{print $3}')"
+ if [ "$thp_enabled" == "[never]" ] ; then
+ error "THP(Transparent Huge Page) is disabled now."
+ fi
+}
+
+result_check()
+{
+ if [ "$1" != "0" ] ; then
+ failed_testcase=`expr $failed_testcase + 1`
+ fi
+}
+
+exec_testcase()
+{
+ if [ "$1" = "head" ] ; then
+ page_position_in_thp=0
+ elif [ "$1" = "tail" ] ; then
+ page_position_in_thp=1
+ else
+ error "Which page do you want to poison?"
+ fi
+
+ if [ "$2" = "early" ] ; then
+ process_type="--early-kill"
+ elif [ "$2" = "late_touch" ] ; then
+ process_type=""
+ elif [ "$2" = "late_avoid" ] ; then
+ process_type="--avoid-touch"
+ else
+ error "No such process type."
+ fi
+
+ executed_testcase=`expr $executed_testcase + 1`
+
+ echo "------------------ Case $executed_testcase --------------------"
+
+ command="$THP_POISON_PRO $process_type --offset $page_position_in_thp"
+ echo $command
+ eval $command
+ result_check $?
+
+ echo -e "\n"
+}
+
+# Environment Check for Test.
+env_check
+
+# Execute Test Cases from Here.
cat <<-EOF
***************************************************************************
@@ -11,17 +88,26 @@ This is the functional test for transparent huge page support of HWPoison.
EOF
-echo 0 > $TMP_DIR/error.$$
+echo "============= HWPoison Test of Transparent Huge Page ================="
+
+exec_testcase "head" "early"
+
+exec_testcase "head" "late_touch"
+
+exec_testcase "head" "late_avoid"
+
+exec_testcase "tail" "early"
+
+exec_testcase "tail" "late_touch"
+
+exec_testcase "tail" "late_avoid"
+
+echo "======================================================================="
+
+free_resources
+
+show_summary
-pushd `dirname $0` > /dev/null
-./run-transhuge-test.sh
-[ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$
popd > /dev/null
-grep -q "1" $TMP_DIR/error.$$
-if [ $? -eq 0 ]
-then
- exit 1
-else
- exit 0
-fi
+exit $failed_testcase