# Set up the environment so that tests will be performed using the systemtap
# client and server.
proc setup_server {} {
- global srcdir env server_pid net_path installed_stap
+ global srcdir env net_path installed_stap
# Make sure that the necessary resources are available to run the client/server.
if {[catch {exec /usr/bin/which avahi-publish-service} dummy]} then {
return 0
}
+ # See what avahi finds. Give the server a chance to advertise.
+ exec sleep 1
+ catch { exec avahi-browse _stap._tcp -t -r | grep -A4 {^=.*Systemtap.Compile} } looksee
+ verbose -log "avahi-browse found:\n$looksee"
+
+ # Make sure that stap can find the server.
+ set use_server --use-server
+ set res [catch { exec stap --list-servers=online,trusted,compatible 2>@ stdout | grep "^ host" } looksee]
+ verbose -log "stap --list-servers found:\n$looksee"
+ if {$res != 0} then {
+ print "Unable to automatically find a systemtap server -- check firewall settings for mDNS"
+ # Try to discover the port the server is listening on from the server
+ # log.
+ set res [catch { exec /bin/cat [exec pwd]/server.log | awk "/^Systemtap Compile Server on port .* ready/ {print \$6}" } server_port]
+ if {$res != 0} then {
+ print "Unable to discover the port used by the systemtap server"
+ return 0
+ }
+ set server_spec $env(HOSTNAME):$server_port
+ print "Client/Server tests will be run by contacting the server directly as $server_spec"
+
+ # Make sure stap can contact the server directly
+ set use_server --use-server=$server_spec
+ set res [catch {exec stap $use_server -p2 -e {probe begin {exit()}}} looksee]
+ if {$res != 0} then {
+ print "Unable to contact the server at $server_spec directly"
+ return 0
+ }
+ }
+
# Substitute a script on the PATH in place of stap which calls the real
# stap with the --use-server flag.
set path "$net_path/stap"
set fp [open $path "w"]
puts $fp "#!/bin/sh"
- puts $fp "[exec which stap] --use-server \"\$@\""
+ puts $fp "[exec which stap] $use_server \"\$@\""
close $fp
exec chmod +x $path
exec touch $logfile
exec chmod 666 $logfile
- # Try to find or start the server.
+ # Try to start the server.
set server_pid [exec env STAP_PR11197_OVERRIDE=1 env SYSTEMTAP_STAP=[exec which stap] stap-start-server --log=$logfile]
if { "$server_pid" == "" } then {
print "Cannot start a systemtap server"
verbose -log "Started a systemtap server as PID==$server_pid"
}
- # See what avahi finds. Give the server a chance to advertise.
- exec sleep 1
- catch { exec avahi-browse _stap._tcp -t -r | grep -A4 {^=.*Systemtap.Compile} } looksee
- verbose -log "avahi-browse found:\n$looksee"
-
- # Make sure that stap can find the server.
- set lines [exec stap --list-servers=online,trusted,compatible 2>@ stdout | wc -l]
- if {$lines < 2} then {
- print "Unable to find a systemtap server -- check firewall settings for mDNS"
- shutdown_server
- return 0
- }
-
return 1
}
}
if {! [setup_systemtap_environment]} then {
- return 0
+ cleanup
+ exit 1
}
print_systemtap_version