Debian Codegraph @

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

raw
1 set test "flightrec4"
2 if {![installtest_p]} { untested $test; return }
3
4 # Make sure we start with a clean slate.
5 catch {exec rm -f $test.out*}
6
7 # run stapio in background mode with number limit
8 spawn stap -u -F -S 1,2 -o $test.out -we {probe timer.ms(200){log("hey!")}}
9 # check whether stap outputs stapio pid
10 set pid 0
11 expect {
12 -timeout 240
13 -re {([0-9]+)\r\n} {
14 pass "$test (flight recorder option)"
15 set pid $expect_out(1,string)
16 exp_continue}
17 timeout { fail "$test (timeout)" }
18 eof { }
19 }
20 # Here we're waiting on the parent stap process to finish. Stapio will
21 # still be running in the background.
22 catch { close }; catch { wait }
23
24 if {$pid == 0} {
25 fail "$test (no pid)"
26 return -1
27 }
28
29 # switch file to .1
30 exec sleep 2
31 kill -USR2 $pid
32
33 # check output file
34 if {[catch {exec rm $test.out.0}]} {
35 fail "$test (no output file)"
36 return -1
37 } else {
38 pass "$test (output file)"
39 }
40
41 # switch file to .2
42 exec sleep 2
43 kill -USR2 $pid
44 # switch file to .3 (this time, .1 file should be deleted)
45 exec sleep 2
46 kill -USR2 $pid
47
48 # check switched output file
49 exec sleep 2
50 if {[catch {exec rm $test.out.1}]} {
51 pass "$test (old output file is removed)"
52 } else {
53 fail "$test (failed to remove output file)"
54 return -1
55 }
56
57 # Kill the background stapio process.
58 kill -TERM $pid 5
59
60 # check switched output file
61 if {[catch {exec rm $test.out.2 $test.out.3}]} {
62 fail "$test (failed to switch output file)"
63 return -1
64 } else {
65 pass "$test (switch output file)"
66 }
67