blob: 4e8ca2725cb73ba4d210f454595c63495855b7ea [file] [log] [blame]
Naresh Kambojuad19d882016-09-20 19:31:00 +05301#!/bin/bash
2
Dan Rue9e11dcd2017-10-04 11:29:04 -05003set -x
4
Chase Qi890c1202017-06-19 16:09:27 +08005# shellcheck disable=SC1091
Naresh Kambojuad19d882016-09-20 19:31:00 +05306. ../../lib/sh-test-lib
7OUTPUT="$(pwd)/output"
8RESULT_FILE="${OUTPUT}/result.txt"
9# Absolute path to this script. /home/user/bin/foo.sh
Naresh Kamboju43e80742017-01-18 15:51:02 +053010SCRIPT="$(readlink -f "${0}")"
Naresh Kambojuad19d882016-09-20 19:31:00 +053011# Absolute path this script is in. /home/user/bin
Naresh Kamboju43e80742017-01-18 15:51:02 +053012SCRIPTPATH="$(dirname "${SCRIPT}")"
13echo "Script path is: ${SCRIPTPATH}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053014# List of test cases
15TST_CMDFILES=""
16# List of test cases to be skipped
17SKIPFILE=""
18# LTP version
Naresh Kamboju17562902017-10-19 16:58:59 +053019LTP_VERSION="20170929"
Naresh Kamboju9bce9162017-07-13 12:56:27 +053020LTP_TMPDIR=/ltp-tmp
Naresh Kambojuad19d882016-09-20 19:31:00 +053021
22LTP_PATH=/opt/ltp
23
24usage() {
Naresh Kamboju3a427952017-07-06 16:56:59 +053025 echo "Usage: ${0} [-T mm,math,syscalls]
26 [-S skipfile-lsk-juno]
27 [-s True|False]
28 [-v LTP_VERSION]
Dan Rue58d3a882017-07-11 16:30:30 -050029 [-M Timeout_Multiplier]
30 [-R root_password]" 1>&2
Naresh Kambojuad19d882016-09-20 19:31:00 +053031 exit 0
32}
33
Dan Rue58d3a882017-07-11 16:30:30 -050034while getopts "M:T:S:s:v:R:" arg; do
Naresh Kambojuad19d882016-09-20 19:31:00 +053035 case "$arg" in
36 T)
37 TST_CMDFILES="${OPTARG}"
Naresh Kamboju43e80742017-01-18 15:51:02 +053038 # shellcheck disable=SC2001
Naresh Kambojuad19d882016-09-20 19:31:00 +053039 LOG_FILE=$(echo "${OPTARG}"| sed 's,\/,_,')
40 ;;
41 S)
42 OPT=$(echo "${OPTARG}" | grep "http")
43 if [ -z "${OPT}" ] ; then
44 # LTP skipfile
Naresh Kamboju43e80742017-01-18 15:51:02 +053045 SKIPFILE="-S ${SCRIPTPATH}/${OPTARG}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053046 else
47 # Download LTP skipfile from speficied URL
Naresh Kamboju43e80742017-01-18 15:51:02 +053048 wget "${OPTARG}" -O "skipfile"
49 SKIPFILE="skipfile"
50 SKIPFILE="-S ${SCRIPTPATH}/${SKIPFILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053051 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 Kamboju3bff06b2017-05-24 14:46:37 +053057 # Slow machines need more timeout Default is 5min and multiply * MINUTES
58 M) export LTP_TIMEOUT_MUL="${OPTARG}";;
Dan Rue58d3a882017-07-11 16:30:30 -050059 R) export PASSWD="${OPTARG}";;
Naresh Kambojuad19d882016-09-20 19:31:00 +053060 esac
61done
62
63# Install LTP test suite
64install_ltp() {
65 rm -rf /opt/ltp
66 mkdir -p /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053067 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053068 cd /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053069 # shellcheck disable=SC2140
Naresh Kambojuad19d882016-09-20 19:31:00 +053070 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 Kambojuad19d882016-09-20 19:31:00 +053077# Parse LTP output
78parse_ltp_output() {
Chase Qi3308d6b2017-08-07 15:19:35 +080079 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 Kambojuad19d882016-09-20 19:31:00 +053082}
83
84# Run LTP test suite
85run_ltp() {
Naresh Kamboju43e80742017-01-18 15:51:02 +053086 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053087 cd "${LTP_PATH}"
Naresh Kambojuff5f6c32017-07-11 14:50:32 +053088 # shellcheck disable=SC2174
89 mkdir -m 777 -p "${LTP_TMPDIR}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053090
Naresh Kamboju3a427952017-07-06 16:56:59 +053091 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 Kamboju43e80742017-01-18 15:51:02 +053096 check_return "runltp_${LOG_FILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053097
Naresh Kambojuad19d882016-09-20 19:31:00 +053098 parse_ltp_output "${OUTPUT}/LTP_${LOG_FILE}.log"
Naresh Kamboju3a427952017-07-06 16:56:59 +053099 # Cleanup
Milosz Wasilewskicacf7382017-11-01 11:25:55 +0000100 # don't fail the whole test job if rm fails
101 rm -rf "${LTP_TMPDIR}" || true
Naresh Kambojuad19d882016-09-20 19:31:00 +0530102}
103
104# Test run.
105! check_root && error_msg "This script must be run as root"
Daniel Díaz6f49a1b2017-02-15 18:56:15 -0600106create_out_dir "${OUTPUT}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530107
108info_msg "About to run ltp test..."
109info_msg "Output directory: ${OUTPUT}"
110
111if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
112 info_msg "install_ltp skipped"
113else
114 dist_name
Naresh Kamboju43e80742017-01-18 15:51:02 +0530115 # shellcheck disable=SC2154
Naresh Kambojuad19d882016-09-20 19:31:00 +0530116 case "${dist}" in
Nicolas Dechesneb7e38762017-01-25 12:07:08 +0100117 debian|ubuntu)
Dan Rue519f5b82017-11-06 16:03:53 -0600118 pkgs="xz-utils flex bison build-essential wget curl net-tools quota genisoimage sudo libaio-dev expect automake acl"
Naresh Kamboju43e80742017-01-18 15:51:02 +0530119 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530120 ;;
Nicolas Dechesneb7e38762017-01-25 12:07:08 +0100121 centos|fedora)
Dan Rue519f5b82017-11-06 16:03:53 -0600122 pkgs="xz flex bison make automake gcc gcc-c++ kernel-devel wget curl net-tools quota genisoimage sudo libaio expect acl"
Naresh Kamboju43e80742017-01-18 15:51:02 +0530123 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530124 ;;
125 *)
Naresh Kamboju43e80742017-01-18 15:51:02 +0530126 warn_msg "Unsupported distribution: package install skipped"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530127 esac
Chase Qifee992c2017-06-19 17:02:50 +0800128
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 Kambojuad19d882016-09-20 19:31:00 +0530141 info_msg "Run install_ltp"
142 install_ltp
143fi
144info_msg "Running run_ltp"
145run_ltp