httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1800152 - in /httpd/test/framework/trunk: Misc.pm t/modules/proxy.t t/modules/proxy_fcgi.t
Date Wed, 28 Jun 2017 11:53:24 GMT
Author: jim
Date: Wed Jun 28 11:53:23 2017
New Revision: 1800152

URL: http://svn.apache.org/viewvc?rev=1800152&view=rev
Log:
Useful condition-wait subr via Perl eval. Used in
more than 1 place.

Added:
    httpd/test/framework/trunk/Misc.pm
Modified:
    httpd/test/framework/trunk/t/modules/proxy.t
    httpd/test/framework/trunk/t/modules/proxy_fcgi.t

Added: httpd/test/framework/trunk/Misc.pm
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/Misc.pm?rev=1800152&view=auto
==============================================================================
--- httpd/test/framework/trunk/Misc.pm (added)
+++ httpd/test/framework/trunk/Misc.pm Wed Jun 28 11:53:23 2017
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+package Misc;
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+use Apache::TestConfig ();
+use Time::HiRes qw(usleep);
+
+use strict;
+use warnings FATAL => 'all';
+
+BEGIN {
+    # Just a bunch of useful subs
+}
+	
+sub cwait
+{
+    my $condition = shift;
+    my $wait = shift || 2;
+    my $inc = shift || 50;
+    my $timer = time() + $wait;
+    while (! eval $condition) {
+        usleep($inc);
+        last if (time() >= $timer);
+    }
+    if ( eval $condition ) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+1;
+__END__
\ No newline at end of file

Modified: httpd/test/framework/trunk/t/modules/proxy.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/proxy.t?rev=1800152&r1=1800151&r2=1800152&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/proxy.t (original)
+++ httpd/test/framework/trunk/t/modules/proxy.t Wed Jun 28 11:53:23 2017
@@ -5,8 +5,7 @@ use Apache::Test;
 use Apache::TestRequest;
 use Apache::TestUtil;
 use Apache::TestConfig ();
-
-use Time::HiRes qw(usleep);
+use Misc;
 
 my $num_tests = 20;
 if (have_min_apache_version('2.4.7')) {
@@ -140,12 +139,7 @@ if (have_min_apache_version('2.4.7')) {
         uds_script($socket_path);
         exit;
     }
-    my $timer = time() + 2;
-    while (! -e $socket_path) {
-        usleep(100);
-        last if (time() >= $timer);
-    }
-    unless ( -e $socket_path) {
+    unless (Misc::cwait('-e "'.$socket_path.'"')) {
         ok 0;
         exit;
     }

Modified: httpd/test/framework/trunk/t/modules/proxy_fcgi.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/proxy_fcgi.t?rev=1800152&r1=1800151&r2=1800152&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/proxy_fcgi.t (original)
+++ httpd/test/framework/trunk/t/modules/proxy_fcgi.t Wed Jun 28 11:53:23 2017
@@ -4,8 +4,7 @@ use warnings FATAL => 'all';
 use Apache::Test;
 use Apache::TestRequest;
 use Apache::TestUtil;
-
-use Time::HiRes qw(usleep);
+use Misc;
 
 my $have_fcgisetenvif    = have_min_apache_version('2.4.26');
 my $have_fcgibackendtype = have_min_apache_version('2.4.26');
@@ -243,14 +242,10 @@ if ($have_php_fpm) {
     }
     if ($pid == 0) {
         system "php-fpm -n -g $pid_file -p $servroot/php-fpm";
+        exit;
     }
     # Wait for php-fpm to start-up
-    my $timer = time() + 2;
-    while (! -e $pid_file) {
-        usleep(100);
-        last if (time() >= $timer);
-    }
-    unless ( -e $pid_file ) {
+    unless ( Misc::cwait('-e "'.$pid_file.'"') ) {
         ok 0;
         exit;
     }



Mime
View raw message