summaryrefslogtreecommitdiff
path: root/common/scripts/kselftest-runner.sh
blob: 6220051978e83eaf6c506e00f55c665206b52092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

TEST_NAME=$1
COMMAND=$(basename "$2")
DIR=$(dirname "$2")
LOG="result.log";

cd ${DIR}
ls ${COMMAND} > /dev/null 2>&1 && chmod a+x ${COMMAND}
export PATH=.:${PATH}
(${COMMAND} 2>&1 || echo "${TEST_NAME}: [FAIL]") | tee ${LOG}
if [ -n "`grep \"skip\" ${LOG}`" ]; then
    echo "${TEST_NAME}: [SKIP]";
elif [ -z "`grep \"SKIP\|FAIL\" ${LOG}`" ]; then
    echo "${TEST_NAME}: [PASS]"
fi

while read l;
do
    [ -n "`echo $l|grep 'running'`" ] && test="`echo $l|sed 's/running //'`"
    [ -n "`echo $l|grep \"\[PASS\|FAIL\|SKIP\"`" ] && result=$l
    [ "${test}" -a "${result}" ] && echo "${test}: ${result}" && unset test && unset result
done < ${LOG}