summaryrefslogtreecommitdiffstats
path: root/testserver.pl
diff options
context:
space:
mode:
authorgerv%gerv.net <>2006-01-05 20:07:01 +0100
committergerv%gerv.net <>2006-01-05 20:07:01 +0100
commite4b964454ad9d9c366b0d4d321269576f7edf232 (patch)
tree57996ee7d2bdbfa311f8345ba3619d20a28d9859 /testserver.pl
parent38f51edb6a70ad23e057bd6c2c03ff00dde4c010 (diff)
downloadbugzilla-e4b964454ad9d9c366b0d4d321269576f7edf232.tar.gz
bugzilla-e4b964454ad9d9c366b0d4d321269576f7edf232.tar.xz
Bug 286724: change testserver.pl to do a simpler check for image creation, thereby avoiding false negatives. Patch by gerv; r=glob, a=justdave.
Diffstat (limited to 'testserver.pl')
-rwxr-xr-xtestserver.pl61
1 files changed, 28 insertions, 33 deletions
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";
}
}