testcurl.pl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2022, 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 buildconf
  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='2014-11-25';
  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 Win32 lets 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(F, $fn) or die;
  180. while (<F>) {
  181. if (/$target/) {
  182. close(F);
  183. return 1;
  184. }
  185. }
  186. close(F);
  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(LIBCONFIGH, "<$configfile")) {
  222. while(<LIBCONFIGH>) {
  223. if($_ =~ /^\#define\s+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(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(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 buildconf";
  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(F, "autoreconf -fi 2>&1 |") or die;
  415. open(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 "buildconf was successful";
  424. }
  425. else {
  426. logit "buildconf was successful (dummy message)";
  427. }
  428. }
  429. # Set timestamp to the one in curlver.h if this isn't a git test build.
  430. if ((-f "include/curl/curlver.h") &&
  431. (open(F, "<include/curl/curlver.h"))) {
  432. while (<F>) {
  433. chomp;
  434. if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
  435. my $stampstring = $1;
  436. if ($stampstring !~ /DEV/) {
  437. $stampstring =~ s/\s+UTC//;
  438. $timestamp = $stampstring." UTC";
  439. }
  440. last;
  441. }
  442. }
  443. close(F);
  444. }
  445. # Show timestamp we are using for this test build.
  446. logit "timestamp = $timestamp";
  447. if ($configurebuild) {
  448. if (-f "configure") {
  449. logit "configure created (at least it exists)";
  450. } else {
  451. mydie "no configure created/found";
  452. }
  453. } else {
  454. logit "configure created (dummy message)"; # dummy message to feign success
  455. }
  456. sub findinpath {
  457. my $c;
  458. my $e;
  459. my $x = ($^O eq 'MSWin32') ? '.exe' : '';
  460. my $s = ($^O eq 'MSWin32') ? ';' : ':';
  461. my $p=$ENV{'PATH'};
  462. my @pa = split($s, $p);
  463. for $c (@_) {
  464. for $e (@pa) {
  465. if( -x "$e/$c$x") {
  466. return $c;
  467. }
  468. }
  469. }
  470. }
  471. my $make = findinpath("gmake", "make", "nmake");
  472. if(!$make) {
  473. mydie "Couldn't find make in the PATH";
  474. }
  475. # force to 'nmake' for VC builds
  476. $make = "nmake" if ($targetos =~ /vc/);
  477. logit "going with $make as make";
  478. # change to build dir
  479. chdir "$pwd/$build";
  480. if ($configurebuild) {
  481. # run configure script
  482. print `$CURLDIR/configure $confopts 2>&1`;
  483. if (-f "lib/Makefile") {
  484. logit "configure seems to have finished fine";
  485. } else {
  486. mydie "configure didn't work";
  487. }
  488. } else {
  489. logit "copying files to build dir ...";
  490. if ($^O eq 'MSWin32') {
  491. system("xcopy /s /q \"$CURLDIR\" .");
  492. system("buildconf.bat");
  493. }
  494. elsif ($^O eq 'linux') {
  495. system("cp -afr $CURLDIR/* .");
  496. system("cp -af $CURLDIR/Makefile.dist Makefile");
  497. system("$make -i -C lib -f Makefile.$targetos prebuild");
  498. system("$make -i -C src -f Makefile.$targetos prebuild");
  499. if (-d "$CURLDIR/ares") {
  500. system("cp -af $CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
  501. system("$make -i -C ares -f Makefile.$targetos prebuild");
  502. }
  503. }
  504. }
  505. if(-f "./libcurl.pc") {
  506. logit_spaced "display libcurl.pc";
  507. if(open(F, "<./libcurl.pc")) {
  508. while(<F>) {
  509. my $ll = $_;
  510. print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
  511. }
  512. close(F);
  513. }
  514. }
  515. logit_spaced "display lib/$confheader";
  516. open(F, "lib/$confheader") or die "lib/$confheader: $!";
  517. while (<F>) {
  518. print if /^ *#/;
  519. }
  520. close(F);
  521. if (($have_embedded_ares) &&
  522. (grepfile("^#define USE_ARES", "lib/$confheader"))) {
  523. print "\n";
  524. logit "setup to build ares";
  525. if(-f "./ares/libcares.pc") {
  526. logit_spaced "display ares/libcares.pc";
  527. if(open(F, "<./ares/libcares.pc")) {
  528. while(<F>) {
  529. my $ll = $_;
  530. print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
  531. }
  532. close(F);
  533. }
  534. }
  535. if(-f "./ares/ares_build.h") {
  536. logit_spaced "display ares/ares_build.h";
  537. if(open(F, "<./ares/ares_build.h")) {
  538. while(<F>) {
  539. my $ll = $_;
  540. print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
  541. }
  542. close(F);
  543. }
  544. }
  545. else {
  546. mydie "no ares_build.h created/found";
  547. }
  548. $confheader =~ s/curl/ares/;
  549. logit_spaced "display ares/$confheader";
  550. if(open(F, "ares/$confheader")) {
  551. while (<F>) {
  552. print if /^ *#/;
  553. }
  554. close(F);
  555. }
  556. print "\n";
  557. logit "build ares";
  558. chdir "ares";
  559. if ($targetos && !$configurebuild) {
  560. logit "$make -f Makefile.$targetos";
  561. open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
  562. }
  563. else {
  564. logit "$make";
  565. open(F, "$make 2>&1 |") or die;
  566. }
  567. while (<F>) {
  568. s/$pwd//g;
  569. print;
  570. }
  571. close(F);
  572. if (-f "libcares$libext") {
  573. logit "ares is now built successfully (libcares$libext)";
  574. } else {
  575. mydie "ares build failed (libcares$libext)";
  576. }
  577. # cd back to the curl build dir
  578. chdir "$pwd/$build";
  579. }
  580. my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
  581. logit "$mkcmd";
  582. open(F, "$mkcmd 2>&1 |") or die;
  583. while (<F>) {
  584. s/$pwd//g;
  585. print;
  586. }
  587. close(F);
  588. if (-f "lib/libcurl$libext") {
  589. logit "libcurl was created fine (libcurl$libext)";
  590. }
  591. else {
  592. mydie "libcurl was not created (libcurl$libext)";
  593. }
  594. if (-f "src/curl$binext") {
  595. logit "curl was created fine (curl$binext)";
  596. }
  597. else {
  598. mydie "curl was not created (curl$binext)";
  599. }
  600. if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
  601. logit "display curl${binext} --version output";
  602. my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
  603. open(F, $cmd);
  604. while(<F>) {
  605. # strip CR from output on non-win32 platforms (wine on Linux)
  606. s/\r// if ($^O ne 'MSWin32');
  607. print;
  608. }
  609. close(F);
  610. }
  611. if ($configurebuild && !$crosscompile) {
  612. my $host_triplet = get_host_triplet();
  613. # build example programs for selected build targets
  614. if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
  615. ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
  616. ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
  617. ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
  618. chdir "$pwd/$build/docs/examples";
  619. logit_spaced "build examples";
  620. open(F, "$make -i 2>&1 |") or die;
  621. open(LOG, ">$buildlog") or die;
  622. while (<F>) {
  623. s/$pwd//g;
  624. print;
  625. print LOG;
  626. }
  627. close(F);
  628. close(LOG);
  629. chdir "$pwd/$build";
  630. }
  631. # build and run full test suite
  632. my $o;
  633. if($runtestopts) {
  634. $o = "TEST_F=\"$runtestopts\" ";
  635. }
  636. logit "$make -k ${o}test-full";
  637. open(F, "$make -k ${o}test-full 2>&1 |") or die;
  638. open(LOG, ">$buildlog") or die;
  639. while (<F>) {
  640. s/$pwd//g;
  641. print;
  642. print LOG;
  643. }
  644. close(F);
  645. close(LOG);
  646. if (grepfile("^TEST", $buildlog)) {
  647. logit "tests were run";
  648. } else {
  649. mydie "test suite failure";
  650. }
  651. if (grepfile("^TESTFAIL:", $buildlog)) {
  652. logit "the tests were not successful";
  653. } else {
  654. logit "the tests were successful!";
  655. }
  656. }
  657. else {
  658. if($crosscompile) {
  659. my $host_triplet = get_host_triplet();
  660. # build example programs for selected cross-compiles
  661. if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
  662. ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
  663. chdir "$pwd/$build/docs/examples";
  664. logit_spaced "build examples";
  665. open(F, "$make -i 2>&1 |") or die;
  666. open(LOG, ">$buildlog") or die;
  667. while (<F>) {
  668. s/$pwd//g;
  669. print;
  670. print LOG;
  671. }
  672. close(F);
  673. close(LOG);
  674. chdir "$pwd/$build";
  675. }
  676. # build test harness programs for selected cross-compiles
  677. if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
  678. chdir "$pwd/$build/tests";
  679. logit_spaced "build test harness";
  680. open(F, "$make -i 2>&1 |") or die;
  681. open(LOG, ">$buildlog") or die;
  682. while (<F>) {
  683. s/$pwd//g;
  684. print;
  685. print LOG;
  686. }
  687. close(F);
  688. close(LOG);
  689. chdir "$pwd/$build";
  690. }
  691. logit_spaced "cross-compiling, can't run tests";
  692. }
  693. # dummy message to feign success
  694. print "TESTDONE: 1 tests out of 0 (dummy message)\n";
  695. }
  696. # create a tarball if we got that option.
  697. if (($mktarball ne '') && (-x $mktarball)) {
  698. system($mktarball);
  699. }
  700. # mydie to cleanup
  701. mydie "ending nicely";