import FCGI-ProcManager 0.16 from CPAN
[catagits/FCGI-ProcManager.git] / t / exporter.t
CommitLineData
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
c2bbadb3 8# $Id: exporter.t,v 1.5 2001/02/09 16:16:13 muaddie Exp $
c146b63d 9
10use strict;
11use Test;
12
518709ed 13BEGIN { plan tests => 4; }
c146b63d 14
15use FCGI::ProcManager qw(:all);
16
c146b63d 17ok pm_parameter('n_processes',100) == 100;
18ok pm_parameter('n_processes',2) == 2;
19ok pm_parameter('n_processes',0) == 0;
20
21ok 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
c2bbadb3 28if ($ENV{PM_N_PROCESSES}) {
29 pm_parameter('n_processes',$ENV{PM_N_PROCESSES});
30 pm_manage();
31 sample_request_loop();
32}
c146b63d 33
34exit 0;
35
36sub sample_request_loop {
37
38 while (1) {
39 # Simulate blocking for a request.
40 my $t1 = int(rand(2)+1);
518709ed 41 print "TEST: simulating blocking for request: $t1 seconds.\n";
c146b63d 42 sleep $t1;
43 # (Here is where accept-fail-on-intr would exit request loop.)
44
45 pm_pre_dispatch();
46
47 # Simulate a request dispatch.
518709ed 48 my $t = int(rand(3)+2);
49 print "TEST: simulating request: sleeping $t seconds.\n";
c146b63d 50 while (my $nslept = sleep $t) {
51 $t -= $nslept;
52 last unless $t;
53 }
54
55 pm_post_dispatch();
56 }
57}