source: subversion/applications/rendering/tilesAtHome-dev/trunk/runTests.pl @ 21834

Revision 21834, 3.4 KB checked in by deelkar, 4 years ago (diff)

whitespace

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2#-------------------------------------------------------------
3# OpenStreetMap tiles@home
4#
5# Contact Deelkar on the Openstreetmap wiki for help using this program
6#-----------------------------------------------------------------------------
7# Copyright 2010, Dirk-Lueder Kreie and others
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 2
12# of the License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22#-----------------------------------------------------------------------------
23
24use warnings;
25use strict;
26use lib './lib';
27use tahlib;
28use TahConf;
29use File::Temp qw(tempfile tempdir);
30use File::Spec;
31use File::Path qw(rmtree);
32use GD 2 qw(:DEFAULT :cmp);
33
34
35delete $ENV{LC_ALL};
36delete $ENV{LC_NUMERIC};
37delete $ENV{LANG};
38$ENV{LANG} = 'C';
39
40print "Reading Config\n";
41my %EnvironmentInfo;
42my $Config = TahConf->getConfig();
43
44print "Testing Basic Config\n";
45
46%EnvironmentInfo = $Config->CheckBasicConfig();
47
48print "Testing Full Config\n";
49
50%EnvironmentInfo = $Config->CheckConfig();
51
52print "\nStart offline tests:\n\n";
53my $Cmd;
54my $success;
55my $PID;
56
57#$Cmd = "perl ./tilesGen.pl localFile tests/emptyfile_12_0_0.osm"; ## must fail
58#$success = runCommand($Cmd,$PID);
59
60##FIXME check result for failure
61
62$Cmd = "perl ./tilesGen.pl --Verbose=3 --CreateTilesetFile=0 localFile tests/fonttest_12_0_0.osm tile"; ##should create zips for font-comparison
63my $retval = system($Cmd);
64##FIXME check result for failure, otherwise graphically compare image
65print "\n\n";
66
67my $tempdir = tempdir ( DIR => $Config->get("WorkingDirectory") );
68my $zipfile = File::Spec->join($Config->get("WorkingDirectory"),"uploadable","tile_12_0_0_*.zip");
69$Cmd = sprintf("unzip -d %s -q %s",$tempdir,$zipfile);
70$success = runCommand($Cmd,$PID);
71
72if ($success) # remove all zips from the test, because they should not be uploaded to the server.
73{ 
74    my @files = glob($zipfile); 
75    foreach my $zip (@files) 
76    {
77        print "removing $zip \n";
78        unlink($zip) or die "cannot delete $zip";
79    }
80}
81
82my @pngList = ("_13_0_0.png","_13_1_0.png","_13_1_1.png","_14_0_2.png","_14_0_3.png","_14_1_1.png","_14_3_3.png"); # these tiles contain font samples"
83foreach my $pngSuffix (@pngList)
84{
85    my $fonttestRef = File::Spec->join("tests","fonttest".$pngSuffix);
86    my $renderResult = File::Spec->join($tempdir,"tile".$pngSuffix);
87
88    print "testing $fonttestRef \n";
89
90    my $ReferenceImage = undef;
91    eval { $ReferenceImage = GD::Image->newFromPng($fonttestRef); };
92    die "$fonttestRef not found" if( not defined $ReferenceImage );
93   
94    my $Image = undef;
95    eval { $Image = GD::Image->newFromPng($renderResult); };
96    die "$renderResult not found" if( not defined $Image );
97   
98    # libGD comparison returns true if images are different.
99    die "Fonttest failed, check installed fonts. $renderResult $fonttestRef" if ($Image->compare($ReferenceImage) & GD_CMP_IMAGE)
100}
101
102print "fonttest succeded.\n";
103rmtree($tempdir);
Note: See TracBrowser for help on using the repository browser.