Discussion:
[oprofile-testsuite PATCH 2/7] Add verbosity statements for test suite
(too old to reply)
Will Schmidt
2016-03-30 21:27:12 UTC
Permalink
Raw Message
Add some intermediate variables to hold commands; add some
verbose statements to display them when run under higher
verbosity. (runtest --verbose --tool=...)

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/lib/operf_util.exp | 17 ++++--
testsuite/lib/verify.exp | 55 ++++++++++++++------
testsuite/oprofile-operf/oprofile-operf-run.exp | 3 +
.../oprofile-single_process-run.exp | 2 +
4 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/testsuite/lib/operf_util.exp b/testsuite/lib/operf_util.exp
index 858d788..c58534e 100644
--- a/testsuite/lib/operf_util.exp
+++ b/testsuite/lib/operf_util.exp
@@ -63,9 +63,9 @@ proc operf_cpu_type {} {
proc operf_delete_samples {} {
set result [local_exec "rm -rf ./oprofile_data" "" "" 100 ]
if { [lindex $result 0] == 0 } {
- verbose "Successfully deleted exiting data directory"
+ verbose "Successfully deleted existing oprofile_data directory"
} else {
- verbose "Failed to delete exiting data directory"
+ verbose "Failed to delete existing oprofile_data directory"
}
}

@@ -123,9 +123,9 @@ proc operf_ocount_get_version {tool} {
# opcontrol results in /dev/oprofile/cpu_type being set to 'timer' by
# the oprofile kernel module. If operf/ocount are run in such a situation,
# they detect the "timer" mode and exit with a message telling the user
- # to run 'opcontrol --deinit'. If we are root user, we'll run the deinit
- # here; then we'll try again to get the version. If we're not user, we'll
- # print a big message asking the user to do so.
+ # to run 'opcontrol --deinit'. If we are the root user, we'll run the deinit
+ # here; then we'll try again to get the version. If we're not running as
+ # root, we'll print an error message with hints to the user on what to do.
set operf_ocount_version 0
check_user
if {$user_is_root == 1} {
@@ -204,6 +204,8 @@ proc do_single_process_test {ctrs output_check test_debug_option} {
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]
+ verbose "Workload: $workload_exc\n"
+ verbose "Counter options: $ctr_opts\n"

# Run the workload
if {$output_check == 3} {
@@ -211,6 +213,7 @@ proc do_single_process_test {ctrs output_check test_debug_option} {
} else {
set cmd "operf --events ${ctr_opts} ${workload_exc}"
}
+ verbose "operf command is: $cmd \n"

if {$test_debug_option == 1} {
set dbg_test " (--debug-info)"
@@ -220,9 +223,9 @@ proc do_single_process_test {ctrs output_check test_debug_option} {
switch -exact "$output_check" {
1 {set test "operf check for symbols$dbg_test: $cmd"}
2 {set test "operf check for kallsyms$dbg_test: $cmd"}
- 3 {set test "operf check for callgraph output$dbg_test: $cmd"}
+ 3 {set test "operf check callgraph output$dbg_test: $cmd"}
}
-
+ verbose "\nTest: $test\n"
if {[lindex [local_exec $cmd "" "" 100] 0] == 0} {
pass $test
} else {
diff --git a/testsuite/lib/verify.exp b/testsuite/lib/verify.exp
index 5427422..85a290a 100644
--- a/testsuite/lib/verify.exp
+++ b/testsuite/lib/verify.exp
@@ -68,14 +68,18 @@ proc validate_xml_report { callgraph } {
set binpath [lindex [local_exec "readlink -f $binpath" "" "" 10] 1]
set idx [string last "/bin" $binpath ]
set op_install_dir [string range $binpath 0 $idx ]
+ verbose "Using install_dir location: $op_install_dir \n"
append schema_file $op_install_dir "/share/doc/oprofile*/opreport.xsd"
set schema_file [glob $schema_file]
- set opreport_result [local_exec "opreport --debug-info --symbols $cg_option --long-filenames --xml -o out.xml" "" "" 100 ]
+ verbose "Using schema file: $schema_file \n"
+ set opreport_cmd "opreport --debug-info --symbols $cg_option --long-filenames --xml -o out.xml"
+ verbose "Opreport command: $opreport_cmd \n"
+ set opreport_result [local_exec "$opreport_cmd" "" "" 100 ]
set xmllint_result [local_exec "xmllint --noout --schema $schema_file out.xml" "" "" 10 ]
if { [regexp "out.xml validates" "$xmllint_result" ]} {
- pass " Verified XML opreport with callgraph option=$callgraph is valid"
+ pass " Verified XML opreport with callgraph option=$cg_option is valid"
} else {
- fail " XML opreport output with callgraph option=$callgraph is invalid"
+ fail " XML opreport output with callgraph option=$cg_option is invalid"
print [lindex $xmllint_result 1]
}
set result [local_exec "rm -rf ./out.xml" "" "" 100 ]
@@ -97,10 +101,15 @@ proc verify_output { workload_table_entry workload ctr_opts debug_opt_enabled} {
# which should be found in opreport output.
for {set index $base} {$index < $max} {incr index} {
set symbol [lindex $workload_spec $index]
+ verbose "Looking for symbol: $symbol \n"
if { $debug_opt_enabled } {
- set result [local_exec "opreport --debug-info --symbols --long-filenames" "" "" 100 ]
+ set opreport_cmd "opreport --debug-info --symbols --long-filenames"
+ verbose "Opreport command: $opreport_cmd \n"
+ set result [local_exec "$opreport_cmd" "" "" 100 ]
} else {
- set result [local_exec "opreport --symbols --long-filenames" "" "" 100 ]
+ set opreport_cmd "opreport --symbols --long-filenames"
+ verbose "Opreport command: $opreport_cmd \n"
+ set result [local_exec "$opreport_cmd" "" "" 100 ]
}
if { [regexp $symbol "$result" ]} {
verbose "Verify the symbols for workload: $workload"
@@ -125,16 +134,23 @@ proc verify_kallsyms_output { } {
set symbol1 "kallsyms"
set symbol2 "no-vmlinux"

- set result [local_exec "opreport --symbols --long-filenames" "" "" 100 ]
+ set opreport_cmd "opreport --symbols --long-filenames"
+ verbose "Opreport command: $opreport_cmd \n"
+ set result [local_exec "$opreport_cmd" "" "" 100 ]

if { [regexp $symbol1 "$result" ] == 1 && [regexp $symbol2 "$result" ] == 0 } {
- pass " Kallsyms was used to get the kernel symbols."
- verbose "\n"
+ pass " Kallsyms was successfully used to get the kernel symbols."
+ verbose "\n"
} else {
- print "Verify the test is being run as root and "
- print "/proc/sys/kernel/kptr_restrict is either 0 or 1."
- fail " Failed to obtain the kernel symbols from kallsyms."
- print "\n"
+ fail " Failed to obtain the kernel symbols from kallsyms."
+ print "Verify the test is being run as root or that "
+ print "/proc/sys/kernel/kptr_restrict is set to 0."
+ send "The current value of kptr_restrict is: "
+ set kptr_restrict_file /proc/sys/kernel/kptr_restrict
+ set file [open $kptr_restrict_file]
+ fcopy $file stdout
+ close $file
+ print "\n"
}
}

@@ -148,18 +164,23 @@ proc verify_callgraph_output { workload_table_entry workload ctr_opts} {
# which should be found in opreport output.

# Verify the output file contains the expected symbols.
- set result [regsub {\{|\}} [local_exec "opreport --callgraph" "" "" 100 ] " "]
+ set opreport_cmd "opreport --callgraph"
+ verbose "Opreport command: $opreport_cmd \n"
+ set result [regsub {\{|\}} [local_exec "$opreport_cmd " "" "" 100 ] " "]

for {set index 2} {$index < $max} {incr index} {
set symbol [lindex $workload_spec $index]
if { [regexp $symbol "$result" ]} {
- verbose "Verify callgraph contains the workload symbols: $workload"
- verbose " Performance counter events: $ctr_opts"
+ verbose "Verify callgraph output contains the expected symbols:\n"
+ verbose " Workload: $workload\n"
+ verbose " Performance counter events: $ctr_opts\n"
+ verbose " Symbol: $symbol\n"
pass " opreport contains symbol: $symbol"
verbose "\n"
} else {
- print "Verify callgraph contains the workload symbols: $workload"
- print " Performance counter events: $ctr_opts"
+ print "Verify callgraph output contains the expected symbols:\n"
+ print " Workload: $workload\n"
+ print " Performance counter events: $ctr_opts\n"
fail " opreport does not contain symbol: $symbol"
print "\n"
}
diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index 763075d..51aa2dc 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -162,7 +162,9 @@ if {$user_is_root == 0} {
# around that opreport might inadvertenly pick up.
operf_delete_samples

+ send "Running the operf system-wide tests\n"
oprofile-operf_run_system_wide_tests
+ send "Running the operf callgraph tests\n"
oprofile-callgraph_run_tests

case $operf_version {
@@ -171,6 +173,7 @@ if {$user_is_root == 0} {
}
{ * } {
# kallsyms support was added in version 1.0.
+ send "Running the operf kallsyms-readable tests. (symbols,kallsyms,callgraph) \n"
oprofile-kallsyms-readable_run_tests
}
}
diff --git a/testsuite/oprofile-single_process/oprofile-single_process-run.exp b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
index 752585d..69fc85f 100644
--- a/testsuite/oprofile-single_process/oprofile-single_process-run.exp
+++ b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
@@ -85,6 +85,8 @@ if { $operf_version == 0} {
# 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
+ # single process tests
oprofile-single_process_run_tests
+ # debug option tests
oprofile-debug-option_run_tests
}
Will Schmidt
2016-03-30 21:27:18 UTC
Permalink
Raw Message
Now that perf events is the interface used underneath oprofile, root
authority is no longer required to retrieve kernel symbol info (via kallsyms).
This swizzles some of the user==root controls around the tests, moving the
check to just around the system-wide tests, which still require root.
Overall, this allows many more tests to run as a non-root user.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/oprofile-operf/oprofile-operf-run.exp | 25 ++++++++++++-----------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index 51aa2dc..a6496be 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -134,22 +134,18 @@ if {$op_version == 0} {
set opcontrol_installed 0
} else {
if {$op_version < $operf_version} {
- # Don't run the opcontrol tests if it is an earlier version
+ # Don't run the opcontrol tests at all if the opcontrol binary appears to
+ # be from an earlier version of OProfile.
set opcontrol_installed 0
} else {
set opcontrol_installed 1
}
}

-check_user
-if {$user_is_root == 0} {
- send "\nYou must be root to run the operf --system-wide command.\n"
- send "Will not run operf tests.\n"
+if { $operf_version == 0 } {
+ send "Skipping the operf tests.\n"
+ send "Unable to find or verify the version of the OProfile operf utility.\n"
} else {
-
- if { $operf_version == 0 } {
- send "\nThe OProfile operf user tool is not supported. Will not run operf tests.\n"
- } else {
# Ensure that the oprofile kernel module is unloaded, since it can
# interfere with proper operf operation on some platforms.
if {$opcontrol_installed == 1} {
@@ -162,8 +158,14 @@ if {$user_is_root == 0} {
# around that opreport might inadvertenly pick up.
operf_delete_samples

- send "Running the operf system-wide tests\n"
- oprofile-operf_run_system_wide_tests
+ check_user
+ if {$user_is_root == 0} {
+ send "Skipping the operf system-wide tests.\n"
+ send " You must be root to run operf with the --system-wide parameter.\n\n"
+ } else {
+ send "Running the operf system-wide tests.\n"
+ oprofile-operf_run_system_wide_tests
+ }
send "Running the operf callgraph tests\n"
oprofile-callgraph_run_tests

@@ -177,5 +179,4 @@ if {$user_is_root == 0} {
oprofile-kallsyms-readable_run_tests
}
}
- }
}
Will Schmidt
2016-03-30 21:27:05 UTC
Permalink
Raw Message
Rename the run_tests() function to run_system_wide_tests()
to better match what the function actually does.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/oprofile-operf/oprofile-operf-run.exp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index d77a7e5..763075d 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -28,7 +28,7 @@ load_lib "verify.exp"
set operf_version 0


-proc oprofile-operf_run_tests {} {
+proc oprofile-operf_run_system_wide_tests {} {
global op_event_table
set cpu [operf_cpu_type]

@@ -162,7 +162,7 @@ if {$user_is_root == 0} {
# around that opreport might inadvertenly pick up.
operf_delete_samples

- oprofile-operf_run_tests
+ oprofile-operf_run_system_wide_tests
oprofile-callgraph_run_tests

case $operf_version {
Will Schmidt
2016-03-30 21:27:30 UTC
Permalink
Raw Message
swizzle kptr_restrict logic

The kptr_restrict field is currently documented as holding one of
three values:
# 0 - no restriction.
# 1 - restricted.
# 2 - addresses are zero'd out.

The existing tests that check the value of the kptr_restrict field
are obsolete in that they don't handle the restricted mode. After some
review and experimentation, simply removing the check simplifies the scripts
and allows more tests to run successfully. Thus, remove the checks.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/oprofile-operf/oprofile-operf-run.exp | 28 +++--------------------
1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index a6496be..c81f75e 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -55,17 +55,6 @@ proc oprofile-callgraph_run_tests {} {
global op_event_table

set cpu [operf_cpu_type]
- set cmd "cat /proc/sys/kernel/kptr_restrict"
- set kptr_restrict [ lindex [split [local_exec $cmd "" "" 10 ] "\{\}" ] 1 ]
-
- if { $kptr_restrict > 1 } {
- send " The setting of /proc/sys/kernel/kptr_restrict is not 0 or 1.\n"
- send " Can not verify the kernel symbols were properly found in \n"
- send " /proc/kallsyms.\n"
- send "\n"
- send " SKIPPING the callgraph option test\n"
- send "\n"
- } else {
if {$cpu == "bogus"} {
send "Error, not able find cpu type exiting.\n"
} else {
@@ -78,27 +67,19 @@ proc oprofile-callgraph_run_tests {} {
set spec [lindex $op_event_table($cpu) 0]
do_single_process_test $spec $output_check $test_debug_option
}
- }
}

proc oprofile-kallsyms-readable_run_tests {} {
- # This test should be run as root as the default is to restrict users
- # from getting the kernel addresses from kallsyms. The test is done as
- # a single process test to keep it simple.
+ # Under the deprecated opcontrol utility, this test would only be valid
+ # when run as root. With the perf-events interface (oprofile 1.0 and
+ # newer), and when kptr_restrict set to permissive, it is
+ # now possible to get kernel symbol information as a normal user.
global op_event_table

set cpu [operf_cpu_type]
set cmd "cat /proc/sys/kernel/kptr_restrict"
set kptr_restrict [ lindex [split [local_exec $cmd "" "" 10 ] "\{\}" ] 1 ]

- if { $kptr_restrict > 1 } {
- send " The setting of /proc/sys/kernel/kptr_restrict is not 0 or 1.\n"
- send " Can not verify the kernel symbols were properly found in \n"
- send " /proc/kallsyms.\n"
- send "\n"
- send " SKIPPING the test to verify kallsyms was readable!!!\n"
- send "\n"
- } else {
if {$cpu == "bogus"} {
send "Error, not able find cpu type exiting.\n"
} else {
@@ -110,7 +91,6 @@ proc oprofile-kallsyms-readable_run_tests {} {
set spec [lindex $op_event_table($cpu) 0]
do_single_process_test $spec $output_check $test_debug_option
}
- }
}
Will Schmidt
2016-03-30 21:27:24 UTC
Permalink
Raw Message
Use mktemp to create unique temp files. This should allow
multiple users on a system to run the oprofile test suite
at the same time, without stomping on each others temp files.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/lib/operf_util.exp | 62 +++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/testsuite/lib/operf_util.exp b/testsuite/lib/operf_util.exp
index c58534e..8aea77e 100644
--- a/testsuite/lib/operf_util.exp
+++ b/testsuite/lib/operf_util.exp
@@ -295,52 +295,52 @@ proc do_system-wide_test {ctrs symbol_check} {
set test "operf systemwide: $workload_exc"
}

- # create the script to run operf command
- set filename "/tmp/operf_run.zzzz"
- set fileId [open $filename "w"]
+ # create the script to run the operf command
+ set operf_run_script [exec mktemp "/tmp/operf_run.XXXX"]
+ set operf_output_log [exec mktemp "/tmp/operf_output.XXXX"]
+ set fileId [open $operf_run_script "w"]
puts $fileId "#!/bin/bash"
puts -nonewline $fileId "operf --system-wide --events "
puts -nonewline $fileId $ctr_opts
- puts -nonewline $fileId " 2>&1 | tee > /tmp/operf_out.zzzz"
+ puts -nonewline $fileId " 2>&1 | tee > $operf_output_log"
close $fileId
+ local_exec "chmod 755 $operf_run_script" "" "" 10

- local_exec "chmod 755 /tmp/operf_run.zzzz" "" "" 10
+ # Run the script to start operf data collection in the background
+ exec $operf_run_script &

- # Start operf data collection in the background
- exec /tmp/operf_run.zzzz &
-
- # Create the script to stop the operf data collection. Note this
- # must be done after operf starts and writes the kill command out to
- # operf_out.zzzz.
- set filename "/tmp/operf_create_stop.zzzz"
- set fileId [open $filename "w"]
+ # Now that operf is running in the background, collect the PID from
+ # the output file. This will be used to stop the system wide data
+ # collection shortly.
+ set create_stop_script [exec mktemp "/tmp/operf_create_stop_script.XXXX"]
+ set fileId [open $create_stop_script "w"]
+ set operf_stop_script [exec mktemp "/tmp/operf_stop_operf.XXXX"]
puts $fileId "#!/bin/bash"
- puts $fileId "echo -n \"kill -s INT \" > /tmp/operf_stop.zzzz "
-
- # Get the process id to kill
- puts $fileId "cat /tmp/operf_out.zzzz | grep \"kill\" | cut -d\"\'\" -f2 | cut -d\" \" -f3 >> /tmp/operf_stop.zzzz "
+ puts $fileId "echo -n \"kill -s INT \" > $operf_stop_script "
+ # logic that collects the process id to be killed
+ puts $fileId "cat $operf_output_log | grep \"kill\" | cut -d\"\'\" -f2 | cut -d\" \" -f3 >> $operf_stop_script "
close $fileId

# check that operf started correctly
- if {[lindex [local_exec "grep \"usage\" /tmp/operf_out.zzzz " "" "" 100] 0] == 1} {
+ if {[lindex [local_exec "grep \"usage\" $operf_output_log " "" "" 100] 0] == 1} {
pass $test
} else {
fail $test
}

- # Run the script to create the operf stop script based on the
- # output of the operf command.
+ # Now, call the script to create the operf kill script.
local_exec "sleep 2" "" "" 10
- local_exec "chmod 755 /tmp/operf_create_stop.zzzz" "" "" 10
- exec /tmp/operf_create_stop.zzzz
+ local_exec "chmod 755 $create_stop_script" "" "" 10
+ exec $create_stop_script

- # Run the workload
- set result [local_exec "$workload_exc" "" "" 60]
+ # Run the workload
+ set result [local_exec "$workload_exc" "" "" 60]

- local_exec "chmod 755 /tmp/operf_stop.zzzz" "" "" 10
- exec /tmp/operf_stop.zzzz
+ # And finally, call the operf kill script.
+ local_exec "chmod 755 $operf_stop_script" "" "" 10
+ exec $operf_stop_script

- operf_check_samples_exist $ctrs
+ 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
@@ -352,10 +352,10 @@ proc do_system-wide_test {ctrs symbol_check} {
}

# cleanup the files created
- local_exec "rm -f /tmp/operf_out.zzzz" "" "" 10
- local_exec "rm -f /tmp/operf_stop.zzzz" "" "" 10
- local_exec "rm -f /tmp/operf_run.zzzz" "" "" 10
- local_exec "rm -f /tmp/operf_create_stop.zzzz" "" "" 10
+ local_exec "rm -f $operf_run_script" "" "" 10
+ local_exec "rm -f $operf_output_log" "" "" 10
+ local_exec "rm -f $create_stop_script" "" "" 10
+ local_exec "rm -f $operf_stop_script" "" "" 10
operf_delete_samples
}
}
Will Schmidt
2016-03-30 21:27:37 UTC
Permalink
Raw Message
A handful of cosmetic updates, typo corrections, etc.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
.../oprofile-opcontrol/oprofile-opcontrol-run.exp | 17 +++++++++--------
testsuite/oprofile-operf/oprofile-operf-run.exp | 4 ++--
.../oprofile-single_process-run.exp | 4 ++--
3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
index 1a39b3b..a20aa7f 100644
--- a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
+++ b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
@@ -278,19 +278,20 @@ op_get_version
operf_get_version

if {$op_version == 0} {
- #The opcontrol program was not found. opcontrol was droped with
+ #The opcontrol program was not found. opcontrol was dropped with
# OProfile version 1.0. We will just silently not run the opcontrol
# tests.
- send "\nNote: The legacy opcontrol command is not available in\n"
- send " OProfile versions 1.0 and newer. Skipping opcontrol\n"
- send " tests.\n"
+ send "Skipping the opcontrol tests.\n"
+ send " The legacy opcontrol command is not available in\n"
+ send " OProfile versions 1.0 and newer.\n"
set opcontrol_installed 0
} elseif {$op_version < $operf_version} {
# Skip the opcontrol tests as the version of opcontrol is older then operf
- send "\nThere appears to be a newer verision of OProfile installed\n"
- send "that does not support opcontrol. Opcontrol support was dropped\n"
- send "with OProfile version 1.0. Will not run the opcontrol tests with\n"
- send "the older opcontrol version.\n\n"
+ send "Skipping the opcontrol tests. \n"
+ send " The opcontrol utility was found in the path, but appears\n"
+ send " to be obsolete (version $op_version) with respect to the\n"
+ send " installed version of operf (version $operf_version). \n"
+ send " Opcontrol support was dropped with OProfile version 1.0.\n\n"
set opcontrol_installed 0
} else {
check_user
diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index c81f75e..2a4b4f8 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -131,11 +131,11 @@ if { $operf_version == 0 } {
if {$opcontrol_installed == 1} {
local_exec "opcontrol --deinit" "" "" 100
# Make sure there are no samples from the opcontrol laying
- # around that opreport might inadvertenly pick up.
+ # around that opreport might inadvertently pick up.
op_daemon_delete_any_samples
}
# Make sure there are no samples from the operf laying
- # around that opreport might inadvertenly pick up.
+ # around that opreport might inadvertently pick up.
operf_delete_samples

check_user
diff --git a/testsuite/oprofile-single_process/oprofile-single_process-run.exp b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
index 69fc85f..caeb002 100644
--- a/testsuite/oprofile-single_process/oprofile-single_process-run.exp
+++ b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
@@ -75,13 +75,13 @@ if {$op_deps_ok == 0} {
operf_get_version

if { $operf_version == 0} {
- send "\nThe OProfile operf user tool is not supported. Will not run operf tests.\n"
+ send "\nThe OProfile operf userspace utility was not found. Will not run operf tests.\n"
} else {
# Ensure that the oprofile kernel module is unloaded, since it can
# interfere with proper operf operation on some platforms.
local_exec "opcontrol --deinit" "" "" 100
# Make sure there are no samples from operf laying around that opreport
- # might inadvertenly pick up. Unfortunately, the user needs to make sure
+ # might inadvertently 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
Will Schmidt
2016-03-30 21:27:43 UTC
Permalink
Raw Message
Refresh all the source files I've touched in this series to use
four spaces for indentation instead of tabs.

Signed-off-by: Will Schmidt <***@vnet.ibm.com>
---
testsuite/lib/operf_util.exp | 222 ++++++++---------
testsuite/lib/verify.exp | 154 ++++++-----
.../oprofile-opcontrol/oprofile-opcontrol-run.exp | 269 ++++++++++----------
testsuite/oprofile-operf/oprofile-operf-run.exp | 128 +++++-----
.../oprofile-single_process-run.exp | 35 +--
5 files changed, 402 insertions(+), 406 deletions(-)

diff --git a/testsuite/lib/operf_util.exp b/testsuite/lib/operf_util.exp
index 8aea77e..b34fd33 100644
--- a/testsuite/lib/operf_util.exp
+++ b/testsuite/lib/operf_util.exp
@@ -29,12 +29,12 @@ proc operf_get_proc_name {string} {
set i 0

foreach field $string {
- set res $res$field
- incr i
+ set res $res$field
+ incr i

- if {$i != $len} {
- set res $res\_
- }
+ if {$i != $len} {
+ set res $res\_
+ }
}
return $res
}
@@ -51,10 +51,10 @@ proc operf_cpu_type {} {
# Note, operf does not support the timer modes

switch -exact "$cpu_name" {
- 4 {set cpu_events bogus}
- timer {set cpu_events bogus}
- 5 {set cpu_events bogus}
- rtc {set cpu_events bogus}
+ 4 {set cpu_events bogus}
+ timer {set cpu_events bogus}
+ 5 {set cpu_events bogus}
+ rtc {set cpu_events bogus}
}

return $cpu_events
@@ -75,16 +75,16 @@ proc operf_check_samples_exist {ctrs} {
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"
- }
+ 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"
+ }
}
}

@@ -105,7 +105,7 @@ proc operf_ocount_get_version {tool} {

if {[regexp "\[0-9\]+\(.\[0-9\]+\)+\[a-zA-Z_\]*" $result operf_ocount_version] == 1} {

-# Need to make sure the kernel has perf support as well
+# Need to make sure the kernel has perf support as well
if {[lindex [local_exec op-check-perfevents "" "" 100] 0] == 0} {
pass $test
} else {
@@ -186,74 +186,74 @@ proc do_single_process_test {ctrs output_check test_debug_option} {
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]
- if {$output_check == 3} {
- # With callgraph profiling, we only use the cycles-based event for the
- # architecture. Just set the count value high enough to make sure it's
- # at least 15x the minimum; 1,500,000 should do it.
- set count 1500000
- } else {
- set count [lindex $ctr 3]
- }
- append ctr_opts "${event}:${count}:${um}:${kernel}:${user},"
+ set n [lindex $ctr 0]
+ set event [lindex $ctr 1]
+ set um [lindex $ctr 2]
+ if {$output_check == 3} {
+ # With callgraph profiling, we only use the cycles-based event for the
+ # architecture. Just set the count value high enough to make sure it's
+ # at least 15x the minimum; 1,500,000 should do it.
+ set count 1500000
+ } else {
+ 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 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]
verbose "Workload: $workload_exc\n"
verbose "Counter options: $ctr_opts\n"

- # Run the workload
- if {$output_check == 3} {
- set cmd "operf --callgraph --lazy-conversion --events ${ctr_opts} ${workload_exc}"
- } else {
- set cmd "operf --events ${ctr_opts} ${workload_exc}"
- }
+ # Run the workload
+ if {$output_check == 3} {
+ set cmd "operf --callgraph --lazy-conversion --events ${ctr_opts} ${workload_exc}"
+ } else {
+ set cmd "operf --events ${ctr_opts} ${workload_exc}"
+ }
verbose "operf command is: $cmd \n"

- if {$test_debug_option == 1} {
- set dbg_test " (--debug-info)"
- } else {
- set dbg_test ""
- }
- switch -exact "$output_check" {
- 1 {set test "operf check for symbols$dbg_test: $cmd"}
- 2 {set test "operf check for kallsyms$dbg_test: $cmd"}
- 3 {set test "operf check callgraph output$dbg_test: $cmd"}
- }
+ if {$test_debug_option == 1} {
+ set dbg_test " (--debug-info)"
+ } else {
+ set dbg_test ""
+ }
+ switch -exact "$output_check" {
+ 1 {set test "operf check for symbols$dbg_test: $cmd"}
+ 2 {set test "operf check for kallsyms$dbg_test: $cmd"}
+ 3 {set test "operf check callgraph output$dbg_test: $cmd"}
+ }
verbose "\nTest: $test\n"
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 {$output_check == 1} {
- local_exec "sleep 1" "" "" 10
- verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
- }
-
- if {$output_check == 2} {
- local_exec "sleep 1" "" "" 10
- verify_kallsyms_output
- }
-
- if {$output_check == 3} {
- # check callgraph output
- local_exec "sleep 1" "" "" 10
- verify_callgraph_output $op_workload_table($entry) $workload_exc $ctr_opts
- }
-
- operf_delete_samples
+ }
+
+ 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 {$output_check == 1} {
+ local_exec "sleep 1" "" "" 10
+ verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
+ }
+
+ if {$output_check == 2} {
+ local_exec "sleep 1" "" "" 10
+ verify_kallsyms_output
+ }
+
+ if {$output_check == 3} {
+ # check callgraph output
+ local_exec "sleep 1" "" "" 10
+ verify_callgraph_output $op_workload_table($entry) $workload_exc $ctr_opts
+ }
+
+ operf_delete_samples
}
}

@@ -277,33 +277,33 @@ proc do_system-wide_test {ctrs symbol_check} {
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},"
+ 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 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]

- if {$symbol_check == 1} {
- set test "operf systemwide check for symbols: $workload_exc"
- } else {
- set test "operf systemwide: $workload_exc"
- }
+ if {$symbol_check == 1} {
+ set test "operf systemwide check for symbols: $workload_exc"
+ } else {
+ set test "operf systemwide: $workload_exc"
+ }

# create the script to run the operf command
set operf_run_script [exec mktemp "/tmp/operf_run.XXXX"]
set operf_output_log [exec mktemp "/tmp/operf_output.XXXX"]
set fileId [open $operf_run_script "w"]
- puts $fileId "#!/bin/bash"
- puts -nonewline $fileId "operf --system-wide --events "
- puts -nonewline $fileId $ctr_opts
- puts -nonewline $fileId " 2>&1 | tee > $operf_output_log"
- close $fileId
+ puts $fileId "#!/bin/bash"
+ puts -nonewline $fileId "operf --system-wide --events "
+ puts -nonewline $fileId $ctr_opts
+ puts -nonewline $fileId " 2>&1 | tee > $operf_output_log"
+ close $fileId
local_exec "chmod 755 $operf_run_script" "" "" 10

# Run the script to start operf data collection in the background
@@ -315,21 +315,21 @@ proc do_system-wide_test {ctrs symbol_check} {
set create_stop_script [exec mktemp "/tmp/operf_create_stop_script.XXXX"]
set fileId [open $create_stop_script "w"]
set operf_stop_script [exec mktemp "/tmp/operf_stop_operf.XXXX"]
- puts $fileId "#!/bin/bash"
+ puts $fileId "#!/bin/bash"
puts $fileId "echo -n \"kill -s INT \" > $operf_stop_script "
# logic that collects the process id to be killed
puts $fileId "cat $operf_output_log | grep \"kill\" | cut -d\"\'\" -f2 | cut -d\" \" -f3 >> $operf_stop_script "
- close $fileId
+ close $fileId

- # check that operf started correctly
+ # check that operf started correctly
if {[lindex [local_exec "grep \"usage\" $operf_output_log " "" "" 100] 0] == 1} {
- pass $test
- } else {
- fail $test
- }
+ pass $test
+ } else {
+ fail $test
+ }

# Now, call the script to create the operf kill script.
- local_exec "sleep 2" "" "" 10
+ local_exec "sleep 2" "" "" 10
local_exec "chmod 755 $create_stop_script" "" "" 10
exec $create_stop_script

@@ -342,20 +342,20 @@ proc do_system-wide_test {ctrs symbol_check} {

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 2" "" "" 10
- set test_debug_option 0
- verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
- }
+ # 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 2" "" "" 10
+ set test_debug_option 0
+ verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
+ }

- # cleanup the files created
+ # cleanup the files created
local_exec "rm -f $operf_run_script" "" "" 10
local_exec "rm -f $operf_output_log" "" "" 10
local_exec "rm -f $create_stop_script" "" "" 10
local_exec "rm -f $operf_stop_script" "" "" 10
- operf_delete_samples
+ operf_delete_samples
}
}
diff --git a/testsuite/lib/verify.exp b/testsuite/lib/verify.exp
index 85a290a..4aad17b 100644
--- a/testsuite/lib/verify.exp
+++ b/testsuite/lib/verify.exp
@@ -3,86 +3,86 @@ set XML_report_cg_done 0
set XML_report_no_cg_done 0

proc should_run_xml_tests { } {
- global operf_version
- if { $operf_version == 0 } {
- return 0
- } else {
- case $operf_version {
- { 0.9.9 } {
- return 1
- }
- { 0.* } {
- return 0
- }
- { * } {
- return 1
- }
- }
- }
+ global operf_version
+ if { $operf_version == 0 } {
+ return 0
+ } else {
+ case $operf_version {
+ { 0.9.9 } {
+ return 1
+ }
+ { 0.* } {
+ return 0
+ }
+ { * } {
+ return 1
+ }
+ }
+ }
}

proc validate_xml_help { } {
- global XML_help_done
- if { [should_run_xml_tests] == 0 || $XML_help_done == 1 } {
- return
- }
- set binpath [lindex [local_exec "which ophelp" "" "" 10] 1]
- set binpath [lindex [local_exec "readlink -f $binpath" "" "" 10] 1]
- set idx [string last "/bin" $binpath ]
- set op_install_dir [string range $binpath 0 $idx ]
- append schema_file $op_install_dir "/share/doc/oprofile*/ophelp.xsd"
- set schema_file [glob $schema_file]
- set ophelp_result [local_exec "ophelp --xml" "" "" 100 ]
- set out [open "help_out.xml" w]
- puts $out [lindex $ophelp_result 1]
- close $out
- set xmllint_result [local_exec "xmllint --noout --schema $schema_file help_out.xml" "" "" 10 ]
- if { [regexp "help_out.xml validates" "$xmllint_result" ]} {
- pass " Verified XML ophelp output is valid"
- } else {
- fail " XML ophelp output is invalid"
- print [lindex $xmllint_result 1]
- }
- set result [local_exec "rm -rf ./help_out.xml" "" "" 100 ]
- set XML_help_done 1
+ global XML_help_done
+ if { [should_run_xml_tests] == 0 || $XML_help_done == 1 } {
+ return
+ }
+ set binpath [lindex [local_exec "which ophelp" "" "" 10] 1]
+ set binpath [lindex [local_exec "readlink -f $binpath" "" "" 10] 1]
+ set idx [string last "/bin" $binpath ]
+ set op_install_dir [string range $binpath 0 $idx ]
+ append schema_file $op_install_dir "/share/doc/oprofile*/ophelp.xsd"
+ set schema_file [glob $schema_file]
+ set ophelp_result [local_exec "ophelp --xml" "" "" 100 ]
+ set out [open "help_out.xml" w]
+ puts $out [lindex $ophelp_result 1]
+ close $out
+ set xmllint_result [local_exec "xmllint --noout --schema $schema_file help_out.xml" "" "" 10 ]
+ if { [regexp "help_out.xml validates" "$xmllint_result" ]} {
+ pass " Verified XML ophelp output is valid"
+ } else {
+ fail " XML ophelp output is invalid"
+ print [lindex $xmllint_result 1]
+ }
+ set result [local_exec "rm -rf ./help_out.xml" "" "" 100 ]
+ set XML_help_done 1
}

proc validate_xml_report { callgraph } {
- global XML_report_cg_done
- global XML_report_no_cg_done
- if { [should_run_xml_tests] == 0 } {
- return
- }
- if { $XML_report_cg_done == 1 && $XML_report_no_cg_done == 1 } {
- return
- }
-
- if { $callgraph } {
- set cg_option "--callgraph"
- set XML_report_cg_done 1
- } else {
- set cg_option ""
- set XML_report_no_cg_done 1
- }
- set binpath [lindex [local_exec "which operf" "" "" 10] 1]
- set binpath [lindex [local_exec "readlink -f $binpath" "" "" 10] 1]
- set idx [string last "/bin" $binpath ]
- set op_install_dir [string range $binpath 0 $idx ]
- verbose "Using install_dir location: $op_install_dir \n"
- append schema_file $op_install_dir "/share/doc/oprofile*/opreport.xsd"
- set schema_file [glob $schema_file]
- verbose "Using schema file: $schema_file \n"
- set opreport_cmd "opreport --debug-info --symbols $cg_option --long-filenames --xml -o out.xml"
- verbose "Opreport command: $opreport_cmd \n"
- set opreport_result [local_exec "$opreport_cmd" "" "" 100 ]
- set xmllint_result [local_exec "xmllint --noout --schema $schema_file out.xml" "" "" 10 ]
- if { [regexp "out.xml validates" "$xmllint_result" ]} {
- pass " Verified XML opreport with callgraph option=$cg_option is valid"
- } else {
- fail " XML opreport output with callgraph option=$cg_option is invalid"
- print [lindex $xmllint_result 1]
- }
- set result [local_exec "rm -rf ./out.xml" "" "" 100 ]
+ global XML_report_cg_done
+ global XML_report_no_cg_done
+ if { [should_run_xml_tests] == 0 } {
+ return
+ }
+ if { $XML_report_cg_done == 1 && $XML_report_no_cg_done == 1 } {
+ return
+ }
+
+ if { $callgraph } {
+ set cg_option "--callgraph"
+ set XML_report_cg_done 1
+ } else {
+ set cg_option ""
+ set XML_report_no_cg_done 1
+ }
+ set binpath [lindex [local_exec "which operf" "" "" 10] 1]
+ set binpath [lindex [local_exec "readlink -f $binpath" "" "" 10] 1]
+ set idx [string last "/bin" $binpath ]
+ set op_install_dir [string range $binpath 0 $idx ]
+ verbose "Using install_dir location: $op_install_dir \n"
+ append schema_file $op_install_dir "/share/doc/oprofile*/opreport.xsd"
+ set schema_file [glob $schema_file]
+ verbose "Using schema file: $schema_file \n"
+ set opreport_cmd "opreport --debug-info --symbols $cg_option --long-filenames --xml -o out.xml"
+ verbose "Opreport command: $opreport_cmd \n"
+ set opreport_result [local_exec "$opreport_cmd" "" "" 100 ]
+ set xmllint_result [local_exec "xmllint --noout --schema $schema_file out.xml" "" "" 10 ]
+ if { [regexp "out.xml validates" "$xmllint_result" ]} {
+ pass " Verified XML opreport with callgraph option=$cg_option is valid"
+ } else {
+ fail " XML opreport output with callgraph option=$cg_option is invalid"
+ print [lindex $xmllint_result 1]
+ }
+ set result [local_exec "rm -rf ./out.xml" "" "" 100 ]
}

proc verify_output { workload_table_entry workload ctr_opts debug_opt_enabled} {
@@ -92,9 +92,9 @@ proc verify_output { workload_table_entry workload ctr_opts debug_opt_enabled} {

if { $debug_opt_enabled } {
# debug option enabled, adds a column to the output for the source
- set base 3
+ set base 3
} else {
- set base 2
+ set base 2
}
# Note, starting with the second entry in the workload spec is the name
# of the workload executable file. The remaining entries are symbols
@@ -201,7 +201,7 @@ proc verify_callgraph_output { workload_table_entry workload ctr_opts} {
set cur_word [ lindex $line $i ]
set next_word [ lindex $line [ expr $i + 1 ] ]
if { ([string compare $cur_word "kallsyms"] == 0 ) &&
- ([string compare $next_word "/proc/kallsyms"] == 0 ) } {
+ ([string compare $next_word "/proc/kallsyms"] == 0 ) } {
set err 1
}
set i [expr $i + 1]
diff --git a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
index a20aa7f..1a1d59d 100644
--- a/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
+++ b/testsuite/oprofile-opcontrol/oprofile-opcontrol-run.exp
@@ -33,14 +33,14 @@ proc op_daemon_flush {} {
set test "opcontrol --dump"

if {$op_daemon_running == 0} {
- unsupported $test
- return
+ unsupported $test
+ return
}
verbose "running opcontrol --dump"
if {[lindex [local_exec "opcontrol --dump" "" "" 100] 0] == 0} {
- pass $test
+ pass $test
} else {
- fail $test
+ fail $test
}
}

@@ -52,51 +52,51 @@ proc op_daemon_check_samples_exist {ctrs} {
set test "nonzero-sized sample file creation"

if {$op_daemon_running == 0} {
- print "op_daemon_check_samples_exist, op_daemon not running as expected"
- unsupported $test
- return
+ print "op_daemon_check_samples_exist, op_daemon not running as expected"
+ unsupported $test
+ return
}

verbose "checking for nonzero sample files"

foreach ctr $ctrs {
- set n [lindex $ctr 0]
- set event [lindex $ctr 1]
- case $op_version {
- { 0.1* 0.2* 0.3* 0.4* } {
- fail "ERROR: testsuite not supported on version {$op_version}"
- }
- { 0.5* } {
- set files [glob -nocomplain -types f "$op_var_prefix/samples/*#$n"]
- if {[llength $files] == 0} {
- unresolved "$test: {$ctr} created no files"
- } else {
- set sz 0
- verbose "looking at [llength $files] sample files for ctr $n"
- foreach f $files {
- set nsz [file size $f]
- if {$nsz > $sz} {
- set sz $nsz
- }
- }
- if {$sz == 0} {
- unresolved "$test: {$ctr} created only zero-length files"
- } else {
- pass "$test: {$ctr} created nonzero sample files"
- }
- }
- }
- { * } {
- # default for all newer versions of oprofile
- verbose "running opreport --long-filenames event:$event"
- set result [local_exec "opreport --long-filenames event:$event" "" "" 100 ]
- if { [regexp "error:" "$result" ]} {
- fail "$test: {$event} created nonzero sample files"
- } else {
- pass "$test: {$event} created nonzero sample files"
- }
- }
- }
+ set n [lindex $ctr 0]
+ set event [lindex $ctr 1]
+ case $op_version {
+ { 0.1* 0.2* 0.3* 0.4* } {
+ fail "ERROR: testsuite not supported on version {$op_version}"
+ }
+ { 0.5* } {
+ set files [glob -nocomplain -types f "$op_var_prefix/samples/*#$n"]
+ if {[llength $files] == 0} {
+ unresolved "$test: {$ctr} created no files"
+ } else {
+ set sz 0
+ verbose "looking at [llength $files] sample files for ctr $n"
+ foreach f $files {
+ set nsz [file size $f]
+ if {$nsz > $sz} {
+ set sz $nsz
+ }
+ }
+ if {$sz == 0} {
+ unresolved "$test: {$ctr} created only zero-length files"
+ } else {
+ pass "$test: {$ctr} created nonzero sample files"
+ }
+ }
+ }
+ { * } {
+ # default for all newer versions of oprofile
+ verbose "running opreport --long-filenames event:$event"
+ set result [local_exec "opreport --long-filenames event:$event" "" "" 100 ]
+ if { [regexp "error:" "$result" ]} {
+ fail "$test: {$event} created nonzero sample files"
+ } else {
+ pass "$test: {$event} created nonzero sample files"
+ }
+ }
+ }
}
}

@@ -111,30 +111,30 @@ proc op_daemon_start {ctrs} {
local_exec "rm -f /root/.oprofile/daemonrc" "" "" 100

if {$op_module_active == 0} {
- unsupported "daemon start"
- return
+ unsupported "daemon start"
+ return
}

set ctr_opts {}
foreach ctr $ctrs {
- set n [lindex $ctr 0]
- set event [lindex $ctr 1]
- set um [lindex $ctr 2]
- set count [lindex $ctr 3]
- case $op_version {
- { 0.1* 0.2* 0.3* 0.4* } {
- fail "ERROR: testsuite not supported on version {$op_version}"
- }
- { 0.5* } {
- append ctr_opts " --ctr${n}-event=${event}"
- append ctr_opts " --ctr${n}-count=${count}"
- append ctr_opts " --ctr${n}-unit-mask=${um}"
- }
- { * } {
- # default for all newer versions of oprofile
- append ctr_opts " --event=${event}:${count}:${um}"
- }
- }
+ set n [lindex $ctr 0]
+ set event [lindex $ctr 1]
+ set um [lindex $ctr 2]
+ set count [lindex $ctr 3]
+ case $op_version {
+ { 0.1* 0.2* 0.3* 0.4* } {
+ fail "ERROR: testsuite not supported on version {$op_version}"
+ }
+ { 0.5* } {
+ append ctr_opts " --ctr${n}-event=${event}"
+ append ctr_opts " --ctr${n}-count=${count}"
+ append ctr_opts " --ctr${n}-unit-mask=${um}"
+ }
+ { * } {
+ # default for all newer versions of oprofile
+ append ctr_opts " --event=${event}:${count}:${um}"
+ }
+ }
}

verbose "running opcontrol --reset"
@@ -143,18 +143,18 @@ proc op_daemon_start {ctrs} {
# this will activate the daemon too. opcontrol is so silly.

if {$op_vmlinux == 0} {
- set kernel_control "--no-vmlinux"
+ set kernel_control "--no-vmlinux"
} else {
- set kernel_control "--vmlinux=${op_vmlinux}"
+ set kernel_control "--vmlinux=${op_vmlinux}"
}
set cmd "opcontrol --setup ${kernel_control} ${ctr_opts}"
set test $cmd
verbose "running '$cmd'"
set result [local_exec $cmd "" "" 100]
if {[lindex $result 0] == 0} {
- pass $test
+ pass $test
} else {
- fail $test
+ fail $test
}

# this starts daemon, but doesn't start profiling
@@ -163,33 +163,33 @@ proc op_daemon_start {ctrs} {
verbose "running '$cmd'"
set result [local_exec $cmd "" "" 100]
if {[lindex $result 0] == 0} {
- if {[regexp oprofiled [exec /bin/ps ax]] == 1} {
- verbose "daemon is now running"
- set op_daemon_running 1
- pass $test
- } else {
- verbose "daemon did not start as requested"
- set op_daemon_running 0
- fail $test
- }
+ if {[regexp oprofiled [exec /bin/ps ax]] == 1} {
+ verbose "daemon is now running"
+ set op_daemon_running 1
+ pass $test
+ } else {
+ verbose "daemon did not start as requested"
+ set op_daemon_running 0
+ fail $test
+ }
} else {
- verbose "opcontrol --init failed. are you root?"
- set op_daemon_running 0
- fail $test
+ verbose "opcontrol --init failed. are you root?"
+ set op_daemon_running 0
+ fail $test
}

# this activates profiling

set test "opcontrol --start"
if {$op_daemon_running == 0} {
- unsupported $test
+ unsupported $test
} else {
- verbose "running 'opcontrol --start'"
- if {[lindex [local_exec "opcontrol --start" "" "" 100] 0] == 0} {
- pass $test
- } else {
- fail $test
- }
+ verbose "running 'opcontrol --start'"
+ if {[lindex [local_exec "opcontrol --start" "" "" 100] 0] == 0} {
+ pass $test
+ } else {
+ fail $test
+ }
}
}

@@ -198,15 +198,15 @@ proc op_daemon_stop {} {

set test "opcontrol --shutdown"
if {$op_daemon_running == 0} {
- unsupported $test
+ unsupported $test
} else {
- verbose "running 'opcontrol --shutdown'"
- if {[lindex [local_exec "opcontrol --shutdown" "" "" 100] 0] == 0} {
- pass $test
- set op_daemon_running 0
- } else {
- fail $test
- }
+ verbose "running 'opcontrol --shutdown'"
+ if {[lindex [local_exec "opcontrol --shutdown" "" "" 100] 0] == 0} {
+ pass $test
+ set op_daemon_running 0
+ } else {
+ fail $test
+ }
}

# delete the daemonrc file to remove any settings from the testsuite
@@ -218,38 +218,37 @@ proc op_daemon_cycle {ctrs symbol_check} {

set ctr_opts {}
foreach ctr $ctrs {
- set n [lindex $ctr 0]
- set event [lindex $ctr 1]
- set um [lindex $ctr 2]
- set count [lindex $ctr 3]
- append ctr_opts "{$n $event $um $count} "
+ set n [lindex $ctr 0]
+ set event [lindex $ctr 1]
+ set um [lindex $ctr 2]
+ set count [lindex $ctr 3]
+ append ctr_opts "{$n $event $um $count} "
}

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 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]
-
- op_daemon_start $ctrs
+ op_daemon_start $ctrs

# run the workload
- local_exec ${workload_exc} "" "" 100
-
- op_daemon_flush
- op_daemon_check_samples_exist $ctrs
- op_daemon_stop
-
- # 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 2" "" "" 10
- set test_debug_option 0
- verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
- }
-
- op_daemon_delete_any_samples
+ local_exec ${workload_exc} "" "" 100
+
+ op_daemon_flush
+ op_daemon_check_samples_exist $ctrs
+ op_daemon_stop
+
+ # 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 2" "" "" 10
+ set test_debug_option 0
+ verify_output $op_workload_table($entry) $workload_exc $ctr_opts $test_debug_option
+ }
+
+ op_daemon_delete_any_samples
}
}

@@ -259,8 +258,8 @@ proc op_check_daemon {} {
set symbol_check 1

foreach spec $op_event_table($cpu) {
- op_daemon_cycle $spec $symbol_check
- set symbol_check 0
+ op_daemon_cycle $spec $symbol_check
+ set symbol_check 0
}
}

@@ -296,18 +295,18 @@ if {$op_version == 0} {
} else {
check_user
if {$user_is_root == 0} {
- send "\nYou must be root to run the OProfile opcontrol interface.\n"
- send "Will not run opcontrol tests.\n"
+ send "\nYou must be root to run the OProfile opcontrol interface.\n"
+ send "Will not run opcontrol tests.\n"
} else {
- # Just to be paranoid and make sure there is no operf or opcontrol
- # data that opreport might pickup by mistake, delete any existing
- # data.
- pass $test
- set opcontrol_installed 1
- operf_delete_samples
- op_daemon_delete_any_samples
-
- oprofile_start
- op_check_daemon
+ # Just to be paranoid and make sure there is no operf or opcontrol
+ # data that opreport might pickup by mistake, delete any existing
+ # data.
+ pass $test
+ set opcontrol_installed 1
+ operf_delete_samples
+ op_daemon_delete_any_samples
+
+ oprofile_start
+ op_check_daemon
}
}
diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofile-operf/oprofile-operf-run.exp
index 2a4b4f8..0d846cf 100644
--- a/testsuite/oprofile-operf/oprofile-operf-run.exp
+++ b/testsuite/oprofile-operf/oprofile-operf-run.exp
@@ -33,18 +33,16 @@ proc oprofile-operf_run_system_wide_tests {} {
set cpu [operf_cpu_type]

if {$cpu == "bogus"} {
- send "Error, not able find cpu type exiting.\n"
-
+ send "Error, not able find cpu type exiting.\n"
} else {
-
- set symbol_check 1
- foreach spec $op_event_table($cpu) {
- # Just do the symbol check on the first event group. The
- # assumption is the first event group contains cycles or count
- # instructions which will reliably collect a lot of samples.
- do_system-wide_test $spec $symbol_check
- set symbol_check 0
- }
+ set symbol_check 1
+ foreach spec $op_event_table($cpu) {
+ # Just do the symbol check on the first event group. The
+ # assumption is the first event group contains cycles or count
+ # instructions which will reliably collect a lot of samples.
+ do_system-wide_test $spec $symbol_check
+ set symbol_check 0
+ }
}
}

@@ -55,18 +53,18 @@ proc oprofile-callgraph_run_tests {} {
global op_event_table

set cpu [operf_cpu_type]
- if {$cpu == "bogus"} {
- send "Error, not able find cpu type exiting.\n"
- } else {
- # test callgraph output
- set output_check 3
- set test_debug_option 0
-
- # 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_single_process_test $spec $output_check $test_debug_option
- }
+ if {$cpu == "bogus"} {
+ send "Error, not able find cpu type exiting.\n"
+ } else {
+ # test callgraph output
+ set output_check 3
+ set test_debug_option 0
+
+ # 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_single_process_test $spec $output_check $test_debug_option
+ }
}

proc oprofile-kallsyms-readable_run_tests {} {
@@ -80,17 +78,17 @@ proc oprofile-kallsyms-readable_run_tests {} {
set cmd "cat /proc/sys/kernel/kptr_restrict"
set kptr_restrict [ lindex [split [local_exec $cmd "" "" 10 ] "\{\}" ] 1 ]

- if {$cpu == "bogus"} {
- send "Error, not able find cpu type exiting.\n"
- } else {
- # kallsyms output check
- set output_check 2
- set test_debug_option 0
-
- # The goal here is a quick check to see if /proc/kallsyms was readable
- set spec [lindex $op_event_table($cpu) 0]
- do_single_process_test $spec $output_check $test_debug_option
- }
+ if {$cpu == "bogus"} {
+ send "Error, not able find cpu type exiting.\n"
+ } else {
+ # kallsyms output check
+ set output_check 2
+ set test_debug_option 0
+
+ # The goal here is a quick check to see if /proc/kallsyms was readable
+ set spec [lindex $op_event_table($cpu) 0]
+ do_single_process_test $spec $output_check $test_debug_option
+ }
}


@@ -126,37 +124,37 @@ if { $operf_version == 0 } {
send "Skipping the operf tests.\n"
send "Unable to find or verify the version of the OProfile operf utility.\n"
} else {
- # Ensure that the oprofile kernel module is unloaded, since it can
- # interfere with proper operf operation on some platforms.
- if {$opcontrol_installed == 1} {
- local_exec "opcontrol --deinit" "" "" 100
- # Make sure there are no samples from the opcontrol laying
- # around that opreport might inadvertently pick up.
- op_daemon_delete_any_samples
- }
- # Make sure there are no samples from the operf laying
+ # Ensure that the oprofile kernel module is unloaded, since it can
+ # interfere with proper operf operation on some platforms.
+ if {$opcontrol_installed == 1} {
+ local_exec "opcontrol --deinit" "" "" 100
+ # Make sure there are no samples from the opcontrol laying
# around that opreport might inadvertently pick up.
- operf_delete_samples
-
- check_user
- if {$user_is_root == 0} {
- send "Skipping the operf system-wide tests.\n"
- send " You must be root to run operf with the --system-wide parameter.\n\n"
- } else {
- send "Running the operf system-wide tests.\n"
- oprofile-operf_run_system_wide_tests
+ op_daemon_delete_any_samples
+ }
+ # Make sure there are no samples from the operf laying
+ # around that opreport might inadvertently pick up.
+ operf_delete_samples
+
+ check_user
+ if {$user_is_root == 0} {
+ send "Skipping the operf system-wide tests.\n"
+ send " You must be root to run operf with the --system-wide parameter.\n\n"
+ } else {
+ send "Running the operf system-wide tests.\n"
+ oprofile-operf_run_system_wide_tests
+ }
+ send "Running the operf callgraph tests\n"
+ oprofile-callgraph_run_tests
+
+ case $operf_version {
+ { 0.* } {
+ # no pre 1.0 specific tests to run
+ }
+ { * } {
+ # kallsyms support was added in version 1.0.
+ send "Running the operf kallsyms-readable tests. (symbols,kallsyms,callgraph) \n"
+ oprofile-kallsyms-readable_run_tests
}
- send "Running the operf callgraph tests\n"
- oprofile-callgraph_run_tests
-
- case $operf_version {
- { 0.* } {
- # no pre 1.0 specific tests to run
- }
- { * } {
- # kallsyms support was added in version 1.0.
- send "Running the operf kallsyms-readable tests. (symbols,kallsyms,callgraph) \n"
- oprofile-kallsyms-readable_run_tests
- }
- }
+ }
}
diff --git a/testsuite/oprofile-single_process/oprofile-single_process-run.exp b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
index caeb002..516780b 100644
--- a/testsuite/oprofile-single_process/oprofile-single_process-run.exp
+++ b/testsuite/oprofile-single_process/oprofile-single_process-run.exp
@@ -32,18 +32,17 @@ proc oprofile-single_process_run_tests {} {
global op_event_table
set cpu [operf_cpu_type]

-
if {$cpu == "bogus"} {
- send "Error, run single process test not able find CPU type, exiting.\n"
+ send "Error, run single process test not able find CPU type, exiting.\n"
} else {
- # check for workload symbols in output
- set output_check 1
- set test_debug_option 0
+ # check for workload symbols in output
+ set output_check 1
+ set test_debug_option 0

- # 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_single_process_test $spec $output_check $test_debug_option
+ # 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_single_process_test $spec $output_check $test_debug_option
}
}

@@ -52,17 +51,17 @@ proc oprofile-debug-option_run_tests {} {
set cpu [operf_cpu_type]

if {$cpu == "bogus"} {
- send "Error, run debug-info option test not able find CPU type, exiting.\n"
+ send "Error, run debug-info option test not able find CPU type, exiting.\n"
} else {
- # check for workload symbols in output
- set output_check 1
- # test --debug-info option
- set test_debug_option 1
+ # check for workload symbols in output
+ set output_check 1
+ # test --debug-info option
+ set test_debug_option 1

- # The goal here is a quick sanity check that the --debug
- # option doesn't crash the opreport tool
- set spec [lindex $op_event_table($cpu) 0]
- do_single_process_test $spec $output_check $test_debug_option
+ # The goal here is a quick sanity check that the --debug
+ # option doesn't crash the opreport tool
+ set spec [lindex $op_event_table($cpu) 0]
+ do_single_process_test $spec $output_check $test_debug_option
}
}
Michael Petlan
2016-04-01 15:21:47 UTC
Permalink
Raw Message
Hi Oprofile devs,
A handful of changes to the oprofile-tests suite, for consideration.
I stumbled across an issue while running the tests, dug in a bit, and came
out with this short series of patches to improve things. Most of the
changes are cosmetic, but a couple will affect the suite behavior, most
notably that more of the tests will be runnable as a normal user, and we
will successfully run more tests as root when the kptr_restrict mode is
in restricted mode, where we previously would have punted. (Additional
detail in the patch descriptions.)
I've tested these changes against an older (0.9.8) install, as well as
against latest (1.2.0git), no new issues in my testing.
before: 49/49 tests passed.
after: 74/78 to 78/78 tests passed. (depending on the value of kptr_restrict)
No notable changes. My latest run showed
after: 113/117 to 117/117 tests passed. (depending on kptr_restrict)
Thanks,
-Will
Hi,

I have run the testsuite with your patches on a few machines and I like
the changes. Thank you for them.

I am interested in the failures related to the value of kptr_restrict.
Could you please provide more information about your testing?

Which kptr_restrict values it passes with? Which values it fails with?
Which kernel versions, archs, systems have you used?

I have met an issue with incorrect kallsyms detection (see the patch
I have sent recently). I noticed that issue by running the patched suite
where it was reporting "set kptr_restrict to 0" despite having it 0.

Also please try to run

grep -e ' _stext' -e ' _text' -e ' _etext' /proc/kallsyms

on the box(es) where you tested the suite and send the output. In case
your kernel's kallsyms file has the _stext symbol, could you also try
to run the tests against oprofile with my patch if anything changes.

Thank you!

Michael
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
oprofile-list mailing list
https://lists.sourceforge.net/lists/listinfo/oprofile-list
Will Schmidt
2016-04-01 20:53:54 UTC
Permalink
Raw Message
Post by Michael Petlan
Hi Oprofile devs,
A handful of changes to the oprofile-tests suite, for consideration.
I stumbled across an issue while running the tests, dug in a bit, and came
out with this short series of patches to improve things. Most of the
changes are cosmetic, but a couple will affect the suite behavior, most
notably that more of the tests will be runnable as a normal user, and we
will successfully run more tests as root when the kptr_restrict mode is
in restricted mode, where we previously would have punted. (Additional
detail in the patch descriptions.)
I've tested these changes against an older (0.9.8) install, as well as
against latest (1.2.0git), no new issues in my testing.
before: 49/49 tests passed.
after: 74/78 to 78/78 tests passed. (depending on the value of kptr_restrict)
No notable changes. My latest run showed
after: 113/117 to 117/117 tests passed. (depending on kptr_restrict)
Thanks,
-Will
Hi,
I have run the testsuite with your patches on a few machines and I like
the changes. Thank you for them.
I am interested in the failures related to the value of kptr_restrict.
Could you please provide more information about your testing?
Which kptr_restrict values it passes with? Which values it fails with?
Which kernel versions, archs, systems have you used?
I'm mostly power focused, so ppc64 and ppc64le arches on power7 and
power8 hardware. I do some sniff tests on x86. The distro flavor
varies, mostly fedora based, but some RHEL/SuSE/Ubuntu installs
sprinkled in from time to time.

For the kernel versions, at a glance the oldest I've run against is
2.6.32.*, and newest is 4.2.0.*. All distro provided kernels.
Post by Michael Petlan
I have met an issue with incorrect kallsyms detection (see the patch
I have sent recently). I noticed that issue by running the patched suite
where it was reporting "set kptr_restrict to 0" despite having it 0.
Is that the blurb that now looks like so: ?
fail " Failed to obtain the kernel symbols from kallsyms."
print "Verify the test is being run as root or that "
print "/proc/sys/kernel/kptr_restrict is set to 0."
send "The current value of kptr_restrict is: "

The alternative path into that error message would be if something else
went wrong such that the expected symbol was not found in the
opreport.
Post by Michael Petlan
Also please try to run
grep -e ' _stext' -e ' _text' -e ' _etext' /proc/kallsyms
Each of my boxes returns roughly the following.
power:
c000000000000000 T _stext
c000000000000000 T _text
c000000000950000 R _etext
x86:
ffffffff81000000 T _text
ffffffff810001c8 T _stext
ffffffff8177a6f2 T _etext

when kptr_restrict is 2, the values are always zero'd out, regardless of
if I run that grep as root or user.
when kptr_restrict is 1, the values are zero for user, valid for root.
and when kptr_restrict is 0, values are always valid.
Post by Michael Petlan
on the box(es) where you tested the suite and send the output. In case
your kernel's kallsyms file has the _stext symbol, could you also try
to run the tests against oprofile with my patch if anything changes.
I don't see any obvious changes in output with your patch applied. The
_stext and _text values on the power systems appear to always be the
same, at the bottom of the kernel address space, so would not make a
difference there. On the x86* boxes I've got, that value varies just a
little bit,.. I'm not sure how significant that delta is in the grand
scheme of things, I don't expect a whole lot of symbols are in the
*[000]-*[1c8] range that I'd be missing. :-)


What arch/kernel versions are you seeing the problem with? I'll look
closer/deeper if I can.

Thanks,
-Will
Post by Michael Petlan
Thank you!
Michael
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
oprofile-list mailing list
https://lists.sourceforge.net/lists/listinfo/oprofile-list
William Cohen
2016-04-01 18:55:12 UTC
Permalink
Raw Message
Hi Oprofile devs,
A handful of changes to the oprofile-tests suite, for consideration.
I stumbled across an issue while running the tests, dug in a bit, and came
out with this short series of patches to improve things. Most of the
changes are cosmetic, but a couple will affect the suite behavior, most
notably that more of the tests will be runnable as a normal user, and we
will successfully run more tests as root when the kptr_restrict mode is
in restricted mode, where we previously would have punted. (Additional
detail in the patch descriptions.)
I've tested these changes against an older (0.9.8) install, as well as
against latest (1.2.0git), no new issues in my testing.
before: 49/49 tests passed.
after: 74/78 to 78/78 tests passed. (depending on the value of kptr_restrict)
No notable changes. My latest run showed
after: 113/117 to 117/117 tests passed. (depending on kptr_restrict)
Thanks,
-Will
Hi Will,

Thanks for the patches. I looked over the patches, tried the patches out and they do improve the results.
They have been applied to the upstream oprofile-testsuite.

-Will
Will Schmidt
2016-04-01 20:54:22 UTC
Permalink
Raw Message
Post by William Cohen
Hi Oprofile devs,
A handful of changes to the oprofile-tests suite, for consideration.
I stumbled across an issue while running the tests, dug in a bit, and came
out with this short series of patches to improve things. Most of the
changes are cosmetic, but a couple will affect the suite behavior, most
notably that more of the tests will be runnable as a normal user, and we
will successfully run more tests as root when the kptr_restrict mode is
in restricted mode, where we previously would have punted. (Additional
detail in the patch descriptions.)
I've tested these changes against an older (0.9.8) install, as well as
against latest (1.2.0git), no new issues in my testing.
before: 49/49 tests passed.
after: 74/78 to 78/78 tests passed. (depending on the value of kptr_restrict)
No notable changes. My latest run showed
after: 113/117 to 117/117 tests passed. (depending on kptr_restrict)
Thanks,
-Will
Hi Will,
Thanks for the patches. I looked over the patches, tried the patches out and they do improve the results.
They have been applied to the upstream oprofile-testsuite.
Awesome, thanks! :-)

Thanks,
-Will
Post by William Cohen
-Will
Loading...