forked from xenserver/status-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_load_plugins.py
74 lines (69 loc) · 2.28 KB
/
test_load_plugins.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
"""Regression tests for bugtool.load_plugins()"""
def test_load_plugins(bugtool, dom0_template):
"""Assert () returning arrays of the in the dom0-template"""
# Use the plugins found in the dom0_template "/etc/xensource/bugtool":
bugtool.PLUGIN_DIR = dom0_template + "/etc/xensource/bugtool"
# Only process the mock bugtool plugin:
bugtool.entries = ["mock"]
# Load the mock plugin:
bugtool.load_plugins(just_capabilities=False)
# Assert the set of properties of the created mock capability:
assert bugtool.caps["mock"] == (
"mock",
"yes",
-1,
16384,
-1,
60,
"text/plain",
True,
False,
9,
)
# Assert the size of the files of the created mock inventory entry:
assert bugtool.cap_sizes["mock"] > 0 # /etc/passwd should have content
# Assert the entries added to the bugtool.data dict:
assert bugtool.data == {
"ls -l /etc": {
"cap": "mock",
"cmd_args": ["ls", "-l", "/etc"],
"filter": None,
},
"/etc/passwd": {
"cap": "mock",
"filename": "/etc/passwd",
},
"/etc/group": {
"cap": "mock",
"filename": "/etc/group",
},
"/proc/self/status": {
"cap": "mock",
"filename": "/proc/self/status",
},
"proc_version": {
"cap": "mock",
"cmd_args": "cat /proc/version",
"filter": None,
},
}
# Assert the tree_output entries for /proc/sys/fs/inotify:
entry_one, entry_two = bugtool.directory_specifications["/proc/sys/fs/inotify"]
cap, regex, negate = entry_one
assert cap == "mock"
assert regex.pattern == ".*user_.*"
assert negate
cap, regex, negate = entry_two
assert cap == "mock"
assert regex.pattern == ".*max_user_instances.*"
assert not negate
# Assert the tree_output entry for /proc/sys/fs/epoll:
entry_one, entry_two = bugtool.directory_specifications["/proc/sys/fs/epoll"]
cap, regex, negate = entry_one
assert cap == "mock"
assert regex.pattern == ".*ax_user_watches"
assert not negate
cap, regex, negate = entry_two
assert cap == "mock"
assert regex.pattern == "no"
assert not negate