diff --git a/.pylintrc b/.pylintrc
index 78dfd299..a9571565 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -105,8 +105,8 @@ max-returns=11
# Maximum number of statements in function / method body.
# defaults to: max-statements=50
-# xen-bugtool:main() is currently at 376, but it has a dedicated pylint disable comment now:
-# max-statements=376
+# For the Python3 fix for bugtool.load_plugins():
+max-statements=52
[FORMAT]
diff --git a/tests/integration/dom0-template/etc/xensource/bugtool/mock.xml b/tests/integration/dom0-template/etc/xensource/bugtool/mock.xml
new file mode 100644
index 00000000..583ed794
--- /dev/null
+++ b/tests/integration/dom0-template/etc/xensource/bugtool/mock.xml
@@ -0,0 +1 @@
+
diff --git a/tests/integration/dom0-template/etc/xensource/bugtool/mock/stuff.xml b/tests/integration/dom0-template/etc/xensource/bugtool/mock/stuff.xml
new file mode 100644
index 00000000..ffcd404f
--- /dev/null
+++ b/tests/integration/dom0-template/etc/xensource/bugtool/mock/stuff.xml
@@ -0,0 +1,6 @@
+
+/etc
+/proc/self/status
+/proc/sys/fs/epoll
+cat /proc/version
+
diff --git a/tests/unit/test_load_plugins.py b/tests/unit/test_load_plugins.py
new file mode 100644
index 00000000..006efd09
--- /dev/null
+++ b/tests/unit/test_load_plugins.py
@@ -0,0 +1,48 @@
+"""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 created mock capability:
+ assert bugtool.cap_sizes["mock"] == 0
+ # Assert the entries added to the bugtool.data dict:
+ assert bugtool.data == {
+ "ls -l /etc": {
+ "cap": "mock",
+ "cmd_args": ["ls", "-l", "/etc"],
+ "filter": None,
+ },
+ "/proc/self/status": {
+ "cap": "mock",
+ "filename": "/proc/self/status",
+ },
+ "/proc/sys/fs/epoll/max_user_watches": {
+ "cap": "mock",
+ "filename": "/proc/sys/fs/epoll/max_user_watches",
+ },
+ "proc_version": {
+ "cap": "mock",
+ "cmd_args": "cat /proc/version",
+ "filter": None,
+ },
+ }
diff --git a/xen-bugtool b/xen-bugtool
index 49189890..c4616d55 100755
--- a/xen-bugtool
+++ b/xen-bugtool
@@ -513,7 +513,8 @@ def dir_list(cap, path_list, recursive = False):
flags = '-lR'
pl = []
- map(lambda x: pl.extend(glob.glob(x)), path_list)
+ for path in path_list:
+ pl.extend(glob.glob(path))
for p in pl:
cmd_output(cap, [LS, flags, p])
@@ -521,7 +522,8 @@ def dir_list(cap, path_list, recursive = False):
def file_output(cap, path_list):
if cap in entries:
pl = []
- map(lambda x: pl.extend(glob.glob(x)), path_list)
+ for path in path_list:
+ pl.extend(glob.glob(path))
for p in pl:
try:
@@ -1593,6 +1595,8 @@ def load_plugins(just_capabilities = False):
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc += node.data
+ if sys.version_info > (3, 0):
+ return rc
return rc.encode()
def getBoolAttr(el, attr, default = False):