~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmake/tests/run_make_tests.pl

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/perl
 
2
# -*-perl-*-
 
3
 
 
4
# Test driver for the Make test suite
 
5
 
 
6
# Usage:  run_make_tests  [testname]
 
7
#                         [-debug]
 
8
#                         [-help]
 
9
#                         [-verbose]
 
10
#                         [-keep]
 
11
#                         [-make <make prog>]
 
12
#                        (and others)
 
13
 
 
14
require "test_driver.pl";
 
15
 
 
16
sub valid_option
 
17
{
 
18
   local($option) = @_;
 
19
   if ($option =~ /^-make([-_]?path)?$/)
 
20
   {
 
21
      $make_path = shift @argv;
 
22
      if (!-f $make_path)
 
23
      {
 
24
         print "$option $make_path: Not found.\n";
 
25
         exit 0;
 
26
      }
 
27
      return 1;
 
28
   }
 
29
 
 
30
# This doesn't work--it _should_!  Someone needs to fix this badly.
 
31
#
 
32
#   elsif ($option =~ /^-work([-_]?dir)?$/)
 
33
#   {
 
34
#      $workdir = shift @argv;
 
35
#      return 1;
 
36
#   }
 
37
 
 
38
   return 0;
 
39
}
 
40
 
 
41
sub run_make_with_options
 
42
{
 
43
   local ($filename,$options,$logname,$expected_code) = @_;
 
44
   local($code);
 
45
   local($command) = $make_path;
 
46
 
 
47
   $expected_code = 0 unless defined($expected_code);
 
48
 
 
49
   if ($filename)
 
50
   {
 
51
      $command .= " -f $filename";
 
52
   }
 
53
 
 
54
   if ($options)
 
55
   {
 
56
      $command .= " $options";
 
57
   }
 
58
 
 
59
   $code = &run_command_with_output($logname,$command);
 
60
 
 
61
   # Check to see if we have Purify errors.  If so, keep the logfile.
 
62
   # For this to work you need to build with the Purify flag -exit-status=yes
 
63
 
 
64
   if ($pure_log && -f $pure_log) {
 
65
     if ($code & 0x7000) {
 
66
       $code &= ~0x7000;
 
67
 
 
68
       # If we have a purify log, save it
 
69
       $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
 
70
       print("Renaming purify log file to $tn\n") if $debug;
 
71
       rename($pure_log, "$tn")
 
72
         || die "Can't rename $log to $tn: $!\n";
 
73
       ++$purify_errors;
 
74
     }
 
75
     else {
 
76
       unlink($pure_log);
 
77
     }
 
78
   }
 
79
 
 
80
   if ($code != $expected_code)
 
81
   {
 
82
      print "Error running $make_path ($code): $command\n";
 
83
      $test_passed = 0;
 
84
      return 0;
 
85
   }
 
86
 
 
87
   if ($profile & $vos)
 
88
   {
 
89
      system "add_profile $make_path";
 
90
   }
 
91
1;
 
92
}
 
93
 
 
94
sub print_usage
 
95
{
 
96
   &print_standard_usage ("run_make_tests", "[-make_path make_pathname]");
 
97
}
 
98
 
 
99
sub print_help
 
100
{
 
101
   &print_standard_help ("-make_path",
 
102
          "\tYou may specify the pathname of the copy of make to run.");
 
103
}
 
104
 
 
105
sub get_this_pwd {
 
106
  if ($vos) {
 
107
    $delete_command = "delete_file";
 
108
    $__pwd = `++(current_dir)`;
 
109
  }
 
110
  else {
 
111
    $delete_command = "rm";
 
112
    chop ($__pwd = `pwd`);
 
113
  }
 
114
 
 
115
  return $__pwd;
 
116
}
 
117
 
 
118
sub set_defaults
 
