Add the long ptest job and enhance the short job
[src/qa-testdefinitions.git] / common / scripts / ptest-lava-wrapper-all.sh
1 #!/bin/bash
2
3 # Check if ptest packages are installed
4 command -v ptest-runner >/dev/null 2>&1
5 if [ $? -ne 0 ] ; then
6     lava-test-case ptest-installed --result SKIP
7 else
8     # Run ptests for specified packages
9         lava-test-set start ptest-full
10         UNIT_LOG=$(ptest-runner 2> results.log )
11         if [ $? -eq 0 ] ; then
12             # grep: Get only the ptests results, no log
13             # sed 1: replace spaces by hyphens
14             # sed 2: remove any special character
15             # sed 3: find status and test name, wrap it in a lava-test-case call
16             # sh: execute the lava-test-case commands
17             test_pass=$(echo "$UNIT_LOG" | grep -e 'PASS' | wc -l)
18             test_fail=$(echo "$UNIT_LOG" | grep -e 'FAIL' | wc -l)
19             lava-test-case passed-commands --result PASS --measurement $test_pass --units pass
20             if ! [ x"0" = x"$test_fail"] ; then
21               lava-test-case failed-commands --result FAIL --measurement $test_fail --units fail
22               echo "$UNIT_LOG" | grep -e 'FAIL'
23             fi
24         else
25             lava-test-case ptest-runner ptest-full --result fail
26         fi
27         lava-test-set stop ptest-full
28     done
29     lava-test-case ptest-runtime --measurement $SECONDS --units seconds --result PASS
30 fi
31
32 # Wait for LAVA to parse all the tests from stdout
33 sleep 15
34
35 cat results.log