aboutsummaryrefslogtreecommitdiffstats
path: root/meta-ivi-test/recipes-extended/node-state-manager/node-state-manager/node-state-manager_t.inc
blob: 477145f3436c9cb8edd585de51f9bb2037692512 (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
#!/bin/sh
get_list() {
  return 1
}

get_title() {
  echo "Node State Manager"
}

_run_dir=/opt/tests/node-state-manager
_run_1() {
  ${_run_dir}/NodeStateTest
}

_setup_env() {
  systemctl stop node-startup-controller

  _p=`pidof NodeStateManager`
  if [ "x${_p}" != "x" ]; then
      kill -9 ${_p} >& /dev/null
  fi
  _p=`pidof nsm-dummy`
  if [ "x${_p}" != "x" ]; then
      kill -9 ${_p} >& /dev/null
  fi
}

_lib=/usr/lib/libNodeStateMachineStub.so
_lib_2=/usr/lib/libNodeStateMachineTest.so
_lib_t=${_run_dir}/lib/libNodeStateMachineTest.so
_lib_bak=${_run_dir}/lib/libNodeStateMachineStub.so
run_1() {
  if [ ! -f ${_lib_bak} ]; then
    cp ${_lib} ${_run_dir}/lib
  fi
  cp ${_lib_t} ${_lib}
  ldconfig
  sleep 1

  _setup_env
  dbus-launch >& /tmp/d.pid
  _dbus_pid=`grep BUS_PID /tmp/d.pid  | awk -F= '{print $2}'`
  sleep 1
  /usr/bin/NodeStateManager >& /dev/null &
  sleep 4

  if [ "x${1}" != "x" ]; then
    _run_1 > /tmp/t 2> /tmp/t.err
    _c1=`cat /tmp/t | grep success | wc -l`
    _c2=`cat /tmp/t | grep failed | wc -l`
    if [ "x${_c1}" = "x0" ]; then
       echo "[ FAILED ] ${_c2} tests."
    elif [ "x${_c2}" = "x0" ]; then
       echo "[ PASSED ] ${_c1} tests."
    else
       echo " ${_c1} PASSED, ${_c2} FAILED"
    fi
  else
    _run_1 2> /tmp/t.err
  fi

  kill -9 ${_dbus_pid} >& /dev/null
  _setup_env

  rm -f ${_lib} ${_lib_2}
  mv ${_lib_bak} ${_lib}
  ldconfig
}