~ubuntu-branches/ubuntu/edgy/libapache2-mod-perl2/edgy-updates

« back to all changes in this revision

Viewing changes to t/response/TestError/runtime.pm

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2004-08-19 06:23:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040819062348-jxl4koqbtvgm8v2t
Tags: 1.99.14-4
Remove the LFS CFLAGS, and build-dep against apache2-*-dev (>= 2.0.50-10)
as we're backing out of the apache2/apr ABI transition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
use Apache::RequestRec ();
7
7
use Apache::RequestIO ();
 
8
use Apache::Connection ();
 
9
use APR::Socket ();
8
10
 
9
11
use Apache::TestUtil;
10
12
 
11
13
use Apache::Const -compile => qw(OK);
 
14
use APR::Const    -compile => qw(TIMEUP);
 
15
 
 
16
use constant SIZE => 2048;
12
17
 
13
18
sub handler {
14
19
    my $r = shift;
 
20
    my $socket = $r->connection->client_socket;
 
21
    my $args = $r->args;
15
22
 
16
23
    $r->content_type('text/plain');
17
24
 
18
 
    t_server_log_error_is_expected();
 
25
    # set timeout to 1 usec (microsec!) which makes sure that any
 
26
    # socket read call will fail
 
27
    $socket->timeout_set(1);
 
28
 
 
29
    no strict 'refs';
 
30
    $args->($r, $socket);
 
31
 
 
32
    return Apache::OK;
 
33
}
 
34
 
 
35
sub plain_mp_error {
 
36
    my($r, $socket) = @_;
 
37
    t_server_log_error_is_expected();
 
38
    mp_error($socket);
 
39
}
 
40
 
 
41
sub plain_non_mp_error {
 
42
    my($r, $socket) = @_;
 
43
    t_server_log_error_is_expected();
 
44
    non_mp_error($socket);
 
45
}
 
46
 
 
47
sub die_hook_confess_mp_error {
 
48
    my($r, $socket) = @_;
 
49
    local $SIG{__DIE__} = \&APR::Error::confess;
 
50
    t_server_log_error_is_expected();
 
51
    mp_error($socket);
 
52
}
 
53
 
 
54
sub die_hook_confess_non_mp_error {
 
55
    my($r, $socket) = @_;
 
56
    local $SIG{__DIE__} = \&APR::Error::confess;
 
57
    t_server_log_error_is_expected();
 
58
    non_mp_error($socket);
 
59
}
 
60
 
 
61
sub die_hook_custom_mp_error {
 
62
    my($r, $socket) = @_;
 
63
    local $SIG{__DIE__} = sub { die "custom die hook: $_[0]" };
 
64
    t_server_log_error_is_expected();
 
65
    mp_error($socket);
 
66
}
 
67
 
 
68
sub die_hook_custom_non_mp_error {
 
69
    my($r, $socket) = @_;
 
70
    local $SIG{__DIE__} = sub { die "custom die hook: $_[0]" };
 
71
    t_server_log_error_is_expected();
 
72
    non_mp_error($socket);
 
73
}
 
74
 
 
75
sub eval_block_mp_error {
 
76
    my($r, $socket) = @_;
 
77
    eval { mp_error($socket) };
 
78
    if ($@ && ref($@) && $@ == APR::TIMEUP) {
 
79
        $r->print("ok eval_block_mp_error");
 
80
    }
 
81
    else {
 
82
        die "eval block has failed: $@";
 
83
    }
 
84
}
 
85
 
 
86
sub eval_string_mp_error {
 
87
    my($r, $socket) = @_;
 
88
    eval "\$socket->recv(SIZE)";
 
89
    if ($@ && ref($@) && $@ == APR::TIMEUP) {
 
90
        $r->print("ok eval_string_mp_error");
 
91
    }
 
92
    else {
 
93
        die "eval string has failed: $@";
 
94
    }
 
95
}
 
96
 
 
97
sub eval_block_non_mp_error {
 
98
    my($r, $socket) = @_;
 
99
    eval { non_mp_error($socket) };
 
100
    if ($@ && !ref($@)) {
 
101
        $r->print("ok eval_block_non_mp_error");
 
102
    }
 
103
    else {
 
104
        die "eval eval_non_mp_error has failed: $@";
 
105
    }
 
106
}
 
107
 
 
108
sub eval_block_non_error {
 
109
    my($r, $socket) = @_;
 
110
    eval { 1; };
 
111
    if ($@) {
 
112
        die "eval eval_block_non_mp_error has failed";
 
113
    }
 
114
    $r->print("ok eval_block_non_error");
 
115
}
 
116
 
 
117
sub non_mp_error {
19
118
    no_such_func();
20
 
 
21
 
    $r->print('ok');
22
 
 
23
 
    return Apache::OK;
 
119
}
 
120
 
 
121
# fails because of the timeout set earlier in the handler
 
122
sub mp_error {
 
123
    my $socket = shift;
 
124
    $socket->recv(SIZE);
24
125
}
25
126
 
26
127
1;