From patchwork Tue Jul 5 18:07:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 945932 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p65I7mdq021019 for ; Tue, 5 Jul 2011 18:07:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509Ab1GESHq (ORCPT ); Tue, 5 Jul 2011 14:07:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31688 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859Ab1GESHp (ORCPT ); Tue, 5 Jul 2011 14:07:45 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p65I7fnf013389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Jul 2011 14:07:42 -0400 Received: from freedom.redhat.com (vpn-8-95.rdu.redhat.com [10.11.8.95]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p65I7dQZ000423; Tue, 5 Jul 2011 14:07:40 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, pradeep Subject: [PATCH] KVM test: Add subtest smbios_table Date: Tue, 5 Jul 2011 15:07:38 -0300 Message-Id: <1309889258-21833-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 05 Jul 2011 18:07:49 +0000 (UTC) From: pradeep Check smbios table : 1) Boot a guest with smbios options 2) verify if host bios options have been emulated, that is, the vendor, date and version options returned by dmidecode are the same on host and on guest. Signed-off-by: Pradeep Kumar Surisetty --- client/tests/kvm/tests/smbios_table.py | 67 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 5 ++ 2 files changed, 72 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/smbios_table.py diff --git a/client/tests/kvm/tests/smbios_table.py b/client/tests/kvm/tests/smbios_table.py new file mode 100644 index 0000000..5d5a1ad --- /dev/null +++ b/client/tests/kvm/tests/smbios_table.py @@ -0,0 +1,67 @@ +import commands, logging +from autotest_lib.client.common_lib import utils, error +from autotest_lib.client.virt import virt_env_process, virt_test_utils + + +@error.context_aware +def run_smbios_table(test, params, env): + """ + Check smbios table : + 1) Boot a guest with smbios options + 2) verify if host bios options have been emulated + + @param test: KVM test object. + @param params: Dictionary with the test parameters. + @param env: Dictionary with test environment. + """ + vendor_cmd = "dmidecode --type 0 | grep Vendor | awk '{print $2}'" + date_cmd = "dmidecode --type 0 | grep Date | awk '{print $3}'" + version_cmd = "dmidecode --type 0 | grep Version | awk '{print $2}'" + + error.context("getting smbios table on host") + host_vendor = utils.system_output(vendor_cmd) + host_date = utils.system_output(date_cmd) + host_version = utils.system_output(version_cmd) + + smbios = (" -smbios type=0,vendor=%s,version=%s,date=%s" % + (host_vendor, host_version, host_date)) + + extra_params = params.get("extra_params", "") + params["extra_params"] = extra_params + smbios + + logging.debug("Booting guest %s", params.get("main_vm")) + virt_env_process.preprocess_vm(test, params, env, params.get("main_vm")) + vm = env.get_vm(params["main_vm"]) + vm.create() + login_timeout = float(params.get("login_timeout", 360)) + session = vm.wait_for_login(timeout=login_timeout) + + error.context("getting smbios table on guest") + guest_vendor = session.cmd(vendor_cmd).strip() + guest_date = session.cmd(date_cmd).strip() + guest_version = session.cmd(version_cmd).strip() + + failures = [] + + if host_vendor != guest_vendor: + e_msg = ("Vendor str mismatch -> host: %s guest: %s" % + (guest_vendor, host_vendor)) + logging.error(e_msg) + failures.append(e_msg) + + if host_date != guest_date: + e_msg = ("Date str mismatch -> host: %s guest: %s" % + (guest_date, host_date)) + logging.error(e_msg) + failures.append(e_msg) + + if host_version != guest_version: + e_msg = ("Version str mismatch -> host: %s guest: %s" % + (guest_version, host_version)) + logging.error(e_msg) + failures.append(e_msg) + + error.context("") + if failures: + raise error.TestFail("smbios table test reported %s failures:\n%s" % + (len(failures), "\n".join(failures))) diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 1a86265..a1f1ef0 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -416,6 +416,11 @@ variants: extra_params += " -watchdog i6300esb -watchdog-action reset" relogin_timeout = 240 + - smbios_table: install setup image_copy unattended_install.cdrom + only Linux + type = smbios_table + start_vm = no + - stress_boot: install setup image_copy unattended_install.cdrom type = stress_boot max_vms = 5