| 1 |
# Test that the --remote=host mechanism is working |
| 2 |
# Requires the test user to specify hosts with automated ssh access. |
| 3 |
|
| 4 |
set test "remote" |
| 5 |
|
| 6 |
if {[info exists env(SYSTEMTAP_TESTREMOTES)]} { |
| 7 |
set remotes [split $env(SYSTEMTAP_TESTREMOTES) ,] |
| 8 |
} |
| 9 |
if {[llength $remotes] == 0} { |
| 10 |
set remotes {direct: stapsh:} |
| 11 |
} |
| 12 |
set batch_remotes [list] |
| 13 |
|
| 14 |
verbose -log "$test: using $remotes" |
| 15 |
if {![llength $remotes] || ![installtest_p]} { untested $test; return } |
| 16 |
|
| 17 |
# Test each remote individually |
| 18 |
foreach remote $remotes { |
| 19 |
# Try building for the remote |
| 20 |
spawn stap $srcdir/$subdir/$test.stp --remote=$remote -p4 |
| 21 |
expect { |
| 22 |
-timeout 180 |
| 23 |
timeout { fail "$test build $remote (timeout)" } |
| 24 |
eof { } |
| 25 |
} |
| 26 |
catch {close}; catch {wait} res |
| 27 |
set rc [lindex $res 3] |
| 28 |
if {$rc == 0} { |
| 29 |
pass "$test build $remote" |
| 30 |
} else { |
| 31 |
fail "$test build $remote ($rc)" |
| 32 |
untested "$test run $remote" |
| 33 |
continue |
| 34 |
} |
| 35 |
|
| 36 |
# Try running on the remote |
| 37 |
set begin 0 |
| 38 |
set end 0 |
| 39 |
set err 0 |
| 40 |
spawn stap $srcdir/$subdir/$test.stp --remote=$remote |
| 41 |
expect { |
| 42 |
-timeout 180 |
| 43 |
-re "^begin0:$remote\r\n" { incr begin; kill -INT [exp_pid] 5; exp_continue } |
| 44 |
-re "^end0:$remote\r\n" { incr end; exp_continue } |
| 45 |
-re {^[^\r\n]*\r\n} { incr err; exp_continue } |
| 46 |
timeout { fail "$test run $remote (timeout)" } |
| 47 |
eof { } |
| 48 |
} |
| 49 |
catch {close}; catch {wait} |
| 50 |
if {!$err && $begin == 1 && $end == 1} { |
| 51 |
pass "$test run $remote" |
| 52 |
lappend batch_remotes "--remote=$remote" |
| 53 |
} else { |
| 54 |
fail "$test run $remote ($begin $end $err)" |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
verbose -log "$test: batch $batch_remotes" |
| 59 |
if {[llength $batch_remotes] < 2} { |
| 60 |
untested "$test batch" |
| 61 |
} else { |
| 62 |
# Try running the good ones together |
| 63 |
set begin 0 |
| 64 |
set end 0 |
| 65 |
set err 0 |
| 66 |
eval spawn stap {$srcdir/$subdir/$test.stp} $batch_remotes |
| 67 |
expect { |
| 68 |
-timeout 180 |
| 69 |
-re {^begin[0-9]+:[^\r\n]+\r\n} { |
| 70 |
incr begin |
| 71 |
if {$begin == [llength $batch_remotes]} {kill -INT [exp_pid] 5} |
| 72 |
exp_continue |
| 73 |
} |
| 74 |
-re {^end[0-9]+:[^\r\n]+\r\n} { incr end; exp_continue } |
| 75 |
-re {^[^\r\n]*\r\n} { |
| 76 |
incr err; |
| 77 |
if {$err == 1} {kill -INT [exp_pid] 5} |
| 78 |
exp_continue |
| 79 |
} |
| 80 |
timeout { fail "$test batch $batch_remotes (timeout)" } |
| 81 |
eof { } |
| 82 |
} |
| 83 |
catch {close}; catch {wait} |
| 84 |
if {!$err && [llength $batch_remotes] == $begin && $begin == $end} { |
| 85 |
pass "$test batch $batch_remotes" |
| 86 |
} else { |
| 87 |
fail "$test batch $batch_remotes ($begin $end $err)" |
| 88 |
} |
| 89 |
} |