blob: 44ed94df65fbf90d2d07a1faee9ab78f6dda414c [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
Fathi Boudra2cc6d052017-01-19 09:42:12 +020016LTP_VERSION="20170116"
Naresh Kambojuad19d882016-09-20 19:31:00 +053017
18LTP_PATH=/opt/ltp
19
20usage() {
Naresh Kamboju43e80742017-01-18 15:51:02 +053021 echo "Usage: ${0} [-T mm,math,syscalls] [-S skipfile-lsk-juno] [-s <flase>] [-v LTP_VERSION]" 1>&2
Naresh Kambojuad19d882016-09-20 19:31:00 +053022 exit 0
23}
24
25while getopts "T:S:s:v:" arg; do
26 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}";;
48 esac
49done
50
51# Install LTP test suite
52install_ltp() {
53 rm -rf /opt/ltp
54 mkdir -p /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053055 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053056 cd /opt/ltp
Naresh Kamboju43e80742017-01-18 15:51:02 +053057 # shellcheck disable=SC2140
Naresh Kambojuad19d882016-09-20 19:31:00 +053058 wget https://github.com/linux-test-project/ltp/releases/download/"${LTP_VERSION}"/ltp-full-"${LTP_VERSION}".tar.xz
59 tar --strip-components=1 -Jxf ltp-full-"${LTP_VERSION}".tar.xz
60 ./configure
61 make -j8 all
62 make SKIP_IDCHECK=1 install
63}
64
Naresh Kambojuad19d882016-09-20 19:31:00 +053065# Parse LTP output
66parse_ltp_output() {
67 egrep "PASS|FAIL|CONF" "$1" | awk '{print $1" "$2}' | sed s/CONF/SKIP/ >> "${RESULT_FILE}"
68}
69
70# Run LTP test suite
71run_ltp() {
Naresh Kamboju43e80742017-01-18 15:51:02 +053072 # shellcheck disable=SC2164
Naresh Kambojuad19d882016-09-20 19:31:00 +053073 cd "${LTP_PATH}"
74
Naresh Kamboju43e80742017-01-18 15:51:02 +053075 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"
76 check_return "runltp_${LOG_FILE}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053077
Naresh Kambojuad19d882016-09-20 19:31:00 +053078 parse_ltp_output "${OUTPUT}/LTP_${LOG_FILE}.log"
79}
80
81# Test run.
82! check_root && error_msg "This script must be run as root"
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060083create_out_dir "${OUTPUT}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053084
85info_msg "About to run ltp test..."
86info_msg "Output directory: ${OUTPUT}"
87
88if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
89 info_msg "install_ltp skipped"
90else
91 dist_name
Naresh Kamboju43e80742017-01-18 15:51:02 +053092 # shellcheck disable=SC2154
Naresh Kambojuad19d882016-09-20 19:31:00 +053093 case "${dist}" in
Nicolas Dechesneb7e38762017-01-25 12:07:08 +010094 debian|ubuntu)
Naresh Kambojue467b092016-12-07 00:16:01 +053095 pkgs="xz-utils flex bison build-essential wget curl net-tools"
Naresh Kamboju43e80742017-01-18 15:51:02 +053096 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +053097 ;;
Nicolas Dechesneb7e38762017-01-25 12:07:08 +010098 centos|fedora)
Naresh Kambojue467b092016-12-07 00:16:01 +053099 pkgs="xz flex bison make automake gcc gcc-c++ kernel-devel wget curl net-tools"
Naresh Kamboju43e80742017-01-18 15:51:02 +0530100 install_deps "${pkgs}" "${SKIP_INSTALL}"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530101 ;;
102 *)
Naresh Kamboju43e80742017-01-18 15:51:02 +0530103 warn_msg "Unsupported distribution: package install skipped"
Naresh Kambojuad19d882016-09-20 19:31:00 +0530104 esac
Naresh Kambojuad19d882016-09-20 19:31:00 +0530105 info_msg "Run install_ltp"
106 install_ltp
107fi
108info_msg "Running run_ltp"
109run_ltp