summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/testchart.gifbin3751 -> 0 bytes
-rw-r--r--t/testchart.pngbin2382 -> 0 bytes
-rw-r--r--t/testgd.pngbin361 -> 0 bytes
-rwxr-xr-xtestserver.pl61
4 files changed, 28 insertions, 33 deletions
diff --git a/t/testchart.gif b/t/testchart.gif
deleted file mode 100644
index a4ed080a0..000000000
--- a/t/testchart.gif
+++ /dev/null
Binary files differ
diff --git a/t/testchart.png b/t/testchart.png
deleted file mode 100644
index 720423e6d..000000000
--- a/t/testchart.png
+++ /dev/null
Binary files differ
diff --git a/t/testgd.png b/t/testgd.png
deleted file mode 100644
index 72c6aa506..000000000
--- a/t/testgd.png
+++ /dev/null
Binary files differ
diff --git a/testserver.pl b/testserver.pl
index 7d3e2b15c..7cdacb0a3 100755
--- a/testserver.pl
+++ b/testserver.pl
@@ -123,37 +123,37 @@ Check your webserver configuration.\n";
print "TEST-OK Webserver is preventing fetch of $url.\n";
}
+# Test chart generation
eval 'use GD';
if ($@ eq '') {
undef $/;
# Ensure major versions of GD and libgd match
- # Windows's GD module include libgd.dll, guarenteed to match
-
+ # Windows's GD module include libgd.dll, guaranteed to match
if ($^O !~ /MSWin32/i) {
- my $gdlib = `gdlib-config --version 2>&1`;
+ my $gdlib = `gdlib-config --version 2>&1` || "";
$gdlib =~ s/\n$//;
if (!$gdlib) {
- print "TEST-WARNING Failed to run gdlib-config, assuming gdlib " .
- "version 1.x\n";
- $gdlib = '1.x';
+ print "TEST-WARNING Failed to run gdlib-config; can't compare " .
+ "GD versions.\n";
}
- my $gd = $GD::VERSION;
-
- my $verstring = "GD version $gd, libgd version $gdlib";
-
- $gdlib =~ s/^([^\.]+)\..*/$1/;
- $gd =~ s/^([^\.]+)\..*/$1/;
-
- if ($gdlib == $gd) {
- print "TEST-OK $verstring; Major versions match.\n";
- } else {
- print "TEST-FAIL $verstring; Major versions do not match\n";
+ else {
+ my $gd = $GD::VERSION;
+
+ my $verstring = "GD version $gd, libgd version $gdlib";
+
+ $gdlib =~ s/^([^\.]+)\..*/$1/;
+ $gd =~ s/^([^\.]+)\..*/$1/;
+
+ if ($gdlib == $gd) {
+ print "TEST-OK $verstring; Major versions match.\n";
+ } else {
+ print "TEST-FAILED $verstring; Major versions do not match.\n";
+ }
}
}
# Test GD
-
eval {
my $image = new GD::Image(100, 100);
my $black = $image->colorAllocate(0, 0, 0);
@@ -167,9 +167,9 @@ if ($@ eq '') {
if ($image->can('png')) {
create_file("$datadir/testgd-local.png", $image->png);
- check_image("$datadir/testgd-local.png", 't/testgd.png', 'GD', 'PNG');
+ check_image("$datadir/testgd-local.png", 'GD');
} else {
- die "GD doesn't support PNG generation\n";
+ print "TEST-FAILED GD doesn't support PNG generation.\n";
}
};
if ($@ ne '') {
@@ -177,10 +177,9 @@ if ($@ eq '') {
}
# Test Chart
-
eval 'use Chart::Lines';
if ($@) {
- print "TEST-FAILED Chart::Lines is not installed\n";
+ print "TEST-FAILED Chart::Lines is not installed.\n";
} else {
eval {
my $chart = Chart::Lines->new(400, 400);
@@ -188,10 +187,8 @@ if ($@ eq '') {
$chart->add_pt('foo', 30, 25);
$chart->add_pt('bar', 16, 32);
- my $type = $chart->can('gif') ? 'gif' : 'png';
- $chart->$type("$datadir/testchart-local.$type");
- check_image("$datadir/testchart-local.$type", "t/testchart.$type",
- "Chart", uc($type));
+ $chart->png("$datadir/testchart-local.png");
+ check_image("$datadir/testchart-local.png", "Chart");
};
if ($@ ne '') {
print "TEST-FAILED Chart returned: $@\n";
@@ -227,7 +224,6 @@ sub fetch {
select((select(SOCK), $| = 1)[0]);
# get content
-
print SOCK "GET $file HTTP/1.0\015\012host: $host:$port\015\012\015\012";
my $header = '';
while (defined(my $line = <SOCK>)) {
@@ -247,14 +243,13 @@ sub fetch {
}
sub check_image {
- my ($local_file, $test_file, $library, $image_type) = @_;
- if (read_file($local_file) eq read_file($test_file)) {
- print "TEST-OK $library library generated a good $image_type image\n";
+ my ($local_file, $library) = @_;
+ my $filedata = read_file($local_file);
+ if ($filedata =~ /^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A/) {
+ print "TEST-OK $library library generated a good PNG image.\n";
unlink $local_file;
} else {
- print "TEST-WARNING $library library generated a $image_type that " .
- "didn't match the expected image.\nIt has been saved as " .
- "$local_file and should be compared with $test_file\n";
+ print "TEST-WARNING $library library did not generate a good PNG.\n";
}
}