0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 TEST_NAME="test_hmm"
0013 DRIVER="test_hmm"
0014
0015
0016 exitcode=1
0017
0018
0019 ksft_skip=4
0020
0021 check_test_requirements()
0022 {
0023 uid=$(id -u)
0024 if [ $uid -ne 0 ]; then
0025 echo "$0: Must be run as root"
0026 exit $ksft_skip
0027 fi
0028
0029 if ! which modprobe > /dev/null 2>&1; then
0030 echo "$0: You need modprobe installed"
0031 exit $ksft_skip
0032 fi
0033
0034 if ! modinfo $DRIVER > /dev/null 2>&1; then
0035 echo "$0: You must have the following enabled in your kernel:"
0036 echo "CONFIG_TEST_HMM=m"
0037 exit $ksft_skip
0038 fi
0039 }
0040
0041 load_driver()
0042 {
0043 if [ $
0044 modprobe $DRIVER > /dev/null 2>&1
0045 else
0046 if [ $
0047 modprobe $DRIVER spm_addr_dev0=$1 spm_addr_dev1=$2
0048 > /dev/null 2>&1
0049 else
0050 echo "Missing module parameters. Make sure pass"\
0051 "spm_addr_dev0 and spm_addr_dev1"
0052 usage
0053 fi
0054 fi
0055 if [ $? == 0 ]; then
0056 major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices)
0057 mknod /dev/hmm_dmirror0 c $major 0
0058 mknod /dev/hmm_dmirror1 c $major 1
0059 if [ $
0060 mknod /dev/hmm_dmirror2 c $major 2
0061 mknod /dev/hmm_dmirror3 c $major 3
0062 fi
0063 fi
0064 }
0065
0066 unload_driver()
0067 {
0068 modprobe -r $DRIVER > /dev/null 2>&1
0069 rm -f /dev/hmm_dmirror?
0070 }
0071
0072 run_smoke()
0073 {
0074 echo "Running smoke test. Note, this test provides basic coverage."
0075
0076 load_driver $1 $2
0077 $(dirname "${BASH_SOURCE[0]}")/hmm-tests
0078 unload_driver
0079 }
0080
0081 usage()
0082 {
0083 echo -n "Usage: $0"
0084 echo
0085 echo "Example usage:"
0086 echo
0087 echo "# Shows help message"
0088 echo "./${TEST_NAME}.sh"
0089 echo
0090 echo "# Smoke testing"
0091 echo "./${TEST_NAME}.sh smoke"
0092 echo
0093 echo "# Smoke testing with SPM enabled"
0094 echo "./${TEST_NAME}.sh smoke <spm_addr_dev0> <spm_addr_dev1>"
0095 echo
0096 exit 0
0097 }
0098
0099 function run_test()
0100 {
0101 if [ $
0102 usage
0103 else
0104 if [ "$1" = "smoke" ]; then
0105 run_smoke $2 $3
0106 else
0107 usage
0108 fi
0109 fi
0110 }
0111
0112 check_test_requirements
0113 run_test $@
0114
0115 exit 0