2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2014, 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 # --nocvsup Don't pull from git even though it is a git tree
50 # --nogitpull Don't pull from git even though it is a git tree
51 # --nobuildconf Don't run buildconf
52 # --noconfigure Don't run configure
53 # --runtestopts=[options] Options to pass to runtests.pl
54 # --setup=[file name] File name to read setup from (deprecated)
55 # --target=[your os] Specify your target environment.
57 # if [curl-daily-name] is omitted, a 'curl' git directory is assumed.
64 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
67 use vars qw($version $fixed $infixed $CURLDIR $git $pwd $build $buildlog
68 $buildlogname $configurebuild $targetos $confheader $binext
71 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
72 $extvercmd $nogitpull $nobuildconf $crosscompile
75 # version of this script
76 $version='2012-11-30';
79 # Determine if we're running from git or a canned copy of curl,
80 # or if we got a specific target option or setup file option.
82 if (-f ".git/config") {
90 if ($ARGV[0] =~ /--target=/) {
91 $targetos = (split(/=/, shift @ARGV))[1];
93 elsif ($ARGV[0] =~ /--setup=/) {
94 $setupfile = (split(/=/, shift @ARGV))[1];
96 elsif ($ARGV[0] =~ /--extvercmd=/) {
97 $extvercmd = (split(/=/, shift @ARGV))[1];
99 elsif ($ARGV[0] =~ /--mktarball=/) {
100 $mktarball = (split(/=/, shift @ARGV))[1];
102 elsif ($ARGV[0] =~ /--name=/) {
103 $name = (split(/=/, shift @ARGV))[1];
105 elsif ($ARGV[0] =~ /--email=/) {
106 $email = (split(/=/, shift @ARGV))[1];
108 elsif ($ARGV[0] =~ /--desc=/) {
109 $desc = (split(/=/, shift @ARGV))[1];
111 elsif ($ARGV[0] =~ /--configure=(.*)/) {
115 elsif (($ARGV[0] eq "--nocvsup") || ($ARGV[0] eq "--nogitpull")) {
119 elsif ($ARGV[0] =~ /--nobuildconf/) {
123 elsif ($ARGV[0] =~ /--noconfigure/) {
127 elsif ($ARGV[0] =~ /--crosscompile/) {
131 elsif ($ARGV[0] =~ /--runtestopts=/) {
132 $runtestopts = (split(/=/, shift @ARGV, 2))[1];
135 $CURLDIR=shift @ARGV;
136 $git=0; # a given dir, assume not using git
140 # Do the platform-specific stuff here
141 $confheader = 'curl_config.h';
143 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
144 if ($^O eq 'MSWin32' || $targetos) {
146 # If no target defined on Win32 lets assume vc
149 if ($targetos =~ /vc/ || $targetos =~ /borland/ || $targetos =~ /watcom/) {
153 elsif ($targetos =~ /mingw/) {
155 if ($^O eq 'MSWin32') {
159 elsif ($targetos =~ /netware/) {
162 if ($^O eq 'MSWin32') {
171 if (($^O eq 'MSWin32' || $^O eq 'msys') &&
172 ($targetos =~ /vc/ || $targetos =~ /mingw32/ ||
173 $targetos =~ /borland/ || $targetos =~ /watcom/)) {
175 # Set these things only when building ON Windows and for Win32 platform.
176 # FOR Windows since we might be cross-compiling on another system. Non-
177 # Windows builds still default to configure-style builds with curl_config.h.
180 $confheader = 'config-win32.h';
183 $ENV{LC_ALL}="C" if (($ENV{LC_ALL}) && ($ENV{LC_ALL} !~ /^C$/));
184 $ENV{LC_CTYPE}="C" if (($ENV{LC_CTYPE}) && ($ENV{LC_CTYPE} !~ /^C$/));
189 if ($^O eq 'MSWin32') {
190 foreach (glob($target)) {
192 system("rd /s /q $_");
195 system("rm -rf $target");
200 my ($target, $fn) = @_;
215 print "testcurl: $text\n";
219 sub logit_spaced($) {
222 print "\ntestcurl: $text\n\n";
229 chdir $pwd; # cd back to the original root dir
231 if ($pwd && $build) {
232 # we have a build directory name, remove the dir
233 logit "removing the $build dir";
234 rmtree "$pwd/$build";
237 # we have a build log output file left, remove it
238 logit "removing the $buildlogname file";
241 logit "ENDING HERE"; # last line logged!
245 sub get_host_triplet {
247 my $configfile = "$pwd/$build/lib/curl_config.h";
249 if(-f $configfile && -s $configfile && open(LIBCONFIGH, "<$configfile")) {
250 while(<LIBCONFIGH>) {
251 if($_ =~ /^\#define\s+OS\s+"*([^"][^"]*)"*\s*/) {
261 if (open(F, "$setupfile")) {
270 $infixed=0; # so that "additional args to configure" works properly first time...
274 print "please enter your name\n";
281 print "please enter your contact email address\n";
288 print "please enter a one line system description\n";
296 print "please enter your additional arguments to configure\n";
297 print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
306 open(F, ">$setupfile") or die;
307 print F "name='$name'\n";
308 print F "email='$email'\n";
309 print F "desc='$desc'\n";
310 print F "confopts='$confopts'\n";
311 print F "notes='$notes'\n";
312 print F "fixed='$fixed'\n";
316 # Enable picky compiler warnings unless explicitly disabled
317 if (($confopts !~ /--enable-debug/) &&
318 ($confopts !~ /--enable-warnings/) &&
319 ($confopts !~ /--disable-warnings/)) {
320 $confopts .= " --enable-warnings";
323 my $str1066os = 'o' x 1066;
325 # Set timestamp to the UTC this script is running. Its value might
326 # be changed later in the script to the value present in curlver.h
327 $timestamp = scalar(gmtime)." UTC";
329 logit "STARTING HERE"; # first line logged, for scripts to trigger on
330 logit 'TRANSFER CONTROL ==== 1120 CHAR LINE' . $str1066os . 'LINE_END';
331 logit "NAME = $name";
332 logit "EMAIL = $email";
333 logit "DESC = $desc";
334 logit "NOTES = $notes";
335 logit "CONFOPTS = $confopts";
336 logit "CPPFLAGS = ".$ENV{CPPFLAGS};
337 logit "CFLAGS = ".$ENV{CFLAGS};
338 logit "LDFLAGS = ".$ENV{LDFLAGS};
339 logit "LIBS = ".$ENV{LIBS};
340 logit "CC = ".$ENV{CC};
341 logit "TMPDIR = ".$ENV{TMPDIR};
342 logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
343 logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
344 logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
345 logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
346 logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
347 logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
348 logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
349 logit "LIBPATH = ".$ENV{LIBPATH};
350 logit "target = ".$targetos;
351 logit "version = $version"; # script version
352 logit "date = $timestamp"; # When the test build starts
356 # Make $pwd to become the path without newline. We'll use that in order to cut
357 # off that path from all possible logs and error messages etc.
360 my $have_embedded_ares = 0;
363 if ($git && -d "$CURLDIR/.git") {
364 logit "$CURLDIR is verified to be a fine git source dir";
365 # remove the generated sources to force them to be re-generated each
366 # time we run this test
367 unlink "$CURLDIR/src/tool_hugehelp.c";
368 # find out if curl source dir has an in-tree c-ares repo
369 $have_embedded_ares = 1 if (-f "$CURLDIR/ares/GIT-INFO");
370 } elsif (!$git && -f "$CURLDIR/tests/testcurl.pl") {
371 logit "$CURLDIR is verified to be a fine daily source dir";
372 # find out if curl source dir has an in-tree c-ares extracted tarball
373 $have_embedded_ares = 1 if (-f "$CURLDIR/ares/ares_build.h");
375 mydie "$CURLDIR is not a daily source dir or checked out from git!"
379 $buildlogname="buildlog-$$";
380 $buildlog="$pwd/$buildlogname";
382 # remove any previous left-overs
386 # this is to remove old build logs that ended up in the wrong dir
387 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
389 # create a dir to build in
393 logit "build dir $build was created fine";
395 mydie "failed to create dir $build";
398 # get in the curl source tree root
401 # Do the git thing, or not...
406 # update quietly to the latest git
408 logit "skipping git pull (--nogitpull)";
410 logit "run git pull in curl";
411 system("git pull 2>&1");
413 logit "failed to update from curl git ($?), continue anyway" if ($?);
415 # Set timestamp to the UTC the git update took place.
416 $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
419 # get the last 5 commits for show (even if no pull was made)
420 @commits=`git log --pretty=oneline --abbrev-commit -5`;
421 logit "The most recent curl git commits:";
427 if (-d "ares/.git") {
431 logit "skipping git pull (--nogitpull) in ares";
433 logit "run git pull in ares";
434 system("git pull 2>&1");
436 logit "failed to update from ares git ($?), continue anyway" if ($?);
438 # Set timestamp to the UTC the git update took place.
439 $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
442 # get the last 5 commits for show (even if no pull was made)
443 @commits=`git log --pretty=oneline --abbrev-commit -5`;
444 logit "The most recent ares git commits:";
450 chdir "$pwd/$CURLDIR";
454 logit "told to not run buildconf";
456 elsif ($configurebuild) {
457 # remove possible left-overs from the past
459 unlink "autom4te.cache";
461 # generate the build files
462 logit "invoke buildconf";
463 open(F, "./buildconf 2>&1 |") or die;
464 open(LOG, ">$buildlog") or die;
467 # ignore messages pertaining to third party m4 files we don't care
468 next if ($ll =~ /aclocal\/gtk\.m4/);
469 next if ($ll =~ /aclocal\/gtkextra\.m4/);
476 if (grepfile("^buildconf: OK", $buildlog)) {
477 logit "buildconf was successful";
480 mydie "buildconf was NOT successful";
484 logit "buildconf was successful (dummy message)";
488 # Set timestamp to the one in curlver.h if this isn't a git test build.
489 if ((-f "include/curl/curlver.h") &&
490 (open(F, "<include/curl/curlver.h"))) {
493 if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
494 my $stampstring = $1;
495 if ($stampstring !~ /DEV/) {
496 $stampstring =~ s/\s+UTC//;
497 $timestamp = $stampstring." UTC";
505 # Show timestamp we are using for this test build.
506 logit "timestamp = $timestamp";
508 if ($configurebuild) {
509 if (-f "configure") {
510 logit "configure created (at least it exists)";
512 mydie "no configure created/found";
515 logit "configure created (dummy message)"; # dummy message to feign success
521 my $x = ($^O eq 'MSWin32') ? '.exe' : '';
522 my $s = ($^O eq 'MSWin32') ? ';' : ':';
524 my @pa = split($s, $p);
534 my $make = findinpath("gmake", "make", "nmake");
536 mydie "Couldn't find make in the PATH";
538 # force to 'nmake' for VC builds
539 $make = "nmake" if ($targetos =~ /vc/);
540 # force to 'wmake' for Watcom builds
541 $make = "wmake" if ($targetos =~ /watcom/);
542 logit "going with $make as make";
544 # change to build dir
547 if ($configurebuild) {
548 # run configure script
549 print `../$CURLDIR/configure $confopts 2>&1`;
551 if (-f "lib/Makefile") {
552 logit "configure seems to have finished fine";
554 mydie "configure didn't work";
557 logit "copying files to build dir ...";
558 if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
559 system("xcopy /s /q ..\\$CURLDIR .");
560 system("buildconf.bat");
562 elsif ($targetos =~ /netware/) {
563 system("cp -afr ../$CURLDIR/* .");
564 system("cp -af ../$CURLDIR/Makefile.dist Makefile");
565 system("$make -i -C lib -f Makefile.netware prebuild");
566 system("$make -i -C src -f Makefile.netware prebuild");
567 if (-d "../$CURLDIR/ares") {
568 system("$make -i -C ares -f Makefile.netware prebuild");
571 elsif ($^O eq 'linux') {
572 system("cp -afr ../$CURLDIR/* .");
573 system("cp -af ../$CURLDIR/Makefile.dist Makefile");
574 system("cp -af ../$CURLDIR/include/curl/curlbuild.h.dist ./include/curl/curlbuild.h");
575 system("$make -i -C lib -f Makefile.$targetos prebuild");
576 system("$make -i -C src -f Makefile.$targetos prebuild");
577 if (-d "../$CURLDIR/ares") {
578 system("cp -af ../$CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
579 system("$make -i -C ares -f Makefile.$targetos prebuild");
584 if(-f "./libcurl.pc") {
585 logit_spaced "display libcurl.pc";
586 if(open(F, "<./libcurl.pc")) {
589 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
595 if(-f "./include/curl/curlbuild.h") {
596 logit_spaced "display include/curl/curlbuild.h";
597 if(open(F, "<./include/curl/curlbuild.h")) {
600 print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/));
606 mydie "no curlbuild.h created/found";
609 logit_spaced "display lib/$confheader";
610 open(F, "lib/$confheader") or die "lib/$confheader: $!";
616 if (($have_embedded_ares) &&
617 (grepfile("^#define USE_ARES", "lib/$confheader"))) {
619 logit "setup to build ares";
621 if(-f "./ares/libcares.pc") {
622 logit_spaced "display ares/libcares.pc";
623 if(open(F, "<./ares/libcares.pc")) {
626 print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
632 if(-f "./ares/ares_build.h") {
633 logit_spaced "display ares/ares_build.h";
634 if(open(F, "<./ares/ares_build.h")) {
637 print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
643 mydie "no ares_build.h created/found";
646 $confheader =~ s/curl/ares/;
647 logit_spaced "display ares/$confheader";
648 if(open(F, "ares/$confheader")) {
659 if ($targetos && !$configurebuild) {
660 logit "$make -f Makefile.$targetos";
661 open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
665 open(F, "$make 2>&1 |") or die;
673 if (-f "libcares$libext") {
674 logit "ares is now built successfully (libcares$libext)";
676 mydie "ares build failed (libcares$libext)";
679 # cd back to the curl build dir
683 my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
685 open(F, "$mkcmd 2>&1 |") or die;
692 if (-f "lib/libcurl$libext") {
693 logit "libcurl was created fine (libcurl$libext)";
696 mydie "libcurl was not created (libcurl$libext)";
699 if (-f "src/curl$binext") {
700 logit "curl was created fine (curl$binext)";
703 mydie "curl was not created (curl$binext)";
706 if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
707 logit "display curl${binext} --version output";
708 my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
711 # strip CR from output on non-win32 platforms (wine on Linux)
712 s/\r// if ($^O ne 'MSWin32');
718 if ($configurebuild && !$crosscompile) {
719 my $host_triplet = get_host_triplet();
720 # build example programs for selected build targets
721 if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
722 ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
723 ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
724 ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
725 chdir "$pwd/$build/docs/examples";
726 logit_spaced "build examples";
727 open(F, "$make -i 2>&1 |") or die;
728 open(LOG, ">$buildlog") or die;
738 # build and run full test suite
741 $o = "TEST_F=\"$runtestopts\" ";
743 logit "$make -k ${o}test-full";
744 open(F, "$make -k ${o}test-full 2>&1 |") or die;
745 open(LOG, ">$buildlog") or die;
754 if (grepfile("^TEST", $buildlog)) {
755 logit "tests were run";
757 mydie "test suite failure";
760 if (grepfile("^TESTFAIL:", $buildlog)) {
761 logit "the tests were not successful";
763 logit "the tests were successful!";
768 my $host_triplet = get_host_triplet();
769 # build example programs for selected cross-compiles
770 if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
771 ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
772 chdir "$pwd/$build/docs/examples";
773 logit_spaced "build examples";
774 open(F, "$make -i 2>&1 |") or die;
775 open(LOG, ">$buildlog") or die;
785 # build test harness programs for selected cross-compiles
786 if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
787 chdir "$pwd/$build/tests";
788 logit_spaced "build test harness";
789 open(F, "$make -i 2>&1 |") or die;
790 open(LOG, ">$buildlog") or die;
800 logit_spaced "cross-compiling, can't run tests";
802 # dummy message to feign success
803 print "TESTDONE: 1 tests out of 0 (dummy message)\n";
806 # create a tarball if we got that option.
807 if (($mktarball ne '') && (-x $mktarball)) {
812 mydie "ending nicely";