>>You can avoid to repeat commands by writing a function that: >>a) Executes command on host and stores result >>b) Executes command on guest, stores result >>c) compares them, and returns pass/fail >>Then you can go through this list of 3 commands. It's important to not >>fail the test away on just one failure, go through the 3 commands and >>only fail the test after we went through all of them. It'll fix the last >>remark
Thanks lucas for your comments. i made changes as per your suggestion. Initially i had plans to do write a function to get both guest and host dmidecode details, and compare. But we needed host details earlier to boot up my guest. So i had to split. >From 4091bb2aac6aa34989adc454fd7e9e851199caf7 Mon Sep 17 00:00:00 2001 From: pradeep <[email protected]> Date: Tue, 5 Jul 2011 12:33:39 +0530 Subject: [PATCH] [AUTOTEST][KVM]: verifying smbios table for guest Signed-off-by: pradeep <[email protected]> new file: client/tests/kvm/tests/smbios_table.py modified: client/tests/kvm/tests_base.cfg.sample --- client/tests/kvm/tests/smbios_table.py | 63 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample | 5 +++ 2 files changed, 68 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..8e7ea36 --- /dev/null +++ b/client/tests/kvm/tests/smbios_table.py @@ -0,0 +1,63 @@ +import commands, logging +from autotest_lib.client.common_lib import utils, error +from autotest_lib.client.virt import virt_env_process, virt_test_utils + [email protected]_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. + """ + + error.context("getting smbios table") + vendor = utils.system_output("dmidecode --type 0 | grep Vendor | awk '{print $2}'") + date = utils.system_output("dmidecode --type 0 | grep Date | awk '{print $3}'") + version = utils.system_output("dmidecode --type 0 | grep Version | awk '{print $2}'") + + def boot_with_smbios(params): + """ + boot guest with host bios options + """ + fail = 0 + params['extra_params'] = standard_extra_params + params['extra_params'] += ("-smbios type=0,vendor=%s,version=%s,date=%s" % (vendor, version, date)) + + 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"]) + login_timeout = float(params.get("login_timeout", 360)) + session = vm.wait_for_login( timeout=login_timeout) + + guest_vendor = session.cmd("dmidecode --type 0 | grep Vendor | awk '{print $2}'") + guest_date = session.cmd("dmidecode --type 0 | grep Date | awk '{print $3}'") + guest_version = session.cmd("dmidecode --type 0 | grep Version | awk '{print $2}'") + + if vendor != guest_vendor.strip(): + logging.info("Vendor is not matching") + fail += 1 + + if date != guest_date.strip(): + logging.info("Date is not matching") + fail += 1 + + if version != guest_version.strip(): + logging.info("Version is not matching") + fail += 1 + + error.context("Verifying for failures of smbios_table test") + if fail != 0: + logging.info("smbios_table test failed") + + + # INITIALIZE + if "extra_params" in params: + standard_extra_params = params['extra_params'] + else: + standard_extra_params = "" + + boot_with_smbios(params) 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 -- 1.7.0.4 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
