Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[51a0cb]: testsuite / oprofile-operf / oprofile-operf-run.exp Maximize Restore History

Download this file

oprofile-operf-run.exp    151 lines (128 with data), 4.7 kB

# oprofile-run.exp
#   Copyright (C) 2012 Carl Love, IBM
#
# Modified by Carl Love <carll@us.ibm.com>
#   Copyright (C) 2013 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
# 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 oprofile-operf_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
	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
	}
    }
}

proc oprofile-callgraph_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.
    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 {
	    # 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 {} {
    # 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.
    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 {
	    # 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
	}
    }
}


#main
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"
} else {

    operf_get_version

    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.
	local_exec "opcontrol --deinit" "" "" 100
	# 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
	oprofile-callgraph_run_tests

	case $operf_version {
	    { 0.* } {
		# no pre 1.0 specific tests to run
	    }
	    { * } {
		# kallsyms support was added in version 1.0.
		oprofile-kallsyms-readable_run_tests
	    }
	}
    }
}