proc probe_ok {probepoint} {
    set cmd {exec stap -p2 -e}
    lappend cmd "probe $probepoint {}"
    return [expr ![catch $cmd]]
}

set systemtap_script {
    global stat
    probe %s {
        stat[probefunc()] <<< 1
    }
    probe begin { log ("systemtap starting probe") }
    probe end {
        log ("systemtap ending probe")
        foreach (func in stat limit 5) # don't overflow expect buffer
            printf("%%d  %%s\n", @count(stat[func]), func)
    }
}

set letters [split {abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ} {}]

set output_string "(\\d+  \\w+\\r\\n)*(WARNING.*skipped.*)?"

# Because this test is known to expose system crashes, it is not enabled
# by default.  Change the line below to 'if 1' to enable it.
if 0 {
    foreach start $letters {
        set probepoint "kernel.function(\"$start*\")"
        set prefix "all_kernel_functions:"
        if [probe_ok $probepoint] {
            set script [format $systemtap_script $probepoint]
            stap_run $prefix$probepoint gen_load $output_string -e $script
        } else {
            unsupported "$prefix no match for $probepoint"
        }
    }
} else {
    untested "all_kernel_functions is disabled"
}
