2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2007, 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.
23 ###########################################################################
25 ###########################
26 # What is This Script?
27 ###########################
29 # testcurl.pl is the master script to use for automatic testing of CVS-curl.
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 # --mktarball=[command] Command to run after completed test
47 # --name=[name] Set name to report as
48 # --nocvsup Don't update from CVS even though it is a CVS tree
49 # --nobuildconf Don't run buildconf
50 # --runtestopts=[options] Options to pass to runtests.pl
51 # --setup=[file name] File name to read setup from (deprecated)
52 # --target=[your os] Specify your target environment.
54 # if [curl-daily-name] is omitted, a 'curl' CVS directory is assumed.
61 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
64 use vars qw($version $fixed $infixed $CURLDIR $CVS $pwd $build $buildlog
65 $buildlogname $configurebuild $targetos $confsuffix $binext
67 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
68 $nocvsup $nobuildconf $crosscompile $timestamp);
70 # version of this script
71 $version='$Revision$';
74 # Determine if we're running from CVS or a canned copy of curl,
75 # or if we got a specific target option or setup file option.
80 if ($ARGV[0] =~ /--target=/) {
81 $targetos = (split(/=/, shift @ARGV))[1];
83 elsif ($ARGV[0] =~ /--setup=/) {
84 $setupfile = (split(/=/, shift @ARGV))[1];
86 elsif ($ARGV[0] =~ /--mktarball=/) {
87 $mktarball = (split(/=/, shift @ARGV))[1];
89 elsif ($ARGV[0] =~ /--name=/) {
90 $name = (split(/=/, shift @ARGV))[1];
92 elsif ($ARGV[0] =~ /--email=/) {
93 $email = (split(/=/, shift @ARGV))[1];
95 elsif ($ARGV[0] =~ /--desc=/) {
96 $desc = (split(/=/, shift @ARGV))[1];
98 elsif ($ARGV[0] =~ /--configure=/) {
99 $confopts = (split(/=/, shift @ARGV))[1];
101 elsif ($ARGV[0] =~ /--nocvsup/) {
105 elsif ($ARGV[0] =~ /--nobuildconf/) {
109 elsif ($ARGV[0] =~ /--crosscompile/) {
113 elsif ($ARGV[0] =~ /--runtestopts=/) {
114 $runtestopts = (split(/=/, shift @ARGV, 2))[1];
117 $CURLDIR=shift @ARGV;
122 # Do the platform-specific stuff here
126 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
127 if ($^O eq 'MSWin32' || $targetos) {
129 # If no target defined on Win32 lets assume vc
132 if ($targetos =~ /vc/ || $targetos =~ /borland/) {
136 elsif ($targetos =~ /mingw32/) {
138 if ($^O eq 'MSWin32') {
142 elsif ($targetos =~ /netware/) {
149 if (($^O eq 'MSWin32') &&
150 ($targetos =~ /vc/ || $targetos =~ /mingw32/ || $targetos =~ /borland/)) {
152 # Set these things only when building ON Windows and for Win32 platform.
153 # FOR Windows since we might be cross-compiling on another system. Non-
154 # Windows builds still default to configure-style builds with no confsuffix.
157 $confsuffix = '-win32';
165 if ($^O eq 'MSWin32') {
166 foreach (glob($target)) {
168 system("rd /s /q $_");
171 system("rm -rf $target");
176 my ($target, $fn) = @_;
191 print "testcurl: $text\n";
198 chdir $pwd; # cd back to the original root dir
200 if ($pwd && $build) {
201 # we have a build directory name, remove the dir
202 logit "removing the $build dir";
203 rmtree "$pwd/$build";
206 # we have a build log output file left, remove it
207 logit "removing the $buildlogname file";
210 logit "ENDING HERE"; # last line logged!
214 if (open(F, "$setupfile")) {
223 $infixed=0; # so that "additional args to configure" works properly first time...
227 print "please enter your name\n";
234 print "please enter your contact email address\n";
241 print "please enter a one line system description\n";
249 print "please enter your additional arguments to configure\n";
250 print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
259 open(F, ">$setupfile") or die;
260 print F "name='$name'\n";
261 print F "email='$email'\n";
262 print F "desc='$desc'\n";
263 print F "confopts='$confopts'\n";
264 print F "fixed='$fixed'\n";
268 logit "STARTING HERE"; # first line logged, for scripts to trigger on
269 logit "NAME = $name";
270 logit "EMAIL = $email";
271 logit "DESC = $desc";
272 logit "CONFOPTS = $confopts";
273 logit "CPPFLAGS = ".$ENV{CPPFLAGS};
274 logit "CFLAGS = ".$ENV{CFLAGS};
275 logit "LDFLAGS = ".$ENV{LDFLAGS};
276 logit "CC = ".$ENV{CC};
277 logit "target = ".$targetos;
278 logit "version = $version"; # script version
279 logit "date = ".(scalar gmtime)." UTC";
281 # Make $pwd to become the path without newline. We'll use that in order to cut
282 # off that path from all possible logs and error messages etc.
285 # libcurl timestamp is present in curlver.h only if this isn't a CVS version.
286 # If no timestamp available in curlver.h then we are building from CVS and we
287 # will use current UTC build time as the CVS version timestamp.
288 if ((-f "$CURLDIR/include/curl/curlver.h") &&
289 (grepfile("define LIBCURL_TIMESTAMP",
290 "$CURLDIR/include/curl/curlver.h")) &&
291 (open(F, "<$CURLDIR/include/curl/curlver.h"))) {
294 if ($_ =~ /^\#define LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
296 $timestamp =~ s/\s+UTC//;
297 $timestamp .= " UTC";
302 if(not defined $timestamp) {
303 $timestamp = scalar(gmtime)." UTC";
305 logit "timestamp = $timestamp";
308 if ($CVS && -d "$CURLDIR/CVS") {
309 logit "$CURLDIR is verified to be a fine source dir";
310 # remove the generated sources to force them to be re-generated each
311 # time we run this test
312 unlink "$CURLDIR/src/hugehelp.c";
313 } elsif (!$CVS && -f "$CURLDIR/tests/testcurl.pl") {
314 logit "$CURLDIR is verified to be a fine daily source dir"
316 mydie "$CURLDIR is not a daily source dir or checked out from CVS!"
320 $buildlogname="buildlog-$$";
321 $buildlog="$pwd/$buildlogname";
323 # remove any previous left-overs
327 # this is to remove old build logs that ended up in the wrong dir
328 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
330 # create a dir to build in
334 logit "build dir $build was created fine";
336 mydie "failed to create dir $build";
339 # get in the curl source tree root
342 # Do the CVS thing, or not...
345 # this is a temporary fix to make things work again, remove later
346 logit "remove ares/aclocal.m4";
347 unlink "ares/aclocal.m4";
349 logit "update from CVS";
353 # update quietly to the latest CVS
356 logit "Skipping CVS update (--nocvsup)";
360 system("cvs -Q up -dP 2>&1");
365 # return !RETURNVALUE so that errors return 0 while goodness
373 logit "failed CVS update attempt number $att.";
376 last; # get out of the loop
382 mydie "failed to update from CVS ($cvsstat), exiting";
386 logit "told to not run buildconf";
388 elsif ($configurebuild) {
389 # remove possible left-overs from the past
391 unlink "autom4te.cache";
393 # generate the build files
394 logit "invoke buildconf, but filter off the silly aclocal warnings";
395 open(F, "./buildconf 2>&1 |") or die;
396 open(LOG, ">$buildlog") or die;
398 next if /warning: underquoted definition of/;
405 if (grepfile("^buildconf: OK", $buildlog)) {
406 logit "buildconf was successful";
409 mydie "buildconf was NOT successful";
413 logit "buildconf was successful (dummy message)";
417 if ($configurebuild) {
418 if (-f "configure") {
419 logit "configure created (at least it exists)";
421 mydie "no configure created/found";
424 logit "configure created (dummy message)"; # dummy message to feign success
431 $x='.exe' if ($^O eq 'MSWin32');
433 $s=';' if ($^O eq 'MSWin32');
435 my @pa = split($s, $p);
445 my $make = findinpath("gmake", "make", "nmake");
447 mydie "Couldn't find make in the PATH";
449 logit "going with $make as make";
451 # change to build dir
454 if ($configurebuild) {
455 # run configure script
456 print `../$CURLDIR/configure $confopts 2>&1`;
458 if (-f "lib/Makefile") {
459 logit "configure seems to have finished fine";
461 mydie "configure didn't work";
464 if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
465 system("xcopy /s /q ..\\$CURLDIR .");
466 system("buildconf.bat");
468 elsif (($^O eq 'linux') || ($targetos =~ /netware/)) {
469 system("cp -afr ../$CURLDIR/* .");
470 system("cp -af ../$CURLDIR/Makefile.dist Makefile");
471 system("$make -i -C lib -f Makefile.$targetos prebuild");
472 system("$make -i -C src -f Makefile.$targetos prebuild");
476 logit "display lib/config$confsuffix.h";
477 open(F, "lib/config$confsuffix.h") or die "lib/config$confsuffix.h: $!";
483 if (grepfile("define USE_ARES", "lib/config$confsuffix.h")) {
484 logit "setup to build ares";
486 logit "display ares/config$confsuffix.h";
487 if(open(F, "ares/config$confsuffix.h")) {
497 if ($targetos && !$configurebuild) {
498 logit "$make -f Makefile.$targetos";
499 open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
503 open(F, "$make 2>&1 |") or die;
511 if (-f "libcares$libext") {
512 logit "ares is now built successfully (libcares$libext)";
514 logit "ares build failed (libares$libext)";
517 # cd back to the curl build dir
521 if ($configurebuild) {
523 open(F, "$make -i 2>&1 |") or die;
531 logit "$make -i $targetos";
532 if ($^O eq 'MSWin32') {
533 if ($targetos =~ /vc/) {
534 open(F, "nmake -i $targetos|") or die;
537 open(F, "$make -i $targetos |") or die;
541 open(F, "$make -i $targetos 2>&1 |") or die;
550 if (-f "lib/libcurl$libext") {
551 logit "libcurl was created fine (libcurl$libext)";
554 mydie "libcurl was not created (libcurl$libext)";
557 if (-f "src/curl$binext") {
558 logit "curl was created fine (curl$binext)";
561 mydie "curl was not created (curl$binext)";
564 if ($targetos =~ /netware/) {
565 if (-f '../../curlver') {
566 system('../../curlver');
569 elsif(!$crosscompile) {
570 logit "display curl$binext --version output";
571 open(F, "./src/curl$binext --version|");
579 if ($configurebuild && !$crosscompile) {
582 $o = "TEST_F=\"$runtestopts\" ";
584 logit "$make -k ${o}test-full";
585 open(F, "$make -k ${o}test-full 2>&1 |") or die;
586 open(LOG, ">$buildlog") or die;
595 if (grepfile("^TEST", $buildlog)) {
596 logit "tests were run";
598 mydie "test suite failure";
601 if (grepfile("^TESTFAIL:", $buildlog)) {
602 logit "the tests were not successful";
604 logit "the tests were successful!";
607 # dummy message to feign success
609 logit "cross-compiling, can't run tests";
611 print "TESTDONE: 1 tests out of 0 (dummy message)\n";
614 # create a tarball if we got that option.
615 if (($mktarball ne '') && (-f $mktarball)) {
620 mydie "ending nicely";