From: Carl E. L. <ce...@li...> - 2012-10-05 16:52:08
|
Oprofile testsuite, fix proc op_daemon_delete_any_samples, it doesn't work correctly The op_daemon_delete_any_samples procedure is not correctly deleting samples. This patch replaces the body of the procedure with the "opcontrol --reset" call to remove the existing samples. The patch also moves the function to lib/op_util.exp so it can be called by the operf testsuite as well. A call to op_daemon_delete_any_samples was added to the operf test main routine to make sure any opcontrol samples are deleted so opreport will not pickup any samples from a previous opcontrol run. Signed-off-by: Carl Love <ce...@us...> --- testsuite/lib/op_util.exp | 16 +++++++++++++ .../oprofile-opcontrol/oprofile-opcontrol-run.exp | 27 ++-------------------- testsuite/oprofile-operf/oprofile-operf-run.exp | 4 ++++ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/testsuite/lib/op_util.exp b/testsuite/lib/op_util.exp index 8679896..6a74b3a 100644 --- a/testsuite/lib/op_util.exp +++ b/testsuite/lib/op_util.exp @@ -21,6 +21,11 @@ set op_proc_prefix "/dev/oprofile" set op_var_prefix "/var/lib/oprofile" +proc found_error {msg} { + print "ERROR: $msg" + opcontrol_exit + exit 1 +} # read contents of file and return proc op_get_file_contents {fname} { @@ -46,6 +51,17 @@ proc op_spin {count} { local_exec "dd bs=16 if=/dev/urandom of=/dev/null count=$count" "" "" 10 } +proc op_daemon_delete_any_samples {} { + set cmd "opcontrol --reset" + set result [local_exec $cmd "" "" 100] + + if {[lindex $result 0] == 0} { + verbose "OProfile reset successfully deleted all samples" + } else { + found_error "OProfile --reset FAILED" + } +} + # If the processor is i386/arch_perfmon, it could be a variant. proc op_intel_perf_arch {cpu_type} { if {[regexp "i386/arch_perfmon" $cpu_type dummy] != 1} { diff --git a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp index 42caa65..935ca46 100644 --- a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp +++ b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp @@ -42,29 +42,6 @@ proc op_daemon_flush {} { } } -proc op_daemon_delete_any_samples {ctrs} { - - global op_var_prefix - foreach ctr $ctrs { - set n [lindex $ctr 0] - foreach f [glob -nocomplain -types f "$op_var_prefix/samples/*#$n"] { - if {[catch "file delete $f" err]} { - verbose "could not delete $f ($err)" - } else { - verbose "deleted $f" - } - } - } - - foreach sess [glob -nocomplain -types d "$op_var_prefix/samples/session-*"] { - if {[catch "file delete -force $sess" err]} { - verbose "could not delete session $sess ($err)" - } else { - verbose "deleted $sess" - } - } -} - proc op_daemon_check_samples_exist {ctrs} { global op_var_prefix op_daemon_running @@ -232,13 +209,13 @@ proc op_daemon_stop {} { } proc op_daemon_cycle {ctrs} { - op_daemon_delete_any_samples $ctrs + op_daemon_delete_any_samples op_daemon_start $ctrs op_spin 5000 op_daemon_flush op_daemon_check_samples_exist $ctrs op_daemon_stop - op_daemon_delete_any_samples $ctrs + op_daemon_delete_any_samples } proc op_check_daemon {} { diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp index bbb68f0..9a8070f 100644 --- a/testsuite/oprofile-operf/oprofile-operf-run.exp +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp @@ -175,7 +175,11 @@ if {$user_is_root == 0} { if { $operf_version == 0} { send "\nThe OProfile operf user tool is not supported. Will not run operf tests.\n" } else { + # Make sure there are no samples from the opcontrol or operf laying + # around that opreport might inadvertenly pick up. + op_daemon_delete_any_samples operf_delete_samples + oprofile-operf_run_tests } } -- 1.7.12.rc1.22.gbfbf4d4 |
From: Maynard J. <may...@us...> - 2012-10-05 19:57:05
|
On 10/05/2012 11:51 AM, Carl E. Love wrote: > Oprofile testsuite, fix proc op_daemon_delete_any_samples, it doesn't work correctly > > The op_daemon_delete_any_samples procedure is not correctly deleting > samples. This patch replaces the body of the procedure with the > "opcontrol --reset" call to remove the existing samples. The patch > also moves the function to lib/op_util.exp so it can be called by > the operf testsuite as well. A call to op_daemon_delete_any_samples was > added to the operf test main routine to make sure any opcontrol samples are > deleted so opreport will not pickup any samples from a previous opcontrol > run. Patch applied. Thanks! -Maynard > > Signed-off-by: Carl Love <ce...@us...> > --- > testsuite/lib/op_util.exp | 16 +++++++++++++ > .../oprofile-opcontrol/oprofile-opcontrol-run.exp | 27 ++-------------------- > testsuite/oprofile-operf/oprofile-operf-run.exp | 4 ++++ > 3 files changed, 22 insertions(+), 25 deletions(-) > > diff --git a/testsuite/lib/op_util.exp b/testsuite/lib/op_util.exp > index 8679896..6a74b3a 100644 > --- a/testsuite/lib/op_util.exp > +++ b/testsuite/lib/op_util.exp > @@ -21,6 +21,11 @@ > set op_proc_prefix "/dev/oprofile" > set op_var_prefix "/var/lib/oprofile" > > +proc found_error {msg} { > + print "ERROR: $msg" > + opcontrol_exit > + exit 1 > +} > > # read contents of file and return > proc op_get_file_contents {fname} { > @@ -46,6 +51,17 @@ proc op_spin {count} { > local_exec "dd bs=16 if=/dev/urandom of=/dev/null count=$count" "" "" 10 > } > > +proc op_daemon_delete_any_samples {} { > + set cmd "opcontrol --reset" > + set result [local_exec $cmd "" "" 100] > + > + if {[lindex $result 0] == 0} { > + verbose "OProfile reset successfully deleted all samples" > + } else { > + found_error "OProfile --reset FAILED" > + } > +} > + > # If the processor is i386/arch_perfmon, it could be a variant. > proc op_intel_perf_arch {cpu_type} { > if {[regexp "i386/arch_perfmon" $cpu_type dummy] != 1} { > diff --git a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp > index 42caa65..935ca46 100644 > --- a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp > +++ b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp > @@ -42,29 +42,6 @@ proc op_daemon_flush {} { > } > } > > -proc op_daemon_delete_any_samples {ctrs} { > - > - global op_var_prefix > - foreach ctr $ctrs { > - set n [lindex $ctr 0] > - foreach f [glob -nocomplain -types f "$op_var_prefix/samples/*#$n"] { > - if {[catch "file delete $f" err]} { > - verbose "could not delete $f ($err)" > - } else { > - verbose "deleted $f" > - } > - } > - } > - > - foreach sess [glob -nocomplain -types d "$op_var_prefix/samples/session-*"] { > - if {[catch "file delete -force $sess" err]} { > - verbose "could not delete session $sess ($err)" > - } else { > - verbose "deleted $sess" > - } > - } > -} > - > proc op_daemon_check_samples_exist {ctrs} { > > global op_var_prefix op_daemon_running > @@ -232,13 +209,13 @@ proc op_daemon_stop {} { > } > > proc op_daemon_cycle {ctrs} { > - op_daemon_delete_any_samples $ctrs > + op_daemon_delete_any_samples > op_daemon_start $ctrs > op_spin 5000 > op_daemon_flush > op_daemon_check_samples_exist $ctrs > op_daemon_stop > - op_daemon_delete_any_samples $ctrs > + op_daemon_delete_any_samples > } > > proc op_check_daemon {} { > diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp > index bbb68f0..9a8070f 100644 > --- a/testsuite/oprofile-operf/oprofile-operf-run.exp > +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp > @@ -175,7 +175,11 @@ if {$user_is_root == 0} { > if { $operf_version == 0} { > send "\nThe OProfile operf user tool is not supported. Will not run operf tests.\n" > } else { > + # Make sure there are no samples from the opcontrol or operf laying > + # around that opreport might inadvertenly pick up. > + op_daemon_delete_any_samples > operf_delete_samples > + > oprofile-operf_run_tests > } > } |