summaryrefslogtreecommitdiff
path: root/common/scripts/kselftest-runner.sh
blob: 3cfd0dbdbdf5ddb3d78e30a2ba23a63bf67b318e (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
25
26
27
28
#!/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]"
elif [ -n "`grep \"FAIL\" ${LOG}`" ]; then
    echo "${TEST_NAME}: [FAIL]"
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}

# clean exit so that lava-test-shell can trust the results
exit 0