-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathunittest-prepare.py
More file actions
55 lines (45 loc) · 1.44 KB
/
unittest-prepare.py
File metadata and controls
55 lines (45 loc) · 1.44 KB
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
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import sys
import os
import os.path
import configparser
import gzip
import shutil
config = configparser.ConfigParser()
filename = os.environ['CRASH_PYTHON_TESTFILE']
try:
f = open(filename)
config.read_file(f)
except FileNotFoundError as e:
print(f"{str(e)}")
sys.exit(1)
try:
vmlinux = config['test']['kernel']
vmcore = config['test']['vmcore']
except KeyError as e:
print(f"{filename} doesn't contain the required sections `{str(e)}.")
sys.exit(1)
roots = config['test'].get('root', None)
vmlinux_debuginfo = config['test'].get('vmlinux_debuginfo', None)
module_path = config['test'].get('module_path', None)
module_debuginfo_path = config['test'].get('module_debuginfo_path', None)
if roots:
dfd = ":".join(roots) + ":/usr/lib/debug"
gdb.execute(f"set debug-file-directory {dfd}")
try:
if vmlinux.endswith(".gz"):
vmlinux_gz = vmlinux
testdir = os.environ['CRASH_PYTHON_TESTDIR']
base = os.path.basename(vmlinux)[:-3]
vmlinux = os.path.join(testdir, base)
with gzip.open(vmlinux_gz, 'r') as f_in, open(vmlinux, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
f_out.close()
f_in.close()
from kdump.target import Target
target = Target(debug=False)
gdb.execute(f"target kdumpfile {vmlinux} {vmcore}")
except Exception as e:
print(str(e))
sys.exit(1)