import FCGI-ProcManager 0.16 from CPAN
[catagits/FCGI-ProcManager.git] / t / procmanager.t
index 28131c3..b0f21eb 100644 (file)
@@ -5,19 +5,18 @@
 # General Public License, Version 2.1, a copy of which can be
 # found in the "COPYING" file of this distribution.
 
-# $Id: procmanager.t,v 1.4 2001/01/13 06:44:35 muaddib Exp $
+# $Id: procmanager.t,v 1.8 2001/02/09 16:16:13 muaddie Exp $
 
 use strict;
 use Test;
 
-BEGIN { plan tests => 6; }
+BEGIN { plan tests => 5; }
 
 use FCGI::ProcManager;
 
 my $m;
 
 ok $m = FCGI::ProcManager->new();
-ok $m->pm_state() eq "idle";
 
 ok $m->n_processes(100) == 100;
 ok $m->n_processes(2) == 2;
@@ -30,10 +29,11 @@ ok $m->pm_manage();
 #ok $@ =~ /dying from number of processes exception: -3/;
 #undef $@;
 
-$m->n_processes(20);
-
-#$m->pm_manage();
-#sample_request_loop($m);
+if ($ENV{PM_N_PROCESSES}) {
+  $m->n_processes($ENV{PM_N_PROCESSES});
+  $m->pm_manage();
+  sample_request_loop($m);
+}
 
 exit 0;
 
@@ -42,16 +42,16 @@ sub sample_request_loop {
 
   while (1) {
     # Simulate blocking for a request.
-    my $t1 = int(rand(2)+1);
-    print "$$ waiting for $t1..\n";
+    my $t1 = int(rand(2)+2);
+    print "TEST: simulating blocking for request: $t1 seconds.\n";
     sleep $t1;
     # (Here is where accept-fail-on-intr would exit request loop.)
 
     $m->pm_pre_dispatch();
 
     # Simulate a request dispatch.
-    my $t = int(rand(3)+1);
-    print "$$ sleeping $t..\n";
+    my $t = int(rand(3)+2);
+    print "TEST: simulating new request: $t seconds.\n";
     while (my $nslept = sleep $t) {
       $t -= $nslept;
       last unless $t;