9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER END
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Use is subject to license terms.
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam# ident "%Z%%M% %I% %E% SMI"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# This script tests that several of the the mib:::tcp* probes fire and fire
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# with a valid args[0].
bd0f52d78d701efcad2c460df61b45677d041c35jhaslamif [ $# != 1 ]; then
bd0f52d78d701efcad2c460df61b45677d041c35jhaslamif [ -f $dtraceout ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl mib:::tcpActiveOpens
9512fe850e98fdd448c638ca63fdd92a8a510255ahl opens = args[0];
9512fe850e98fdd448c638ca63fdd92a8a510255ahl mib:::tcpOutDataBytes
9512fe850e98fdd448c638ca63fdd92a8a510255ahl bytes = args[0];
9512fe850e98fdd448c638ca63fdd92a8a510255ahl mib:::tcpOutDataSegs
9512fe850e98fdd448c638ca63fdd92a8a510255ahl segs = args[0];
9512fe850e98fdd448c638ca63fdd92a8a510255ahl profile:::tick-10msec
9512fe850e98fdd448c638ca63fdd92a8a510255ahl /opens && bytes && segs/
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam profile:::tick-1s
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam /n++ >= 10/
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam use strict;
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam use Socket;
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam socket(S, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam or die "socket() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam setsockopt(S, SOL_SOCKET, SO_REUSEADDR, 1)
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam or die "setsockopt() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam my \$addr = sockaddr_in($port, INADDR_ANY);
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam bind(S, \$addr) or die "bind() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam listen(S, SOMAXCONN) or die "listen() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam while (1) {
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam next unless my \$raddr = accept(SESSION, S);
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam while (<SESSION>) {
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam close SESSION;
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam use strict;
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam use Socket;
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam my \$peer = sockaddr_in($port, INADDR_ANY);
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam socket(S, AF_INET, SOCK_STREAM, getprotobyname('tcp'))
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam or die "socket() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam connect(S, \$peer) or die "connect failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam for (my \$i = 0; \$i < 10; \$i++) {
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam send(S, "There!", 0) or die "send() failed: \$!";
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam# Sleep while the above script fires into life. To guard against dtrace dying
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam# and us sleeping forever we allow 15 secs for this to happen. This should be
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam# enough for even the slowest systems.
bd0f52d78d701efcad2c460df61b45677d041c35jhaslamwhile [ ! -f $dtraceout ]; do
bd0f52d78d701efcad2c460df61b45677d041c35jhaslam echo "dtrace failed to start. Exiting."