From a732e8474826bfce9ce93f693ee81e7d54b75cd9 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Thu, 1 Sep 2005 12:10:59 +0000 Subject: [PATCH] use netstat to check if a process is listening on port 1026 git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@673 152afb58-edef-0310-8abb-c4023f1b3aa9 --- tests/LightyTest.pm | 13 +++++-------- tests/mod-fastcgi.t | 2 +- tests/mod-rewrite.t | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/LightyTest.pm b/tests/LightyTest.pm index 120db313..97e138e5 100755 --- a/tests/LightyTest.pm +++ b/tests/LightyTest.pm @@ -38,20 +38,17 @@ sub new { return $self; } -sub pidof { +sub listening_on { my $self = shift; my $prog = shift; - open F, "ps ax | grep $prog | grep -v grep | awk '{ print \$1 }'|" or - open F, "ps -ef | grep $prog | grep -v grep | awk '{ print \$2 }'|" or - return -1; + open F, "netstat -an | grep :1026|" or return 0; + + my $foo = ; - my $pid = ; close F; - if (defined $pid) { return $pid; } - - return -1; + return (defined $foo ? 1 : 0); } sub stop_proc { diff --git a/tests/mod-fastcgi.t b/tests/mod-fastcgi.t index a5a88a3c..c6acec7e 100755 --- a/tests/mod-fastcgi.t +++ b/tests/mod-fastcgi.t @@ -15,7 +15,7 @@ my $tf = LightyTest->new(); my $t; SKIP: { - skip "no PHP running on port 1026", 28 if $tf->pidof("php") == -1; + skip "no PHP running on port 1026", 28 unless $tf->listening_on(1026); ok($tf->start_proc == 0, "Starting lighttpd") or die(); diff --git a/tests/mod-rewrite.t b/tests/mod-rewrite.t index cb37a421..31c7d1ae 100755 --- a/tests/mod-rewrite.t +++ b/tests/mod-rewrite.t @@ -16,7 +16,7 @@ my $t; SKIP: { - skip "no PHP running on port 1026", 5 if $tf->pidof("php") == -1; + skip "no PHP running on port 1026", 5 unless $tf->listening_on(1026); ok($tf->start_proc == 0, "Starting lighttpd") or die();