forked from avocado-framework/avocado-misc-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gdb.py
executable file
·65 lines (57 loc) · 2.32 KB
/
gdb.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
#!/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: Pavithra <[email protected]>
import os
import re
from avocado import Test
from avocado import main
from avocado.utils import archive
from avocado.utils import build
from avocado.utils import distro
from avocado.utils import process
from avocado.utils.software_manager import SoftwareManager
class GDB(Test):
def setUp(self):
sm = SoftwareManager()
dist = distro.detect()
packages = ['gcc', 'dejagnu', 'flex', 'bison']
if dist.name == 'Ubuntu':
packages.extend(['g++', 'binutils-dev'])
elif dist.name in ['SuSE', 'redhat', 'fedora']:
packages.extend(['gcc-c++', 'binutils-devel'])
else:
self.fail('no packages list for your distro.')
for package in packages:
if not sm.check_installed(package) and not sm.install(package):
self.error("Fail to install %s required for this test." %
package)
gdb_version = self.params.get('gdb_version', default='7.10')
tarball = self.fetch_asset(
"http://ftp.gnu.org/gnu/gdb/gdb-%s.tar.gz" % gdb_version)
archive.extract(tarball, self.srcdir)
self.srcdir = os.path.join(
self.srcdir, os.path.basename(tarball.split('.tar')[0]))
os.chdir(self.srcdir)
process.run('./configure', ignore_status=True, sudo=True)
build.make(self.srcdir)
def test(self):
process.run("make check-gdb", ignore_status=True, sudo=True)
logfile = os.path.join(self.logdir, "stdout")
with open(logfile, 'r') as f:
for line in f.readlines():
for match in re.finditer("of unexpected failures\s[1-9]", line):
self.log.info(line)
self.fail("Few gdb tests have failed")
if __name__ == "__main__":
main()