summaryrefslogtreecommitdiffstats
path: root/common/scripts/ptest-lava-wrapper.sh
blob: d3ce449563d83922c4e4b6e0a1c54df61bcbe9cc (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
#!/bin/bash

REQUIREDPTESTS="acl attr systemd cynara xmlsec1 libxml2 openssl openssh lua smack afb-test agl-service-signal-composer dbus-test"

# Check if ptest packages are installed
command -v ptest-runner >/dev/null 2>&1
if [ $? -ne 0 ] ; then
    lava-test-case ptest-installed --result SKIP
else
    # Run ptests for specified packages
    for unit in ${REQUIREDPTESTS}; do
        UNIT_LOG=$(ptest-runner ${unit} 2> /dev/null)
        if [ $? -eq 0 ] ; then
            lava-test-set start ptest-$unit
            # grep: Get only the ptests results, no log
            # sed 1: replace spaces by hyphens
            # sed 2: remove any special character
            # sed 3: find status and test name, wrap it in a lava-test-case call
            # sh: execute the lava-test-case commands
            test_pass=$(echo "$UNIT_LOG" | grep -e 'PASS' | wc -l)
            test_fail=$(echo "$UNIT_LOG" | grep -e 'FAIL' | wc -l)
            lava-test-case ${unit}-passed-commands --result PASS --measurement $test_pass --units pass
            if ! [ x"0" = x"$test_fail" ] ; then
              lava-test-case ${unit}-failed-commands --result FAIL --measurement $test_fail --units fail
              echo "$UNIT_LOG" | grep -e 'FAIL'
            fi
            lava-test-set stop ptest-$unit
        else
            lava-test-case ptest-runner-${unit} --result fail
        fi
    done
    lava-test-case ptest-runtime --measurement $SECONDS --units seconds --result PASS
fi

# Wait for LAVA to parse all the tests from stdout
sleep 15