| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
use 5.004; |
|---|
| 36 |
|
|---|
| 37 |
use strict 'vars'; |
|---|
| 38 |
use vars qw($base_dir $MODULE $root_dir $Win32); |
|---|
| 39 |
use vars qw(@gen_files); |
|---|
| 40 |
use vars qw(%MODULES); |
|---|
| 41 |
|
|---|
| 42 |
use Cwd qw(chdir getcwd); |
|---|
| 43 |
use File::Basename; |
|---|
| 44 |
use Getopt::Long; |
|---|
| 45 |
|
|---|
| 46 |
BEGIN |
|---|
| 47 |
{ |
|---|
| 48 |
$base_dir = (fileparse("$0"))[1]; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
use lib("$base_dir"); |
|---|
| 52 |
use JugglerConfigure; |
|---|
| 53 |
|
|---|
| 54 |
sub configureModule($); |
|---|
| 55 |
sub compileModule($); |
|---|
| 56 |
sub buildTests($); |
|---|
| 57 |
sub makeOutputFile($); |
|---|
| 58 |
|
|---|
| 59 |
my $cfg = 'juggler.cfg'; |
|---|
| 60 |
|
|---|
| 61 |
my $user_cfg = ''; |
|---|
| 62 |
my $module = ''; |
|---|
| 63 |
|
|---|
| 64 |
Getopt::Long::Configure('pass_through'); |
|---|
| 65 |
GetOptions('cfg=s' => \$user_cfg, 'module=s' => \$module); |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
$ENV{'OSTYPE'} = `uname -s` unless defined($ENV{'OSTYPE'}); |
|---|
| 69 |
|
|---|
| 70 |
$Win32 = 1 if $ENV{'OS'} && $ENV{'OS'} =~ /Windows/; |
|---|
| 71 |
|
|---|
| 72 |
my $cfg_load = ("$user_cfg" eq "") ? "$base_dir/$cfg" : "$user_cfg"; |
|---|
| 73 |
%MODULES = JugglerConfigure::parseConfigFile("$cfg_load"); |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
$MODULE = ("$module" eq "") ? "$JugglerConfigure::DEFAULT_MODULE" : "$module"; |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
my $unique = $$; |
|---|
| 84 |
$unique = "$ENV{'OSTYPE'}-$unique"; |
|---|
| 85 |
|
|---|
| 86 |
my $build_dir = "build.$unique-test"; |
|---|
| 87 |
$root_dir = getcwd(); |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
@gen_files = (); |
|---|
| 93 |
|
|---|
| 94 |
my $cfg_outfile = makeOutputFile("configure.out"); |
|---|
| 95 |
my $build_outfile = makeOutputFile("buildworld.out"); |
|---|
| 96 |
|
|---|
| 97 |
mkdir("$build_dir") or die "ERROR: Failed to create $root_dir/$build_dir: $!\n"; |
|---|
| 98 |
chdir("$build_dir") or die "ERROR: Failed to chdir to $root_dir/$build_dir: $!\n"; |
|---|
| 99 |
|
|---|
| 100 |
if ( $unique =~ /irix/i ) |
|---|
| 101 |
{ |
|---|
| 102 |
$ENV{'PATH'} = "/usr/freeware/bin:$ENV{'PATH'}"; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
configureModule("$MODULE") or die "Failed to configure $MODULE\n"; |
|---|
| 106 |
compileModule("$MODULE") or die "Failed to build $MODULE\n"; |
|---|
| 107 |
buildTests("$MODULE"); |
|---|
| 108 |
|
|---|
| 109 |
exit 0; |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
sub configureModule ($) |
|---|
| 116 |
{ |
|---|
| 117 |
my $module_name = shift; |
|---|
| 118 |
|
|---|
| 119 |
my $cfg_command = "perl ../configure.pl --module=$module_name @ARGV"; |
|---|
| 120 |
print "Configuring ...\n '$cfg_command'\n"; |
|---|
| 121 |
return (system("$cfg_command >$cfg_outfile 2>&1") == 0); |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
sub compileModule ($) |
|---|
| 125 |
{ |
|---|
| 126 |
print "Building world ...\n"; |
|---|
| 127 |
return (system("gmake buildworld >$build_outfile 2>&1") == 0); |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
sub buildTests ($) |
|---|
| 131 |
{ |
|---|
| 132 |
my $module_name = shift; |
|---|
| 133 |
|
|---|
| 134 |
my $cwd = getcwd(); |
|---|
| 135 |
my $safe_cwd; |
|---|
| 136 |
|
|---|
| 137 |
if ( $Win32 ) |
|---|
| 138 |
{ |
|---|
| 139 |
$safe_cwd = `cygpath -w $cwd`; |
|---|
| 140 |
chomp($safe_cwd); |
|---|
| 141 |
$safe_cwd =~ s/\\/\//g; |
|---|
| 142 |
} |
|---|
| 143 |
else |
|---|
| 144 |
{ |
|---|
| 145 |
$safe_cwd = "$cwd"; |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
my $dependency; |
|---|
| 149 |
foreach $dependency ( $MODULES{"$module_name"}->getDependencies() ) |
|---|
| 150 |
{ |
|---|
| 151 |
my $test_dir = $dependency->getPath() . "/test/TestSuite"; |
|---|
| 152 |
|
|---|
| 153 |
if ( -d "$test_dir" ) |
|---|
| 154 |
{ |
|---|
| 155 |
if ( chdir("$test_dir") ) |
|---|
| 156 |
{ |
|---|
| 157 |
my $full_test_dir = "$root_dir/$build_dir/$test_dir"; |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
my %mod_env = $dependency->getEnvironment(); |
|---|
| 162 |
foreach ( keys(%mod_env) ) |
|---|
| 163 |
{ |
|---|
| 164 |
if ( /_CONFIG$/ ) |
|---|
| 165 |
{ |
|---|
| 166 |
next; |
|---|
| 167 |
} |
|---|
| 168 |
elsif ( /_BASE_DIR$/ ) |
|---|
| 169 |
{ |
|---|
| 170 |
if ( "$mod_env{$_}" eq "instlinks" ) |
|---|
| 171 |
{ |
|---|
| 172 |
$ENV{"$_"} = "$safe_cwd/instlinks"; |
|---|
| 173 |
} |
|---|
| 174 |
else |
|---|
| 175 |
{ |
|---|
| 176 |
$ENV{"$_"} = "$mod_env{$_}"; |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
if ( $Win32 ) |
|---|
| 182 |
{ |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
$ENV{'PATH'} .= ":$ENV{$_}/lib"; |
|---|
| 186 |
} |
|---|
| 187 |
elsif ( $ENV{'OSTYPE'} =~ /irix/i ) |
|---|
| 188 |
{ |
|---|
| 189 |
if ( defined($ENV{'LD_LIBRARYN32_PATH'}) ) |
|---|
| 190 |
{ |
|---|
| 191 |
$ENV{'LD_LIBRARYN32_PATH'} .= ":$ENV{$_}/lib32"; |
|---|
| 192 |
} |
|---|
| 193 |
else |
|---|
| 194 |
{ |
|---|
| 195 |
$ENV{'LD_LIBRARYN32_PATH'} = "$ENV{$_}/lib32"; |
|---|
| 196 |
} |
|---|
| 197 |
} |
|---|
| 198 |
else |
|---|
| 199 |
{ |
|---|
| 200 |
if ( defined($ENV{'LD_LIBRARY_PATH'}) ) |
|---|
| 201 |
{ |
|---|
| 202 |
$ENV{'LD_LIBRARY_PATH'} .= ":$ENV{$_}/lib"; |
|---|
| 203 |
} |
|---|
| 204 |
else |
|---|
| 205 |
{ |
|---|
| 206 |
$ENV{'LD_LIBRARY_PATH'} = "$ENV{$_}/lib"; |
|---|
| 207 |
} |
|---|
| 208 |
} |
|---|
| 209 |
} |
|---|
| 210 |
else |
|---|
| 211 |
{ |
|---|
| 212 |
$ENV{"$_"} = "$mod_env{$_}"; |
|---|
| 213 |
} |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
my $test_name = "$test_dir"; |
|---|
| 219 |
$test_name =~ s/\//_/g; |
|---|
| 220 |
|
|---|
| 221 |
print "Building test suite in $full_test_dir ...\n"; |
|---|
| 222 |
|
|---|
| 223 |
my $test_outfile = makeOutputFile("$test_name.out"); |
|---|
| 224 |
|
|---|
| 225 |
if ( system("gmake >>$build_outfile 2>&1") == 0 ) |
|---|
| 226 |
{ |
|---|
| 227 |
print "Running test suite ...\n"; |
|---|
| 228 |
if ( system("./runner noninteractive >$test_outfile 2>&1") != 0 ) |
|---|
| 229 |
{ |
|---|
| 230 |
warn "ERROR: Test suite failed!\n"; |
|---|
| 231 |
} |
|---|
| 232 |
} |
|---|
| 233 |
else |
|---|
| 234 |
{ |
|---|
| 235 |
warn "ERROR: Test suite build failed in $full_test_dir\n"; |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
chdir("$cwd"); |
|---|
| 239 |
} |
|---|
| 240 |
else |
|---|
| 241 |
{ |
|---|
| 242 |
warn "WARNING: Could not chdir to $test_dir: $!\n"; |
|---|
| 243 |
} |
|---|
| 244 |
} |
|---|
| 245 |
} |
|---|
| 246 |
} |
|---|
| 247 |
|
|---|
| 248 |
sub makeOutputFile ($) |
|---|
| 249 |
{ |
|---|
| 250 |
my $base_name = shift; |
|---|
| 251 |
my $full_name = "$root_dir/$base_name-$unique"; |
|---|
| 252 |
push(@gen_files, "$full_name"); |
|---|
| 253 |
|
|---|
| 254 |
return $full_name; |
|---|
| 255 |
} |
|---|