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