Skip to content

Commit

Permalink
Test multipathd_topology() and fix it for Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardkaindl committed Dec 15, 2023
1 parent bf051b5 commit 5747829
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/integration/dom0-template/usr/sbin/multipathd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo -n "${0##*/}$*"
5 changes: 5 additions & 0 deletions tests/unit/test_process_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ def test_module_info(bugtool, dom0_template):
bugtool.PROC_MODULES = dom0_template + "/proc/modules"
output = bugtool.module_info(bugtool.CAP_KERNEL_INFO)
assert output == "modinfo for tcp_diag\nmodinfo for udp_diag\nmodinfo for inet_diag\n"


def test_multipathd_topology(bugtool, dom0_template):
"""Assert multipathd_topology() returning the output of the faked multipathd tool"""
assert bugtool.multipathd_topology(bugtool.CAP_MULTIPATH) == bugtool.MULTIPATHD + "-k"
12 changes: 9 additions & 3 deletions xen-bugtool
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,15 @@ def csl_logs(cap):
return output.getvalue()

def multipathd_topology(cap):
pipe = Popen([MULTIPATHD, '-k'], bufsize=1, stdin=PIPE,
stdout=PIPE, stderr=dev_null)
stdout, _ = pipe.communicate('show topology')
pipe = Popen(
[MULTIPATHD, "-k"],
universal_newlines=sys.version_info > (3, 0),
bufsize=1,
stdin=PIPE,
stdout=PIPE,
stderr=dev_null,
)
stdout, _ = pipe.communicate("show topology")

return stdout

Expand Down

0 comments on commit 5747829

Please sign in to comment.