Mercurial > hg > nginx-tests
comparison image_filter.t @ 1542:451e787aad76
Tests: reworked libgd version detection.
The "libgd-config" binary is deprecated in recent versions and may not exist
or have unexpected output. More, it may not present within older versions,
as well, if installed separately, which previously broke test assumptions.
The fix is change the fallback to skip tests. In addition, recent Perl GD
module (2.57) started to export libgd version, which is now also consulted.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 13 Jan 2020 18:15:35 +0300 |
parents | 104701299b91 |
children |
comparison
equal
deleted
inserted
replaced
1541:b9de5364dfc9 | 1542:451e787aad76 |
---|---|
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: { | 214 SKIP: { |
215 skip 'broken libgd', 1 unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE}; | 215 skip 'broken/unknown libgd', 1 |
216 unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE}; | |
216 | 217 |
217 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif')); | 218 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif')); |
218 is($im->interlaced, 1, 'gif interlaced on'); | 219 is($im->interlaced, 1, 'gif interlaced on'); |
219 | 220 |
220 } | 221 } |
277 } | 278 } |
278 | 279 |
279 sub has_gdversion { | 280 sub has_gdversion { |
280 my ($need) = @_; | 281 my ($need) = @_; |
281 | 282 |
282 my $v_str = `gdlib-config --version 2>&1` or return 1; | 283 my $v_str = `gdlib-config --version 2>&1` |
283 ($v_str) = $v_str =~ m!^([0-9.]+)! or return 1; | 284 || eval { GD::VERSION_STRING() } or return 0; |
285 ($v_str) = $v_str =~ m!^([0-9.]+)!m or return 0; | |
284 my @v = split(/\./, $v_str); | 286 my @v = split(/\./, $v_str); |
285 my ($n, $v); | 287 my ($n, $v); |
286 | 288 |
287 for $n (split(/\./, $need)) { | 289 for $n (split(/\./, $need)) { |
288 $v = shift @v || 0; | 290 $v = shift @v || 0; |