summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/ChangeLog5
-rw-r--r--testsuite/systemtap.samples/tcptest.exp41
-rw-r--r--testsuite/systemtap.samples/tcptest.stp45
3 files changed, 60 insertions, 31 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index b589d8c7..be44b9e5 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-21 Thang Nguyen <thang.p.nguyen@intel.com>
+
+ * systemtap.samples/tcptest.exp: fix bug #3404
+ * systemtap.samples/tcptest.stp: fix bug #3404
+
2006-10-18 David Smith <dsmith@redhat.com>
* systemtap.syscall/.cvsignore: Added file.
diff --git a/testsuite/systemtap.samples/tcptest.exp b/testsuite/systemtap.samples/tcptest.exp
index d34cc5f4..4f424416 100644
--- a/testsuite/systemtap.samples/tcptest.exp
+++ b/testsuite/systemtap.samples/tcptest.exp
@@ -1,12 +1,39 @@
+#!/usr/bin/tclsh
# Test the functionality of the tcp probes
-
-load_lib "stap_run.exp"
set test "tcptest"
-proc sleep_ten_secs {} {
- after 10000;
- return 0;
+set host localhost
+set port 11900
+
+proc start_server {sock addr port} {
+ set resp_str "Nice to meet you"
+ fconfigure $sock -encoding binary -buffersize 16
+ while {[read $sock 16] != {}} {
+ puts -nonewline $sock $resp_str ;
+ }
+ exit
}
-set output_string "\\mTCP totalbytes: \\d+\\M"
-stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string
+proc start_client { } {
+ set hello_str "Hello New World!"
+ after 2000
+ while {[catch {set sock [socket $::host $::port]}]} {}
+ fconfigure $sock -encoding binary -buffersize 16
+ for {set i 6400} {$i > 0} {incr i -1} {
+ puts -nonewline $sock $hello_str;
+ read $sock 16
+ }
+ return 0
+}
+
+if {[llength $argv] == 0} {
+ socket -server start_server $port
+ after 30000 set thirty_secs timeout
+ vwait thirty_secs
+} else {
+ load_lib "stap_run.exp"
+ exec chmod a+x $srcdir/$subdir/tcptest.exp
+ exec $srcdir/$subdir/tcptest.exp &
+ set output_string "\\mTCP totalbytes: \\d+\\M"
+ stap_run $srcdir/$subdir/$test.stp start_client $output_string
+}
diff --git a/testsuite/systemtap.samples/tcptest.stp b/testsuite/systemtap.samples/tcptest.stp
index 2c88e2c7..8dffb217 100644
--- a/testsuite/systemtap.samples/tcptest.stp
+++ b/testsuite/systemtap.samples/tcptest.stp
@@ -2,26 +2,31 @@
global uids, pidnames, send_bytes, recv_bytes, pid_ports, pid_src_ips, pid_rtos
global pid_state, pid_mss, pid_ssthresh, pid_cwnd, totalbytes
-probe begin { log("systemtap starting probe") }
+probe begin {
+ log("systemtap starting probe")
+}
probe end {
- log("systemtap ending probe")
- printf("TCP totalbytes: %d\n", totalbytes)
+ log("systemtap ending probe")
+ if (totalbytes > 0) {
+ printf("TCP totalbytes: %d\n",totalbytes)
+ print_report()
+ }
}
function print_report()
{
lines = 0;
log ("UID\tPID\tSIZE\tNAME\t\t\tPORT\tSOURCE\t\tRTO\tRCVMSS\tSSTHRES\tCWND\tSTATE")
- for (lines = 0; lines <= 21; lines ++) {
+ for (lines = 0; lines <= 5; lines ++) {
if (!lines) {
foreach (_pid_ in pidnames) {
- printf("%d\t%d\t%d\t%s\t\t\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",
- uids[_pid_],_pid_,send_bytes[_pid_] + recv_bytes[_pid_],
- pidnames[_pid_],pid_ports[_pid_],
- pid_src_ips[_pid_],pid_rtos[_pid_], pid_mss[_pid_],
- pid_ssthresh[_pid_],pid_cwnd[_pid_],pid_state[_pid_]);
- lines++
+ printf("%d\t%d\t%d\t%s\t\t\t%d\t%s\t%d\t%d\t%d\t%d\t%d\n",
+ uids[_pid_],_pid_,send_bytes[_pid_] + recv_bytes[_pid_],
+ pidnames[_pid_],pid_ports[_pid_],
+ pid_src_ips[_pid_],pid_rtos[_pid_], pid_mss[_pid_],
+ pid_ssthresh[_pid_],pid_cwnd[_pid_],pid_state[_pid_]);
+ lines++
}
} else {
print("\n")
@@ -36,16 +41,16 @@ probe tcp.sendmsg {
}
probe tcp.recvmsg {
- pid_cwnd[pid()] = tcp_get_info_snd_cwnd(sock)
- pid_mss[pid()] = tcp_ts_get_info_rcv_mss(sock)
- pid_ssthresh[pid()] = tcp_ts_get_info_snd_ssthresh(sock)
- pid_state[pid()] = tcp_ts_get_info_state(sock)
+ pid_cwnd[pid()] = tcp_get_info_snd_cwnd(sock)
+ pid_mss[pid()] = tcp_ts_get_info_rcv_mss(sock)
+ pid_ssthresh[pid()] = tcp_ts_get_info_snd_ssthresh(sock)
+ pid_state[pid()] = tcp_ts_get_info_state(sock)
}
probe tcp.sendmsg.return {
if (size > 0) {
send_bytes[pid()] += size
- totalbytes += size
+ totalbytes += size
pidnames[pid()] = execname()
uids[pid()] = uid()
}
@@ -54,7 +59,7 @@ probe tcp.sendmsg.return {
probe tcp.recvmsg.return {
if (size > 0) {
recv_bytes[pid()] += size
- totalbytes += size
+ totalbytes += size
pidnames[pid()] = execname()
uids[pid()] = uid()
}
@@ -63,11 +68,3 @@ probe tcp.recvmsg.return {
probe tcp.disconnect {
delete pidnames[pid()]
}
-
-probe timer.ms(2000) {
- print_report()
- foreach (_pid_ in pidnames) {
- send_bytes[_pid_] = 0
- recv_bytes[_pid_] = 0
- }
-}