Message ID | ec71b9e574fac8a7d2e4d6e98ad135d7f312e789.1245094830.git.mgoldish@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/15/2009 10:45 PM, Michael Goldish wrote: > Currently parameters for barrier_2() are extracted from 'params' in the main > run_steps() test routine, and then passed to barrier_2(). > Instead, let barrier_2() extract parameters from 'params' as it sees fit. > This will make adding new parameters slightly easier and cleaner. > > Signed-off-by: Michael Goldish<mgoldish@redhat.com> > --- > client/tests/kvm/kvm_guest_wizard.py | 37 ++++++++++++++++----------------- > 1 files changed, 18 insertions(+), 19 deletions(-) > > diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py > index 143e61e..eb0e2d5 100644 > --- a/client/tests/kvm/kvm_guest_wizard.py > +++ b/client/tests/kvm/kvm_guest_wizard.py > @@ -41,6 +41,18 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, > "cropped_scrdump_expected.ppm") > comparison_filename = os.path.join(debug_dir, "comparison.ppm") > > + fail_if_stuck_for = params.get("fail_if_stuck_for") > + if fail_if_stuck_for: > + fail_if_stuck_for = float(fail_if_stuck_for) > + else: > + fail_if_stuck_for = 1e308 > + > + stuck_detection_history = params.get("stuck_detection_history") > + if stuck_detection_history: > + stuck_detection_history = int(stuck_detection_history) > + else: > + stuck_detection_history = 2 > + Could be simplified by (preferably in a separate patch): fail_if_stuck_for = params.get("fail_if_stuck_for", 1e308) fail_if_stuck_for = float(fail_if_stuck_for) stuck_detection_history = params.get("stuck_detection_history", 2) stuck_detection_history = int(stuck_detection_history) or even with a single line for each param: var = cast(params.get(var_name, default_value)) Regards, Uri -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index 143e61e..eb0e2d5 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -17,8 +17,8 @@ def handle_var(vm, params, varname): return True -def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, - debug_dir, data_scrdump_filename, current_step_num): +def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, + current_step_num): if len(words) < 7: logging.error("Bad barrier_2 command line") return False @@ -41,6 +41,18 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history, "cropped_scrdump_expected.ppm") comparison_filename = os.path.join(debug_dir, "comparison.ppm") + fail_if_stuck_for = params.get("fail_if_stuck_for") + if fail_if_stuck_for: + fail_if_stuck_for = float(fail_if_stuck_for) + else: + fail_if_stuck_for = 1e308 + + stuck_detection_history = params.get("stuck_detection_history") + if stuck_detection_history: + stuck_detection_history = int(stuck_detection_history) + else: + stuck_detection_history = 2 + end_time = time.time() + timeout end_time_stuck = time.time() + fail_if_stuck_for start_time = time.time() @@ -151,18 +163,6 @@ def run_steps(test, params, env): if not os.path.exists(steps_filename): raise error.TestError("Steps file not found: %s" % steps_filename) - fail_if_stuck_for = params.get("fail_if_stuck_for") - if fail_if_stuck_for: - fail_if_stuck_for = float(fail_if_stuck_for) - else: - fail_if_stuck_for = 1e308 - - stuck_detection_history = params.get("stuck_detection_history") - if stuck_detection_history: - stuck_detection_history = int(stuck_detection_history) - else: - stuck_detection_history = 2 - sf = open(steps_filename, "r") lines = sf.readlines() sf.close() @@ -201,13 +201,12 @@ def run_steps(test, params, env): logging.error("Variable not defined: %s" % words[1]) elif words[0] == "barrier_2": if current_screendump: - scrdump_filename = ( - os.path.join(ppm_utils.get_data_dir(steps_filename), - current_screendump)) + scrdump_filename = os.path.join( + ppm_utils.get_data_dir(steps_filename), + current_screendump) else: scrdump_filename = None - if not barrier_2(vm, words, fail_if_stuck_for, - stuck_detection_history, test.debugdir, + if not barrier_2(vm, words, params, test.debugdir, scrdump_filename, current_step_num): skip_current_step = True else:
Currently parameters for barrier_2() are extracted from 'params' in the main run_steps() test routine, and then passed to barrier_2(). Instead, let barrier_2() extract parameters from 'params' as it sees fit. This will make adding new parameters slightly easier and cleaner. Signed-off-by: Michael Goldish <mgoldish@redhat.com> --- client/tests/kvm/kvm_guest_wizard.py | 37 ++++++++++++++++----------------- 1 files changed, 18 insertions(+), 19 deletions(-)