root/juggler/tags/1.1_dr_1/testall.pl

Revision 9194, 7.5 kB (checked in by patrickh, 6 years ago)

It occurred to me that $OSTYPE is by no means a standard environment
variable that we can expect to have. The output from uname(1) is much
more reliable.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/perl -w
2
3 # ************** <auto-copyright.pl BEGIN do not edit this line> **************
4 #
5 # VR Juggler is (C) Copyright 1998-2002 by Iowa State University
6 #
7 # Original Authors:
8 #   Allen Bierbaum, Christopher Just,
9 #   Patrick Hartling, Kevin Meinert,
10 #   Carolina Cruz-Neira, Albert Baker
11 #
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Library General Public
14 # License as published by the Free Software Foundation; either
15 # version 2 of the License, or (at your option) any later version.
16 #
17 # This library is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # Library General Public License for more details.
21 #
22 # You should have received a copy of the GNU Library General Public
23 # License along with this library; if not, write to the
24 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 # Boston, MA 02111-1307, USA.
26 #
27 # -----------------------------------------------------------------
28 # File:          $RCSfile$
29 # Date modified: $Date$
30 # Version:       $Revision$
31 # -----------------------------------------------------------------
32 #
33 # *************** <auto-copyright.pl END do not edit this line> ***************
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 # Give ourselves a convenient way to know which OS we're using.
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 # Assign $MODULE the value of the module that has been configured.  This will
76 # either be the value passed via --module or the default module in the loaded
77 # configuration file.
78 $MODULE = ("$module" eq "") ? "$JugglerConfigure::DEFAULT_MODULE" : "$module";
79
80 # Make a unique identifier for this instance of the script.  It begins with
81 # a process ID and has the host operating system type prepended if the right
82 # environment variable is defined.
83 my $unique  = $$;
84 $unique     = "$ENV{'OSTYPE'}-$unique";
85
86 my $build_dir = "build.$unique-test";
87 $root_dir     = getcwd();
88
89 # This array will keep track of all generated files containing the output of
90 # executing various commands.  At the end of the script, the files named in
91 # this array may be searched for keywords such as "error" or "fail".
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 # Subroutines follow.
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             # Set up any environment stuff necessary before compiling and
160             # running the test suite.
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                   # Extend the right path variable so that any shared libraries
180                   # are found at run time.
181                   if ( $Win32 )
182                   {
183                      # XXX: Is the Win32 path environment variable set up to
184                      # act like a Cygwin path or a DOS path?  Probably Cygwin...
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             # Construct a name for this test based on the module test suite
217             # path.
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 }
Note: See TracBrowser for help on using the browser.