For master do not check connman.service
[src/qa-testdefinitions.git] / common / scripts / service-check-gfx.sh
1 #!/bin/bash
2
3 export LANG=C
4 export TERM=dumb
5 export COLUMNS=1000
6
7 while getopts ":b:d:" option; do
8     case "${option}" in
9         b)
10             if [[ $OPTARG = -* ]]; then
11                 ((OPTIND--))
12                 continue
13             fi
14             BUILD_TAGS=${OPTARG}
15             ;;
16         d)
17             DEVICE_TAGS=${OPTARG}
18             ;;
19     esac
20 done
21
22 REQUIREDSOCKETS="dbus.socket"
23 REQUIREDSERVICES=""
24
25 ALL="${REQUIREDSOCKETS} ${REQUIREDSERVICES}"
26 RESULT="unknown"
27
28 # add delay for services to fully start
29 sleep 10
30
31 for i in ${ALL} ; do
32     echo -e "\n\n########## Test for service ${i} being active ##########\n\n"
33     RESULT=""
34     if [[ ${i} == "weston.service" ]]; then
35         if [[ ${DEVICE_TAGS} != *"screen"* ]] || [[ ${BUILD_TAGS} != *"screen"* ]]; then
36             RESULT="skip"
37         fi
38     fi
39     if [[ -z $RESULT ]]; then
40         systemctl is-active ${i} >/dev/null 2>&1
41         if [ $? -eq 0 ] ; then
42             RESULT="pass"
43         else
44             RESULT="fail"
45             if [[ ${i} == "bluetooth.service" ]]; then
46                 if [[ ${DEVICE_TAGS} != *"bluetooth"* ]] || [[ ${BUILD_TAGS} != *"bluetooth"* ]]; then
47                     RESULT="skip"
48                 fi
49             fi
50             if [[ ${i} == "ofono.service" ]]; then
51                 if [[ ${DEVICE_TAGS} != *"bluetooth"* ]] || [[ ${BUILD_TAGS} != *"bluetooth"* ]]; then
52                     RESULT="skip"
53                 fi
54             fi
55         fi
56     fi
57
58     lava-test-case ${i} --result ${RESULT}
59     systemctl status ${i} || true
60     echo -e "\n\n"
61
62     echo -e "\n\n########## Result for service ${i} : $RESULT ##########\n\n"
63 done
64
65 echo "------------------------------------------------"
66 echo "All systemd units:"
67 echo "------------------------------------------------"
68 systemctl list-units || true
69 echo "------------------------------------------------"
70 echo "Only the failed systemd units:"
71 echo "------------------------------------------------"
72 ( systemctl list-units | grep failed ) || true
73
74 exit 0