diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-03-17 16:58:35 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-03-17 16:58:35 +0100 |
commit | bf33ee46c8fff4d181b7f28521f12175bd32ec77 (patch) | |
tree | 5e0a9e1047af60389eee36da54182b52d3d53ee7 /testsuite/lib | |
parent | 524c6f82b0a3c010d0fd6a67b1afcfbf55b789a6 (diff) | |
parent | 30cb532a560ed152b86506b80490e99195970271 (diff) | |
download | systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.tar.gz systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.tar.xz systemtap-steved-bf33ee46c8fff4d181b7f28521f12175bd32ec77.zip |
Merge branch 'master' into pr6866
Resolved conflicts:
runtime/task_finder.c: name vs path.
Diffstat (limited to 'testsuite/lib')
-rw-r--r-- | testsuite/lib/stap_run2.exp | 30 | ||||
-rw-r--r-- | testsuite/lib/systemtap.exp | 124 |
2 files changed, 105 insertions, 49 deletions
diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp index 9849aefb..b734a1e7 100644 --- a/testsuite/lib/stap_run2.exp +++ b/testsuite/lib/stap_run2.exp @@ -10,12 +10,27 @@ proc stap_run2 { TEST_NAME args } { # zap the srcdir prefix - set test_file_name $TEST_NAME + set TEST_FILE $TEST_NAME set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""] - + if {[llength $args] == 0} { + stap_run3 $TEST_NAME $TEST_FILE + } else { + stap_run3 $TEST_NAME $TEST_FILE $args + } +} + +# stap_run3 TEST_NAME TEST_FILE +# TEST_NAME is the name of the test as shown in PASS/FAIL/SKIPPED messages. +# TEST_FILE is the path to the current test +# Additional arguments are passed to stap as-is. +# +# global result_string must be set to the expected output + +proc stap_run3 { TEST_NAME TEST_FILE args } { if {[info procs installtest_p] != "" && ![installtest_p]} { untested $TEST_NAME; return } - - set cmd [concat stap $args $test_file_name] + + set cmd [concat stap $args $TEST_FILE] + send_log "executing: $cmd\n" catch {eval exec $cmd} res set n 0 @@ -29,5 +44,10 @@ proc stap_run2 { TEST_NAME args } { } incr n } - pass "$TEST_NAME" + if {[expr $n == [llength $expected]]} { + pass "$TEST_NAME" + } else { + fail "$TEST_NAME" + send_log "too few lines of output, got $n, expected [llength $expected]\n" + } } diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index 5bf125b9..c80ad171 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -37,7 +37,7 @@ proc print_systemtap_version {} { proc setup_systemtap_environment {} { - global srcdir prefix env server_pid net_path + global srcdir env # need an absolute SRCDIR for the top-level src/ tree # XXX: or, we could change nearby uses of ${SRCDIR}/testsuite to ${SRCDIR} @@ -53,40 +53,9 @@ proc setup_systemtap_environment {} { # Find or start a systemtap server, if requested. if {[use_server_p]} then { - print "Testing using a systemtap server" - - # A place for some temporary files and scripts. - set net_path [exec pwd]/net - exec /bin/mkdir -p $net_path - - # Server management scripts and data are installed if this is an - # install test, otherwise there is some setup to do. - if {! [installtest_p]} then { - # Make sure the server management scripts and tools are on the $PATH. - set env(PATH) "$srcdir/..:[exec pwd]/..:$env(PATH)" + if {! [setup_server]} then { + return 0 } - - # Try to find or start the server. - set server_pid [exec stap-find-or-start-server] - if { "$server_pid" == "-1" } then { - print "Cannot find or start a systemtap server" - set server_pid 0 - # TODO: How do we abort here? - } elseif { "$server_pid" == "0" } then { - print "A compatible systemtap server is already available" - } else { - print "Started a systemtap server as PID==$server_pid" - } - - # Make a copy of 'stap-client' as 'stap' and make sure it's at the - # beginning of the $PATH. Do this after starting the server so that - # The server does not call this instance of 'stap' - if {[installtest_p]} then { - exec /bin/cp -p [exec which stap-client] $net_path/stap - } else { - exec /bin/cp -p $srcdir/../stap-client $net_path/stap - } - set env(PATH) "$net_path:$env(PATH)" } # PATH, SYSTEMTAP_TAPSET, SYSTEMTAP_RUNTIME, LD_LIBRARY_PATH are already set. @@ -95,6 +64,78 @@ proc setup_systemtap_environment {} { verbose -log "env $var = $env($var)" } } + + return 1 +} + +# 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 + + # Make sure that the necessary resources are available to run the client/server. + if {[installtest_p]} then { + if {[exec /usr/bin/which stap-client-connect] == ""} then { + print "Unable to start a server: stap-client-connect is not found in PATH" + return 0 + } + } elseif {! [file exists [exec pwd]/../stap-client-connect]} then { + print "Unable to start a server: [exec pwd]/../stap-client-connect is not found" + return 0 + } + if {[exec /usr/bin/which avahi-publish-service] == ""} then { + print "Unable to start a server: avahi-publish-service is not found in PATH" + return 0 + } + + print "Testing using a systemtap server" + + # A place for some temporary files and scripts. + set net_path [exec pwd]/net + exec /bin/mkdir -p $net_path + + # Server management scripts and data are installed if this is an + # install test, otherwise there is some setup to do. + if {! [installtest_p]} then { + # Make sure the server management scripts and tools are on the $PATH. + set env(PATH) "$srcdir/..:[exec pwd]/..:$env(PATH)" + } + + # Try to find or start the server. + set server_pid [exec stap-find-or-start-server] + if { "$server_pid" == "-1" } then { + print "Cannot find or start a systemtap server" + set server_pid 0 + return 0 + } elseif { "$server_pid" == "0" } then { + print "A compatible systemtap server is already available" + } else { + print "Started a systemtap server as PID==$server_pid" + } + + # Make a copy of 'stap-client' as 'stap' and make sure it's at the + # beginning of the $PATH. Do this after starting the server so that + # The server does not call this instance of 'stap' + if {[installtest_p]} then { + exec /bin/cp -p [exec which stap-client] $net_path/stap + } else { + exec /bin/cp -p $srcdir/../stap-client $net_path/stap + } + set env(PATH) "$net_path:$env(PATH)" + + return 1 +} + +proc shutdown_server {} { + global server_pid net_path + + if { $server_pid != 0 } then { + print "Stopping the systemtap server with PID==$server_pid" + exec stap-stop-server $server_pid + } + + # Remove the temporary stap script + exec /bin/rm -fr $net_path } proc get_system_info {} { @@ -116,7 +157,10 @@ proc get_system_info {} { if [file exists /etc/debian_version] {set Distro [exec /bin/cat /etc/debian_version]} } -setup_systemtap_environment +if {! [setup_systemtap_environment]} then { + return 0 +} + print_systemtap_version get_system_info @@ -124,17 +168,9 @@ proc systemtap_init {args} {} proc systemtap_version {} {} proc systemtap_exit {} { - global server_pid net_path - # Stop the stap server, if we started it. if {[use_server_p]} then { - if { $server_pid != 0 } then { - print "Stopping the systemtap server with PID==$server_pid" - exec stap-stop-server $server_pid - } - - # Remove the temporary stap script - exec /bin/rm -fr $net_path + shutdown_server } } |