blob: 2b5201aee8f44f52435cb48804b1aa4c9b017d86 [file] [log] [blame]
Naresh Kambojuad19d882016-09-20 19:31:00 +05301#!/bin/bash
2
3. ../../lib/sh-test-lib
4OUTPUT="$(pwd)/output"
5RESULT_FILE="${OUTPUT}/result.txt"
6# Absolute path to this script. /home/user/bin/foo.sh
Naresh Kamboju43e80742017-01-18 15:51:02 +05307SCRIPT="$(readlink -f "${0}")"
Naresh Kambojuad19d882016-09-20 19:31:00 +05308# Absolute path this script is in. /home/user/bin
Naresh Kamboju43e80742017-01-18 15:51:02 +05309SCRIPTPATH="$(dirname "${SCRIPT}")"
10echo "Script path is: ${SCRIPTPATH}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053011# List of test cases
12TST_CMDFILES=""
13# List of test cases to be skipped
14SKIPFILE=""
15# LTP version
Naresh Kamboju336e3212017-05-17 18:15:02 +053016LTP_VERSION="20170516"
Naresh Kambojuad19d882016-09-20 19:31:00 +053017
18LTP_PATH=/opt/ltp
19
20usage() {
Naresh Kamboju3bff06b2017-05-24 14:46:37 +053021 echo "Usage: ${0} [-T mm,math,syscalls] [-S skipfile-lsk-juno] [-s <flase>] [-v LTP_VERSION] [-M Minutes_To_Timeout]" 1>&2
Naresh Kambojuad19d882016-09-20 19:31:00 +053022 exit 0
23}
24
Naresh Kamboju3bff06b2017-05-24 14:46:37 +053025while getopts "M:T:S:s:v:" arg; do
Naresh Kambojuad19d882016-09-20 19:31:00 +053026 case "$arg" in
27 T)
28 TST_CMDFILES="${OPTARG}"
Naresh Kamboju43e80742017-01-18 15:51:02 +053029 # shellcheck disable=SC2001
Naresh Kambojuad19d882016-09-20 19:31:00 +053030 LOG_FILE=$(echo "${OPTARG}"| sed 's,\/,_,')
31 ;;
32 S)
33 OPT=$(echo "${OPTARG}" | grep "http")
34 if [ -z "${OPT}" ] ; then
35 # LTP skipfile
Naresh Kamboju43e80742017-01-18 15:51:02 +053036 SKIPFILE="-S ${SCRIPTPATH}/${OPTARG}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053037 else
38 # Download LTP skipfile from speficied URL
Naresh Kamboju43e80742017-01-18 15:51:02 +053039 wget "${OPTARG}" -O "skipfile"
40 SKIPFILE="skipfile"
41 SKIPFILE="-S ${SCRIPTPATH}/${SKIPFILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053042 fi
43 ;;
44 # SKIP_INSTALL is true in case of Open Embedded builds
45 # SKIP_INSTALL is flase in case of Debian builds
46 s) SKIP_INSTALL="${OPTARG}";;
47 v) LTP_VERSION="${OPTARG}";;
Naresh Kamboju3bff06b2017-05-24 14:46:37 +053048 # Slow machines need more timeout Default is 5min and multiply * MINUTES
49 M) export LTP_TIMEOUT_MUL="${OPTARG}";;
Naresh Kambojuad19d882016-09-20 19:31:00 +053050 esac
51done
52
53# Install LTP test suite
54install_ltp() {
55 rm -rf /opt/ltp
56 mkdir -p /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053057 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053058 cd /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053059 # shellcheck disable=SC2140
Naresh Kambojuad19d882016-09-20 19:31:00 +053060 wget https://github.com/linux-test-project/ltp/releases/download/"${LTP_VERSION}"/ltp-full-"${LTP_VERSION}".tar.xz
61 tar --strip-components=1 -Jxf ltp-full-"${LTP_VERSION}".tar.xz
62 ./configure
63 make -j8 all
64 make SKIP_IDCHECK=1 install
65}
66
Naresh Kambojuad19d882016-09-20 19:31:00 +053067# Parse LTP output
68parse_ltp_output() {
69 egrep "PASS|FAIL|CONF" "$1" | awk '{print $1" "$2}' | sed s/CONF/SKIP/ >> "${RESULT_FILE}"
70}
71
72# Run LTP test suite
73run_ltp() {
Naresh Kamboju43e80742017-01-18 15:51:02 +053074 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053075 cd "${LTP_PATH}"
76
Naresh Kamboju43e80742017-01-18 15:51:02 +053077 pipe0_status "./runltp -p -q -f ${TST_CMDFILES} -l ${OUTPUT}/LTP_${LOG_FILE}.log -C ${OUTPUT}/LTP_${LOG_FILE}.failed ${SKIPFILE}" "tee ${OUTPUT}/LTP_${LOG_FILE}.out"
78 check_return "runltp_${LOG_FILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053079
Naresh Kambojuad19d882016-09-20 19:31:00 +053080 parse_ltp_output "${OUTPUT}/LTP_${LOG_FILE}.log"
81}
82
83# Test run.
84! check_root && error_msg "This script must be run as root"
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060085create_out_dir "${OUTPUT}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053086
87info_msg "About to run ltp test..."
88info_msg "Output directory: ${OUTPUT}"
89
90if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
91 info_msg "install_ltp skipped"
92else
93 dist_name
Naresh Kamboju43e80742017-01-18 15:51:02 +053094 # shellcheck disable=SC2154
Naresh Kambojuad19d882016-09-20 19:31:00 +053095 case "${dist}" in
Nicolas Dechesneb7e38762017-01-25 12:07:08 +010096 debian|ubuntu)
Naresh Kambojue467b092016-12-07 00:16:01 +053097 pkgs="xz-utils flex bison build-essential wget curl net-tools"
Naresh Kamboju43e80742017-01-18 15:51:02 +053098 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053099 ;;
Nicolas Dechesneb7e38762017-01-25 12:07:08 +0100100 centos|fedora)
Naresh Kambojue467b092016-12-07 00:16:01 +0530101 pkgs="xz flex bison make automake gcc gcc-c++ kernel-devel wget curl net-tools"
Naresh Kamboju43e80742017-01-18 15:51:02 +0530102 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530103 ;;
104 *)
Naresh Kamboju43e80742017-01-18 15:51:02 +0530105 warn_msg "Unsupported distribution: package install skipped"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530106 esac
Naresh Kambojuad19d882016-09-20 19:31:00 +0530107 info_msg "Run install_ltp"
108 install_ltp
109fi
110info_msg "Running run_ltp"
111run_ltp