Message ID | f94eada132769b28f470ebc1a1acc20fe080b6b9.1248102188.git.mgoldish@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jul 20, 2009 at 12:07 PM, Michael Goldish<mgoldish@redhat.com> 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. Applied. > 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 > @@ -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: > -- > 1.5.4.1 > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >
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(-)