forked from avocado-framework/avocado-misc-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interbench.py
74 lines (62 loc) · 2.41 KB
/
interbench.py
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
69
70
71
72
73
74
#!/usr/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: 2016 IBM
# Author: Praveen K Pandey <[email protected]>
#
# Based on code by Brandon Philips
# copyright: 2006 IBM
# https://github.com/autotest/autotest-client-tests/tree/master/interbench
import os
from avocado import Test
from avocado import main
from avocado.utils import archive
from avocado.utils import process
from avocado.utils import build
from avocado.utils.software_manager import SoftwareManager
class Interbench(Test):
"""
Interbench is designed to measure the effect of changes in Linux kernel
design or system configuration changes such as cpu, I/O scheduler and
filesystem changes and options. With careful benchmarking, different
hardware can be compared
"""
def setUp(self):
'''
Build interbench
Source:
http://ck.kolivas.org/apps/interbench/interbench-0.31.tar.bz2
'''
sm_manager = SoftwareManager()
if (not sm_manager.check_installed("gcc") and not
sm_manager.install("gcc")):
self.error("Gcc is needed for the test to be run")
tarball = self.fetch_asset('http://ck.kolivas.org'
'/apps/interbench/'
'interbench-0.31.tar.bz2')
data_dir = os.path.abspath(self.datadir)
archive.extract(tarball, self.srcdir)
version = os.path.basename(tarball.split('.tar.')[0])
self.srcdir = os.path.join(self.srcdir, version)
# Patch for make file
os.chdir(self.srcdir)
makefile_patch = 'patch -p1 < %s ' % (
os.path.join(data_dir, 'makefile_fix.patch'))
process.run(makefile_patch, shell=True)
build.make(self.srcdir)
def test(self):
args = self.params.get('arg', default='')
args += ' c'
process.system("%s ' run ' %s" % (os.path.join(
self.srcdir, 'interbench'), args), sudo=True)
if __name__ == "__main__":
main()