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