[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/7] tests/acceptance: Refactor and improve reporting in linux_ssh
From: |
Cleber Rosa |
Subject: |
[PULL 5/7] tests/acceptance: Refactor and improve reporting in linux_ssh_mips_malta.py |
Date: |
Mon, 23 Sep 2019 09:40:17 -0400 |
From: Aleksandar Markovic <address@hidden>
This patch restructures code organization around the test case
executions. At the same time, rather than outputing a cryptic message:
FAIL: True not found in [False],
the following will be reported too, if the command output does not meet
specified expectations:
'lspci -d 11ab:4620' output doesn't contain the word 'GT-64120'
Signed-off-by: Aleksandar Markovic <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
tests/acceptance/linux_ssh_mips_malta.py | 36 ++++++++++++++----------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/tests/acceptance/linux_ssh_mips_malta.py
b/tests/acceptance/linux_ssh_mips_malta.py
index 7200507a3a..7fc44f43d1 100644
--- a/tests/acceptance/linux_ssh_mips_malta.py
+++ b/tests/acceptance/linux_ssh_mips_malta.py
@@ -145,27 +145,33 @@ class LinuxSSH(Test):
self.ssh_disconnect_vm()
self.wait_for_console_pattern('Power down')
+ def ssh_command_output_contains(self, cmd, exp):
+ stdout, _ = self.ssh_command(cmd)
+ for line in stdout:
+ if exp in line:
+ break
+ else:
+ self.fail('"%s" output does not contain "%s"' % (cmd, exp))
+
def run_common_commands(self):
- stdout, stderr = self.ssh_command('lspci -d 11ab:4620')
- self.assertIn(True, ["GT-64120" in line for line in stdout])
-
- stdout, stderr = self.ssh_command('cat
/sys/bus/i2c/devices/i2c-0/name')
- self.assertIn(True, ["SMBus PIIX4 adapter" in line
- for line in stdout])
-
- stdout, stderr = self.ssh_command('cat /proc/mtd')
- self.assertIn(True, ["YAMON" in line
- for line in stdout])
-
+ self.ssh_command_output_contains(
+ 'lspci -d 11ab:4620',
+ 'GT-64120')
+ self.ssh_command_output_contains(
+ 'cat /sys/bus/i2c/devices/i2c-0/name',
+ 'SMBus PIIX4 adapter')
+ self.ssh_command_output_contains(
+ 'cat /proc/mtd',
+ 'YAMON')
# Empty 'Board Config'
- stdout, stderr = self.ssh_command('md5sum /dev/mtd2ro')
- self.assertIn(True, ["0dfbe8aa4c20b52e1b8bf3cb6cbdf193" in line
- for line in stdout])
+ self.ssh_command_output_contains(
+ 'md5sum /dev/mtd2ro',
+ '0dfbe8aa4c20b52e1b8bf3cb6cbdf193')
def check_mips_malta(self, endianess, kernel_path, uname_m):
self.boot_debian_wheezy_image_and_ssh_login(endianess, kernel_path)
- stdout, stderr = self.ssh_command('uname -a')
+ stdout, _ = self.ssh_command('uname -a')
self.assertIn(True, [uname_m + " GNU/Linux" in line for line in
stdout])
self.run_common_commands()
--
2.21.0
- [PULL 0/7] Python (acceptance tests) queue - 2019-09-23, Cleber Rosa, 2019/09/23
- [PULL 1/7] Acceptance test machine_m68k_nextcube.py: relax the error code pattern, Cleber Rosa, 2019/09/23
- [PULL 2/7] Acceptance test x86_cpu_model_versions: shutdown VMs, Cleber Rosa, 2019/09/23
- [PULL 3/7] Acceptance test x86_cpu_model_versions: fix mismatches between test and messages, Cleber Rosa, 2019/09/23
- [PULL 4/7] Acceptance test x86_cpu_model_versions: split into smaller tests, Cleber Rosa, 2019/09/23
- [PULL 5/7] tests/acceptance: Refactor and improve reporting in linux_ssh_mips_malta.py,
Cleber Rosa <=
- [PULL 6/7] tests/acceptance: Add new test cases in linux_ssh_mips_malta.py, Cleber Rosa, 2019/09/23
- [PULL 7/7] Acceptance tests: use avocado.utils.ssh for SSH interaction, Cleber Rosa, 2019/09/23
- Re: [PULL 0/7] Python (acceptance tests) queue - 2019-09-23, no-reply, 2019/09/23
- Re: [PULL 0/7] Python (acceptance tests) queue - 2019-09-23, no-reply, 2019/09/23
- Re: [PULL 0/7] Python (acceptance tests) queue - 2019-09-23, no-reply, 2019/09/24
- Re: [PULL 0/7] Python (acceptance tests) queue - 2019-09-23, Peter Maydell, 2019/09/24