Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/flightrec2.exp

raw
1 set test "flightrec2"
2 if {![installtest_p]} { untested $test; return }
3
4 # cleanup
5 system "rm -f flightlog.out*"
6
7 set pid 0
8 # check -S option
9 spawn stap -F -o flightlog.out -S 1,3 $srcdir/$subdir/$test.stp
10 expect {
11 -timeout 240
12 -re {([0-9]+)\r\n} {
13 pass "$test (-S option)"
14 set pid $expect_out(1,string)
15 exp_continue}
16 timeout { fail "$test (timeout)"}
17 eof { }
18 }
19
20 # After 10 seconds the stap run should be finished and logs generated
21 # So, wait slightly more than 10 seconds - to be on the safe side.
22
23 exec sleep 15
24
25 # At this point we've generated ~4.2MB of data. Given stap -S 1,3, we
26 # can expect flightlog.out.2 flightlog.out.3 flightlog.out.4. Where
27 # first two have their size roughly 1 MB and the last one roughly 200 kB.
28
29 set scnt 0
30 set cnt1 0
31
32 # check log files
33 eval spawn stat -c %s [glob flightlog.out.*]
34 expect {
35 -timeout 100
36 -re {[0-9]+} {
37 incr cnt1;
38 if {$expect_out(buffer) <= 1100000 } {incr scnt}
39 exp_continue}
40 timeout { fail "$test (logfile timeout)"}
41 }
42 catch { close }; catch { wait }
43 exec sleep 3
44 set cnt2 0
45
46 # check logfile count
47 if {$cnt1 == 3} {
48 pass "$test (log file numbers limitation)"
49 } else {
50 fail "$test (log file numbers ($cnt1, $cnt2))"
51 }
52
53 # check logfile size
54 if {$scnt == $cnt1 } {
55 pass "$test (log file size limitation)"
56 } else {
57 fail "$test (log file size ($scnt != $cnt1))"
58 }
59