• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env perl
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) 1998 - 2017, 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.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 reasonable backlog) will
35# be published on the curl site, at https://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# --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 '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-ssl --enable-debug --enable-ipv6 --with-krb4\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      # ignore messages pertaining to third party m4 files we don't care
485      next if ($ll =~ /aclocal\/gtk\.m4/);
486      next if ($ll =~ /aclocal\/gtkextra\.m4/);
487      print $ll;
488      print LOG $ll;
489    }
490    close(F);
491    close(LOG);
492
493    if (grepfile("^buildconf: OK", $buildlog)) {
494      logit "buildconf was successful";
495    }
496    else {
497      mydie "buildconf was NOT successful";
498    }
499  }
500  else {
501    logit "buildconf was successful (dummy message)";
502  }
503}
504
505# Set timestamp to the one in curlver.h if this isn't a git test build.
506if ((-f "include/curl/curlver.h") &&
507    (open(F, "<include/curl/curlver.h"))) {
508  while (<F>) {
509    chomp;
510    if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
511      my $stampstring = $1;
512      if ($stampstring !~ /DEV/) {
513          $stampstring =~ s/\s+UTC//;
514          $timestamp = $stampstring." UTC";
515      }
516      last;
517    }
518  }
519  close(F);
520}
521
522# Show timestamp we are using for this test build.
523logit "timestamp = $timestamp";
524
525if ($configurebuild) {
526  if (-f "configure") {
527    logit "configure created (at least it exists)";
528  } else {
529    mydie "no configure created/found";
530  }
531} else {
532  logit "configure created (dummy message)"; # dummy message to feign success
533}
534
535sub findinpath {
536  my $c;
537  my $e;
538  my $x = ($^O eq 'MSWin32') ? '.exe' : '';
539  my $s = ($^O eq 'MSWin32') ? ';' : ':';
540  my $p=$ENV{'PATH'};
541  my @pa = split($s, $p);
542  for $c (@_) {
543    for $e (@pa) {
544      if( -x "$e/$c$x") {
545        return $c;
546      }
547    }
548  }
549}
550
551my $make = findinpath("gmake", "make", "nmake");
552if(!$make) {
553    mydie "Couldn't find make in the PATH";
554}
555# force to 'nmake' for VC builds
556$make = "nmake" if ($targetos =~ /vc/);
557# force to 'wmake' for Watcom builds
558$make = "wmake" if ($targetos =~ /watcom/);
559logit "going with $make as make";
560
561# change to build dir
562chdir "$pwd/$build";
563
564if ($configurebuild) {
565  # run configure script
566  print `$CURLDIR/configure $confopts 2>&1`;
567
568  if (-f "lib/Makefile") {
569    logit "configure seems to have finished fine";
570  } else {
571    mydie "configure didn't work";
572  }
573} else {
574  logit "copying files to build dir ...";
575  if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
576    system("xcopy /s /q \"$CURLDIR\" .");
577    system("buildconf.bat");
578  }
579  elsif ($targetos =~ /netware/) {
580    system("cp -afr $CURLDIR/* .");
581    system("cp -af $CURLDIR/Makefile.dist Makefile");
582    system("$make -i -C lib -f Makefile.netware prebuild");
583    system("$make -i -C src -f Makefile.netware prebuild");
584    if (-d "$CURLDIR/ares") {
585      system("$make -i -C ares -f Makefile.netware prebuild");
586    }
587  }
588  elsif ($^O eq 'linux') {
589    system("cp -afr $CURLDIR/* .");
590    system("cp -af $CURLDIR/Makefile.dist Makefile");
591    system("$make -i -C lib -f Makefile.$targetos prebuild");
592    system("$make -i -C src -f Makefile.$targetos prebuild");
593    if (-d "$CURLDIR/ares") {
594      system("cp -af $CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
595      system("$make -i -C ares -f Makefile.$targetos prebuild");
596    }
597  }
598}
599
600if(-f "./libcurl.pc") {
601  logit_spaced "display libcurl.pc";
602  if(open(F, "<./libcurl.pc")) {
603    while(<F>) {
604      my $ll = $_;
605      print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
606    }
607    close(F);
608  }
609}
610
611logit_spaced "display lib/$confheader";
612open(F, "lib/$confheader") or die "lib/$confheader: $!";
613while (<F>) {
614  print if /^ *#/;
615}
616close(F);
617
618if (($have_embedded_ares) &&
619    (grepfile("^#define USE_ARES", "lib/$confheader"))) {
620  print "\n";
621  logit "setup to build ares";
622
623  if(-f "./ares/libcares.pc") {
624    logit_spaced  "display ares/libcares.pc";
625    if(open(F, "<./ares/libcares.pc")) {
626      while(<F>) {
627        my $ll = $_;
628        print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
629      }
630      close(F);
631    }
632  }
633
634  if(-f "./ares/ares_build.h") {
635    logit_spaced "display ares/ares_build.h";
636    if(open(F, "<./ares/ares_build.h")) {
637      while(<F>) {
638        my $ll = $_;
639        print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
640      }
641      close(F);
642    }
643  }
644  else {
645    mydie "no ares_build.h created/found";
646  }
647
648  $confheader =~ s/curl/ares/;
649  logit_spaced "display ares/$confheader";
650  if(open(F, "ares/$confheader")) {
651      while (<F>) {
652          print if /^ *#/;
653      }
654      close(F);
655  }
656
657  print "\n";
658  logit "build ares";
659  chdir "ares";
660
661  if ($targetos && !$configurebuild) {
662      logit "$make -f Makefile.$targetos";
663      open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
664  }
665  else {
666      logit "$make";
667      open(F, "$make 2>&1 |") or die;
668  }
669  while (<F>) {
670    s/$pwd//g;
671    print;
672  }
673  close(F);
674
675  if (-f "libcares$libext") {
676    logit "ares is now built successfully (libcares$libext)";
677  } else {
678    mydie "ares build failed (libcares$libext)";
679  }
680
681  # cd back to the curl build dir
682  chdir "$pwd/$build";
683}
684
685my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
686logit "$mkcmd";
687open(F, "$mkcmd 2>&1 |") or die;
688while (<F>) {
689  s/$pwd//g;
690  print;
691}
692close(F);
693
694if (-f "lib/libcurl$libext") {
695  logit "libcurl was created fine (libcurl$libext)";
696}
697else {
698  mydie "libcurl was not created (libcurl$libext)";
699}
700
701if (-f "src/curl$binext") {
702  logit "curl was created fine (curl$binext)";
703}
704else {
705  mydie "curl was not created (curl$binext)";
706}
707
708if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
709  logit "display curl${binext} --version output";
710  my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
711  open(F, $cmd);
712  while(<F>) {
713    # strip CR from output on non-win32 platforms (wine on Linux)
714    s/\r// if ($^O ne 'MSWin32');
715    print;
716  }
717  close(F);
718}
719
720if ($configurebuild && !$crosscompile) {
721  my $host_triplet = get_host_triplet();
722  # build example programs for selected build targets
723  if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
724     ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
725     ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
726     ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
727    chdir "$pwd/$build/docs/examples";
728    logit_spaced "build examples";
729    open(F, "$make -i 2>&1 |") or die;
730    open(LOG, ">$buildlog") or die;
731    while (<F>) {
732      s/$pwd//g;
733      print;
734      print LOG;
735    }
736    close(F);
737    close(LOG);
738    chdir "$pwd/$build";
739  }
740  # build and run full test suite
741  my $o;
742  if($runtestopts) {
743      $o = "TEST_F=\"$runtestopts\" ";
744  }
745  logit "$make -k ${o}test-full";
746  open(F, "$make -k ${o}test-full 2>&1 |") or die;
747  open(LOG, ">$buildlog") or die;
748  while (<F>) {
749    s/$pwd//g;
750    print;
751    print LOG;
752  }
753  close(F);
754  close(LOG);
755
756  if (grepfile("^TEST", $buildlog)) {
757    logit "tests were run";
758  } else {
759    mydie "test suite failure";
760  }
761
762  if (grepfile("^TESTFAIL:", $buildlog)) {
763    logit "the tests were not successful";
764  } else {
765    logit "the tests were successful!";
766  }
767}
768else {
769  if($crosscompile) {
770    my $host_triplet = get_host_triplet();
771    # build example programs for selected cross-compiles
772    if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
773       ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
774      chdir "$pwd/$build/docs/examples";
775      logit_spaced "build examples";
776      open(F, "$make -i 2>&1 |") or die;
777      open(LOG, ">$buildlog") or die;
778      while (<F>) {
779        s/$pwd//g;
780        print;
781        print LOG;
782      }
783      close(F);
784      close(LOG);
785      chdir "$pwd/$build";
786    }
787    # build test harness programs for selected cross-compiles
788    if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
789      chdir "$pwd/$build/tests";
790      logit_spaced "build test harness";
791      open(F, "$make -i 2>&1 |") or die;
792      open(LOG, ">$buildlog") or die;
793      while (<F>) {
794        s/$pwd//g;
795        print;
796        print LOG;
797      }
798      close(F);
799      close(LOG);
800      chdir "$pwd/$build";
801    }
802    logit_spaced "cross-compiling, can't run tests";
803  }
804  # dummy message to feign success
805  print "TESTDONE: 1 tests out of 0 (dummy message)\n";
806}
807
808# create a tarball if we got that option.
809if (($mktarball ne '') && (-x $mktarball)) {
810  system($mktarball);
811}
812
813# mydie to cleanup
814mydie "ending nicely";
815