From 72629a44d453ddbdaec22a680b207e96a5e19ec3 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Fri, 20 Feb 2009 12:25:59 -0500 Subject: New basic tests for client/server. --- testsuite/lib/systemtap.exp | 100 +++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 44 deletions(-) (limited to 'testsuite/lib') diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index 5bf125b9..9dea8a89 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,7 @@ 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)" - } - - # 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)" + setup_server } # PATH, SYSTEMTAP_TAPSET, SYSTEMTAP_RUNTIME, LD_LIBRARY_PATH are already set. @@ -97,6 +64,59 @@ proc setup_systemtap_environment {} { } } +# 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 + + 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 + # 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)" +} + +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 {} { global Host Snapshot Distro env @@ -124,17 +144,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 } } -- cgit From e26df1cb46bf61450a3e9569cd892c91fd52c0a7 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Fri, 20 Feb 2009 16:58:57 -0500 Subject: Check for required resources and tools before attempting tests using the client/server. Ensure that tests run with/without the server have unique names. --- testsuite/lib/systemtap.exp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'testsuite/lib') diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index 9dea8a89..c80ad171 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -53,7 +53,9 @@ proc setup_systemtap_environment {} { # Find or start a systemtap server, if requested. if {[use_server_p]} then { - setup_server + if {! [setup_server]} then { + return 0 + } } # PATH, SYSTEMTAP_TAPSET, SYSTEMTAP_RUNTIME, LD_LIBRARY_PATH are already set. @@ -62,6 +64,8 @@ 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 @@ -69,6 +73,21 @@ proc setup_systemtap_environment {} { 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. @@ -87,7 +106,7 @@ proc setup_server {} { if { "$server_pid" == "-1" } then { print "Cannot find or start a systemtap server" set server_pid 0 - # TODO: How do we abort here? + return 0 } elseif { "$server_pid" == "0" } then { print "A compatible systemtap server is already available" } else { @@ -103,6 +122,8 @@ proc setup_server {} { exec /bin/cp -p $srcdir/../stap-client $net_path/stap } set env(PATH) "$net_path:$env(PATH)" + + return 1 } proc shutdown_server {} { @@ -136,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 -- cgit From 1d4cb9b5f957bd3825fd1f0cfa1df1c24a07164d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 8 Mar 2009 23:23:35 +0100 Subject: Make stap_run2 count exact number of lines. * testsuite/lib/stap_run2.exp: Compare found and expected number of lines. * testsuite/systemtap.*/*.exp (result_string): Make number of lines exact. --- testsuite/lib/stap_run2.exp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'testsuite/lib') diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp index 9849aefb..cb1c6615 100644 --- a/testsuite/lib/stap_run2.exp +++ b/testsuite/lib/stap_run2.exp @@ -29,5 +29,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" + } } -- cgit From fafd79e3a65854c8e7b3c0048e044af9741a0fff Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 13 Mar 2009 14:44:54 +0100 Subject: Introduce stap_run3 for distinct test names. * testsuite/lib/stap_run2.exp: Add stap_run3, called from stap_run2. * testsuite/systemtap.base/sdt.exp: Use stap_run3, for distinct test names. --- testsuite/lib/stap_run2.exp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'testsuite/lib') diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp index cb1c6615..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 -- cgit