if {![installtest_p]} {untested "OVERLOAD"; return}

set script {
    global k

    probe begin {
	print("systemtap starting probe\n")
	k["foo"] = 0
    }

    probe kernel.function("vfs_read"), kernel.function("vfs_write") {
	k["foo"]++
    }
    probe end {
	print("systemtap ending probe\n")
    }
}

# OVERLOAD1 tests to make sure normal operation doesn't receive an
# overload indication
set test "OVERLOAD1"
set error "probe overhead exceeded threshold"
stap_run_error $test 0 $error "" -u -e $script

# OVERLOAD2 is the same script, but we're adjusting the
# STP_OVERLOAD_INTERVAL and STP_OVERLOAD_THRESHOLD to low values so
# that we *will* get an overload.
set test "OVERLOAD2"
stap_run_error $test 1 $error "" -u -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script

# OVERLOAD3 is the same script with the same low STP_OVERLOAD_INTERVAL
# and STP_OVERLOAD_THRESHOLD values, but we're also specifying
# STP_NO_OVERLOAD, which should turn overload processing off.   So,
# even though we have low overhead tuning values, we *shouldn't*
# overload.
set test "OVERLOAD3"
stap_run_error $test 0 $error "" -u -DSTP_NO_OVERLOAD -DSTP_OVERLOAD_INTERVAL=1000LL -DSTP_OVERLOAD_THRESHOLD=100LL -e $script
