2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2004, 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 will be suitable to be mailed automaticly
32 # to "curl-autocompile@haxx.se" to be dealt with automatically. The most
33 # current build status (with a resonable backlog) will be published on the
34 # curl site, at http://curl.haxx.se/auto/
37 # testcurl.pl [--target=your_os] [curl-daily-name] > output
40 # v1.7 22-Jun-04 - added --target option for other platform targets.
41 # v1.2 8-Mar-04 - rewritten in perl
42 # v1.1 6-Nov-03 - to take an optional parameter, the name of a daily-build
43 # directory. If present, build from that directory, otherwise
44 # perform a normal CVS build.
50 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
53 use vars qw($version $fixed $infixed $CURLDIR $CVS $pwd $build $buildlog
54 $buildlogname $gnulikebuild $targetos $confsuffix $binext $libext);
55 use vars qw($name $email $desc $confopts $setupfile $mktarball);
57 # version of this script
58 $version='$Revision$';
61 # Determine if we're running from CVS or a canned copy of curl,
62 # or if we got a specific target option or setup file option.
69 if ($ARGV[0] =~ /--target=/) {
70 $targetos = (split(/=/, shift @ARGV))[1];
71 } elsif ($ARGV[0] =~ /--setup=/) {
72 $setupfile = (split(/=/, shift @ARGV))[1];
73 } elsif ($ARGV[0] =~ /--mktarball=/) {
74 $mktarball = (split(/=/, shift @ARGV))[1];
81 # Do the platform-specific stuff here
85 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
86 if ($^O eq 'MSWin32' || $targetos ne '') {
88 if ($targetos eq '') {
89 # If no target defined on Win32 lets assume vc
92 if ($targetos =~ /vc/ || $targetos =~ /mingw32/ || $targetos =~ /borland/) {
93 $confsuffix = '-win32';
95 $libext = '.lib' if ($targetos =~ /vc/ || $targetos =~ /borland/);
96 $libext = '.a' if ($targetos =~ /mingw32/);
97 } elsif ($targetos =~ /netware/) {
107 if ($^O eq 'MSWin32') {
108 foreach (glob($target)) {
110 system("rd /s /q $_");
113 system("rm -rf $target");
118 my ($target, $fn) = @_;
133 print "testcurl: $text\n";
140 chdir $pwd; # cd back to the original root dir
142 if ($pwd && $build) {
143 # we have a build directory name, remove the dir
144 logit "removing the $build dir";
145 rmtree "$pwd/$build";
148 # we have a build log output file left, remove it
149 logit "removing the $buildlogname file";
152 logit "ENDING HERE"; # last line logged!
156 if (open(F, "$setupfile")) {
165 $infixed=0; # so that "additional args to configure" works properly first time...
169 print "please enter your name\n";
176 print "please enter your contact email address\n";
183 print "please enter a one line system description\n";
191 print "please enter your additional arguments to configure\n";
192 print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
201 open(F, ">$setupfile") or die;
202 print F "name='$name'\n";
203 print F "email='$email'\n";
204 print F "desc='$desc'\n";
205 print F "confopts='$confopts'\n";
206 print F "fixed='$fixed'\n";
210 logit "STARTING HERE"; # first line logged
211 logit "NAME = $name";
212 logit "EMAIL = $email";
213 logit "DESC = $desc";
214 logit "CONFOPTS = $confopts";
215 logit "CFLAGS = ".($ENV{CFLAGS} ? $ENV{CFLAGS} : "");
216 logit "CC = ".($ENV{CC} ? $ENV{CC} : "");
217 logit "target = ".($targetos ? $targetos : "");
218 logit "version = $version";
219 logit "date = ".(scalar gmtime)." UTC";
221 # Make $pwd to become the path without newline. We'll use that in order to cut
222 # off that path from all possible logs and error messages etc.
226 if ($CVS && -d "$CURLDIR/CVS") {
227 logit "$CURLDIR is verified to be a fine source dir";
228 # remove the generated sources to force them to be re-generated each
229 # time we run this test
230 unlink "$CURLDIR/lib/getdate.c";
231 unlink "$CURLDIR/src/hugehelp.c";
232 } elsif (!$CVS && -f "$CURLDIR/tests/testcurl.pl") {
233 logit "$CURLDIR is verified to be a fine daily source dir"
235 mydie "$CURLDIR is not a daily source dir or checked out from CVS!"
239 $buildlogname="buildlog-$$";
240 $buildlog="$pwd/$buildlogname";
242 # remove any previous left-overs
246 # this is to remove old build logs that ended up in the wrong dir
247 foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
249 # create a dir to build in
253 logit "build dir $build was created fine";
255 mydie "failed to create dir $build";
258 # get in the curl source tree root
261 # Do the CVS thing, or not...
264 # this is a temporary fix to make things work again, remove later
265 logit "remove ares/aclocal.m4";
266 unlink "ares/aclocal.m4";
268 logit "update from CVS";
272 # update quietly to the latest CVS
274 system("cvs -Q up -dP 2>&1");
278 # return !RETURNVALUE so that errors return 0 while goodness
286 logit "failed CVS update attempt number $att.";
289 last; # get out of the loop
295 mydie "failed to update from CVS ($cvsstat), exiting";
298 # remove possible left-overs from the past
300 unlink "autom4te.cache";
303 # generate the build files
304 logit "invoke buildconf, but filter off the silly aclocal warnings";
305 open(F, "./buildconf 2>&1 |") or die;
306 open(LOG, ">$buildlog") or die;
308 next if /warning: underquoted definition of/;
315 if (grepfile("^buildconf: OK", $buildlog)) {
316 logit "buildconf was successful";
318 mydie "buildconf was NOT successful";
321 if($confopts =~ /--enable-ares/) {
322 logit "run buildconf for ares";
324 open(F, "./buildconf 2>&1 |") or die;
325 open(LOG, ">$buildlog") or die;
327 next if /warning: underquoted definition of/;
337 logit "buildconf was successful (dummy message)";
342 if (-f "configure") {
343 logit "configure created";
345 mydie "no configure created";
348 logit "configure created (dummy message)"; # dummy message to feign success
351 # change to build dir
355 # run configure script
356 system("../$CURLDIR/configure $confopts 2>&1");
358 if (-f "lib/Makefile") {
359 logit "configure seems to have finished fine";
361 mydie "configure didn't work";
364 if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
365 system("xcopy /s /q ..\\$CURLDIR .");
366 system("buildconf.bat");
367 } elsif (($^O eq 'linux') || ($targetos =~ /netware/)) {
368 system("cp -afr ../$CURLDIR/* .");
369 system("cp -af ../$CURLDIR/Makefile.dist Makefile");
370 system("make -i -C lib -f Makefile.$targetos prebuild");
371 system("make -i -C src -f Makefile.$targetos prebuild");
375 logit "display lib/config$confsuffix.h";
376 open(F, "lib/config$confsuffix.h") or die "lib/config$confsuffix.h: $!";
382 logit "display src/config$confsuffix.h";
383 open(F, "src/config$confsuffix.h") or die "src/config$confsuffix.h: $!";
389 if (grepfile("define USE_ARES", "lib/config$confsuffix.h")) {
390 logit "setup to build ares";
395 if ($targetos ne '') {
396 open(F, "make -f Makefile.$targetos 2>&1 |") or die;
398 open(F, "make 2>&1 |") or die;
406 if (-f "libcares$libext") {
407 logit "ares is now built successfully (libcares$libext)";
409 logit "ares build failed (libares$libext)";
412 # cd back to the curl build dir
418 open(F, "make -i 2>&1 |") or die;
425 if ($^O eq 'MSWin32') {
426 if ($targetos =~ /vc/) {
427 open(F, "nmake -i $targetos|") or die;
429 open(F, "make -i $targetos |") or die;
432 open(F, "make -i $targetos 2>&1 |") or die;
441 if (-f "lib/libcurl$libext") {
442 logit "lib/libcurl was created fine (libcurl$libext)";
444 logit "lib/libcurl was not created (libcurl$libext)";
447 if (-f "src/curl$binext") {
448 logit "src/curl was created fine (curl$binext)";
450 mydie "src/curl was not created (curl$binext)";
453 if ($targetos ne '' && $targetos =~ /netware/) {
454 if (-f '../../curlver') {
455 system('../../curlver');
458 logit "display curl$binext --version output";
459 system("./src/curl$binext --version");
463 logit "run make test-full";
464 open(F, "make test-full 2>&1 |") or die;
465 open(LOG, ">$buildlog") or die;
474 if (grepfile("^TEST", $buildlog)) {
475 logit "tests were run";
477 mydie "test suite failure";
480 if (grepfile("^TESTFAIL:", $buildlog)) {
481 logit "the tests were not successful";
483 logit "the tests were successful!";
486 print "TESTDONE: 1 tests out of 0 (dummy message)\n"; # dummy message to feign success
489 # create a tarball if we got that option.
490 if (($mktarball ne '') && (-f $mktarball)) {
495 mydie "ending nicely";