119
{
 
120
   # $profile = 1;
 
121
   $testee = "GNU make";
 
122
   $make_path = "make";
 
123
   $tmpfilesuffix = "mk";
 
124
   $pwd = &get_this_pwd;
 
125
}
 
126
 
 
127
sub set_more_defaults
 
128
{
 
129
   local($string);
 
130
   local($index);
 
131
 
 
132
   # find the type of the port.  We do this up front to have a single
 
133
   # point of change if it needs to be tweaked.
 
134
   #
 
135
   # This is probably not specific enough.
 
136
   #
 
137
   if ($osname =~ /Windows/i) {
 
138
     $port_type = 'W32';
 
139
   }
 
140
   # Bleah, the osname is so variable on DOS.  This kind of bites.
 
141
   # Well, as far as I can tell if we check for some text at the
 
142
   # beginning of the line with either no spaces or a single space, then
 
143
   # a D, then either "OS", "os", or "ev" and a space.  That should
 
144
   # match and be pretty specific.
 
145
   elsif ($osname =~ /^([^ ]*|[^ ]* [^ ]*)D(OS|os|ev) /) {
 
146
     $port_type = 'DOS';
 
147
   }
 
148
   # Everything else, right now, is UNIX.  Note that we should integrate
 
149
   # the VOS support into this as well and get rid of $vos; we'll do
 
150
   # that next time.
 
151
   else {
 
152
     $port_type = 'UNIX';
 
153
   }
 
154
 
 
155
   # Find the full pathname of Make.  For DOS systems this is more
 
156
   # complicated, so we ask make itself.
 
157
 
 
158
   $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`;
 
159
   chop $make_path;
 
160
   print "Make\t= `$make_path'\n" if $debug;
 
161
 
 
162
   $string = `$make_path -v -f /dev/null 2> /dev/null`;
 
163
 
 
164
   $string =~ /^(GNU Make [^,\n]*)/;
 
165
   $testee_version = "$1\n";
 
166
 
 
167
   $string = `sh -c "$make_path -f /dev/null 2>&1"`;
 
168
   if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
 
169
     $make_name = $1;
 
170
   }
 
171
   else {
 
172
     if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) {
 
173
       $make_name = $1;
 
174
     }
 
175
     else {
 
176
       $make_name = $make_path;
 
177
     }
 
178
   }
 
179
 
 
180
   # prepend pwd if this is a relative path (ie, does not
 
181
   # start with a slash, but contains one).  Thanks for the
 
182
   # clue, Roland.
 
183
 
 
184
   if (index ($make_path, ":") != 1 && index ($make_path, "/") > 0)
 
185
   {
 
186
      $mkpath = "$pwd$pathsep$make_path";
 
187
   }
 
188
   else
 
189
   {
 
190
      $mkpath = $make_path;
 
191
   }
 
192
 
 
193
   # Get Purify log info--if any.
 
194
 
 
195
   $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/;
 
196
   $pure_log = $1 || '';
 
197
   $pure_log =~ s/%v/$make_name/;
 
198
   $purify_errors = 0;
 
199
 
 
200
   $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;
 
201
   if ($string =~ /not supported/) {
 
202
     $parallel_jobs = 0;
 
203
   }
 
204
   else {
 
205
     $parallel_jobs = 1;
 
206
   }
 
207
}
 
208
 
 
209
sub setup_for_test
 
210
{
 
211
  $makefile = &get_tmpfile;
 
212
  if (-f $makefile) {
 
213
    unlink $makefile;
 
214
  }
 
215
 
 
216
  # Get rid of any Purify logs.
 
217
  if ($pure_log) {
 
218
    ($pure_testname = $testname) =~ tr,/,_,;
 
219
    $pure_testname = "$pure_log.$pure_testname";
 
220
    system("rm -f $pure_testname*");
 
221
    print("Purify testfiles are: $pure_testname*\n") if $debug;
 
222
  }
 
223
}
 
224
 
 
225
exit !&toplevel;