2 # Copyright (c) 2000, FundsXpress Financial Network, Inc.
3 # This library is free software released "AS IS WITH ALL FAULTS"
4 # and WITHOUT ANY WARRANTIES under the terms of the GNU Lesser
5 # General Public License, Version 2.1, a copy of which can be
6 # found in the "COPYING" file of this distribution.
8 # $Id: procmanager.t,v 1.9 2001/04/23 16:13:45 muaddie Exp $
13 BEGIN { plan tests => 5; }
15 use FCGI::ProcManager;
19 ok $m = FCGI::ProcManager->new();
21 ok $m->n_processes(100) == 100;
22 ok $m->n_processes(2) == 2;
23 ok $m->n_processes(0) == 0;
27 #ok $m->n_processes(-3);
28 #eval { $m->pm_manage(); };
29 #ok $@ =~ /dying from number of processes exception: -3/;
32 if ($ENV{PM_N_PROCESSES}) {
33 $m->n_processes($ENV{PM_N_PROCESSES});
35 sample_request_loop($m);
40 sub sample_request_loop {
44 # Simulate blocking for a request.
45 my $t1 = int(rand(2)+2);
46 print "TEST: simulating blocking for request: $t1 seconds.\n";
48 # (Here is where accept-fail-on-intr would exit request loop.)
50 $m->pm_pre_dispatch();
52 # Simulate a request dispatch.
53 my $t = int(rand(3)+2);
54 print "TEST: simulating new request: $t seconds.\n";
55 while (my $nslept = sleep $t) {
60 $m->pm_post_dispatch();