-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathunittest-bootstrap.py
More file actions
53 lines (44 loc) · 1.37 KB
/
unittest-bootstrap.py
File metadata and controls
53 lines (44 loc) · 1.37 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
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import unittest
import sys
import os
import os.path
import configparser
import gzip
import shutil
config = configparser.ConfigParser()
filename = os.environ['CRASH_PYTHON_TESTFILE']
try:
matchfn = os.environ['CRASH_PYTHON_TESTS']
except KeyError:
matchfn = None
if not matchfn:
matchfn = "test_*.py"
try:
f = open(filename)
config.read_file(f)
except FileNotFoundError as e:
print(f"{str(e)}")
sys.exit(1)
try:
vmcore = config['test']['vmcore']
except KeyError:
print(f"{filename} doesn't contain the required sections.")
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)
from crash.kernel import CrashKernel
kernel = CrashKernel(roots=roots, vmlinux_debuginfo=vmlinux_debuginfo,
module_path=module_path,
module_debuginfo_path=module_debuginfo_path, verbose=True)
kernel.setup_tasks()
kernel.load_modules()
test_loader = unittest.TestLoader()
test_suite = test_loader.discover('kernel-tests', pattern=matchfn)
ret = unittest.TextTestRunner(verbosity=2).run(test_suite)
if not ret.wasSuccessful():
sys.exit(1)
sys.exit(0)