Code review comment for lp:~le-chi-thu/linaro-ci/add-testplan-support

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

Your changes fail when we pass LAVA_TEST_PLAN="test_abc(option_abc):100, test_bcd":
python ./get_latest_ci_hwpack
Traceback (most recent call last):
  File "./get_latest_ci_hwpack", line 94, in <module>
    lava_test_install_command["parameters"]["tests"].append(r.group("testcase"))
AttributeError: 'NoneType' object has no attribute 'group'

The following changes fix the above problem and includes other changes like aligning to 80 columns rule.
=== modified file 'get_latest_ci_hwpack'
--- get_latest_ci_hwpack 2012-05-09 12:01:28 +0000
+++ get_latest_ci_hwpack 2012-05-14 08:49:26 +0000
@@ -16,7 +16,7 @@
 job_name = os.getenv("KERNEL_JOB_NAME", "unknown") + '_' + \
            os.getenv("HWPACK_BUILD_DATE", "unknown") + '_daily test'

-testplan = os.getenv("LAVA_TEST_PLAN", "ltp,pwrmgmt")
+testplan = os.getenv("LAVA_TEST_PLAN", "ltp, pwrmgmt")

 template = {
   "timeout": 20000,
@@ -66,50 +66,48 @@
 metadata['kernel.git_log_info'] = os.getenv("GIT_LOG", "unknown")
 metadata['hwpack.type'] = hwpacktype
 metadata['hwpack.date'] = hwpackdate
-
-
 rootfsdate, rootfsbuild = rootfs_id.split('.')
 metadata['rootfs.type'] = imagetype
 metadata['rootfs.date'] = rootfsdate
 metadata['rootfs.build'] = rootfsbuild
-
 template['actions'][0]['metadata'] = metadata

 testcases = testplan.split(',')
-
-regex = re.compile("(?P<testcase>^\w+)(\((?P<options>[^\)]+)\))?(:(?P<timeout>\d+))?")
-
-# lava_test_install command
-
+testcases = [tc.strip() for tc in testplan.split(',')]
+regex = re.compile("(?P<testcase>^\w+)(\((?P<options>[^\)]+)\))?"\
+ "(:(?P<timeout>\d+))?")
+
+# Dict for lava_test_install
 lava_test_install_command = {}
 lava_test_install_command["command"] = "lava_test_install"
 lava_test_install_command["parameters"] = { "tests" : [], "timeout" : 4000 }

-# where in the template dict we shall insert test commands
+# The positions in the template dict to insert test install/run commands
 install_cmd_pos = 1
 run_cmd_pos = 2

 for testcase in testcases:
     r = regex.search(testcase)
- lava_test_install_command["parameters"]["tests"].append(r.group("testcase"))
-
- # append lava_test_run commands
- timeout = 4800
- if r.group('timeout'):
- timeout = r.group('timeout')
-
- lava_test_run_command = {}
- lava_test_run_command["command"] = "lava_test_run"
- lava_test_run_command["parameters"] = { "test_name" : r.group('testcase'),
- "timeout" : timeout }
-
- if r.group("options"):
- lava_test_run_command["parameters"]["test_options"] = r.group("options")
-
- template['actions'].insert(run_cmd_pos, lava_test_run_command)
- run_cmd_pos = run_cmd_pos + 1
+ if r.group("testcase") != None:
+ lava_test_install_command["parameters"]["tests"].\
+ append(r.group("testcase"))
+
+ # append lava_test_run commands
+ timeout = 4800
+ if r.group('timeout'):
+ timeout = r.group('timeout')
+
+ lava_test_run_command = {}
+ lava_test_run_command["command"] = "lava_test_run"
+ lava_test_run_command["parameters"] = {"test_name" : r.group('testcase'),
+ "timeout" : timeout }
+
+ if r.group("options"):
+ lava_test_run_command["parameters"]["test_options"] = r.group("options")
+
+ template['actions'].insert(run_cmd_pos, lava_test_run_command)
+ run_cmd_pos = run_cmd_pos + 1

 # append the lava test install command
 template['actions'].insert(install_cmd_pos, lava_test_install_command)
-
 print json.dumps(template, indent=2)

review: Needs Fixing

« Back to merge proposal