| 1 |
set test "flightrec1" |
| 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 |
| 8 |
spawn stap -u -F -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 |
# check whether stapio is running in background |
| 30 |
spawn ps -o cmd hc $pid |
| 31 |
expect { |
| 32 |
-timeout 10 |
| 33 |
"stapio" {pass "$test (stapio in background)"} # don't contine |
| 34 |
timeout { fail "$test (timeout)"} |
| 35 |
eof { fail "$test (stapio was not found)" } |
| 36 |
} |
| 37 |
catch { close }; catch { wait } |
| 38 |
|
| 39 |
# switch file |
| 40 |
exec sleep 2 |
| 41 |
kill -USR2 $pid |
| 42 |
|
| 43 |
# check output file |
| 44 |
exec sleep 2 |
| 45 |
if {[catch {exec rm $test.out}]} { |
| 46 |
fail "$test (no output file)" |
| 47 |
return -1 |
| 48 |
} else { |
| 49 |
pass "$test (output file)" |
| 50 |
} |
| 51 |
|
| 52 |
# Kill the background stapio process. |
| 53 |
kill -TERM $pid 5 |
| 54 |
|
| 55 |
# check switched output file |
| 56 |
if {[catch {exec rm $test.out.1}]} { |
| 57 |
fail "$test (failed to switch output file)" |
| 58 |
return -1 |
| 59 |
} else { |
| 60 |
pass "$test (switch output file)" |
| 61 |
} |