Commit | Line | Data |
0baf5fac |
1 | # -*- perl -*- |
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. |
7 | |
518709ed |
8 | # $Id: procmanager.t,v 1.6 2001/01/31 06:57:28 muaddib Exp $ |
0baf5fac |
9 | |
10 | use strict; |
11 | use Test; |
12 | |
518709ed |
13 | BEGIN { plan tests => 5; } |
0baf5fac |
14 | |
15 | use FCGI::ProcManager; |
16 | |
17 | my $m; |
18 | |
19 | ok $m = FCGI::ProcManager->new(); |
0baf5fac |
20 | |
21 | ok $m->n_processes(100) == 100; |
22 | ok $m->n_processes(2) == 2; |
23 | ok $m->n_processes(0) == 0; |
24 | |
4ceac1a1 |
25 | ok $m->pm_manage(); |
0baf5fac |
26 | |
27 | #ok $m->n_processes(-3); |
4ceac1a1 |
28 | #eval { $m->pm_manage(); }; |
0baf5fac |
29 | #ok $@ =~ /dying from number of processes exception: -3/; |
30 | #undef $@; |
31 | |
518709ed |
32 | $m->n_processes(10); |
0baf5fac |
33 | |
4ceac1a1 |
34 | #$m->pm_manage(); |
c146b63d |
35 | #sample_request_loop($m); |
0baf5fac |
36 | |
37 | exit 0; |
38 | |
c146b63d |
39 | sub sample_request_loop { |
0baf5fac |
40 | my ($m) = @_; |
41 | |
42 | while (1) { |
c146b63d |
43 | # Simulate blocking for a request. |
518709ed |
44 | my $t1 = int(rand(2)+2); |
45 | print "TEST: simulating blocking for request: $t1 seconds.\n"; |
c146b63d |
46 | sleep $t1; |
47 | # (Here is where accept-fail-on-intr would exit request loop.) |
48 | |
49 | $m->pm_pre_dispatch(); |
0baf5fac |
50 | |
51 | # Simulate a request dispatch. |
518709ed |
52 | my $t = int(rand(3)+2); |
53 | print "TEST: simulating new request: $t seconds.\n"; |
0baf5fac |
54 | while (my $nslept = sleep $t) { |
55 | $t -= $nslept; |
56 | last unless $t; |
57 | } |
58 | |
c146b63d |
59 | $m->pm_post_dispatch(); |
0baf5fac |
60 | } |
61 | } |