commit 17c5160c0fca436ef8aff8da971887b08d89628f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 17 17:26:27 2014 +0100
ResultSerializer: update summary formatting
There are two updates to summary formating in this commit:
* shorten the alignment of command types to -9 from -14 the reason is
* that the longes command type is now 'ctl_wait' instead of
* 'system_config'
* add machine identification to each command in the format:
* 'machine id: cmd_type'
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 8 ++++----
lnst/Common/TestsCommon.py | 2 +-
lnst/Controller/NetTestController.py | 2 +-
lnst/Controller/NetTestResultSerializer.py | 19 ++++++++++++++++---
4 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index abfa71a..47a3e4a 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -344,7 +344,7 @@ class NetTestCommandGeneric:
raise CommandException(msg)
def _format_cmd_res_header(self):
- return "%-14s" % self._command["type"]
+ return "%-9s" % self._command["type"]
def set_handle_intr(self):
pass
@@ -383,11 +383,11 @@ class NetTestCommandExec(NetTestCommandGeneric):
cmd_val = self._command["command"]
if "bg_id" in self._command:
- bg_id = " bg_id: %s" % self._command["bg_id"]
+ bg_id = "bg_id: %s " % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s cmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
+ cmd = "%-9s%scmd: \"%s\"" %(cmd_type, bg_id, cmd_val)
return cmd
class NetTestCommandConfig(NetTestCommandGeneric):
@@ -454,7 +454,7 @@ class NetTestCommandControl(NetTestCommandGeneric):
def _format_cmd_res_header(self):
cmd_type = self._command["type"]
cmd_val = self._command["proc_id"]
- cmd = "%-14s id: %s" % (cmd_type, cmd_val)
+ cmd = "%-9sid: %s" % (cmd_type, cmd_val)
return cmd
class NetTestCommandWait(NetTestCommandControl):
diff --git a/lnst/Common/TestsCommon.py b/lnst/Common/TestsCommon.py
index 01ae678..8086121 100644
--- a/lnst/Common/TestsCommon.py
+++ b/lnst/Common/TestsCommon.py
@@ -146,5 +146,5 @@ class TestGeneric(NetTestCommandGeneric):
bg_id = " bg_id: %s" % self._command["bg_id"]
else:
bg_id = ""
- cmd = "%-14s%s%s" %(cmd_type, cmd_val, bg_id)
+ cmd = "%-9s%s%s" %(cmd_type, cmd_val, bg_id)
return cmd
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index ad5a2df..348c064 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -653,7 +653,7 @@ class NetTestController:
if command["type"] == "ctl_wait":
sleep(command["seconds"])
cmd_res = {"passed": True,
- "res_header": "%-14s%ss" %
("ctl_wait",
+ "res_header": "%-9s%ss" %
("ctl_wait",
command["seconds"]),
"msg": "",
"res_data": None}
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index 9c26dfc..7f2e6d1 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -84,17 +84,30 @@ class NetTestResultSerializer:
seq_num += 1
+ m_id_max = 0
for cmd, cmd_res in task:
- self._format_command(cmd, cmd_res, output_pairs)
+ if "machine" in cmd and\
+ len(cmd["machine"]) > m_id_max:
+ m_id_max = len(cmd["machine"])
+ for cmd, cmd_res in task:
+ self._format_command(cmd, cmd_res, output_pairs, m_id_max)
self._print_pairs(output_pairs)
- def _format_command(self, command, cmd_res, output_pairs):
+ def _format_command(self, command, cmd_res, output_pairs, m_id_max):
if cmd_res["passed"]:
res = "PASS"
else:
res = "FAIL"
- output_pairs.append((8*" " + cmd_res["res_header"], res))
+
+ if "machine" in command:
+ m_id = "host %s: " % command["machine"]
+ m_id += " " * (m_id_max - len(command["machine"]))
+ else:
+ #len("ctl") == 3; len("host ") == 5; 5-3 = 2
+ m_id = "ctl: " + " " * (m_id_max + 2)
+
+ output_pairs.append((8*" " + m_id + cmd_res["res_header"],
res))
if "msg" in cmd_res and cmd_res["msg"] != "":
output_pairs.append((12*" " + "message: " +
cmd_res["msg"], ""))