summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/maxactive.exp
blob: b5cb7dd75461ca7e4ed9381aa8d0fc6ffeba0f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# maxactive.exp
#
# Check to see if using the 'maxactive(N)' limit on return probes
# works, by seeing if skipped probes increases when using it.

if {[info procs installtest_p] != "" && ![installtest_p]} {
    untested "MAXACTIVE"
    return
}

proc sleep_five_sec {} {
    after 5000;
    return 0;
}

# Script1.  For 5 seconds, probe the return of "sys_select" and
# "sys_read".  See if we skip any probes.
set script1 {
    probe kernel.function("sys_select").return,
        kernel.function("sys_read").return { }

    probe timer.ms(5000) { exit(); }
    probe begin { log("systemtap starting probe"); }
    probe end { log("systemtap ending probe"); }
}

# Run script1 and save the number of skipped probes (which will most
# likely be 0).
stap_run "MAXACTIVE01" sleep_five_sec "" -e $script1
set skipped1 $skipped_probes

# Script2.  For 5 seconds, probe the return of "sys_select" and
# "sys_read", with a limit of 1 probe active at a time.  See if we
# skip any probes.
set script2 {
    probe kernel.function("sys_select").return.maxactive(1),
        kernel.function("sys_read").return.maxactive(1) { }

    probe timer.ms(5000) { exit(); }
    probe begin { log("systemtap starting probe"); }
    probe end { log("systemtap ending probe"); }
}

# Run script2 and save the number of skipped probes.
stap_run "MAXACTIVE02" sleep_five_sec "" -e $script2
set skipped2 $skipped_probes

# If the number of skipped probes for script 1 is less than the number
# of skipped probes for script 2, we can assume that "maxactive(N)" is
# working.
#
# Note that this isn't 100% accurate based on the system load at the
# time of the scripts.
set test "MAXACTIVE03"
if {$skipped1 < $skipped2} {
    pass "$test ($skipped1 skipped probes < $skipped2 skipped probes)"
} else {
    fail "$test ($skipped1 skipped probes > $skipped2 skipped probes)"
}