2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2005, 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 # --runtestopts=[options] Options to pass to runtests.pl
50 # --setup=[file name] File name to read setup from (deprecated)
51 # --target=[your os] Specify your target environment.
53 # if [curl-daily-name] is omitted, a 'curl' CVS directory is assumed.
60 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
63 use vars qw($version $fixed $infixed $CURLDIR $CVS $pwd $build $buildlog
64 $buildlogname $configurebuild $targetos $confsuffix $binext
66 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
67 $nocvsup $crosscompile);
69 # version of this script
70 $version='$Revision$';
73 # Determine if we're running from CVS or a canned copy of curl,
74 # or if we got a specific target option or setup file option.
79 if ($ARGV[0] =~ /--target=/) {
80 $targetos = (split(/=/, shift @ARGV))[1];
82 elsif ($ARGV[0] =~ /--setup=/) {
83 $setupfile = (split(/=/, shift @ARGV))[1];
85 elsif ($ARGV[0] =~ /--mktarball=/) {
86 $mktarball = (split(/=/, shift @ARGV))[1];
88 elsif ($ARGV[0] =~ /--name=/) {
89 $name = (split(/=/, shift @ARGV))[1];
91 elsif ($ARGV[0] =~ /--email=/) {
92 $email = (split(/=/, shift @ARGV))[1];
94 elsif ($ARGV[0] =~ /--desc=/) {
95 $desc = (split(/=/, shift @ARGV))[1];
97 elsif ($ARGV[0] =~ /--configure=/) {
98 $confopts = (split(/=/, shift @ARGV))[1];
100 elsif ($ARGV[0] =~ /--nocvsup/) {
104 elsif ($ARGV[0] =~ /--crosscompile/) {
108 elsif ($ARGV[0] =~ /--runtestopts=/) {
109 $runtestopts = (split(/=/, shift @ARGV, 2))[1];
112 $CURLDIR=shift @ARGV;
117 # Do the platform-specific stuff here
121 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
122 if ($^O eq 'MSWin32' || $targetos) {
124 # If no target defined on Win32 lets assume vc
127 if ($targetos =~ /vc/ || $targetos =~ /mingw32/ || $targetos =~ /borland/) {
129 $libext = '.lib' if ($targetos =~ /vc/ || $targetos =~ /borland/);
130 $libext = '.a' if ($targetos =~ /mingw32/);
132 elsif ($targetos =~ /netware/) {
139 if ($^O eq 'MSWin32') {
141 # Set these things only when building ON Windows, not when simply building
142 # FOR Windows since we might be cross-compiling on another system. Non-
143 # Windows builds still default to configure-style builds with no confsuffix.
146 $confsuffix = '-win32';
154 if ($^O eq 'MSWin32') {
155 foreach (glob($target)) {
157 system("rd /s /q $_");
160 system("rm -rf $target");
165 my ($target, $fn) = @_;
180 print "testcurl: $text\n";
187 chdir $pwd; # cd back to the original root dir
189 if ($pwd && $build) {
190 # we have a build directory name, remove the dir
191 logit "removing the $build dir";
192 rmtree "$pwd/$build";
195 # we have a build log output file left, remove it
196 logit "removing the $buildlogname file";
199 logit "ENDING HERE"; # last line logged!
203 if (open(F, "$setupfile")) {
212 $infixed=0; # so that "additional args to configure" works properly first time...
216 print "please enter your name\n";
223 print "please enter your contact email address\n";
230 print "please enter a one line system description\n";
238 print "please enter your additional arguments to configure\n";
239 print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
248 open(F, ">$setupfile") or die;
249 print F "name='$name'\n";
250 print F "email='$email'\n";
251 print F "desc='$desc'\n";
252 print F "confopts='$confopts'\n";
253 print F "fixed='$fixed'\n";
257 logit "STARTING HERE"; # first line logged, for scripts to trigger on
258 logit "NAME = $name";
259 logit "EMAIL = $email";
260 logit "DESC = $desc";
261 logit "CONFOPTS = $confopts";
262 logit "CFLAGS = ".$ENV{CFLAGS};
263 logit "LDFLAGS = ".$ENV{LDFLAGS};
264 logit "CC = ".$ENV{CC};
265 logit "target = ".$targetos;
266 logit "version = $version"; # script version
267 logit "date = ".(scalar gmtime)." UTC";
269 # Make $pwd to become the path without newline. We'll use that in order to cut
270 # off that path from all possible logs and error messages etc.
274 if ($CVS && -d "$CURLDIR/CVS") {
275 logit "$CURLDIR is verified to be a fine source dir";
276 # remove the generated sources to force them to be re-generated each
277 # time we run this test
278 unlink "$CURLDIR/src/hugehelp.c";
279 } elsif (!$CVS && -f "$CURLDIR/tests/testcurl.pl") {
280 logit "$CURLDIR is verified to be a fine daily source dir"
282 mydie "$CURLDIR is not a daily source dir or checked out from CVS!"
286 $buildlogname="buildlog-$$";
287 $buildlog="$pwd/$buildlogname";
289 # remove any previous left-overs
293 # this is to remove old build logs that ended up in the wrong dir
294 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
296 # create a dir to build in
300 logit "build dir $build was created fine";
302 mydie "failed to create dir $build";
305 # get in the curl source tree root
308 # Do the CVS thing, or not...
311 # this is a temporary fix to make things work again, remove later
312 logit "remove ares/aclocal.m4";
313 unlink "ares/aclocal.m4";
315 logit "update from CVS";
319 # update quietly to the latest CVS
322 logit "Skipping CVS update (--nocvsup)";
326 system("cvs -Q up -dP 2>&1");
331 # return !RETURNVALUE so that errors return 0 while goodness
339 logit "failed CVS update attempt number $att.";
342 last; # get out of the loop
348 mydie "failed to update from CVS ($cvsstat), exiting";
351 # remove possible left-overs from the past
353 unlink "autom4te.cache";
355 if ($configurebuild) {
356 # generate the build files
357 logit "invoke buildconf, but filter off the silly aclocal warnings";
358 open(F, "./buildconf 2>&1 |") or die;
359 open(LOG, ">$buildlog") or die;
361 next if /warning: underquoted definition of/;
368 if (grepfile("^buildconf: OK", $buildlog)) {
369 logit "buildconf was successful";
372 mydie "buildconf was NOT successful";
375 if($confopts =~ /--enable-ares/) {
376 logit "run buildconf for ares";
378 open(F, "./buildconf 2>&1 |") or die;
379 open(LOG, ">$buildlog") or die;
381 next if /warning: underquoted definition of/;
392 logit "buildconf was successful (dummy message)";
396 if ($configurebuild) {
397 if (-f "configure") {
398 logit "configure created";
400 mydie "no configure created";
403 logit "configure created (dummy message)"; # dummy message to feign success
410 my @pa = split(":", $p);
421 my $make = findinpath("gmake", "make", "nmake");
423 mydie "Couldn't find make in the PATH";
425 logit "going with $make as make";
427 # change to build dir
430 if ($configurebuild) {
431 # run configure script
432 print `../$CURLDIR/configure $confopts 2>&1`;
434 if (-f "lib/Makefile") {
435 logit "configure seems to have finished fine";
437 mydie "configure didn't work";
440 if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
441 system("xcopy /s /q ..\\$CURLDIR .");
442 system("buildconf.bat");
444 elsif (($^O eq 'linux') || ($targetos =~ /netware/)) {
445 system("cp -afr ../$CURLDIR/* .");
446 system("cp -af ../$CURLDIR/Makefile.dist Makefile");
447 system("$make -i -C lib -f Makefile.$targetos prebuild");
448 system("$make -i -C src -f Makefile.$targetos prebuild");
452 logit "display lib/config$confsuffix.h";
453 open(F, "lib/config$confsuffix.h") or die "lib/config$confsuffix.h: $!";
459 if (grepfile("define USE_ARES", "lib/config$confsuffix.h")) {
460 logit "setup to build ares";
462 logit "display ares/config$confsuffix.h";
463 if(open(F, "ares/config$confsuffix.h")) {
473 if ($targetos && !$configurebuild) {
474 logit "$make -f Makefile.$targetos";
475 open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
479 open(F, "$make 2>&1 |") or die;
487 if (-f "libcares$libext") {
488 logit "ares is now built successfully (libcares$libext)";
490 logit "ares build failed (libares$libext)";
493 # cd back to the curl build dir
497 if ($configurebuild) {
499 open(F, "$make -i 2>&1 |") or die;
507 logit "$make -i $targetos";
508 if ($^O eq 'MSWin32') {
509 if ($targetos =~ /vc/) {
510 open(F, "nmake -i $targetos|") or die;
513 open(F, "$make -i $targetos |") or die;
517 open(F, "$make -i $targetos 2>&1 |") or die;
526 if (-f "lib/libcurl$libext") {
527 logit "lib/libcurl was created fine (libcurl$libext)";
530 logit "lib/libcurl was not created (libcurl$libext)";
533 if (-f "src/curl$binext") {
534 logit "src/curl was created fine (curl$binext)";
537 mydie "src/curl was not created (curl$binext)";
540 if ($targetos =~ /netware/) {
541 if (-f '../../curlver') {
542 system('../../curlver');
545 elsif(!$crosscompile) {
546 logit "display curl$binext --version output";
547 open(F, "./src/curl$binext --version|");
555 if ($configurebuild && !$crosscompile) {
558 $o = "TEST_F=\"$runtestopts\" ";
560 logit "$make ${o}test-full";
561 open(F, "$make ${o}test-full 2>&1 |") or die;
562 open(LOG, ">$buildlog") or die;
571 if (grepfile("^TEST", $buildlog)) {
572 logit "tests were run";
574 mydie "test suite failure";
577 if (grepfile("^TESTFAIL:", $buildlog)) {
578 logit "the tests were not successful";
580 logit "the tests were successful!";
583 # dummy message to feign success
585 logit "cross-compiling, can't run tests";
587 print "TESTDONE: 1 tests out of 0 (dummy message)\n";
590 # create a tarball if we got that option.
591 if (($mktarball ne '') && (-f $mktarball)) {
596 mydie "ending nicely";