| 1 |
set test "flightrec5" |
| 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 and bulk mode |
| 8 |
spawn stap -u -F -S 1,2 -b -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 |
exec sleep 2 |
| 35 |
eval set outfile {[glob -nocomplain $test.out_cpu*.0]} |
| 36 |
if {$outfile == ""} { |
| 37 |
fail "$test (no output file) $outfile" |
| 38 |
kill -TERM $pid 5 |
| 39 |
return -1 |
| 40 |
} else { |
| 41 |
pass "$test (output file)" |
| 42 |
} |
| 43 |
eval exec rm $outfile |
| 44 |
|
| 45 |
# switch file to .2 |
| 46 |
kill -USR2 $pid |
| 47 |
# switch file to .3 (this time, .1 file should be deleted) |
| 48 |
exec sleep 2 |
| 49 |
kill -USR2 $pid |
| 50 |
|
| 51 |
exec sleep 2 |
| 52 |
|
| 53 |
# Kill the background stapio process. |
| 54 |
kill -TERM $pid 5 |
| 55 |
|
| 56 |
# check switched output file |
| 57 |
exec sleep 2 |
| 58 |
eval set outfile {[glob -nocomplain $test.out_cpu*.1]} |
| 59 |
if {$outfile == ""} { |
| 60 |
pass "$test (old output file is removed)" |
| 61 |
} else { |
| 62 |
fail "$test (failed to remove output file) $outfile" |
| 63 |
eval exec rm $outfile |
| 64 |
return -1 |
| 65 |
} |
| 66 |
|
| 67 |
# check switched output file |
| 68 |
eval set outfile {[glob -nocomplain $test.out_cpu*.*]} |
| 69 |
if {$outfile == ""} { |
| 70 |
fail "$test (failed to switch output file)" |
| 71 |
return -1 |
| 72 |
} else { |
| 73 |
pass "$test (switch output file)" |
| 74 |
} |
| 75 |
eval exec rm -f $outfile |
| 76 |
|