Mercurial > hg > nginx-tests
comparison fastcgi.t @ 131:21a428b31f37
Tests: add test for fastcgi regression introduced in 0.8.34.
Besides marking as TODO use todo_skip unless TEST_NGINX_UNSAFE defined
as it causes coredump.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 11 Mar 2010 02:30:44 +0300 |
parents | 8ac1faaddd2c |
children | b436d71bb41b |
comparison
equal
deleted
inserted
replaced
130:df9a573fde22 | 131:21a428b31f37 |
---|---|
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 eval { require FCGI; }; | 24 eval { require FCGI; }; |
25 plan(skip_all => 'FCGI not installed') if $@; | 25 plan(skip_all => 'FCGI not installed') if $@; |
26 | 26 |
27 my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(4) | 27 my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(5) |
28 ->write_file_expand('nginx.conf', <<'EOF'); | 28 ->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
32 master_process off; | 32 master_process off; |
42 listen 127.0.0.1:8080; | 42 listen 127.0.0.1:8080; |
43 server_name localhost; | 43 server_name localhost; |
44 | 44 |
45 location / { | 45 location / { |
46 fastcgi_pass 127.0.0.1:8081; | 46 fastcgi_pass 127.0.0.1:8081; |
47 fastcgi_param REQUEST_URI $request_uri; | |
47 } | 48 } |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 EOF | 52 EOF |
59 like(http_get('/redir'), qr/302/, 'fastcgi redirect'); | 60 like(http_get('/redir'), qr/302/, 'fastcgi redirect'); |
60 like(http_get('/'), qr/^3$/m, 'fastcgi third request'); | 61 like(http_get('/'), qr/^3$/m, 'fastcgi third request'); |
61 | 62 |
62 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); | 63 unlike(http_head('/'), qr/SEE-THIS/, 'no data in HEAD'); |
63 | 64 |
65 TODO: { | |
66 local $TODO = 'coredumps in 0.8.34'; | |
67 todo_skip $TODO, 1 unless $ENV{TEST_NGINX_UNSAFE}; | |
68 | |
69 like(http_get('/stderr'), qr/SEE-THIS/, 'large stderr handled'); | |
70 | |
71 } | |
72 | |
64 ############################################################################### | 73 ############################################################################### |
65 | 74 |
66 sub fastcgi_daemon { | 75 sub fastcgi_daemon { |
67 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); | 76 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); |
68 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, | 77 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, |
69 $socket); | 78 $socket); |
70 | 79 |
71 my $count; | 80 my $count; |
72 while( $request->Accept() >= 0 ) { | 81 while( $request->Accept() >= 0 ) { |
73 $count++; | 82 $count++; |
83 | |
84 if ($ENV{REQUEST_URI} eq '/stderr') { | |
85 warn "sample stderr text" x 512; | |
86 } | |
87 | |
74 print <<EOF; | 88 print <<EOF; |
75 Location: http://127.0.0.1:8080/redirect | 89 Location: http://127.0.0.1:8080/redirect |
76 Content-Type: text/html | 90 Content-Type: text/html |
77 | 91 |
78 SEE-THIS | 92 SEE-THIS |