Improvements include:
* Relaxed error code pattern on machine_m68k_nextcube.py * Better naming and separation of tests in x86_cpu_model_versions.py * New checks on guest side on linux_ssh_mips_malta.py * Use of avocado.utils.ssh, and thus "/usr/bin/ssh" for SSH interaction -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEeruW64tGuU1eD+m7ZX6NM6XyCfMFAl2IyrkACgkQZX6NM6Xy CfMFOBAAy6rYpXGBtLtbrS1g3FGA70PiSCQMi/ydLhTzO/5DEZ050tlVLXKyUWrS 8VUSV0qbw+QeQ+yJPcLbfxFQ1MrRfDZlo0TvQiRRceUocex1FSsMR5RoER5O8dS4 DUUBFUPLhtLiCjorQWKZFPXePqvUPDBri9FNcCisdg4Mkkqhcuw/j6iMrSzW2B5G NxFi0hXoYSoAMebTA2UIrZ+TtZw6BFZTpENkLBxN9+ARwqc8Rhg18YHh91mxISH9 vgyXAK6CJ4MeNsQ6Dqsx/LCloVra4vCfQ+3oz7KtihYOzbtcP2jssMfXON8Ui0Vf WRdkMVCTzf5HuwILm69VKOyRnEtIlVGq36gnf61wtn0LokBn5m+DUuKVFMOsqpN3 JZ1Wrur+Dd6xLTvJnwhE1kwGqEWHbkH68XIR7ZRckp0zwul3L/xspVDxN0p8nYfU J06FV4sQIzAI0rTc7fuYMkhrjUzWKfYYhLAEwCKIaEe9LHTcdtD7w/dFZMjcbZVy AdVxwFDCfHucEb9eEDawRe5rY5SJiRpytUpyv8NH7gBXhhL7CgaYpxtcbe/a7eck 3MAd3bMhv4cRxnlrz4gOBtKWyQNOG6VjZFMQurXTynJ8PAsL7vkTwdWyY1L4C8zM 2ris83xs55PZdpN9BN8KyPZqhO4sB9YrsFwSluqatLhCFd64yG0= =Xv0l -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging Improvements include: * Relaxed error code pattern on machine_m68k_nextcube.py * Better naming and separation of tests in x86_cpu_model_versions.py * New checks on guest side on linux_ssh_mips_malta.py * Use of avocado.utils.ssh, and thus "/usr/bin/ssh" for SSH interaction # gpg: Signature made Mon 23 Sep 2019 14:38:01 BST # gpg: using RSA key 7ABB96EB8B46B94D5E0FE9BB657E8D33A5F209F3 # gpg: Good signature from "Cleber Rosa <crosa@redhat.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 7ABB 96EB 8B46 B94D 5E0F E9BB 657E 8D33 A5F2 09F3 * remotes/cleber/tags/python-next-pull-request: Acceptance tests: use avocado.utils.ssh for SSH interaction tests/acceptance: Add new test cases in linux_ssh_mips_malta.py tests/acceptance: Refactor and improve reporting in linux_ssh_mips_malta.py Acceptance test x86_cpu_model_versions: split into smaller tests Acceptance test x86_cpu_model_versions: fix mismatches between test and messages Acceptance test x86_cpu_model_versions: shutdown VMs Acceptance test machine_m68k_nextcube.py: relax the error code pattern Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
8dc57281b8
@ -9,13 +9,13 @@ import os
|
||||
import re
|
||||
import base64
|
||||
import logging
|
||||
import paramiko
|
||||
import time
|
||||
|
||||
from avocado import skipUnless
|
||||
from avocado_qemu import Test
|
||||
from avocado.utils import process
|
||||
from avocado.utils import archive
|
||||
from avocado.utils import ssh
|
||||
|
||||
|
||||
class LinuxSSH(Test):
|
||||
@ -26,35 +26,19 @@ class LinuxSSH(Test):
|
||||
VM_IP = '127.0.0.1'
|
||||
|
||||
IMAGE_INFO = {
|
||||
'be': {
|
||||
'image_url': 'https://people.debian.org/~aurel32/qemu/mips/'
|
||||
'debian_wheezy_mips_standard.qcow2',
|
||||
'image_hash': '8987a63270df67345b2135a6b7a4885a35e392d5',
|
||||
'rsa_hostkey': b'AAAAB3NzaC1yc2EAAAADAQABAAABAQCca1VitiyLAdQOld'
|
||||
b'zT43IOEVJZ0wHD78GJi8wDAjMiYWUzNSSn0rXGQsINHuH5'
|
||||
b'IlF+kBZsHinb/FtKCAyS9a8uCHhQI4SuB4QhAb0+39MlUw'
|
||||
b'Mm0CLkctgM2eUUZ6MQMQvDlqnue6CCkxN62EZYbaxmby7j'
|
||||
b'CQa1125o1HRKBvdGm2zrJWxXAfA+f1v6jHLyE8Jnu83eQ+'
|
||||
b'BFY25G+Vzx1PVc3zQBwJ8r0NGTRqy2//oWQP0h+bMsgeFe'
|
||||
b'KH/J3RJM22vg6+I4JAdBFcxnK+l781h1FuRxOn4O/Xslbg'
|
||||
b'go6WtB4V4TOsw2E/KfxI5IZ/icxF+swVcnvF46Hf3uQc/0'
|
||||
b'BBqb',
|
||||
},
|
||||
'le': {
|
||||
'image_url': 'https://people.debian.org/~aurel32/qemu/mipsel/'
|
||||
'debian_wheezy_mipsel_standard.qcow2',
|
||||
'image_hash': '7866764d9de3ef536ffca24c9fb9f04ffdb45802',
|
||||
'rsa_hostkey': b'AAAAB3NzaC1yc2EAAAADAQABAAABAQClXJlBT71HL5yKvv'
|
||||
b'gfC7jmxSWx5zSBCzET6CLZczwAafSIs7YKfNOy/dQTxhuk'
|
||||
b'yIGFUugZFoF3E9PzdhunuyvyTd56MPoNIqFbb5rGokwU5I'
|
||||
b'TOx3dBHZR0mClypL6MVrwe0bsiIb8GhF1zioNwcsaAZnAi'
|
||||
b'KfXStVDtXvn/kLLq+xLABYt48CC5KYWoFaCoICskLAY+qo'
|
||||
b'L+LWyAnQisj4jAH8VSaSKIImFpfkHWEXPhHcC4ZBlDKtnH'
|
||||
b'po9vhfCHgnfW3Pzrqmk8BI4HysqPFVmJWkJGlGUL+sGeg3'
|
||||
b'ZZolAYuDXGuBrw8ooPJq2v2dOH+z6dyD2q/ypmAbyPqj5C'
|
||||
b'rc8H',
|
||||
},
|
||||
}
|
||||
'be': {'image_url': ('https://people.debian.org/~aurel32/qemu/mips/'
|
||||
'debian_wheezy_mips_standard.qcow2'),
|
||||
'image_hash': '8987a63270df67345b2135a6b7a4885a35e392d5'},
|
||||
'le': {'image_url': ('https://people.debian.org/~aurel32/qemu/mipsel/'
|
||||
'debian_wheezy_mipsel_standard.qcow2'),
|
||||
'image_hash': '7866764d9de3ef536ffca24c9fb9f04ffdb45802'}
|
||||
}
|
||||
|
||||
|
||||
@skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available')
|
||||
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
|
||||
def setUp(self):
|
||||
super(LinuxSSH, self).setUp()
|
||||
|
||||
def wait_for_console_pattern(self, success_message,
|
||||
failure_message='Oops'):
|
||||
@ -78,23 +62,14 @@ class LinuxSSH(Test):
|
||||
self.log.debug("sshd listening on port:" + port)
|
||||
return port
|
||||
|
||||
def ssh_connect(self, username, password, rsa_hostkey_b64=None):
|
||||
def ssh_connect(self, username, password):
|
||||
self.ssh_logger = logging.getLogger('ssh')
|
||||
self.ssh_username = username
|
||||
self.ssh_ps1 = '# ' if username is 'root' else '$ '
|
||||
self.ssh_client = paramiko.SSHClient()
|
||||
port = self.get_portfwd()
|
||||
if rsa_hostkey_b64:
|
||||
rsa_hostkey_bin = base64.b64decode(rsa_hostkey_b64)
|
||||
rsa_hostkey = paramiko.RSAKey(data = rsa_hostkey_bin)
|
||||
ipport = '[%s]:%s' % (self.VM_IP, port)
|
||||
self.ssh_logger.debug('ipport ' + ipport)
|
||||
self.ssh_client.get_host_keys().add(ipport, 'ssh-rsa', rsa_hostkey)
|
||||
self.ssh_session = ssh.Session(self.VM_IP, port=int(port),
|
||||
user=username, password=password)
|
||||
for i in range(10):
|
||||
try:
|
||||
self.ssh_client.connect(self.VM_IP, int(port),
|
||||
username, password, banner_timeout=90)
|
||||
self.ssh_logger.info("Entering interactive session.")
|
||||
self.ssh_session.connect()
|
||||
return
|
||||
except:
|
||||
time.sleep(4)
|
||||
@ -102,15 +77,15 @@ class LinuxSSH(Test):
|
||||
self.fail("sshd timeout")
|
||||
|
||||
def ssh_disconnect_vm(self):
|
||||
self.ssh_client.close()
|
||||
self.ssh_session.quit()
|
||||
|
||||
def ssh_command(self, command, is_root=True):
|
||||
self.ssh_logger.info(self.ssh_ps1 + command)
|
||||
stdin, stdout, stderr = self.ssh_client.exec_command(command)
|
||||
stdout_lines = [line.strip('\n') for line in stdout]
|
||||
self.ssh_logger.info(command)
|
||||
result = self.ssh_session.cmd(command)
|
||||
stdout_lines = [line.rstrip() for line in result.stdout_text.splitlines()]
|
||||
for line in stdout_lines:
|
||||
self.ssh_logger.info(line)
|
||||
stderr_lines = [line.strip('\n') for line in stderr]
|
||||
stderr_lines = [line.rstrip() for line in result.stderr_text.splitlines()]
|
||||
for line in stderr_lines:
|
||||
self.ssh_logger.warning(line)
|
||||
return stdout_lines, stderr_lines
|
||||
@ -119,7 +94,6 @@ class LinuxSSH(Test):
|
||||
image_url = self.IMAGE_INFO[endianess]['image_url']
|
||||
image_hash = self.IMAGE_INFO[endianess]['image_hash']
|
||||
image_path = self.fetch_asset(image_url, asset_hash=image_hash)
|
||||
rsa_hostkey_b64 = self.IMAGE_INFO[endianess]['rsa_hostkey']
|
||||
|
||||
self.vm.set_machine('malta')
|
||||
self.vm.set_console()
|
||||
@ -138,40 +112,90 @@ class LinuxSSH(Test):
|
||||
self.wait_for_console_pattern(console_pattern)
|
||||
self.log.info('sshd ready')
|
||||
|
||||
self.ssh_connect('root', 'root', rsa_hostkey_b64=rsa_hostkey_b64)
|
||||
self.ssh_connect('root', 'root')
|
||||
|
||||
def shutdown_via_ssh(self):
|
||||
self.ssh_command('poweroff')
|
||||
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(
|
||||
'cat /proc/cpuinfo',
|
||||
'24Kc')
|
||||
self.ssh_command_output_contains(
|
||||
'uname -m',
|
||||
'mips')
|
||||
self.ssh_command_output_contains(
|
||||
'uname -r',
|
||||
'3.2.0-4-4kc-malta')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'timer')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'i8042')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'serial')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'ata_piix')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'eth0')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/interrupts',
|
||||
'eth0')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/devices',
|
||||
'input')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/devices',
|
||||
'usb')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/devices',
|
||||
'fb')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/ioports',
|
||||
'serial')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/ioports',
|
||||
'ata_piix')
|
||||
self.ssh_command_output_contains(
|
||||
'cat /proc/ioports',
|
||||
'piix4_smbus')
|
||||
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()
|
||||
self.shutdown_via_ssh()
|
||||
|
||||
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
|
||||
def test_mips_malta32eb_kernel3_2_0(self):
|
||||
"""
|
||||
:avocado: tags=arch:mips
|
||||
@ -186,7 +210,6 @@ class LinuxSSH(Test):
|
||||
|
||||
self.check_mips_malta('be', kernel_path, 'mips')
|
||||
|
||||
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
|
||||
def test_mips_malta32el_kernel3_2_0(self):
|
||||
"""
|
||||
:avocado: tags=arch:mipsel
|
||||
@ -201,7 +224,6 @@ class LinuxSSH(Test):
|
||||
|
||||
self.check_mips_malta('le', kernel_path, 'mips')
|
||||
|
||||
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
|
||||
def test_mips_malta64eb_kernel3_2_0(self):
|
||||
"""
|
||||
:avocado: tags=arch:mips64
|
||||
@ -215,7 +237,6 @@ class LinuxSSH(Test):
|
||||
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
|
||||
self.check_mips_malta('be', kernel_path, 'mips64')
|
||||
|
||||
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
|
||||
def test_mips_malta64el_kernel3_2_0(self):
|
||||
"""
|
||||
:avocado: tags=arch:mips64el
|
||||
|
@ -116,6 +116,6 @@ class NextCubeMachine(Test):
|
||||
if len(line):
|
||||
console_logger.debug(line)
|
||||
self.assertIn('Testing the FPU, SCC', text)
|
||||
self.assertIn('System test failed. Error code 51', text)
|
||||
self.assertIn('System test failed. Error code', text)
|
||||
self.assertIn('Boot command', text)
|
||||
self.assertIn('Next>', text)
|
||||
|
@ -234,7 +234,14 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
|
||||
self.validate_aliases(cpus)
|
||||
|
||||
def test_Cascadelake_arch_capabilities_result(self):
|
||||
|
||||
class CascadelakeArchCapabilities(avocado_qemu.Test):
|
||||
"""
|
||||
Validation of Cascadelake arch-capabilities
|
||||
|
||||
:avocado: tags=arch:x86_64
|
||||
"""
|
||||
def test_4_1(self):
|
||||
# machine-type only:
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
@ -244,6 +251,7 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.1 + Cascadelake-Server should not have arch-capabilities')
|
||||
|
||||
def test_4_0(self):
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
vm.set_machine('pc-i440fx-4.0')
|
||||
@ -252,6 +260,7 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.0 + Cascadelake-Server should not have arch-capabilities')
|
||||
|
||||
def test_set_4_0(self):
|
||||
# command line must override machine-type if CPU model is not versioned:
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
@ -261,6 +270,7 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabilities should have arch-capabilities')
|
||||
|
||||
def test_unset_4_1(self):
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
vm.set_machine('pc-i440fx-4.1')
|
||||
@ -269,6 +279,7 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabilities should not have arch-capabilities')
|
||||
|
||||
def test_v1_4_0(self):
|
||||
# versioned CPU model overrides machine-type:
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
@ -276,25 +287,28 @@ class X86CPUModelAliases(avocado_qemu.Test):
|
||||
vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off')
|
||||
vm.launch()
|
||||
self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.1 + Cascadelake-Server-v1 should not have arch-capabilities')
|
||||
'pc-i440fx-4.0 + Cascadelake-Server-v1 should not have arch-capabilities')
|
||||
|
||||
def test_v2_4_0(self):
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
vm.set_machine('pc-i440fx-4.0')
|
||||
vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=on,check=off,enforce=off')
|
||||
vm.launch()
|
||||
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.1 + Cascadelake-Server-v1 should have arch-capabilities')
|
||||
'pc-i440fx-4.0 + Cascadelake-Server-v2 should have arch-capabilities')
|
||||
|
||||
def test_v1_set_4_0(self):
|
||||
# command line must override machine-type and versioned CPU model:
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
vm.set_machine('pc-i440fx-4.0')
|
||||
vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=on,check=off,enforce=off,+arch-capabilities')
|
||||
vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=on,check=off,enforce=off,+arch-capabilities')
|
||||
vm.launch()
|
||||
self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'),
|
||||
'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capabilities should have arch-capabilities')
|
||||
|
||||
def test_v2_unset_4_1(self):
|
||||
vm = self.get_vm()
|
||||
vm.add_args('-S')
|
||||
vm.set_machine('pc-i440fx-4.1')
|
||||
|
@ -1,5 +1,4 @@
|
||||
# Add Python module requirements, one per line, to be installed
|
||||
# in the tests/venv Python virtual environment. For more info,
|
||||
# refer to: https://pip.pypa.io/en/stable/user_guide/#id1
|
||||
avocado-framework==68.0
|
||||
paramiko==2.4.2
|
||||
avocado-framework==72.0
|
||||
|
Loading…
Reference in New Issue
Block a user