Skip to contentSkip to conversation

KVM test: use the new Params methods instead of get_sub_dict_.*()

PATCH New Lucas Meneghel Rodrigues 1 participant 1 message Dec 29, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 KVM test: use the new Params methods instead of get_sub_dict_.*()

Changes from v1:
- Resolved small rebase conflict

---
 client/tests/kvm/kvm_preprocessing.py              |   14 ++---
 client/tests/kvm/kvm_vm.py                         |   58 ++++++++++----------
 client/tests/kvm/tests/pci_hotplug.py              |    4 +-
 client/tests/kvm/tests/physical_resources_check.py |    8 ++--
 client/tests/kvm/tests/unittest.py                 |    4 +-
 client/tests/kvm/tests/whql_submission.py          |   26 +++++-----
 6 files changed, 55 insertions(+), 59 deletions(-)
client/tests/kvm/kvm_preprocessing.py +6 -8
index 90382cc..25c4e5f 100644
@@ -183,13 +183,11 @@ def process(test, params, env, image_func, vm_func):
     @param vm_func: A function to call for each VM.
     """
     # Get list of VMs specified for this test
-    vm_names = kvm_utils.get_sub_dict_names(params, "vms")
-    for vm_name in vm_names:
-        vm_params = kvm_utils.get_sub_dict(params, vm_name)
+    for vm_name in params.objects("vms"):
+        vm_params = params.object_params(vm_name)
         # Get list of images specified for this VM
-        image_names = kvm_utils.get_sub_dict_names(vm_params, "images")
-        for image_name in image_names:
-            image_params = kvm_utils.get_sub_dict(vm_params, image_name)
+        for image_name in vm_params.objects("images"):
+            image_params = vm_params.object_params(image_name)
             # Call image_func for each image
             image_func(test, image_params)
         # Call vm_func for each vm
@@ -226,7 +224,7 @@ def preprocess(test, params, env):
                 env["tcpdump"].get_output()))
 
     # Destroy and remove VMs that are no longer needed in the environment
-    requested_vms = kvm_utils.get_sub_dict_names(params, "vms")
+    requested_vms = params.objects("vms")
     for key in env.keys():
         vm = env[key]
         if not kvm_utils.is_vm(vm):
@@ -372,7 +370,7 @@ def postprocess_on_error(test, params, env):
     @param params: A dict containing all VM and image parameters.
     @param env: The environment (a dict-like object).
     """
-    params.update(kvm_utils.get_sub_dict(params, "on_error"))
+    params.update(params.object_params("on_error"))
 
 
 def _update_address_cache(address_cache, line):
client/tests/kvm/kvm_vm.py +28 -30

152 lines not on this page · raw message

client/tests/kvm/tests/pci_hotplug.py +2 -2
index 727ee62..27b81de 100644
@@ -51,7 +51,7 @@ def run_pci_hotplug(test, params, env):
         if test_type == "nic":
             pci_add_cmd = "pci_add pci_addr=auto nic model=%s" % tested_model
         elif test_type == "block":
-            image_params = kvm_utils.get_sub_dict(params, "stg")
+            image_params = params.object_params("stg")
             image_filename = kvm_vm.get_image_filename(image_params,
                                                        test.bindir)
             pci_add_cmd = ("pci_add pci_addr=auto storage file=%s,if=%s" %
@@ -73,7 +73,7 @@ def run_pci_hotplug(test, params, env):
             pci_add_cmd = "device_add id=%s,driver=%s" % (id, tested_model)
 
         elif test_type == "block":
-            image_params = kvm_utils.get_sub_dict(params, "stg")
+            image_params = params.object_params("stg")
             image_filename = kvm_vm.get_image_filename(image_params,
                                                        test.bindir)
             if tested_model == "virtio":
client/tests/kvm/tests/physical_resources_check.py +4 -4
index 0630ac8..3234da7 100644
@@ -51,7 +51,7 @@ def run_physical_resources_check(test, params, env):
     # Define a function for checking number of hard drivers & NICs
     def check_num(devices, info_cmd, check_str):
         f_fail = 0
-        expected_num = kvm_utils.get_sub_dict_names(params, devices).__len__()
+        expected_num = params.objects(devices).__len__()
         try:
             o = vm.monitor.info(info_cmd)
         except kvm_monitor.MonitorError, e:
@@ -78,9 +78,9 @@ def run_physical_resources_check(test, params, env):
     # Define a function for checking hard drives & NICs' model
     def chk_fmt_model(device, fmt_model, info_cmd, str):
         f_fail = 0
-        devices = kvm_utils.get_sub_dict_names(params, device)
+        devices = params.objects(device)
         for chk_device in devices:
-            expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model)
+            expected = params.object_params(chk_device).get(fmt_model)
             if not expected:
                 expected = "rtl8139"
             try:
