]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
- Remove hardcoded paths for the perl executable.
authormarkj <markj@FreeBSD.org>
Sun, 2 Aug 2015 00:23:18 +0000 (00:23 +0000)
committermarkj <markj@FreeBSD.org>
Sun, 2 Aug 2015 00:23:18 +0000 (00:23 +0000)
- Rather than assuming that a process is listening on 127.0.0.1:22, use
  nc(1) to find an available port and bind to it for the duration of the
  test.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division

cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh

index ccc247dec51400d0b877bb4f08bd6c921f95a833..5f58eb8e0ca89960eb5f8a4f0161ef0db6cfd15d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # CDDL HEADER START
 #
index 35bea8e58fa12e216ebdcad42874c1990688cb8d..fbfcdfdab35f13aaab67c63e322192c9e876a763 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # CDDL HEADER START
 #
index 2e3ffec52ba6f511c21350c9a61e95f3004d6634..1d2a99237068dd6b61a77542ecfe33f113208f46 100755 (executable)
@@ -58,12 +58,25 @@ fi
 
 dtrace=$1
 local=127.0.0.1
-tcpport=22
 DIR=/var/tmp/dtest.$$
 
+tcpport=1024
+bound=5000
+while [ $tcpport -lt $bound ]; do
+       nc -z $local $tcpport >/dev/null || break
+       tcpport=$(($tcpport + 1))
+done
+if [ $tcpport -eq $bound ]; then
+       echo "couldn't find an available TCP port"
+       exit 1
+fi
+
 mkdir $DIR
 cd $DIR
 
+# nc will exit when the connection is closed.
+nc -l $local $tcpport &
+
 cat > test.pl <<-EOPERL
        use IO::Socket;
        my \$s = IO::Socket::INET->new(
@@ -76,7 +89,7 @@ cat > test.pl <<-EOPERL
        sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
 BEGIN
 {
        ipsend = tcpsend = ipreceive = tcpreceive = 0;
index 65ede66f5fe928041abee3ebfb5a3a268793ef69..4c91f0002e86b701969216208d467aea9b940d03 100755 (executable)
@@ -79,7 +79,7 @@ cat > test.pl <<-EOPERL
        sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
 BEGIN
 {
        ipsend = tcpsend = ipreceive = tcpreceive = 0;
index 9668ad5868b847f9f9ab43bda080d29fbc0d409b..d7a3780ad49ed66f6280a7b4582ef18a08b08eaf 100644 (file)
@@ -82,7 +82,7 @@ cat > test.pl <<-EOPERL
        sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
 BEGIN
 {
        ipsend = tcpsend = ipreceive = tcpreceive = 0;
index 67712803d978f3b2a9419b839518efe9009659ac..271cc7849f7ef15ee677e80425db35c30d8f91f6 100644 (file)
@@ -87,7 +87,7 @@ cat > test.pl <<-EOPERL
        sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
 BEGIN
 {
        ipsend = tcpsend = ipreceive = tcpreceive = 0;