From: Maynard J. <may...@us...> - 2012-10-16 19:06:27
|
On 10/16/2012 01:14 PM, Carl E. Love wrote: > OProfile testsuite, add single process profiling functionality > > This patch adds another test to the suite of tests. The test runs each of > the workloads with operf in single process mode. The test verifies that > samples were collected for each run. The test checks to make sure the > symbols were found for the first event group, just as is done in the > oprofile-operf test. The testsuite can be run as root or as a regular user. Carl, Thanks for the patch! Just a couple small issues to fix, though. See below. -Maynard > > Signed-off-by: Carl Love <ce...@us...> > --- > testsuite/README | 19 +++- > testsuite/config/unix.exp | 11 +++ > testsuite/lib/operf_util.exp | 19 ++++ > testsuite/oprofile-operf/oprofile-operf-run.exp | 19 ---- > .../oprofile-single_process-run.exp | 105 +++++++++++++++++++++ > 5 files changed, 152 insertions(+), 21 deletions(-) > create mode 100644 testsuite/oprofile-single_process/oprofile-single_process-run.exp > > diff --git a/testsuite/README b/testsuite/README > index ce35e08..d901885 100644 > --- a/testsuite/README > +++ b/testsuite/README > @@ -31,9 +31,24 @@ the following command: > > runtest --tool oprofile-operf > > +The single process operf testsuite requires the following: > > -To run both oprontrol and operf testsuites (provided the requirements for > -both are met), use the command > +-The dejagnu and expect packages are installed > +-The OProfile commands to be on the PATH > +-Note, you should run the command "opcontrol --reset" as root to make sure > + there are no opcontrol data samples around that opreport might accidentally > + pickup on. The testsuite is setup so it can run as a regular user. Regular > + users can't delete the opcontrol data. > +-In order to run oprofile--single_process as an normal user, the testsuite > + directories need to be writable by normal user running the test. > + > +The single process operf tests are run by being in this directory and running > +the following command as either root or a normal user: > + > +runtest --tool oprofile-single_process > + > +To run all three testsuites (provided the requirements for all of them are > +met), use the command > > runtest --tool oprofile > > diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp > index 7b8e4b7..0254c10 100644 > --- a/testsuite/config/unix.exp > +++ b/testsuite/config/unix.exp > @@ -133,6 +133,13 @@ proc oprofile-operf_version {} { > op-userspace-version > } > > +proc oprofile-single_process_version {} { > + set version [exec /bin/uname -r] > + print "" > + print "kernel version: $version" > + op-userspace-version > +} > + > proc oprofile_version {} { > oprofile-opcontrol_version > } > @@ -186,6 +193,10 @@ proc oprofile-operf_exit {} { > operf_exit > } > > +proc oprofile-single_process_exit {} { > + operf_exit > +} > + > proc oprofile_exit {} { > opcontrol_exit > operf_exit > diff --git a/testsuite/lib/operf_util.exp b/testsuite/lib/operf_util.exp > index 5f3abc2..72bda5d 100644 > --- a/testsuite/lib/operf_util.exp > +++ b/testsuite/lib/operf_util.exp > @@ -232,3 +232,22 @@ proc operf_delete_samples {} { > verbose "Failed to delete exiting data directory" > } > } > + > +proc operf_check_samples_exist {ctrs} { > + set test "nonzero-sized sample file creation" > + > + verbose "checking for nonzero sample files" > + > + foreach ctr $ctrs { > + set n [lindex $ctr 0] > + set event [lindex $ctr 1] > + > + verbose "running opreport --symbols --long-filenames event:$event" > + set result [ local_exec "opreport --symbols --long-filenames event:$event" "" "" 100 ] > + if { [regexp "error:" "$result" ]} { > + fail "$test: {$event} created nonzero sample files" > + } else { > + pass "$test: {$event} created nonzero sample files" > + } > + } > +} > diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp > index 5993daa..ae45a6b 100644 > --- a/testsuite/oprofile-operf/oprofile-operf-run.exp > +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp > @@ -145,25 +145,6 @@ proc do_test {ctrs symbol_check} { > } > } > > -proc operf_check_samples_exist {ctrs} { > - set test "nonzero-sized sample file creation" > - > - verbose "checking for nonzero sample files" > - > - foreach ctr $ctrs { > - set n [lindex $ctr 0] > - set event [lindex $ctr 1] > - > - verbose "running opreport --symbols --long-filenames event:$event" > - set result [ local_exec "opreport --symbols --long-filenames event:$event" "" "" 100 ] > - if { [regexp "error:" "$result" ]} { > - fail "$test: {$event} created nonzero sample files" > - } else { > - pass "$test: {$event} created nonzero sample files" > - } > - } > -} > - > proc oprofile-operf_run_tests {} { > global op_event_table > set cpu [operf_cpu_type] > diff --git a/testsuite/oprofile-single_process/oprofile-single_process-run.exp b/testsuite/oprofile-single_process/oprofile-single_process-run.exp > new file mode 100644 > index 0000000..1c96b5a > --- /dev/null > +++ b/testsuite/oprofile-single_process/oprofile-single_process-run.exp > @@ -0,0 +1,105 @@ > +# oprofile-single_process-run.exp > +# Copyright (C) 2012 Carl Love, IBM > +# > +# This file 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 warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program; if not, write to the Free Software > +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. > +# > + > + > +load_lib "op_events.exp" > +load_lib "op_util.exp" > +load_lib "op_workloads.exp" > +load_lib "verify.exp" > + > +set operf_version "" > + > +proc do_test {ctrs symbol_check} { > +# The tests are run in single process mode which does not require root > +# > + global op_workload_table > + set kernel 1 > + set user 1 > + set ctr_opts {} > + > + foreach ctr $ctrs { > +# n - counter number, no longer used but didn't want to change > +# specification format > + set n [lindex $ctr 0] > + set event [lindex $ctr 1] > + set um [lindex $ctr 2] > + set count [lindex $ctr 3] > + append ctr_opts "${event}:${count}:${um}:${kernel}:${user}," > + } > + > + foreach entry [array name op_workload_table] { > + set workload_src [lindex $op_workload_table($entry) 0] > + set compile_options [lindex $op_workload_table($entry) 1] > + set workload_exc [compile_workload $workload_src $compile_options] > + set test "operf do test" > + > + > + # Run the workload > + set cmd "operf --events ${ctr_opts} ${workload_exc}" > + set test $cmd > + > + if {[lindex [local_exec $cmd "" "" 100] 0] == 0} { > + pass $test > + } else { > + fail $test > + } > + > + operf_check_samples_exist $ctrs > + > + # Verify the interesting symbols for this test are found in > + # the output. Only checking the symbols for the first group of > + # events. > + if {$symbol_check == 1} { > + local_exec "sleep 1" "" "" 10 > + verify_output $op_workload_table($entry) $workload_exc $ctr_opts > + } > + operf_delete_samples > + } > +} > + > +proc oprofile-single_process_run_tests {} { > + global op_event_table > + set cpu [operf_cpu_type] > + > + if {$cpu == "bogus"} { > + send "Error, not able find cpu type exiting.\n" > + > + } else { > + > + set symbol_check 1 > + > + # The goal here is a quick sanity check so we will just do the > + # test using the first event entry > + set spec [lindex $op_event_table($cpu) 0] > + do_test $spec $symbol_check > + } > +} > + > +#main > +global operf_get_version ^---- The above line has no effect. > + > +if { $operf_version == 0} { ^-- S/B checking for "" > + send "\nThe OProfile operf user tool is not supported. Will not run operf tests.\n" > +} else { > + # Make sure there are no samples from operf laying around that opreport > + # might inadvertenly pick up. Unfortunately, the user needs to make sure > + # the opcontrol data was previously deleted as root. The goal is to be > + # able to run this test as a regular user. > + operf_delete_samples > + oprofile-single_process_run_tests > +} |