@@ -123,7 +123,7 @@ def run_physical_resources_check(test, params, env):
     found_mac_addresses = re.findall("macaddr=(\S+)", o)
     logging.debug("Found MAC adresses: %s" % found_mac_addresses)
 
-    num_nics = len(kvm_utils.get_sub_dict_names(params, "nics"))
+    num_nics = len(params.objects("nics"))
     for nic_index in range(num_nics):
         mac = vm.get_mac_address(nic_index)
         if not string.lower(mac) in found_mac_addresses:
client/tests/kvm/tests/unittest.py +2 -2
index 54e5f73..67686e3 100644
@@ -36,8 +36,8 @@ def run_unittest(test, params, env):
                               unittest_cfg)
     logging.debug('Unit test list: %s' % test_list)
 
-    if params.get('test_list', None):
-        test_list = kvm_utils.get_sub_dict_names(params, 'test_list')
+    if params.get('test_list'):
+        test_list = params.get('test_list').split()
         logging.info('Original test list overriden by user')
         logging.info('User defined unit test list: %s' % test_list)
 
client/tests/kvm/tests/whql_submission.py +13 -13
index e40e369..2a108ac 100644
@@ -21,7 +21,7 @@ def run_whql_submission(test, params, env):
     # Log into all client VMs
     vms = []
     sessions = []
-    for vm_name in kvm_utils.get_sub_dict_names(params, "vms"):
+    for vm_name in params.objects("vms"):
         vms.append(kvm_test_utils.get_living_vm(env, vm_name))
         sessions.append(kvm_test_utils.wait_for_login(vms[-1], 0, 240))
 
@@ -108,8 +108,8 @@ def run_whql_submission(test, params, env):
 
     # Set submission DeviceData
     find_prompt("DeviceData name:")
-    for dd in kvm_utils.get_sub_dict_names(params, "device_data"):
-        dd_params = kvm_utils.get_sub_dict(params, dd)
+    for dd in params.objects("device_data"):
+        dd_params = params.object_params(dd)
         if dd_params.get("dd_name") and dd_params.get("dd_data"):
             server_session.sendline(dd_params.get("dd_name"))
             server_session.sendline(dd_params.get("dd_data"))
@@ -117,29 +117,29 @@ def run_whql_submission(test, params, env):
 
     # Set submission descriptors
     find_prompt("Descriptor path:")
-    for desc in kvm_utils.get_sub_dict_names(params, "descriptors"):
-        desc_params = kvm_utils.get_sub_dict(params, desc)
+    for desc in params.objects("descriptors"):
+        desc_params = params.object_params(desc)
         if desc_params.get("desc_path"):
             server_session.sendline(desc_params.get("desc_path"))
     server_session.sendline()
 
     # Set machine dimensions for each client machine
-    for vm_name in kvm_utils.get_sub_dict_names(params, "vms"):
-        vm_params = kvm_utils.get_sub_dict(params, vm_name)
+    for vm_name in params.objects("vms"):
+        vm_params = params.object_params(vm_name)
         find_prompt(r"Dimension name\b.*:")
-        for dp in kvm_utils.get_sub_dict_names(vm_params, "dimensions"):
-            dp_params = kvm_utils.get_sub_dict(vm_params, dp)
+        for dp in vm_params.objects("dimensions"):
+            dp_params = vm_params.object_params(dp)
             if dp_params.get("dim_name") and dp_params.get("dim_value"):
                 server_session.sendline(dp_params.get("dim_name"))
                 server_session.sendline(dp_params.get("dim_value"))
         server_session.sendline()
 
     # Set extra parameters for tests that require them (e.g. NDISTest)
-    for vm_name in kvm_utils.get_sub_dict_names(params, "vms"):
-        vm_params = kvm_utils.get_sub_dict(params, vm_name)
+    for vm_name in params.objects("vms"):
+        vm_params = params.object_params(vm_name)
         find_prompt(r"Parameter name\b.*:")
-        for dp in kvm_utils.get_sub_dict_names(vm_params, "device_params"):
-            dp_params = kvm_utils.get_sub_dict(vm_params, dp)
+        for dp in vm_params.objects("device_params"):
+            dp_params = vm_params.object_params(dp)
             if dp_params.get("dp_name") and dp_params.get("dp_regex"):
                 server_session.sendline(dp_params.get("dp_name"))
                 server_session.sendline(dp_params.get("dp_regex"))
Signature · 1 line
1.7.2.3