~aleteoryx/muditaos

ref: 395e99e16239630263d5892e2462f1333236ae99 muditaos/tools/run_unittests.sh -rwxr-xr-x 1.8 KiB
395e99e1 — Marek Niepieklo [CP-583] Update failure due to version.json on the phone 4 years ago
                                                                                
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

root_dir="$(realpath $(dirname $(realpath $0))/..)"
build_dir="${root_dir}/build-linux-Debug"

run_logs=${build_dir}/ut_run_logs

function help() {
    cat <<- EOF
		Usage: $0 tests_list
	EOF
}

trim() {
    local var="$*"
    # remove leading whitespace characters
    var="${var#"${var%%[![:space:]]*}"}"
    # remove trailing whitespace characters
    var="${var%"${var##*[![:space:]]}"}"   
    printf '%s' "$var"
}

if [[ $# -ne 1 ]]; then
    help
    exit 1
fi

source ${root_dir}/config/common_scripsts_lib

TESTS_FILE=$1

if [[ ! -r ${TESTS_FILE} ]]; then
    echo "Cannot read: \"${TESTS_FILE}\""
    exit 2
fi

TEMP_SOURCE=$(mktemp)

sed -e '/^[[:space:]]*#.*/d' ${TESTS_FILE} > $TEMP_SOURCE

source ${TEMP_SOURCE}

pushd ${build_dir}
for TEST_BINARY in catch2-*
do
    echo "= ${TEST_BINARY} ="
    readarray -d\; -t TESTS < <(echo ${TESTS_LIST["${TEST_BINARY}"]} | tr "\n" " " )
    I=0
    while [[ $I -lt ${#TESTS[@]} ]]
    do
        CUR_TEST=$( trim ${TESTS[$I]}) 
        if [[ -n "${CUR_TEST}" ]]; then
            echo -en "${TEST_BINARY} \"${CUR_TEST}\":"
            ./${TEST_BINARY} "${CUR_TEST}" --use-colour=yes > ${run_logs}
            RESULT=$?

            if [[ ${RESULT} -eq 0 ]]; then
                echo -e "${OK}"
            else
                echo -e "${ERROR}"
                cat ${run_logs}
                exit 1
            fi

            CHK_IF_RUN=`cat ${run_logs} | grep "No tests ran" || true` 
            echo "---$CHK_IF_RUN---"
            if [[ -n "${CHK_IF_RUN}" ]]; then
                echo "no such test: ${TEST_BINARY} ${CUR_TEST}"
                exit 1
            fi
        fi
        I=$(( $I + 1 ))
    done
done
popd