~pwlars/ubuntu-test-cases/krillin-recovery

« back to all changes in this revision

Viewing changes to tests/systemsettle/systemsettle.sh

  • Committer: Chris Johnston
  • Date: 2013-08-30 17:40:26 UTC
  • mto: (19.1.1 touch)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: chrisjohnston@ubuntu.com-20130830174026-47dkp6obl6ub14uo
Add smoke-touch-apps tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# Configuration variables:
 
4
#  TARGET_PREFIX - Allows this to be run from the host, by providings something
 
5
#                  like TARGET_PREFIX="adb shell"
 
6
#  UTAH_PROBE_DIR - optionally where to save log files so utah will grab them
 
7
 
 
8
set -e
 
9
 
 
10
[ -z $UTAH_PROBE_DIR ] && UTAH_PROBE_DIR="/tmp"
 
11
 
 
12
# default exit code storage
 
13
dump_error=1
 
14
 
 
15
calc () { awk "BEGIN{ print $* }" ;}
 
16
 
 
17
function show_usage() {
 
18
   echo "Usage:"
 
19
   echo " $0 [options]"
 
20
   echo "Options:"
 
21
   echo " -r  run forever without exiting"
 
22
   echo " -p  minimum idle percent to wait for (Default: 99)"
 
23
   echo " -c  number of times to run top at each iteration (Default: 10)"
 
24
   echo " -d  seconds to delay between each top iteration (Default: 6)"
 
25
   echo " -i  top measurements to ignore from each loop (Default: 1)"
 
26
   echo " -m  maximum loops of top before giving up if minimum idle"
 
27
   echo "     percent is not reached (Default: 10)"
 
28
   echo " -l  label to include for the top_log file"
 
29
   exit 129
 
30
}
 
31
 
 
32
while getopts "h?rp:c:d:i:m:l:" opt; do
 
33
    case "$opt" in
 
34
        h|\?) show_usage
 
35
              ;;
 
36
        r)    settle_prefix='-'
 
37
              ;;
 
38
        p)    idle_avg_min=$OPTARG
 
39
              ;;
 
40
        c)    top_repeat=$OPTARG
 
41
              ;;
 
42
        d)    top_wait=$OPTARG
 
43
              ;;
 
44
        i)    top_ignore=$OPTARG
 
45
              ;;
 
46
        m)    settle_max=$OPTARG
 
47
              ;;
 
48
        l)    top_log_label=$OPTARG
 
49
              ;;
 
50
    esac
 
51
done
 
52
 
 
53
# minimum average idle level required to succeed
 
54
idle_avg_min=${idle_avg_min:-99}
 
55
# measurement details: top $top_wait $top_repeat
 
56
top_repeat=${top_repeat:-10}
 
57
top_wait=${top_wait:-6}
 
58
# how many samples to ignore
 
59
top_ignore=${top_ignore:-1}
 
60
# how many total attempts to settle the system
 
61
settle_max=${settle_max:-10}
 
62
 
 
63
top_log="$UTAH_PROBE_DIR/top$top_log_label.log"
 
64
 
 
65
# set and calc more runtime values
 
66
top_tail=`calc $top_repeat - $top_ignore`
 
67
settle_count=0
 
68
idle_avg=0
 
69
 
 
70
echo "System Settle run - quiesce the system"
 
71
echo "--------------------------------------"
 
72
echo
 
73
echo "  idle_avg_min   = '$idle_avg_min'"
 
74
echo "  top_repeat  = '$top_repeat'"
 
75
echo "  top_wait    = '$top_wait'"
 
76
echo "  top_ignore  = '$top_ignore'"
 
77
echo "  settle_max     = '$settle_max'"
 
78
echo "  run_forever    = '$settle_prefix' (- = yes)"
 
79
echo "  log files   = $top_log $top_log.reduced"
 
80
echo
 
81
 
 
82
while test `calc $idle_avg '<' $idle_avg_min` = 1 -a "$settle_prefix$settle_count" -lt "$settle_max"; do
 
83
  echo -n "Starting system idle measurement (run: $settle_count) ... "
 
84
 
 
85
  # get top
 
86
  echo "TOP DUMP (after settle run: $settle_count)" >> $top_log
 
87
  echo "========================" >> $top_log
 
88
  ${TARGET_PREFIX} top -b -d $top_wait -n $top_repeat >> $top_log
 
89
  cat $top_log | grep '.Cpu.*' | tail -n $top_tail > $top_log.reduced
 
90
  echo >> $top_log
 
91
 
 
92
  # calc average of idle field for this measurement
 
93
  sum=0
 
94
  count=0
 
95
  while read line; do
 
96
     idle=`echo $line | sed -e 's/.* \([0-9\.]*\) id.*/\1/'`
 
97
     sum=`calc $sum + $idle`
 
98
     count=`calc $count + 1`
 
99
  done < $top_log.reduced
 
100
 
 
101
  idle_avg=`calc $sum / $count`
 
102
  settle_count=`calc $settle_count + 1`
 
103
 
 
104
  echo " DONE."
 
105
  echo
 
106
  echo "Measurement:"
 
107
  echo "  + idle level: $idle_avg"
 
108
  echo "  + idle sum: $sum / count: $count"
 
109
  echo
 
110
done
 
111
 
 
112
if test `calc $idle_avg '<' $idle_avg_min` = 1; then
 
113
  echo "system not settled. FAIL"
 
114
  exit 1
 
115
else
 
116
  echo "system settled. SUCCESS"
 
117
  exit 0
 
118
fi
 
119