~sylvain-pineau/checkbox/fix-1475539

« back to all changes in this revision

Viewing changes to providers/plainbox-provider-checkbox/bin/cpu_stress

  • Committer: Sylvain Pineau
  • Author(s): Rod Smith
  • Date: 2016-02-03 20:51:25 UTC
  • mfrom: (4201.1.1 005-new-cpu-test)
  • Revision ID: sylvain_pineau-20160203205125-aan0cydfwptvr400
"automatic merge of lp:~rodsmith/checkbox/new-cpu-test/ by tarmac [r=bladernr][bug=][author=rodsmith]"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Script to perform CPU stress tests
 
4
#
 
5
# Copyright (c) 2016 Canonical Ltd.
 
6
#
 
7
# Authors
 
8
#   Rod Smith <rod.smith@canonical.com>
 
9
#
 
10
# This program is free software: you can redistribute it and/or modify
 
11
# it under the terms of the GNU General Public License version 3,
 
12
# as published by the Free Software Foundation.
 
13
#
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
#
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
#
 
22
# The purpose of this script is to run CPU stress tests using the
 
23
# stress-ng program.
 
24
#
 
25
# Usage:
 
26
#   cpu_stress [ --runtime <time-in-seconds> ]
 
27
#
 
28
# If --runtime is not specified, it defaults to 7200 (2 hours).
 
29
 
 
30
runtime=7200
 
31
if [ "$#" = "2" ] && [ "$1" = "--runtime" ] && [ "$2" -eq "$2" ] ; then
 
32
    runtime=$2
 
33
elif [ "$#" != "0" ] ; then
 
34
    echo "Usage:"
 
35
    echo " $0 [ --runtime <time-in-seconds> ]"
 
36
    exit 1
 
37
fi
 
38
echo "Setting run time to $runtime seconds"
 
39
# Add 10% to runtime; will forcefully terminate if stress-ng
 
40
# fails to return in that time.
 
41
end_time=$((runtime*11/10))
 
42
 
 
43
# NOTE:
 
44
# Options --af-alg 0 through --wcs 0 specify CPU stressors. As of stress-ng
 
45
# version 0.05.12, this is equivalent to --class cpu --all 0 --exclude numa,cpu_online.
 
46
# This script specifies stressors individually because the list of stressors keeps
 
47
# increasing, and we want consistency -- if the stress-ng version bumps up, we
 
48
# don't want new stressors being run. We're omitting numa because it's most
 
49
# useful on systems with massive numbers of CPUs, and cpu_online because it's
 
50
# failed on 4 of 8 test systems, so it seems too strict.
 
51
# Use "timeout" command to launch stress-ng, to catch it should it go into la-la land
 
52
timeout -s 9 $end_time stress-ng --aggressive --verify --timeout $runtime \
 
53
                                 --metrics-brief --tz --times \
 
54
                                 --af-alg 0 --bsearch 0 --context 0 --cpu 0 \
 
55
                                 --crypt 0 --hsearch 0 --longjmp 0 --lsearch 0 \
 
56
                                 --matrix 0 --qsort 0 --str 0 --stream 0 \
 
57
                                 --tsearch 0 --vecmath 0 --wcs 0
 
58
result="$?"
 
59
 
 
60
echo "**********************************************************"
 
61
if [ $result = "0" ] ; then
 
62
    echo "* stress-ng CPU test passed!"
 
63
else
 
64
    if [ $result = "137" ] ; then
 
65
        echo "* stress-ng CPU test timed out and was forcefully terminated!"
 
66
    fi
 
67
    echo "* stress-ng CPU test failed with result $result"
 
68
fi
 
69
echo "**********************************************************"
 
70
exit $result