~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to mysql-test/lib/mtr_cases.pm

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- cperl -*-
2
 
# Copyright (C) 2005-2006 MySQL AB
3
 
#
 
2
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
 
3
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
6
6
# the Free Software Foundation; version 2 of the License.
143
143
      {
144
144
        last unless $opt_reorder;
145
145
        # test->{name} is always in suite.name format
146
 
        if ( $test->{name} =~ /.*\.$tname/ )
 
146
        if ( $test->{name} =~ /^$sname.*\.$tname$/ )
147
147
        {
148
148
          $found= 1;
149
149
          last;
170
170
  if ( $opt_reorder && !$quick_collect)
171
171
  {
172
172
    # Reorder the test cases in an order that will make them faster to run
173
 
    my %sort_criteria;
174
 
 
175
173
    # Make a mapping of test name to a string that represents how that test
176
174
    # should be sorted among the other tests.  Put the most important criterion
177
175
    # first, then a sub-criterion, then sub-sub-criterion, etc.
183
181
      # Append the criteria for sorting, in order of importance.
184
182
      #
185
183
      push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "A" : "B"));
 
184
      push(@criteria, $tinfo->{template_path});
186
185
      # Group test with equal options together.
187
186
      # Ending with "~" makes empty sort later than filled
188
187
      my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
189
188
      push(@criteria, join("!", sort @{$opts}) . "~");
 
189
      # Add slave opts if any
 
190
      if ($tinfo->{'slave_opt'})
 
191
      {
 
192
        push(@criteria, join("!", sort @{$tinfo->{'slave_opt'}}));
 
193
      }
 
194
      # This sorts tests with force-restart *before* identical tests
 
195
      push(@criteria, $tinfo->{force_restart} ? "force-restart" : "no-restart");
190
196
 
191
 
      $sort_criteria{$tinfo->{name}} = join(" ", @criteria);
 
197
      $tinfo->{criteria}= join(" ", @criteria);
192
198
    }
193
199
 
194
 
    @$cases = sort {
195
 
      $sort_criteria{$a->{'name'}} . $a->{'name'} cmp
196
 
        $sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
 
200
    @$cases = sort {$a->{criteria} cmp $b->{criteria}; } @$cases;
197
201
 
198
202
    # For debugging the sort-order
199
203
    # foreach my $tinfo (@$cases)
200
204
    # {
201
 
    #   print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
 
205
    #   my $tname= $tinfo->{name} . ' ' . $tinfo->{combination};
 
206
    #   my $crit= $tinfo->{criteria};
 
207
    #   print("$tname\n\t$crit\n");
202
208
    # }
203
 
 
204
209
  }
205
210
 
206
211
  if (defined $print_testcases){
217
222
sub split_testname {
218
223
  my ($test_name)= @_;
219
224
 
220
 
  # Get rid of directory part and split name on .'s
221
 
  my @parts= split(/\./, basename($test_name));
 
225
  # If .test file name is used, get rid of directory part
 
226
  $test_name= basename($test_name) if $test_name =~ /\.test$/;
 
227
 
 
228
  # Now split name on .'s
 
229
  my @parts= split(/\./, $test_name);
222
230
 
223
231
  if (@parts == 1){
224
232
    # Only testname given, ex: alias
266
274
    }
267
275
    else
268
276
    {
269
 
      $suitedir= my_find_dir($::basedir,
270
 
                             ["mysql-test/suite",
271
 
                              "mysql-test",
 
277
      $suitedir= my_find_dir($suitedir,
 
278
                             ["suite",
 
279
                              ".",
272
280
                              # Look in storage engine specific suite dirs
273
 
                              "storage/*/mysql-test-suites"
 
281
                              "../storage/*/mysql-test-suites"
274
282
                             ],
275
283
                             [$suite]);
276
284
    }
312
320
  my %disabled;
313
321
  if ( open(DISABLED, "$testdir/disabled.def" ) )
314
322
  {
 
323
    # $^O on Windows considered not generic enough
 
324
    my $plat= (IS_WINDOWS) ? 'windows' : $^O;
 
325
 
315
326
    while ( <DISABLED> )
316
327
      {
317
328
        chomp;
318
 
        if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
 
329
        #diasble the test case if platform matches
 
330
        if ( /\@/ )
 
331
          {
 
332
             if ( /\@$plat/ )
 
333
               {
 
334
                  /^\s*(\S+)\s*\@$plat.*:\s*(.*?)\s*$/ ;
 
335
                  $disabled{$1}= $2;
 
336
               }
 
337
             elsif ( /\@!(\S*)/ )
 
338
               {
 
339
                  if ( $1 ne $plat)
 
340
                    {
 
341
                       /^\s*(\S+)\s*\@!.*:\s*(.*?)\s*$/ ;
 
342
                       $disabled{$1}= $2;
 
343
                    }
 
344
               }
 
345
          }
 
346
       elsif ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ )
319
347
          {
320
348
            $disabled{$1}= $2;
321
349
          }
584
612
    # Check that engine selected by
585
613
    # --default-storage-engine=<engine> is supported
586
614
    # =======================================================
587
 
    my %builtin_engines = ('myisam' => 1, 'memory' => 1);
 
615
    my %builtin_engines = ('myisam' => 1, 'memory' => 1, 'csv' => 1);
588
616
 
589
617
    foreach my $opt ( @{$tinfo->{master_opt}} ) {
590
618
      my $default_engine=
684
712
        next;
685
713
      }
686
714
 
 
715
      $value= mtr_match_prefix($opt, "--testcase-timeout=");
 
716
      if ( defined $value ) {
 
717
        # Overrides test case timeout for this test
 
718
        $tinfo->{'case-timeout'}= $value;
 
719
        next;
 
720
      }
 
721
 
687
722
      # Ok, this was a real option, add it
688
723
      push(@{$tinfo->{$opt_name}}, $opt);
689
724
    }
902
937
    {
903
938
      # Ndb is not supported, skip it
904
939
      $tinfo->{'skip'}= 1;
905
 
      $tinfo->{'comment'}= "No ndbcluster support";
 
940
      $tinfo->{'comment'}= "No ndbcluster support or ndb tests not enabled";
906
941
      return $tinfo;
907
942
    }
908
943
    elsif ( $::opt_skip_ndbcluster )