[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [test-API PATCH 2/4] cfgcheck: new class implement testcase config file checking



On 04/12/2012 07:38 PM, Martin Kletzander wrote:
On 04/11/2012 04:04 PM, Guannan Ren wrote:
     casecfgcheck.py
---
  casecfgcheck.py |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 66 insertions(+), 0 deletions(-)
  create mode 100644 casecfgcheck.py

diff --git a/casecfgcheck.py b/casecfgcheck.py
new file mode 100644
index 0000000..3c4696d
--- /dev/null
+++ b/casecfgcheck.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc.
+#
+# libvirt-test-API is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version. This program is distributed in
+# the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+# even the implied warranties of TITLE, NON-INFRINGEMENT,
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# The GPL text is available in the file COPYING that accompanies this
+# distribution and at<http://www.gnu.org/licenses>.
+#
+
+import proxy
+
+class CaseCfgCheck(object):
+    """validate the options in testcase config file"""
+    def __init__(self, unique_testcases, activities_list):
+        self.unique_testcases = unique_testcases
+
+        # XXX to check the first testcase list in activities_list
+        self.activitie = activities_list[0]
+
+        proxy_obj = proxy.Proxy(self.unique_testcases)
+        self.case_params = proxy_obj.get_params_variables()
typo:
s/activitie/activity/

plus I'm not sure if we can be sure that all the activities are the same
in this call (if it's just a multiplication of one array)? On other
places (like 'libvirt-test-api.py') we check for all members in the array.

+
+    def check(self):
+        """check options to each testcase in case config file"""
+        case_number = 0
+        error_flag = 0
+        passed_testcase = []
+        for testcase in self.activitie:
second typo or copy paste error :)
s/activitie/activity/

       Thanks,  it is fixed and pushed.

+            case_number += 1
+            if testcase in passed_testcase:
+                continue
+
+            testcase_name = testcase.keys()[0]
+            actual_params = testcase.values()[0]
I don't quite understand what are you trying to achieve here. The order
of keys and values in python dict cannot be guaranteed if I'm not wrong.
And even if yes, that would mean you are checking just for the first
testcase, I guess. Or maybe I just don't get this right.


If time is permitted, please run "python parser.py testcase.cfg"
             It will output the data format after parsing.
             example:  run it using the command above.
                    #testcase.cfg
                    domain:testa
                        guestname
                            fedora16

The data format is: [[{'domain:testa': {'guestname': 'fedora16'}}]] The variable "testcase" refer to "{'domain:testa': {'guestname': 'fedora16'}" The variable "activity" refet to [{'domain:testa': {'guestname': 'fedora16'}]
             Note: the code just to check the first inner list here.

then, we use 'testcase_name'(domain:testa) as the key to fetch two
             global variable that defined in testa.py
one is "required_params", the other is "optional_params", then compare them
             with "actual_params" by invoking _check_params(...)

Tips: the proxy.py will place the two references to the global params in a data format like {'domain:testa':[required_params, optional_params]}

             Guannan Ren






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]