From: Carl E. L. <ce...@li...> - 2012-10-17 23:38:21
|
A couple issues were found with the posted patch. The operf_get_version function was not being called and the if test to verify that $operf_version variable was correctly set was not working. Both issues have been fixed and the updated patch is attached below. Carl Love ---------------------------------------------------------------------- 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. Signed-off-by: Carl Love <ce...@us...> --- testsuite/README | 19 +++- testsuite/config/unix.exp | 11 +++ testsuite/lib/operf_util.exp | 44 +++++++++ testsuite/oprofile-operf/oprofile-operf-run.exp | 46 +-------- .../oprofile-single_process-run.exp | 106 +++++++++++++++++++++ 5 files changed, 180 insertions(+), 46 deletions(-) create mode 100644 testsuite/oprofile-single_process/oprofile-single_process-run.exp diff --git a/testsuite/README b/testsuite/README index ce35e08..fa97ff7 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..468f9f4 100644 --- a/testsuite/lib/operf_util.exp +++ b/testsuite/lib/operf_util.exp @@ -232,3 +232,47 @@ 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" + } + } +} + + +proc operf_get_version {} { + global operf_version + + set test "OProfile operf version check" + verbose $test + set result [ local_exec "operf -v" "" "" 100 ] + + + if {[regexp "\[0-9\]+\(.\[0-9\]+\)+\[a-zA-Z_\]*" $result operf_version] == 1} { + +# Need to make sure the kernel has operf support as well + if {[lindex [local_exec op-check-perfevents "" "" 100] 0] == 0} { + pass $test + } else { + verbose "Kernel does not support operf\n" + set operf_version 0 + } + } else { + verbose "unable to determine version" + set operf_version 0 + warning $test + } +} diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp index 5993daa..421f100 100644 --- a/testsuite/oprofile-operf/oprofile-operf-run.exp +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp @@ -22,30 +22,7 @@ load_lib "op_util.exp" load_lib "op_workloads.exp" load_lib "verify.exp" -set operf_version "" - -proc operf_get_version {} { - global operf_version - - set test "OProfile operf version check" - verbose $test - set result [ local_exec "operf -v" "" "" 100 ] - - if {[regexp "\[0-9\]+\(.\[0-9\]+\)+\[a-zA-Z_\]*" $result operf_version] == 1} { - -# Need to make sure the kernel has operf support as well - if {[lindex [local_exec op-check-perfevents "" "" 100] 0] == 0} { - pass $test - } else { - verbose "Kernel does not support operf\n" - set operf_version 0 - } - } else { - verbose "unable to determine version" - set operf_version 0 - warning $test - } -} +set operf_version 0 proc do_test {ctrs symbol_check} { # The tests are run in system-wide mode which requires the user to be @@ -145,25 +122,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] @@ -194,7 +152,7 @@ if {$user_is_root == 0} { operf_get_version - if { $operf_version == 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 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..7296cc7 --- /dev/null +++ b/testsuite/oprofile-single_process/oprofile-single_process-run.exp @@ -0,0 +1,106 @@ +# 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 0 + +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 + +operf_get_version + +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 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 +} -- 1.7.12.rc1.22.gbfbf4d4 |