Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / tests / testcurl.pl
1 #!/usr/bin/env perl
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 ###########################################################################
23
24 ###########################
25 #  What is This Script?
26 ###########################
27
28 # testcurl.pl is the master script to use for automatic testing of curl
29 # directly off its source repository.
30 # This is written for the purpose of being run from a crontab job or similar
31 # at a regular interval. The output is suitable to be mailed to
32 # curl-autocompile@haxx.se to be dealt with automatically (make sure the
33 # subject includes the word "autobuild" as the mail gets silently discarded
34 # otherwise).  The most current build status (with a resonable backlog) will
35 # be published on the curl site, at http://curl.haxx.se/auto/
36
37 # USAGE:
38 # testcurl.pl [options] [curl-daily-name] > output
39
40 # Options:
41 #
42 # --configure=[options]    Configure options
43 # --crosscompile           This is a crosscompile
44 # --desc=[desc]            Description of your test system
45 # --email=[email]          Set email address to report as
46 # --extvercmd=[command]    Command to use for displaying version with cross compiles.
47 # --mktarball=[command]    Command to run after completed test
48 # --name=[name]            Set name to report as
49 # --nocvsup                Don't pull from git even though it is a git tree
50 # --nogitpull              Don't pull from git even though it is a git tree
51 # --nobuildconf            Don't run buildconf
52 # --noconfigure            Don't run configure
53 # --runtestopts=[options]  Options to pass to runtests.pl
54 # --setup=[file name]      File name to read setup from (deprecated)
55 # --target=[your os]       Specify your target environment.
56 #
57 # if [curl-daily-name] is omitted, a 'curl' git directory is assumed.
58 #
59
60 use strict;
61
62 use Cwd;
63
64 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
65 #BEGIN { $^W = 1; }
66
67 use vars qw($version $fixed $infixed $CURLDIR $git $pwd $build $buildlog
68             $buildlogname $configurebuild $targetos $confheader $binext
69             $libext);
70
71 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
72             $extvercmd $nogitpull $nobuildconf $crosscompile
73             $timestamp $notes);
74
75 # version of this script
76 $version='2014-11-25';
77 $fixed=0;
78
79 # Determine if we're running from git or a canned copy of curl,
80 # or if we got a specific target option or setup file option.
81 $CURLDIR="curl";
82 if (-f ".git/config") {
83   $CURLDIR = "./";
84 }
85
86 $git=1;
87 $setupfile = 'setup';
88 $configurebuild = 1;
89 while ($ARGV[0]) {
90   if ($ARGV[0] =~ /--target=/) {
91     $targetos = (split(/=/, shift @ARGV))[1];
92   }
93   elsif ($ARGV[0] =~ /--setup=/) {
94     $setupfile = (split(/=/, shift @ARGV))[1];
95   }
96   elsif ($ARGV[0] =~ /--extvercmd=/) {
97     $extvercmd = (split(/=/, shift @ARGV))[1];
98   }
99   elsif ($ARGV[0] =~ /--mktarball=/) {
100     $mktarball = (split(/=/, shift @ARGV))[1];
101   }
102   elsif ($ARGV[0] =~ /--name=/) {
103     $name = (split(/=/, shift @ARGV))[1];
104   }
105   elsif ($ARGV[0] =~ /--email=/) {
106     $email = (split(/=/, shift @ARGV))[1];
107   }
108   elsif ($ARGV[0] =~ /--desc=/) {
109     $desc = (split(/=/, shift @ARGV))[1];
110   }
111   elsif ($ARGV[0] =~ /--configure=(.*)/) {
112     $confopts = $1;
113     shift @ARGV;
114   }
115   elsif (($ARGV[0] eq "--nocvsup") || ($ARGV[0] eq "--nogitpull")) {
116     $nogitpull=1;
117     shift @ARGV;
118   }
119   elsif ($ARGV[0] =~ /--nobuildconf/) {
120     $nobuildconf=1;
121     shift @ARGV;
122   }
123   elsif ($ARGV[0] =~ /--noconfigure/) {
124     $configurebuild=0;
125     shift @ARGV;
126   }
127   elsif ($ARGV[0] =~ /--crosscompile/) {
128     $crosscompile=1;
129     shift @ARGV;
130   }
131   elsif ($ARGV[0] =~ /--runtestopts=/) {
132     $runtestopts = (split(/=/, shift @ARGV, 2))[1];
133   }
134   else {
135     $CURLDIR=shift @ARGV;
136     $git=0; # a given dir, assume not using git
137   }
138 }
139
140 # Do the platform-specific stuff here
141 $confheader = 'curl_config.h';
142 $binext = '';
143 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
144 if ($^O eq 'MSWin32' || $targetos) {
145   if (!$targetos) {
146     # If no target defined on Win32 lets assume vc
147     $targetos = 'vc';
148   }
149   if ($targetos =~ /vc/ || $targetos =~ /borland/ || $targetos =~ /watcom/) {
150     $binext = '.exe';
151     $libext = '.lib';
152   }
153   elsif ($targetos =~ /mingw/) {
154     $binext = '.exe';
155     if ($^O eq 'MSWin32') {
156       $libext = '.a';
157     }
158   }
159   elsif ($targetos =~ /netware/) {
160     $configurebuild = 0;
161     $binext = '.nlm';
162     if ($^O eq 'MSWin32') {
163       $libext = '.lib';
164     }
165     else {
166       $libext = '.a';
167     }
168   }
169 }
170
171 if (($^O eq 'MSWin32' || $^O eq 'msys') &&
172     ($targetos =~ /vc/ || $targetos =~ /mingw32/ ||
173      $targetos =~ /borland/ || $targetos =~ /watcom/)) {
174
175   # Set these things only when building ON Windows and for Win32 platform.
176   # FOR Windows since we might be cross-compiling on another system. Non-
177   # Windows builds still default to configure-style builds with curl_config.h.
178
179   $configurebuild = 0;
180   $confheader = 'config-win32.h';
181 }
182
183 $ENV{LC_ALL}="C" if (($ENV{LC_ALL}) && ($ENV{LC_ALL} !~ /^C$/));
184 $ENV{LC_CTYPE}="C" if (($ENV{LC_CTYPE}) && ($ENV{LC_CTYPE} !~ /^C$/));
185 $ENV{LANG}="C";
186
187 sub rmtree($) {
188     my $target = $_[0];
189     if ($^O eq 'MSWin32') {
190       foreach (glob($target)) {
191         s:/:\\:g;
192         system("rd /s /q $_");
193       }
194     } else {
195       system("rm -rf $target");
196     }
197 }
198
199 sub grepfile($$) {
200     my ($target, $fn) = @_;
201     open(F, $fn) or die;
202     while (<F>) {
203       if (/$target/) {
204         close(F);
205         return 1;
206       }
207     }
208     close(F);
209     return 0;
210 }
211
212 sub logit($) {
213     my $text=$_[0];
214     if ($text) {
215       print "testcurl: $text\n";
216     }
217 }
218
219 sub logit_spaced($) {
220     my $text=$_[0];
221     if ($text) {
222       print "\ntestcurl: $text\n\n";
223     }
224 }
225
226 sub mydie($){
227     my $text=$_[0];
228     logit "$text";
229     chdir $pwd; # cd back to the original root dir
230
231     if ($pwd && $build) {
232       # we have a build directory name, remove the dir
233       logit "removing the $build dir";
234       rmtree "$pwd/$build";
235     }
236     if (-r $buildlog) {
237       # we have a build log output file left, remove it
238       logit "removing the $buildlogname file";
239       unlink "$buildlog";
240     }
241     logit "ENDING HERE"; # last line logged!
242     exit 1;
243 }
244
245 sub get_host_triplet {
246   my $triplet;
247   my $configfile = "$pwd/$build/lib/curl_config.h";
248
249   if(-f $configfile && -s $configfile && open(LIBCONFIGH, "<$configfile")) {
250     while(<LIBCONFIGH>) {
251       if($_ =~ /^\#define\s+OS\s+"*([^"][^"]*)"*\s*/) {
252         $triplet = $1;
253         last;
254       }
255     }
256     close(LIBCONFIGH);
257   }
258   return $triplet;
259 }
260
261 if($name && $email && $desc) {
262   # having these fields set are enough to continue, skip reading the setup
263   # file
264   $infixed=4;
265   $fixed=4;
266 }
267 elsif (open(F, "$setupfile")) {
268   while (<F>) {
269     if (/(\w+)=(.*)/) {
270       eval "\$$1=$2;";
271     }
272   }
273   close(F);
274   $infixed=$fixed;
275 }
276 else {
277   $infixed=0;    # so that "additional args to configure" works properly first time...
278 }
279
280 if (!$name) {
281   print "please enter your name\n";
282   $name = <>;
283   chomp $name;
284   $fixed=1;
285 }
286
287 if (!$email) {
288   print "please enter your contact email address\n";
289   $email = <>;
290   chomp $email;
291   $fixed=2;
292 }
293
294 if (!$desc) {
295   print "please enter a one line system description\n";
296   $desc = <>;
297   chomp $desc;
298   $fixed=3;
299 }
300
301 if (!$confopts) {
302   if ($infixed < 4) {
303     print "please enter your additional arguments to configure\n";
304     print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
305     $confopts = <>;
306     chomp $confopts;
307   }
308 }
309
310
311 if ($fixed < 4) {
312     $fixed=4;
313     open(F, ">$setupfile") or die;
314     print F "name='$name'\n";
315     print F "email='$email'\n";
316     print F "desc='$desc'\n";
317     print F "confopts='$confopts'\n";
318     print F "notes='$notes'\n";
319     print F "fixed='$fixed'\n";
320     close(F);
321 }
322
323 # Enable picky compiler warnings unless explicitly disabled
324 if (($confopts !~ /--enable-debug/) &&
325     ($confopts !~ /--enable-warnings/) &&
326     ($confopts !~ /--disable-warnings/)) {
327   $confopts .= " --enable-warnings";
328 }
329
330 my $str1066os = 'o' x 1066;
331
332 # Set timestamp to the UTC this script is running. Its value might
333 # be changed later in the script to the value present in curlver.h
334 $timestamp = scalar(gmtime)." UTC";
335
336 logit "STARTING HERE"; # first line logged, for scripts to trigger on
337 logit 'TRANSFER CONTROL ==== 1120 CHAR LINE' . $str1066os . 'LINE_END';
338 logit "NAME = $name";
339 logit "EMAIL = $email";
340 logit "DESC = $desc";
341 logit "NOTES = $notes";
342 logit "CONFOPTS = $confopts";
343 logit "RUNTESTOPTS = ".$runtestopts;
344 logit "CPPFLAGS = ".$ENV{CPPFLAGS};
345 logit "CFLAGS = ".$ENV{CFLAGS};
346 logit "LDFLAGS = ".$ENV{LDFLAGS};
347 logit "LIBS = ".$ENV{LIBS};
348 logit "CC = ".$ENV{CC};
349 logit "TMPDIR = ".$ENV{TMPDIR};
350 logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
351 logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
352 logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
353 logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
354 logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
355 logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
356 logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
357 logit "LIBPATH = ".$ENV{LIBPATH};
358 logit "target = ".$targetos;
359 logit "version = $version"; # script version
360 logit "date = $timestamp";  # When the test build starts
361
362 $str1066os = undef;
363
364 # Make $pwd to become the path without newline. We'll use that in order to cut
365 # off that path from all possible logs and error messages etc.
366 $pwd = getcwd();
367
368 my $have_embedded_ares = 0;
369
370 if (-d $CURLDIR) {
371   if ($git && -d "$CURLDIR/.git") {
372     logit "$CURLDIR is verified to be a fine git source dir";
373     # remove the generated sources to force them to be re-generated each
374     # time we run this test
375     unlink "$CURLDIR/src/tool_hugehelp.c";
376     # find out if curl source dir has an in-tree c-ares repo
377     $have_embedded_ares = 1 if (-f "$CURLDIR/ares/GIT-INFO");
378   } elsif (!$git && -f "$CURLDIR/tests/testcurl.pl") {
379     logit "$CURLDIR is verified to be a fine daily source dir";
380     # find out if curl source dir has an in-tree c-ares extracted tarball
381     $have_embedded_ares = 1 if (-f "$CURLDIR/ares/ares_build.h");
382   } else {
383     mydie "$CURLDIR is not a daily source dir or checked out from git!"
384   }
385 }
386 $build="build-$$";
387 $buildlogname="buildlog-$$";
388 $buildlog="$pwd/$buildlogname";
389
390 # remove any previous left-overs
391 rmtree "build-*";
392 rmtree "buildlog-*";
393
394 # this is to remove old build logs that ended up in the wrong dir
395 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
396
397 # create a dir to build in
398 mkdir $build, 0777;
399
400 if (-d $build) {
401   logit "build dir $build was created fine";
402 } else {
403   mydie "failed to create dir $build";
404 }
405
406 # get in the curl source tree root
407 chdir $CURLDIR;
408
409 # Do the git thing, or not...
410 if ($git) {
411   my $gitstat = 0;
412   my @commits;
413
414   # update quietly to the latest git
415   if($nogitpull) {
416     logit "skipping git pull (--nogitpull)";
417   } else {
418     logit "run git pull in curl";
419     system("git pull 2>&1");
420     $gitstat += $?;
421     logit "failed to update from curl git ($?), continue anyway" if ($?);
422
423     # Set timestamp to the UTC the git update took place.
424     $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
425   }
426
427   # get the last 5 commits for show (even if no pull was made)
428   @commits=`git log --pretty=oneline --abbrev-commit -5`;
429   logit "The most recent curl git commits:";
430   for (@commits) {
431     chomp ($_);
432     logit "  $_";
433   }
434
435   if (-d "ares/.git") {
436     chdir "ares";
437
438     if($nogitpull) {
439       logit "skipping git pull (--nogitpull) in ares";
440     } else {
441       logit "run git pull in ares";
442       system("git pull 2>&1");
443       $gitstat += $?;
444       logit "failed to update from ares git ($?), continue anyway" if ($?);
445
446       # Set timestamp to the UTC the git update took place.
447       $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
448     }
449
450     # get the last 5 commits for show (even if no pull was made)
451     @commits=`git log --pretty=oneline --abbrev-commit -5`;
452     logit "The most recent ares git commits:";
453     for (@commits) {
454       chomp ($_);
455       logit "  $_";
456     }
457
458     chdir "$pwd/$CURLDIR";
459   }
460
461   if($nobuildconf) {
462     logit "told to not run buildconf";
463   }
464   elsif ($configurebuild) {
465     # remove possible left-overs from the past
466     unlink "configure";
467     unlink "autom4te.cache";
468
469     # generate the build files
470     logit "invoke buildconf";
471     open(F, "./buildconf 2>&1 |") or die;
472     open(LOG, ">$buildlog") or die;
473     while (<F>) {
474       my $ll = $_;
475       # ignore messages pertaining to third party m4 files we don't care
476       next if ($ll =~ /aclocal\/gtk\.m4/);
477       next if ($ll =~ /aclocal\/gtkextra\.m4/);
478       print $ll;
479       print LOG $ll;
480     }
481     close(F);
482     close(LOG);
483
484     if (grepfile("^buildconf: OK", $buildlog)) {
485       logit "buildconf was successful";
486     }
487     else {
488       mydie "buildconf was NOT successful";
489     }
490   }
491   else {
492     logit "buildconf was successful (dummy message)";
493   }
494 }
495
496 # Set timestamp to the one in curlver.h if this isn't a git test build.
497 if ((-f "include/curl/curlver.h") &&
498     (open(F, "<include/curl/curlver.h"))) {
499   while (<F>) {
500     chomp;
501     if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
502       my $stampstring = $1;
503       if ($stampstring !~ /DEV/) {
504           $stampstring =~ s/\s+UTC//;
505           $timestamp = $stampstring." UTC";
506       }
507       last;
508     }
509   }
510   close(F);
511 }
512
513 # Show timestamp we are using for this test build.
514 logit "timestamp = $timestamp";
515
516 if ($configurebuild) {
517   if (-f "configure") {
518     logit "configure created (at least it exists)";
519   } else {
520     mydie "no configure created/found";
521   }
522 } else {
523   logit "configure created (dummy message)"; # dummy message to feign success
524 }
525
526 sub findinpath {
527   my $c;
528   my $e;
529   my $x = ($^O eq 'MSWin32') ? '.exe' : '';
530   my $s = ($^O eq 'MSWin32') ? ';' : ':';
531   my $p=$ENV{'PATH'};
532   my @pa = split($s, $p);
533   for $c (@_) {
534     for $e (@pa) {
535       if( -x "$e/$c$x") {
536         return $c;
537       }
538     }
539   }
540 }
541
542 my $make = findinpath("gmake", "make", "nmake");
543 if(!$make) {
544     mydie "Couldn't find make in the PATH";
545 }
546 # force to 'nmake' for VC builds
547 $make = "nmake" if ($targetos =~ /vc/);
548 # force to 'wmake' for Watcom builds
549 $make = "wmake" if ($targetos =~ /watcom/);
550 logit "going with $make as make";
551
552 # change to build dir
553 chdir "$pwd/$build";
554
555 if ($configurebuild) {
556   # run configure script
557   print `../$CURLDIR/configure $confopts 2>&1`;
558
559   if (-f "lib/Makefile") {
560     logit "configure seems to have finished fine";
561   } else {
562     mydie "configure didn't work";
563   }
564 } else {
565   logit "copying files to build dir ...";
566   if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
567     system("xcopy /s /q ..\\$CURLDIR .");
568     system("buildconf.bat");
569   }
570   elsif ($targetos =~ /netware/) {
571     system("cp -afr ../$CURLDIR/* .");
572     system("cp -af ../$CURLDIR/Makefile.dist Makefile");
573     system("$make -i -C lib -f Makefile.netware prebuild");
574     system("$make -i -C src -f Makefile.netware prebuild");
575     if (-d "../$CURLDIR/ares") {
576       system("$make -i -C ares -f Makefile.netware prebuild");
577     }
578   }
579   elsif ($^O eq 'linux') {
580     system("cp -afr ../$CURLDIR/* .");
581     system("cp -af ../$CURLDIR/Makefile.dist Makefile");
582     system("cp -af ../$CURLDIR/include/curl/curlbuild.h.dist ./include/curl/curlbuild.h");
583     system("$make -i -C lib -f Makefile.$targetos prebuild");
584     system("$make -i -C src -f Makefile.$targetos prebuild");
585     if (-d "../$CURLDIR/ares") {
586       system("cp -af ../$CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
587       system("$make -i -C ares -f Makefile.$targetos prebuild");
588     }
589   }
590 }
591
592 if(-f "./libcurl.pc") {
593   logit_spaced "display libcurl.pc";
594   if(open(F, "<./libcurl.pc")) {
595     while(<F>) {
596       my $ll = $_;
597       print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
598     }
599     close(F);
600   }
601 }
602
603 if(-f "./include/curl/curlbuild.h") {
604   logit_spaced "display include/curl/curlbuild.h";
605   if(open(F, "<./include/curl/curlbuild.h")) {
606     while(<F>) {
607       my $ll = $_;
608       print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/));
609     }
610     close(F);
611   }
612 }
613 else {
614   mydie "no curlbuild.h created/found";
615 }
616
617 logit_spaced "display lib/$confheader";
618 open(F, "lib/$confheader") or die "lib/$confheader: $!";
619 while (<F>) {
620   print if /^ *#/;
621 }
622 close(F);
623
624 if (($have_embedded_ares) &&
625     (grepfile("^#define USE_ARES", "lib/$confheader"))) {
626   print "\n";
627   logit "setup to build ares";
628
629   if(-f "./ares/libcares.pc") {
630     logit_spaced  "display ares/libcares.pc";
631     if(open(F, "<./ares/libcares.pc")) {
632       while(<F>) {
633         my $ll = $_;
634         print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
635       }
636       close(F);
637     }
638   }
639
640   if(-f "./ares/ares_build.h") {
641     logit_spaced "display ares/ares_build.h";
642     if(open(F, "<./ares/ares_build.h")) {
643       while(<F>) {
644         my $ll = $_;
645         print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
646       }
647       close(F);
648     }
649   }
650   else {
651     mydie "no ares_build.h created/found";
652   }
653
654   $confheader =~ s/curl/ares/;
655   logit_spaced "display ares/$confheader";
656   if(open(F, "ares/$confheader")) {
657       while (<F>) {
658           print if /^ *#/;
659       }
660       close(F);
661   }
662
663   print "\n";
664   logit "build ares";
665   chdir "ares";
666
667   if ($targetos && !$configurebuild) {
668       logit "$make -f Makefile.$targetos";
669       open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
670   }
671   else {
672       logit "$make";
673       open(F, "$make 2>&1 |") or die;
674   }
675   while (<F>) {
676     s/$pwd//g;
677     print;
678   }
679   close(F);
680
681   if (-f "libcares$libext") {
682     logit "ares is now built successfully (libcares$libext)";
683   } else {
684     mydie "ares build failed (libcares$libext)";
685   }
686
687   # cd back to the curl build dir
688   chdir "$pwd/$build";
689 }
690
691 my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
692 logit "$mkcmd";
693 open(F, "$mkcmd 2>&1 |") or die;
694 while (<F>) {
695   s/$pwd//g;
696   print;
697 }
698 close(F);
699
700 if (-f "lib/libcurl$libext") {
701   logit "libcurl was created fine (libcurl$libext)";
702 }
703 else {
704   mydie "libcurl was not created (libcurl$libext)";
705 }
706
707 if (-f "src/curl$binext") {
708   logit "curl was created fine (curl$binext)";
709 }
710 else {
711   mydie "curl was not created (curl$binext)";
712 }
713
714 if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
715   logit "display curl${binext} --version output";
716   my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
717   open(F, $cmd);
718   while(<F>) {
719     # strip CR from output on non-win32 platforms (wine on Linux)
720     s/\r// if ($^O ne 'MSWin32');
721     print;
722   }
723   close(F);
724 }
725
726 if ($configurebuild && !$crosscompile) {
727   my $host_triplet = get_host_triplet();
728   # build example programs for selected build targets
729   if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
730      ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
731      ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
732      ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
733     chdir "$pwd/$build/docs/examples";
734     logit_spaced "build examples";
735     open(F, "$make -i 2>&1 |") or die;
736     open(LOG, ">$buildlog") or die;
737     while (<F>) {
738       s/$pwd//g;
739       print;
740       print LOG;
741     }
742     close(F);
743     close(LOG);
744     chdir "$pwd/$build";
745   }
746   # build and run full test suite
747   my $o;
748   if($runtestopts) {
749       $o = "TEST_F=\"$runtestopts\" ";
750   }
751   logit "$make -k ${o}test-full";
752   open(F, "$make -k ${o}test-full 2>&1 |") or die;
753   open(LOG, ">$buildlog") or die;
754   while (<F>) {
755     s/$pwd//g;
756     print;
757     print LOG;
758   }
759   close(F);
760   close(LOG);
761
762   if (grepfile("^TEST", $buildlog)) {
763     logit "tests were run";
764   } else {
765     mydie "test suite failure";
766   }
767
768   if (grepfile("^TESTFAIL:", $buildlog)) {
769     logit "the tests were not successful";
770   } else {
771     logit "the tests were successful!";
772   }
773 }
774 else {
775   if($crosscompile) {
776     my $host_triplet = get_host_triplet();
777     # build example programs for selected cross-compiles
778     if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
779        ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
780       chdir "$pwd/$build/docs/examples";
781       logit_spaced "build examples";
782       open(F, "$make -i 2>&1 |") or die;
783       open(LOG, ">$buildlog") or die;
784       while (<F>) {
785         s/$pwd//g;
786         print;
787         print LOG;
788       }
789       close(F);
790       close(LOG);
791       chdir "$pwd/$build";
792     }
793     # build test harness programs for selected cross-compiles
794     if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
795       chdir "$pwd/$build/tests";
796       logit_spaced "build test harness";
797       open(F, "$make -i 2>&1 |") or die;
798       open(LOG, ">$buildlog") or die;
799       while (<F>) {
800         s/$pwd//g;
801         print;
802         print LOG;
803       }
804       close(F);
805       close(LOG);
806       chdir "$pwd/$build";
807     }
808     logit_spaced "cross-compiling, can't run tests";
809   }
810   # dummy message to feign success
811   print "TESTDONE: 1 tests out of 0 (dummy message)\n";
812 }
813
814 # create a tarball if we got that option.
815 if (($mktarball ne '') && (-x $mktarball)) {
816   system($mktarball);
817 }
818
819 # mydie to cleanup
820 mydie "ending nicely";