1#!/usr/bin/env perl 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) 1998 - 2015, 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# --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("cp -af $CURLDIR/include/curl/curlbuild.h.dist ./include/curl/curlbuild.h"); 592 system("$make -i -C lib -f Makefile.$targetos prebuild"); 593 system("$make -i -C src -f Makefile.$targetos prebuild"); 594 if (-d "$CURLDIR/ares") { 595 system("cp -af $CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h"); 596 system("$make -i -C ares -f Makefile.$targetos prebuild"); 597 } 598 } 599} 600 601if(-f "./libcurl.pc") { 602 logit_spaced "display libcurl.pc"; 603 if(open(F, "<./libcurl.pc")) { 604 while(<F>) { 605 my $ll = $_; 606 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/)); 607 } 608 close(F); 609 } 610} 611 612if(-f "./include/curl/curlbuild.h") { 613 logit_spaced "display include/curl/curlbuild.h"; 614 if(open(F, "<./include/curl/curlbuild.h")) { 615 while(<F>) { 616 my $ll = $_; 617 print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/)); 618 } 619 close(F); 620 } 621} 622else { 623 mydie "no curlbuild.h created/found"; 624} 625 626logit_spaced "display lib/$confheader"; 627open(F, "lib/$confheader") or die "lib/$confheader: $!"; 628while (<F>) { 629 print if /^ *#/; 630} 631close(F); 632 633if (($have_embedded_ares) && 634 (grepfile("^#define USE_ARES", "lib/$confheader"))) { 635 print "\n"; 636 logit "setup to build ares"; 637 638 if(-f "./ares/libcares.pc") { 639 logit_spaced "display ares/libcares.pc"; 640 if(open(F, "<./ares/libcares.pc")) { 641 while(<F>) { 642 my $ll = $_; 643 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/)); 644 } 645 close(F); 646 } 647 } 648 649 if(-f "./ares/ares_build.h") { 650 logit_spaced "display ares/ares_build.h"; 651 if(open(F, "<./ares/ares_build.h")) { 652 while(<F>) { 653 my $ll = $_; 654 print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/)); 655 } 656 close(F); 657 } 658 } 659 else { 660 mydie "no ares_build.h created/found"; 661 } 662 663 $confheader =~ s/curl/ares/; 664 logit_spaced "display ares/$confheader"; 665 if(open(F, "ares/$confheader")) { 666 while (<F>) { 667 print if /^ *#/; 668 } 669 close(F); 670 } 671 672 print "\n"; 673 logit "build ares"; 674 chdir "ares"; 675 676 if ($targetos && !$configurebuild) { 677 logit "$make -f Makefile.$targetos"; 678 open(F, "$make -f Makefile.$targetos 2>&1 |") or die; 679 } 680 else { 681 logit "$make"; 682 open(F, "$make 2>&1 |") or die; 683 } 684 while (<F>) { 685 s/$pwd//g; 686 print; 687 } 688 close(F); 689 690 if (-f "libcares$libext") { 691 logit "ares is now built successfully (libcares$libext)"; 692 } else { 693 mydie "ares build failed (libcares$libext)"; 694 } 695 696 # cd back to the curl build dir 697 chdir "$pwd/$build"; 698} 699 700my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : ""); 701logit "$mkcmd"; 702open(F, "$mkcmd 2>&1 |") or die; 703while (<F>) { 704 s/$pwd//g; 705 print; 706} 707close(F); 708 709if (-f "lib/libcurl$libext") { 710 logit "libcurl was created fine (libcurl$libext)"; 711} 712else { 713 mydie "libcurl was not created (libcurl$libext)"; 714} 715 716if (-f "src/curl$binext") { 717 logit "curl was created fine (curl$binext)"; 718} 719else { 720 mydie "curl was not created (curl$binext)"; 721} 722 723if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) { 724 logit "display curl${binext} --version output"; 725 my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|"; 726 open(F, $cmd); 727 while(<F>) { 728 # strip CR from output on non-win32 platforms (wine on Linux) 729 s/\r// if ($^O ne 'MSWin32'); 730 print; 731 } 732 close(F); 733} 734 735if ($configurebuild && !$crosscompile) { 736 my $host_triplet = get_host_triplet(); 737 # build example programs for selected build targets 738 if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) || 739 ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) || 740 ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) || 741 ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) { 742 chdir "$pwd/$build/docs/examples"; 743 logit_spaced "build examples"; 744 open(F, "$make -i 2>&1 |") or die; 745 open(LOG, ">$buildlog") or die; 746 while (<F>) { 747 s/$pwd//g; 748 print; 749 print LOG; 750 } 751 close(F); 752 close(LOG); 753 chdir "$pwd/$build"; 754 } 755 # build and run full test suite 756 my $o; 757 if($runtestopts) { 758 $o = "TEST_F=\"$runtestopts\" "; 759 } 760 logit "$make -k ${o}test-full"; 761 open(F, "$make -k ${o}test-full 2>&1 |") or die; 762 open(LOG, ">$buildlog") or die; 763 while (<F>) { 764 s/$pwd//g; 765 print; 766 print LOG; 767 } 768 close(F); 769 close(LOG); 770 771 if (grepfile("^TEST", $buildlog)) { 772 logit "tests were run"; 773 } else { 774 mydie "test suite failure"; 775 } 776 777 if (grepfile("^TESTFAIL:", $buildlog)) { 778 logit "the tests were not successful"; 779 } else { 780 logit "the tests were successful!"; 781 } 782} 783else { 784 if($crosscompile) { 785 my $host_triplet = get_host_triplet(); 786 # build example programs for selected cross-compiles 787 if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) || 788 ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) { 789 chdir "$pwd/$build/docs/examples"; 790 logit_spaced "build examples"; 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 # build test harness programs for selected cross-compiles 803 if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) { 804 chdir "$pwd/$build/tests"; 805 logit_spaced "build test harness"; 806 open(F, "$make -i 2>&1 |") or die; 807 open(LOG, ">$buildlog") or die; 808 while (<F>) { 809 s/$pwd//g; 810 print; 811 print LOG; 812 } 813 close(F); 814 close(LOG); 815 chdir "$pwd/$build"; 816 } 817 logit_spaced "cross-compiling, can't run tests"; 818 } 819 # dummy message to feign success 820 print "TESTDONE: 1 tests out of 0 (dummy message)\n"; 821} 822 823# create a tarball if we got that option. 824if (($mktarball ne '') && (-x $mktarball)) { 825 system($mktarball); 826} 827 828# mydie to cleanup 829mydie "ending nicely"; 830