Debian Codegraph @

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

raw
1 set test "flightrec3"
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 with bulk(percpu file) mode
9 catch {spawn stap -F -o flightlog.out -S 1,3 -b $srcdir/$subdir/$test.stp}
10 expect {
11 -timeout 240
12 -re {([0-9]+)\r\n} {
13 pass "$test (-S option with bulk mode)"
14 set pid $expect_out(1,string)
15 exp_continue}
16 timeout { fail "$test (timeout)"}
17 eof { }
18 }
19 # Here we're waiting on the parent stap process to finish. Stapio will
20 # still be running in the background.
21 catch { close }; catch { wait }
22
23 if {$pid == 0} {
24 fail "$test (no pid)"
25 return -1
26 }
27
28 exec sleep 4
29 array set cpus {}
30 set scnt 0
31 # wait for log files
32 kill -STOP $pid
33 exec sleep 1
34 catch {eval spawn stat -c \"%n %s\" [glob -nocomplain flightlog.out_cpu*]}
35 expect {
36 -timeout 100
37 -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
38 set cpuid $expect_out(1,string)
39 set size $expect_out(2,string)
40 if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
41 incr cpus($cpuid);
42 if {$size <= 1048576 } {incr scnt}
43 exp_continue}
44 timeout { fail "$test (logfile timeout)"}
45 }
46 catch { close -i $spawn_id }; catch { wait -i $spawn_id }
47 kill -CONT $pid
48 exec sleep 3
49 kill -STOP $pid
50
51 catch {eval spawn stat -c \"%n %s\" [glob -nocomplain flightlog.out_cpu*]}
52 expect {
53 -timeout 100
54 -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
55 set cpuid $expect_out(1,string)
56 set size $expect_out(2,string)
57 if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
58 incr cpus($cpuid);
59 if {$size <= 1048576 } {incr scnt}
60 exp_continue}
61 timeout { fail "$test (logfile timeout)"}
62 }
63 catch { close -i $spawn_id }; catch { wait -i $spawn_id }
64 kill -CONT $pid
65 # check logfile number
66 set cnt 0
67 foreach e [array names cpus] {
68 # If we have more than 6 files per cpu, something is wrong. We
69 # might have less than 6 files per cpu if the machine is slow.
70 if {$cpus($e) > 6} {
71 fail "$test (log file numbers cpu:$e, cnt:$cpus($e)))"
72 }
73 set cnt [expr $cnt + $cpus($e)]
74 }
75 # check logfile size
76 if {$scnt == $cnt} {
77 pass "$test (log file size limitation with bulk mode)"
78 } else {
79 fail "$test (log file size ($scnt != $cnt))"
80 }
81
82 # Kill the background stapio process.
83 kill -TERM $pid 5
84 catch {system "rm -f flightlog.out*"}
85