blob: 063186492b66b3a82e51f3cbb42382a46641d8e0 [file] [log] [blame]
Naresh Kambojuad19d882016-09-20 19:31:00 +05301#!/bin/bash
2
Chase Qi890c1202017-06-19 16:09:27 +08003# shellcheck disable=SC1091
Naresh Kambojuad19d882016-09-20 19:31:00 +05304. ../../lib/sh-test-lib
5OUTPUT="$(pwd)/output"
6RESULT_FILE="${OUTPUT}/result.txt"
7# Absolute path to this script. /home/user/bin/foo.sh
Naresh Kamboju43e80742017-01-18 15:51:02 +05308SCRIPT="$(readlink -f "${0}")"
Naresh Kambojuad19d882016-09-20 19:31:00 +05309# Absolute path this script is in. /home/user/bin
Naresh Kamboju43e80742017-01-18 15:51:02 +053010SCRIPTPATH="$(dirname "${SCRIPT}")"
11echo "Script path is: ${SCRIPTPATH}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053012# List of test cases
13TST_CMDFILES=""
14# List of test cases to be skipped
15SKIPFILE=""
16# LTP version
Naresh Kamboju336e3212017-05-17 18:15:02 +053017LTP_VERSION="20170516"
Naresh Kambojuad19d882016-09-20 19:31:00 +053018
19LTP_PATH=/opt/ltp
20
21usage() {
Milosz Wasilewski748a54d2017-05-26 08:59:37 +010022 echo "Usage: ${0} [-T mm,math,syscalls] [-S skipfile-lsk-juno] [-s <flase>] [-v LTP_VERSION] [-M Timeout_Multiplier]" 1>&2
Naresh Kambojuad19d882016-09-20 19:31:00 +053023 exit 0
24}
25
Naresh Kamboju3bff06b2017-05-24 14:46:37 +053026while getopts "M:T:S:s:v:" arg; do
Naresh Kambojuad19d882016-09-20 19:31:00 +053027 case "$arg" in
28 T)
29 TST_CMDFILES="${OPTARG}"
Naresh Kamboju43e80742017-01-18 15:51:02 +053030 # shellcheck disable=SC2001
Naresh Kambojuad19d882016-09-20 19:31:00 +053031 LOG_FILE=$(echo "${OPTARG}"| sed 's,\/,_,')
32 ;;
33 S)
34 OPT=$(echo "${OPTARG}" | grep "http")
35 if [ -z "${OPT}" ] ; then
36 # LTP skipfile
Naresh Kamboju43e80742017-01-18 15:51:02 +053037 SKIPFILE="-S ${SCRIPTPATH}/${OPTARG}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053038 else
39 # Download LTP skipfile from speficied URL
Naresh Kamboju43e80742017-01-18 15:51:02 +053040 wget "${OPTARG}" -O "skipfile"
41 SKIPFILE="skipfile"
42 SKIPFILE="-S ${SCRIPTPATH}/${SKIPFILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053043 fi
44 ;;
45 # SKIP_INSTALL is true in case of Open Embedded builds
46 # SKIP_INSTALL is flase in case of Debian builds
47 s) SKIP_INSTALL="${OPTARG}";;
48 v) LTP_VERSION="${OPTARG}";;
Naresh Kamboju3bff06b2017-05-24 14:46:37 +053049 # Slow machines need more timeout Default is 5min and multiply * MINUTES
50 M) export LTP_TIMEOUT_MUL="${OPTARG}";;
Naresh Kambojuad19d882016-09-20 19:31:00 +053051 esac
52done
53
54# Install LTP test suite
55install_ltp() {
56 rm -rf /opt/ltp
57 mkdir -p /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053058 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053059 cd /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053060 # shellcheck disable=SC2140
Naresh Kambojuad19d882016-09-20 19:31:00 +053061 wget https://github.com/linux-test-project/ltp/releases/download/"${LTP_VERSION}"/ltp-full-"${LTP_VERSION}".tar.xz
62 tar --strip-components=1 -Jxf ltp-full-"${LTP_VERSION}".tar.xz
63 ./configure
64 make -j8 all
65 make SKIP_IDCHECK=1 install
66}
67
Naresh Kambojuad19d882016-09-20 19:31:00 +053068# Parse LTP output
69parse_ltp_output() {
Chase Qi890c1202017-06-19 16:09:27 +080070 grep -E "PASS|FAIL|CONF" "$1" | awk '{print $1" "$2}' | sed s/CONF/SKIP/ >> "${RESULT_FILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053071}
72
73# Run LTP test suite
74run_ltp() {
Naresh Kamboju43e80742017-01-18 15:51:02 +053075 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053076 cd "${LTP_PATH}"
77
Naresh Kamboju43e80742017-01-18 15:51:02 +053078 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"
79 check_return "runltp_${LOG_FILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053080
Naresh Kambojuad19d882016-09-20 19:31:00 +053081 parse_ltp_output "${OUTPUT}/LTP_${LOG_FILE}.log"
82}
83
84# Test run.
85! check_root && error_msg "This script must be run as root"
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060086create_out_dir "${OUTPUT}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053087
88info_msg "About to run ltp test..."
89info_msg "Output directory: ${OUTPUT}"
90
91if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
92 info_msg "install_ltp skipped"
93else
94 dist_name
Naresh Kamboju43e80742017-01-18 15:51:02 +053095 # shellcheck disable=SC2154
Naresh Kambojuad19d882016-09-20 19:31:00 +053096 case "${dist}" in
Nicolas Dechesneb7e38762017-01-25 12:07:08 +010097 debian|ubuntu)
Chase Qifee992c2017-06-19 17:02:50 +080098 pkgs="xz-utils flex bison build-essential wget curl net-tools quota genisoimage"
Naresh Kamboju43e80742017-01-18 15:51:02 +053099 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530100 ;;
Nicolas Dechesneb7e38762017-01-25 12:07:08 +0100101 centos|fedora)
Chase Qifee992c2017-06-19 17:02:50 +0800102 pkgs="xz flex bison make automake gcc gcc-c++ kernel-devel wget curl net-tools quota genisoimage"
Naresh Kamboju43e80742017-01-18 15:51:02 +0530103 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530104 ;;
105 *)
Naresh Kamboju43e80742017-01-18 15:51:02 +0530106 warn_msg "Unsupported distribution: package install skipped"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530107 esac
Chase Qifee992c2017-06-19 17:02:50 +0800108
109 # Check if mkisofs or genisoimage installed for isofs test.
110 if echo "${TST_CMDFILES}" | grep 'fs'; then
111 # link mkisofs to genisoimage on distributions that have replaced mkisofs with genisoimage.
112 if ! which mkisofs; then
113 if which genisoimage; then
114 ln -s "$(which genisoimage)" /usr/bin/mkisofs
115 else
116 warn_msg "Neither mkisofs nor genisoimage found! Either of them is required by isofs test."
117 fi
118 fi
119 fi
120
Naresh Kambojuad19d882016-09-20 19:31:00 +0530121 info_msg "Run install_ltp"
122 install_ltp
123fi
124info_msg "Running run_ltp"
125run_ltp