comparison image_filter.t @ 407:2711722a85c3

Tests: added safety measure for old libgd versions.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 22 May 2014 23:14:08 +0400
parents 077ffeac825c
children 9fe6fc05c1d1
comparison
equal deleted inserted replaced
406:811fbc213fd8 407:2711722a85c3
209 209
210 $im = GD::Image->newFromGifData(http_get_body('/gif')); 210 $im = GD::Image->newFromGifData(http_get_body('/gif'));
211 is($im->interlaced, 0, 'gif interlaced off'); 211 is($im->interlaced, 0, 'gif interlaced off');
212 is($im->transparent, 0, 'gif transparent white'); 212 is($im->transparent, 0, 'gif transparent white');
213 213
214 SKIP: {
215 skip 'broken libgd', 1 unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE};
216
214 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif')); 217 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif'));
215 is($im->interlaced, 1, 'gif interlaced on'); 218 is($im->interlaced, 1, 'gif interlaced on');
219
220 }
216 221
217 $im = GD::Image->newFromGifData(http_get_body('/nontransparent/gif')); 222 $im = GD::Image->newFromGifData(http_get_body('/nontransparent/gif'));
218 is($im->transparent, -1, 'gif transparent loss'); 223 is($im->transparent, -1, 'gif transparent loss');
219 224
220 $im = GD::Image->newFromPngData(http_get_body('/png')); 225 $im = GD::Image->newFromPngData(http_get_body('/png'));
267 if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) { 272 if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) {
268 return undef; 273 return undef;
269 } 274 }
270 275
271 return $2; 276 return $2;
277 }
278
279 sub has_gdversion {
280 my ($need) = @_;
281
282 my $v_str = `gdlib-config --version 2>&1` or return;
283 my @v = split(/\./, $v_str);
284 my ($n, $v);
285
286 for $n (split(/\./, $need)) {
287 $v = shift @v || 0;
288 return 0 if $n > $v;
289 return 1 if $v > $n;
290 }
291
292 return 1;
272 } 293 }
273 294
274 ############################################################################### 295 ###############################################################################
275 296
276 # serve static files without Content-Length 297 # serve static files without Content-Length