testcurl.pl 21 KB

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