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