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.
diff --git a/image_filter.t b/image_filter.t
index b9438cd..273230c 100644
--- a/image_filter.t
+++ b/image_filter.t
@@ -212,7 +212,8 @@
 is($im->transparent, 0, 'gif transparent white');
 
 SKIP: {
-skip 'broken libgd', 1 unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE};
+skip 'broken/unknown libgd', 1
+	unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE};
 
 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif'));
 is($im->interlaced, 1, 'gif interlaced on');
@@ -279,8 +280,9 @@
 sub has_gdversion {
 	my ($need) = @_;
 
-	my $v_str = `gdlib-config --version 2>&1` or return 1;
-	($v_str) = $v_str =~ m!^([0-9.]+)! or return 1;
+	my $v_str = `gdlib-config --version 2>&1`
+		|| eval { GD::VERSION_STRING() } or return 0;
+	($v_str) = $v_str =~ m!^([0-9.]+)!m or return 0;
 	my @v = split(/\./, $v_str);
 	my ($n, $v);