summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/gnutls/gnutls/run-ptest
blob: 17e26eae70dc50a0b167dc693470156273a96c94 (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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh

rjob() {
    local job=$1
    local log=$2

    # TODO: Output will be garbled
    ./${job} >> ${log} 2>&1

    ret=$?
    case $ret in
    0)
        echo "PASS: $t" >> ${log}
        echo "PASS: $t"
        ;;
    77)
        echo "SKIP: $t" >> ${log}
        echo "SKIP: $t"
        ;;
    *)
        echo "FAIL: $t" >> ${log}
        echo "FAIL: $t"
        ;;
    esac
}

is_disallowed() {
    local key=$1
    $(echo ${test_disallowlist} | grep -w -q ${key})
    return $?
}

# TODO
# This list should probably be in a external file
# Testcases defined here either take very long time (dtls-stress)
# or are dependent on local files (certs, etc) in local file system
# currently not exported to target.

test_disallowlist=""
test_disallowlist="${test_disallowlist} dtls-stress"
test_disallowlist="${test_disallowlist} handshake-large-cert"
test_disallowlist="${test_disallowlist} id-on-xmppAddr"
test_disallowlist="${test_disallowlist} mini-x509-cas"
test_disallowlist="${test_disallowlist} pkcs12_simple"
test_disallowlist="${test_disallowlist} protocol-set-allowlist"
test_disallowlist="${test_disallowlist} psk-file"
test_disallowlist="${test_disallowlist} rawpk-api"
test_disallowlist="${test_disallowlist} set_pkcs12_cred"
test_disallowlist="${test_disallowlist} system-override-curves-allowlist"
test_disallowlist="${test_disallowlist} system-override-hash"
test_disallowlist="${test_disallowlist} system-override-sig"
test_disallowlist="${test_disallowlist} system-override-sig-tls"
test_disallowlist="${test_disallowlist} system-prio-file"
test_disallowlist="${test_disallowlist} x509cert-tl"

LOG=${PWD}/tests.log
cd tests
max_njobs=$(grep -c ^processor /proc/cpuinfo)
njobs=0

set +e

for t in *; do
    [ -x $t ] || continue
    [ -f $t ] || continue

    is_disallowed ${t}
    [ $? -eq 0 ] && continue

    rjob ${t} ${LOG} &
    one=1
    njobs=$(expr ${njobs} + ${one})
    if [ ${njobs} -eq ${max_njobs} ]; then
        wait
        njobs=0
    fi
done
wait

skipped=$(grep -c SKIP ${LOG})
passed=$(grep -c PASS ${LOG})
failed=$(grep -c FAIL ${LOG})
total=$(expr ${passed} + ${failed} + ${skipped})

if [ ${failed} -ne 0 ]; then
    echo
    echo "Tests failed for gnutls, log is:"
    echo "--------------------"
    cat ${LOG}
    echo
fi

echo
echo "gnutls test summary:"
echo "--------------------"
echo "total: ${total}"
echo "pass : ${passed}"
echo "fail : ${failed}"
echo "skip : ${skipped}"
echo