Re: [PATCH] [V2] oprofile-tests update error handling around ocount calls
Will Schmidt <[email protected]>
| Newsgroups | gmane.linux.oprofile |
|---|---|
| Message-ID | <[email protected]> |
Update the expect script to handle (and return with an error message) when ocount returns an "Unable to obtain cpu_type" error message/string. Subsequently turns this confusing output: ERROR: tcl error sourcing ./oprofile-ocount/ocount-run.exp. ERROR: invalid bareword "to" in expression "to * 2"; into this easier to understand blurb: ERROR: Ocount failed to obtain a valid cpu_type. While in the neighborhood, also did a few cosmetic touch-ups. Tested on ppc64/ppc64le/x86_64. Signed-off-by: Will Schmidt <[email protected]> --- lib/ocount_util.exp | 9 +++++++++ oprofile-ocount/ocount-run.exp | 11 ++++++++--- oprofile-operf/oprofile-operf-run.exp | 8 ++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/testsuite/lib/ocount_util.exp b/testsuite/lib/ocount_util.exp index 28df1a4..292fad0 100644 --- a/testsuite/lib/ocount_util.exp +++ b/testsuite/lib/ocount_util.exp @@ -68,6 +68,15 @@ proc check_nonzero_count {count workload event} { } } +proc check_ocount_valid_cpu_type {} { + set ocount_result [ local_exec "ocount " "" "" 5 ] + if { [ regexp "Unable to obtain cpu_type" $ocount_result ] } { + send "\nERROR: Ocount failed to obtain a valid cpu_type.\n" + return 0 + } + return 1 +} + proc get_event_count { result symbol} { set words [regexp -all -inline {\S+} $result] diff --git a/testsuite/oprofile-ocount/ocount-run.exp b/testsuite/oprofile-ocoun index 047e0ff..a0abcea 100644 --- a/testsuite/oprofile-ocount/ocount-run.exp +++ b/testsuite/oprofile-ocount/ocount-run.exp @@ -90,7 +90,7 @@ proc do_test_ocount_scaling {workload_exec} { # Version 1.0 and beyond time interval is in units of milliseconds set run_time_interval1 [expr $interval1 * 1000] set run_time_interval2 [expr $interval2 * 1000] - set run_time_interval4 [expr $interval4 * 1000] + set run_time_interval4 [expr $interval4 * 1000] } } @@ -245,7 +245,7 @@ proc do_test_ocount_modes {workload_exec} { # Check the counts are not zero check_nonzero_count $u_count $workload_exec $event - check_nonzero_count $k_count $workload_exec $event] + check_nonzero_count $k_count $workload_exec $event check_nonzero_count $u_k_count $workload_exec $event # Check the scaling of the results @@ -267,7 +267,12 @@ proc ocount_run_tests {} { set workload_exec [compile_ocount_workload "workload_ocount/load.c"] -send "ocount_run_tests\n" + send "ocount_run_tests\n" + + # if ocount can't determine the cpu_type properly, just return. + if {[check_ocount_valid_cpu_type] == 0 } { + return 0 + } # Check the brief format counting cycles gives non-zero count do_test_ocount_cycle_test $workload_exec "--brief-format" diff --git a/testsuite/oprofile-operf/oprofile-operf-run.exp b/testsuite/oprofil index 0d846cf..2409a9c 100644 --- a/testsuite/oprofile-operf/oprofile-operf-run.exp +++ b/testsuite/oprofile-operf/oprofile-operf-run.exp @@ -2,7 +2,7 @@ # Copyright (C) 2012 Carl Love, IBM # # Modified by Carl Love <[email protected]> -# Copyright (C) 2013 Carl Love, IBM Corporation +# Copyright (C) 2013-2017 Carl Love, IBM Corporation # # 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 @@ -33,7 +33,7 @@ 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 to find a valid cpu type. Exiting.\n" } else { set symbol_check 1 foreach spec $op_event_table($cpu) { @@ -54,7 +54,7 @@ proc oprofile-callgraph_run_tests {} { set cpu [operf_cpu_type] if {$cpu == "bogus"} { - send "Error, not able find cpu type exiting.\n" + send "Error, not able to find a valid cpu type. Exiting.\n" } else { # test callgraph output set output_check 3 @@ -79,7 +79,7 @@ proc oprofile-kallsyms-readable_run_tests {} { set kptr_restrict [ lindex [split [local_exec $cmd "" "" 10 ] "\{\}" ] 1 ] if {$cpu == "bogus"} { - send "Error, not able find cpu type exiting.\n" + send "Error, not able to find a valid cpu type. Exiting.\n" } else { # kallsyms output check set output_check 2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot