Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Dan Rue | 9e11dcd | 2017-10-04 11:29:04 -0500 | [diff] [blame] | 3 | set -x |
| 4 | |
Chase Qi | 890c120 | 2017-06-19 16:09:27 +0800 | [diff] [blame] | 5 | # shellcheck disable=SC1091 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 6 | . ../../lib/sh-test-lib |
| 7 | OUTPUT="$(pwd)/output" |
| 8 | RESULT_FILE="${OUTPUT}/result.txt" |
| 9 | # Absolute path to this script. /home/user/bin/foo.sh |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 10 | SCRIPT="$(readlink -f "${0}")" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 11 | # Absolute path this script is in. /home/user/bin |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 12 | SCRIPTPATH="$(dirname "${SCRIPT}")" |
| 13 | echo "Script path is: ${SCRIPTPATH}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 14 | # List of test cases |
| 15 | TST_CMDFILES="" |
| 16 | # List of test cases to be skipped |
| 17 | SKIPFILE="" |
| 18 | # LTP version |
Naresh Kamboju | 1756290 | 2017-10-19 16:58:59 +0530 | [diff] [blame] | 19 | LTP_VERSION="20170929" |
Naresh Kamboju | 9bce916 | 2017-07-13 12:56:27 +0530 | [diff] [blame] | 20 | LTP_TMPDIR=/ltp-tmp |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 21 | |
| 22 | LTP_PATH=/opt/ltp |
| 23 | |
| 24 | usage() { |
Naresh Kamboju | 3a42795 | 2017-07-06 16:56:59 +0530 | [diff] [blame] | 25 | echo "Usage: ${0} [-T mm,math,syscalls] |
| 26 | [-S skipfile-lsk-juno] |
| 27 | [-s True|False] |
| 28 | [-v LTP_VERSION] |
Dan Rue | 58d3a88 | 2017-07-11 16:30:30 -0500 | [diff] [blame] | 29 | [-M Timeout_Multiplier] |
| 30 | [-R root_password]" 1>&2 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 31 | exit 0 |
| 32 | } |
| 33 | |
Dan Rue | 58d3a88 | 2017-07-11 16:30:30 -0500 | [diff] [blame] | 34 | while getopts "M:T:S:s:v:R:" arg; do |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 35 | case "$arg" in |
| 36 | T) |
| 37 | TST_CMDFILES="${OPTARG}" |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 38 | # shellcheck disable=SC2001 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 39 | LOG_FILE=$(echo "${OPTARG}"| sed 's,\/,_,') |
| 40 | ;; |
| 41 | S) |
| 42 | OPT=$(echo "${OPTARG}" | grep "http") |
| 43 | if [ -z "${OPT}" ] ; then |
| 44 | # LTP skipfile |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 45 | SKIPFILE="-S ${SCRIPTPATH}/${OPTARG}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 46 | else |
| 47 | # Download LTP skipfile from speficied URL |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 48 | wget "${OPTARG}" -O "skipfile" |
| 49 | SKIPFILE="skipfile" |
| 50 | SKIPFILE="-S ${SCRIPTPATH}/${SKIPFILE}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 51 | fi |
| 52 | ;; |
| 53 | # SKIP_INSTALL is true in case of Open Embedded builds |
| 54 | # SKIP_INSTALL is flase in case of Debian builds |
| 55 | s) SKIP_INSTALL="${OPTARG}";; |
| 56 | v) LTP_VERSION="${OPTARG}";; |
Naresh Kamboju | 3bff06b | 2017-05-24 14:46:37 +0530 | [diff] [blame] | 57 | # Slow machines need more timeout Default is 5min and multiply * MINUTES |
| 58 | M) export LTP_TIMEOUT_MUL="${OPTARG}";; |
Dan Rue | 58d3a88 | 2017-07-11 16:30:30 -0500 | [diff] [blame] | 59 | R) export PASSWD="${OPTARG}";; |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 60 | esac |
| 61 | done |
| 62 | |
| 63 | # Install LTP test suite |
| 64 | install_ltp() { |
| 65 | rm -rf /opt/ltp |
| 66 | mkdir -p /opt/ltp |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 67 | # shellcheck disable=SC2164 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 68 | cd /opt/ltp |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 69 | # shellcheck disable=SC2140 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 70 | wget https://github.com/linux-test-project/ltp/releases/download/"${LTP_VERSION}"/ltp-full-"${LTP_VERSION}".tar.xz |
| 71 | tar --strip-components=1 -Jxf ltp-full-"${LTP_VERSION}".tar.xz |
| 72 | ./configure |
| 73 | make -j8 all |
| 74 | make SKIP_IDCHECK=1 install |
| 75 | } |
| 76 | |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 77 | # Parse LTP output |
| 78 | parse_ltp_output() { |
Chase Qi | 3308d6b | 2017-08-07 15:19:35 +0800 | [diff] [blame] | 79 | grep -E "PASS|FAIL|CONF" "$1" \ |
| 80 | | awk '{print $1" "$2}' \ |
| 81 | | sed 's/PASS/pass/; s/FAIL/fail/; s/CONF/skip/' >> "${RESULT_FILE}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | # Run LTP test suite |
| 85 | run_ltp() { |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 86 | # shellcheck disable=SC2164 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 87 | cd "${LTP_PATH}" |
Naresh Kamboju | ff5f6c3 | 2017-07-11 14:50:32 +0530 | [diff] [blame] | 88 | # shellcheck disable=SC2174 |
| 89 | mkdir -m 777 -p "${LTP_TMPDIR}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 90 | |
Naresh Kamboju | 3a42795 | 2017-07-06 16:56:59 +0530 | [diff] [blame] | 91 | pipe0_status "./runltp -p -q -f ${TST_CMDFILES} \ |
| 92 | -l ${OUTPUT}/LTP_${LOG_FILE}.log \ |
| 93 | -C ${OUTPUT}/LTP_${LOG_FILE}.failed \ |
| 94 | -d ${LTP_TMPDIR} \ |
| 95 | ${SKIPFILE}" "tee ${OUTPUT}/LTP_${LOG_FILE}.out" |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 96 | check_return "runltp_${LOG_FILE}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 97 | |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 98 | parse_ltp_output "${OUTPUT}/LTP_${LOG_FILE}.log" |
Naresh Kamboju | 3a42795 | 2017-07-06 16:56:59 +0530 | [diff] [blame] | 99 | # Cleanup |
Milosz Wasilewski | cacf738 | 2017-11-01 11:25:55 +0000 | [diff] [blame] | 100 | # don't fail the whole test job if rm fails |
| 101 | rm -rf "${LTP_TMPDIR}" || true |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | # Test run. |
| 105 | ! check_root && error_msg "This script must be run as root" |
Daniel Díaz | 6f49a1b | 2017-02-15 18:56:15 -0600 | [diff] [blame] | 106 | create_out_dir "${OUTPUT}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 107 | |
| 108 | info_msg "About to run ltp test..." |
| 109 | info_msg "Output directory: ${OUTPUT}" |
| 110 | |
| 111 | if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then |
| 112 | info_msg "install_ltp skipped" |
| 113 | else |
| 114 | dist_name |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 115 | # shellcheck disable=SC2154 |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 116 | case "${dist}" in |
Nicolas Dechesne | b7e3876 | 2017-01-25 12:07:08 +0100 | [diff] [blame] | 117 | debian|ubuntu) |
Dan Rue | 519f5b8 | 2017-11-06 16:03:53 -0600 | [diff] [blame^] | 118 | pkgs="xz-utils flex bison build-essential wget curl net-tools quota genisoimage sudo libaio-dev expect automake acl" |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 119 | install_deps "${pkgs}" "${SKIP_INSTALL}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 120 | ;; |
Nicolas Dechesne | b7e3876 | 2017-01-25 12:07:08 +0100 | [diff] [blame] | 121 | centos|fedora) |
Dan Rue | 519f5b8 | 2017-11-06 16:03:53 -0600 | [diff] [blame^] | 122 | pkgs="xz flex bison make automake gcc gcc-c++ kernel-devel wget curl net-tools quota genisoimage sudo libaio expect acl" |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 123 | install_deps "${pkgs}" "${SKIP_INSTALL}" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 124 | ;; |
| 125 | *) |
Naresh Kamboju | 43e8074 | 2017-01-18 15:51:02 +0530 | [diff] [blame] | 126 | warn_msg "Unsupported distribution: package install skipped" |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 127 | esac |
Chase Qi | fee992c | 2017-06-19 17:02:50 +0800 | [diff] [blame] | 128 | |
| 129 | # Check if mkisofs or genisoimage installed for isofs test. |
| 130 | if echo "${TST_CMDFILES}" | grep 'fs'; then |
| 131 | # link mkisofs to genisoimage on distributions that have replaced mkisofs with genisoimage. |
| 132 | if ! which mkisofs; then |
| 133 | if which genisoimage; then |
| 134 | ln -s "$(which genisoimage)" /usr/bin/mkisofs |
| 135 | else |
| 136 | warn_msg "Neither mkisofs nor genisoimage found! Either of them is required by isofs test." |
| 137 | fi |
| 138 | fi |
| 139 | fi |
| 140 | |
Naresh Kamboju | ad19d88 | 2016-09-20 19:31:00 +0530 | [diff] [blame] | 141 | info_msg "Run install_ltp" |
| 142 | install_ltp |
| 143 | fi |
| 144 | info_msg "Running run_ltp" |
| 145 | run_ltp |