2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 ###########################
25 # What is This Script?
26 ###########################
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/
38 # testcurl.pl [options] [curl-daily-name] > output
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.
58 # if [curl-daily-name] is omitted, a 'curl' git directory is assumed.
66 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
69 use vars qw($version $fixed $infixed $CURLDIR $git $pwd $build $buildlog
70 $buildlogname $configurebuild $targetos $confheader $binext
73 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
74 $extvercmd $nogitpull $nobuildconf $crosscompile
77 # version of this script
78 $version='2014-11-25';
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.
84 if (-f ".git/config") {
92 if ($ARGV[0] =~ /--target=/) {
93 $targetos = (split(/=/, shift @ARGV, 2))[1];
95 elsif ($ARGV[0] =~ /--setup=/) {
96 $setupfile = (split(/=/, shift @ARGV, 2))[1];
98 elsif ($ARGV[0] =~ /--extvercmd=/) {
99 $extvercmd = (split(/=/, shift @ARGV, 2))[1];
101 elsif ($ARGV[0] =~ /--mktarball=/) {
102 $mktarball = (split(/=/, shift @ARGV, 2))[1];
104 elsif ($ARGV[0] =~ /--name=/) {
105 $name = (split(/=/, shift @ARGV, 2))[1];
107 elsif ($ARGV[0] =~ /--email=/) {
108 $email = (split(/=/, shift @ARGV, 2))[1];
110 elsif ($ARGV[0] =~ /--desc=/) {
111 $desc = (split(/=/, shift @ARGV, 2))[1];
113 elsif ($ARGV[0] =~ /--notes=/) {
114 $notes = (split(/=/, shift @ARGV, 2))[1];
116 elsif ($ARGV[0] =~ /--configure=(.*)/) {
120 elsif (($ARGV[0] eq "--nocvsup") || ($ARGV[0] eq "--nogitpull")) {
124 elsif ($ARGV[0] =~ /--nobuildconf/) {
128 elsif ($ARGV[0] =~ /--noconfigure/) {
132 elsif ($ARGV[0] =~ /--crosscompile/) {
136 elsif ($ARGV[0] =~ /--runtestopts=/) {
137 $runtestopts = (split(/=/, shift @ARGV, 2))[1];
140 $CURLDIR=shift @ARGV;
141 $git=0; # a given dir, assume not using git
145 # Do the platform-specific stuff here
146 $confheader = 'curl_config.h';
148 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
149 if ($^O eq 'MSWin32' || $targetos) {
151 # If no target defined on Win32 lets assume vc
154 if ($targetos =~ /vc/ || $targetos =~ /borland/ || $targetos =~ /watcom/) {
158 elsif ($targetos =~ /mingw/) {
160 if ($^O eq 'MSWin32') {
164 elsif ($targetos =~ /netware/) {
167 if ($^O eq 'MSWin32') {
176 if (($^O eq 'MSWin32' || $^O eq 'msys') &&
177 ($targetos =~ /vc/ || $targetos =~ /mingw32/ ||
178 $targetos =~ /borland/ || $targetos =~ /watcom/)) {
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.
185 $confheader = 'config-win32.h';
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$/));
194 if ($^O eq 'MSWin32') {
195 foreach (glob($target)) {
197 system("rd /s /q $_");
200 system("rm -rf $target");
205 my ($target, $fn) = @_;
220 print "testcurl: $text\n";
224 sub logit_spaced($) {
227 print "\ntestcurl: $text\n\n";
234 chdir $pwd; # cd back to the original root dir
236 if ($pwd && $build) {
237 # we have a build directory name, remove the dir
238 logit "removing the $build dir";
239 rmtree "$pwd/$build";
242 # we have a build log output file left, remove it
243 logit "removing the $buildlogname file";
246 logit "ENDING HERE"; # last line logged!
250 sub get_host_triplet {
252 my $configfile = "$pwd/$build/lib/curl_config.h";
254 if(-f $configfile && -s $configfile && open(LIBCONFIGH, "<$configfile")) {
255 while(<LIBCONFIGH>) {
256 if($_ =~ /^\#define\s+OS\s+"*([^"][^"]*)"*\s*/) {
266 if($name && $email && $desc) {
267 # having these fields set are enough to continue, skip reading the setup
272 elsif (open(F, "$setupfile")) {
282 $infixed=0; # so that "additional args to configure" works properly first time...
286 print "please enter your name\n";
293 print "please enter your contact email address\n";
300 print "please enter a one line system description\n";
308 print "please enter your additional arguments to configure\n";
309 print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
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";
328 # Enable picky compiler warnings unless explicitly disabled
329 if (($confopts !~ /--enable-debug/) &&
330 ($confopts !~ /--enable-warnings/) &&
331 ($confopts !~ /--disable-warnings/)) {
332 $confopts .= " --enable-warnings";
335 my $str1066os = 'o' x 1066;
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";
341 logit "STARTING HERE"; # first line logged, for scripts to trigger on
342 logit 'TRANSFER CONTROL ==== 1120 CHAR LINE' . $str1066os . 'LINE_END';
343 logit "NAME = $name";
344 logit "EMAIL = $email";
345 logit "DESC = $desc";
346 logit "NOTES = $notes";
347 logit "CONFOPTS = $confopts";
348 logit "RUNTESTOPTS = ".$runtestopts;
349 logit "CPPFLAGS = ".$ENV{CPPFLAGS};
350 logit "CFLAGS = ".$ENV{CFLAGS};
351 logit "LDFLAGS = ".$ENV{LDFLAGS};
352 logit "LIBS = ".$ENV{LIBS};
353 logit "CC = ".$ENV{CC};
354 logit "TMPDIR = ".$ENV{TMPDIR};
355 logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
356 logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
357 logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
358 logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
359 logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
360 logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
361 logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
362 logit "LIBPATH = ".$ENV{LIBPATH};
363 logit "target = ".$targetos;
364 logit "version = $version"; # script version
365 logit "date = $timestamp"; # When the test build starts
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.
373 my $have_embedded_ares = 0;
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");
388 mydie "$CURLDIR is not a daily source dir or checked out from git!"
392 # make the path absolute so we can use it everywhere
393 $CURLDIR = File::Spec->rel2abs("$CURLDIR");
396 $buildlogname="buildlog-$$";
397 $buildlog="$pwd/$buildlogname";
399 # remove any previous left-overs
403 # this is to remove old build logs that ended up in the wrong dir
404 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
406 # create a dir to build in
410 logit "build dir $build was created fine";
412 mydie "failed to create dir $build";
415 # get in the curl source tree root
418 # Do the git thing, or not...
423 # update quietly to the latest git
425 logit "skipping git pull (--nogitpull)";
427 logit "run git pull in curl";
428 system("git pull 2>&1");
430 logit "failed to update from curl git ($?), continue anyway" if ($?);
432 # Set timestamp to the UTC the git update took place.
433 $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
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:";
444 if (-d "ares/.git") {
448 logit "skipping git pull (--nogitpull) in ares";
450 logit "run git pull in ares";
451 system("git pull 2>&1");
453 logit "failed to update from ares git ($?), continue anyway" if ($?);
455 # Set timestamp to the UTC the git update took place.
456 $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
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:";
471 logit "told to not run buildconf";
473 elsif ($configurebuild) {
474 # remove possible left-overs from the past
476 unlink "autom4te.cache";
478 # generate the build files
479 logit "invoke buildconf";
480 open(F, "./buildconf 2>&1 |") or die;
481 open(LOG, ">$buildlog") or die;
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/);
493 if (grepfile("^buildconf: OK", $buildlog)) {
494 logit "buildconf was successful";
497 mydie "buildconf was NOT successful";
501 logit "buildconf was successful (dummy message)";
505 # Set timestamp to the one in curlver.h if this isn't a git test build.
506 if ((-f "include/curl/curlver.h") &&
507 (open(F, "<include/curl/curlver.h"))) {
510 if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
511 my $stampstring = $1;
512 if ($stampstring !~ /DEV/) {
513 $stampstring =~ s/\s+UTC//;
514 $timestamp = $stampstring." UTC";
522 # Show timestamp we are using for this test build.
523 logit "timestamp = $timestamp";
525 if ($configurebuild) {
526 if (-f "configure") {
527 logit "configure created (at least it exists)";
529 mydie "no configure created/found";
532 logit "configure created (dummy message)"; # dummy message to feign success
538 my $x = ($^O eq 'MSWin32') ? '.exe' : '';
539 my $s = ($^O eq 'MSWin32') ? ';' : ':';
541 my @pa = split($s, $p);
551 my $make = findinpath("gmake", "make", "nmake");
553 mydie "Couldn't find make in the PATH";
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/);
559 logit "going with $make as make";
561 # change to build dir
564 if ($configurebuild) {
565 # run configure script
566 print `$CURLDIR/configure $confopts 2>&1`;
568 if (-f "lib/Makefile") {
569 logit "configure seems to have finished fine";
571 mydie "configure didn't work";
574 logit "copying files to build dir ...";
575 if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
576 system("xcopy /s /q \"$CURLDIR\" .");
577 system("buildconf.bat");
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");
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");
601 if(-f "./libcurl.pc") {
602 logit_spaced "display libcurl.pc";
603 if(open(F, "<./libcurl.pc")) {
606 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
612 if(-f "./include/curl/curlbuild.h") {
613 logit_spaced "display include/curl/curlbuild.h";
614 if(open(F, "<./include/curl/curlbuild.h")) {
617 print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/));
623 mydie "no curlbuild.h created/found";
626 logit_spaced "display lib/$confheader";
627 open(F, "lib/$confheader") or die "lib/$confheader: $!";
633 if (($have_embedded_ares) &&
634 (grepfile("^#define USE_ARES", "lib/$confheader"))) {
636 logit "setup to build ares";
638 if(-f "./ares/libcares.pc") {
639 logit_spaced "display ares/libcares.pc";
640 if(open(F, "<./ares/libcares.pc")) {
643 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
649 if(-f "./ares/ares_build.h") {
650 logit_spaced "display ares/ares_build.h";
651 if(open(F, "<./ares/ares_build.h")) {
654 print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
660 mydie "no ares_build.h created/found";
663 $confheader =~ s/curl/ares/;
664 logit_spaced "display ares/$confheader";
665 if(open(F, "ares/$confheader")) {
676 if ($targetos && !$configurebuild) {
677 logit "$make -f Makefile.$targetos";
678 open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
682 open(F, "$make 2>&1 |") or die;
690 if (-f "libcares$libext") {
691 logit "ares is now built successfully (libcares$libext)";
693 mydie "ares build failed (libcares$libext)";
696 # cd back to the curl build dir
700 my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
702 open(F, "$mkcmd 2>&1 |") or die;
709 if (-f "lib/libcurl$libext") {
710 logit "libcurl was created fine (libcurl$libext)";
713 mydie "libcurl was not created (libcurl$libext)";
716 if (-f "src/curl$binext") {
717 logit "curl was created fine (curl$binext)";
720 mydie "curl was not created (curl$binext)";
723 if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
724 logit "display curl${binext} --version output";
725 my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
728 # strip CR from output on non-win32 platforms (wine on Linux)
729 s/\r// if ($^O ne 'MSWin32');
735 if ($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;
755 # build and run full test suite
758 $o = "TEST_F=\"$runtestopts\" ";
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;
771 if (grepfile("^TEST", $buildlog)) {
772 logit "tests were run";
774 mydie "test suite failure";
777 if (grepfile("^TESTFAIL:", $buildlog)) {
778 logit "the tests were not successful";
780 logit "the tests were successful!";
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;
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;
817 logit_spaced "cross-compiling, can't run tests";
819 # dummy message to feign success
820 print "TESTDONE: 1 tests out of 0 (dummy message)\n";
823 # create a tarball if we got that option.
824 if (($mktarball ne '') && (-x $mktarball)) {
829 mydie "ending nicely";