Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/timers.stp

raw
1 /*
2 * timers.stp
3 *
4 * Test the functionality of the various timer.* probes.
5 */
6
7 global p
8 global phz
9 global j1, j2, jmax, jr
10 global ms1, ms500, msmax, msr
11 global sec, secr, us, usr, ns, nsr, hz
12
13 probe begin
14 {
15 printf("systemtap starting probe\n")
16 }
17
18 probe timer.profile { ++p }
19 probe timer.profile.freq.hz(10) { ++phz }
20
21 probe timer.jiffies(1) { ++j1 }
22 probe timer.jiffies(2) { ++j2 }
23 probe timer.jiffies(1000000) { ++jmax }
24 probe timer.jiffies(100).randomize(50) { ++jr }
25
26 /* as long as HZ>2, ms(1) and ms(500)
27 * will produce different counts */
28 probe timer.ms(1) { ++ms1 }
29 probe timer.ms(500) { ++ms500 }
30 probe timer.ms(1000000) { ++msmax }
31 probe timer.ms(1000).randomize(500) { ++msr }
32
33 probe timer.sec(5) { ++sec }
34 probe timer.sec(5).randomize(4) { ++secr }
35
36 probe timer.us(1000) { ++us }
37 probe timer.us(1000).randomize(500) { ++usr }
38
39 probe timer.ns(1000000) { ++ns }
40 probe timer.ns(1000000).randomize(500000) { ++nsr }
41
42 probe timer.hz(1000) { ++hz }
43
44 probe end
45 {
46 printf("systemtap ending probe\n")
47 printf("p = %d\n", p)
48 printf("phz = %d\n", phz)
49 printf("j1 = %d\n", j1)
50 printf("j2 = %d\n", j2)
51 printf("jr = %d\n", jr)
52 printf("jmax = %d\n", jmax)
53 printf("ms1 = %d\n", ms1)
54 printf("ms500 = %d\n", ms500)
55 printf("msmax = %d\n", msmax)
56 printf("msr = %d\n", msr)
57
58 printf("sec = %d\n", sec)
59 printf("secr = %d\n", secr)
60 printf("us = %d\n", us)
61 printf("usr = %d\n", usr)
62 printf("ns = %d\n", nsr)
63 printf("nsr = %d\n", nsr)
64 printf("hz = %d\n", hz)
65
66 /* profile counter should be non-zero, and at
67 * least as many as the jiffies(1) counter */
68 /* (fudge comparison by ~1% since start & end aren't synchronized) */
69 if ((p > 0) && (p*100 >= j1*99)) {
70 printf("systemtap test success\n")
71 } else {
72 printf("unexpected profile count: %d profiles and %d jiffies\n", p, j1)
73 printf("systemtap test failure\n");
74 }
75
76 /* jiffies(1) should count more than jiffies(2),
77 * and both should be non-zero. */
78 if ((j2 > 0) && (j2 < j1)) {
79 printf("systemtap test success\n")
80 } else {
81 printf("unexpected jiffies count\n")
82 printf("systemtap test failure\n");
83 }
84
85 /* timer.profile.freq.hz(10) should be more than
86 * ms(500) and less than ms(1). */
87 if ((phz > ms500) && (phz < ms1)) {
88 printf("systemtap test success\n")
89 } else {
90 printf("unexpected ms count\n")
91 printf("systemtap test failure\n");
92 }
93
94 /* ms(1) should count more than ms(500),
95 * and both should be non-zero. */
96 if ((ms500 > 0) && (ms500 < ms1)) {
97 printf("systemtap test success\n")
98 } else {
99 printf("unexpected ms count\n")
100 printf("systemtap test failure\n");
101 }
102
103 /* both 'infinite' intervals should register zero counts */
104 if ((jmax == 0) && (msmax == 0)) {
105 printf("systemtap test success\n")
106 } else {
107 printf("unexpected count on 'infinite' interval\n")
108 printf("systemtap test failure\n");
109 }
110
111 if (jr * msr * secr * usr * nsr > 0) {
112 printf("systemtap test success\n")
113 } else {
114 printf("unexpected randomize count\n")
115 printf("systemtap test failure\n");
116 }
117
118 if (sec > 0) {
119 printf("systemtap test success\n")
120 } else {
121 printf("unexpected sec count\n")
122 printf("systemtap test failure\n");
123 }
124
125 if (us > 0) {
126 printf("systemtap test success\n")
127 } else {
128 printf("unexpected us count\n")
129 printf("systemtap test failure\n");
130 }
131
132 if (ns > 0) {
133 printf("systemtap test success\n")
134 } else {
135 printf("unexpected ns count\n")
136 printf("systemtap test failure\n");
137 }
138
139 if (hz > 0) {
140 printf("systemtap test success\n")
141 } else {
142 printf("unexpected hz count\n")
143 printf("systemtap test failure\n");
144 }
145 }