~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/test-run.pl

  • Committer: Jay Pipes
  • Date: 2008-12-18 16:03:09 UTC
  • mfrom: (713 testable)
  • mto: This revision was merged to the branch mainline in revision 717.
  • Revision ID: jpipes@serialcoder-20081218160309-rx3w2zsonf9ffo7v
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
use File::Basename;
66
66
use File::Copy;
67
67
use File::Temp qw /tempdir/;
68
 
use File::Spec::Functions qw /splitdir/;
 
68
use File::Spec::Functions qw /splitdir catpath catdir
 
69
                              updir curdir splitpath rel2abs/;
69
70
use Cwd;
70
71
use Getopt::Long;
71
72
use IO::Socket;
104
105
our $glob_timers=                 undef;
105
106
our @glob_test_mode;
106
107
 
 
108
our $glob_builddir;
 
109
 
107
110
our $glob_basedir;
108
111
 
109
112
our $path_client_bindir;
116
119
our $opt_vardir;                 # A path but set directly on cmd line
117
120
our $path_vardir_trace;          # unix formatted opt_vardir for trace files
118
121
our $opt_tmpdir;                 # A path but set directly on cmd line
 
122
our $opt_testdir;
119
123
 
120
124
 
121
125
our $default_vardir;
296
300
sub mysqld_arguments ($$$$);
297
301
sub stop_all_servers ();
298
302
sub run_drizzletest ($);
 
303
sub collapse_path ($);
299
304
sub usage ($);
300
305
 
301
306
 
543
548
             # Directories
544
549
             'tmpdir=s'                 => \$opt_tmpdir,
545
550
             'vardir=s'                 => \$opt_vardir,
 
551
             'testdir=s'                => \$opt_testdir,
546
552
             'benchdir=s'               => \$glob_mysql_bench_dir,
547
553
             'mem'                      => \$opt_mem,
548
554
 
584
590
    $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
585
591
  }
586
592
 
587
 
  # We require that we are in the "mysql-test" directory
588
 
  # to run drizzle-test-run
589
 
  if (! -f $glob_scriptname)
590
 
  {
591
 
    mtr_error("Can't find the location for the drizzle-test-run script\n" .
592
 
              "Go to to the mysql-test directory and execute the script " .
593
 
              "as follows:\n./$glob_scriptname");
594
 
  }
595
 
 
596
593
  if ( -d "../drizzled" )
597
594
  {
598
595
    $source_dist=  1;
599
596
  }
600
597
 
601
598
  # Find the absolute path to the test directory
602
 
  $glob_mysql_test_dir=  cwd();
 
599
  if ( ! $opt_testdir )
 
600
  {
 
601
    $glob_mysql_test_dir=  cwd();
 
602
  } 
 
603
  else
 
604
  {
 
605
    $glob_mysql_test_dir= $opt_testdir;
 
606
  }
603
607
  $default_vardir= "$glob_mysql_test_dir/var";
604
608
 
605
609
  # In most cases, the base directory we find everything relative to,
617
621
    $glob_basedir= dirname($glob_basedir);
618
622
  }
619
623
 
 
624
  if ( -d $opt_testdir and -d $opt_vardir
 
625
         and -f "$opt_vardir/../../drizzled/drizzled")
 
626
  {
 
627
    # probably in a VPATH build
 
628
    $glob_builddir= "$opt_vardir/../..";
 
629
  }
 
630
  else
 
631
  {
 
632
    $glob_builddir="..";
 
633
  }
 
634
 
620
635
  # Expect mysql-bench to be located adjacent to the source tree, by default
621
636
  $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench"
622
637
    unless defined $glob_mysql_bench_dir;
634
649
  #
635
650
 
636
651
  # Look for the client binaries directory
637
 
  $path_client_bindir= mtr_path_exists("$glob_basedir/client",
 
652
  $path_client_bindir= mtr_path_exists("$glob_builddir/client",
 
653
                                       "$glob_basedir/client",
638
654
                                       "$glob_basedir/bin");
639
655
 
640
656
  if (!$opt_extern)
643
659
                                       "$path_client_bindir/drizzled",
644
660
                                       "$glob_basedir/libexec/drizzled",
645
661
                                       "$glob_basedir/bin/drizzled",
646
 
                                       "$glob_basedir/sbin/drizzled");
 
662
                                       "$glob_basedir/sbin/drizzled",
 
663
                                       "$glob_builddir/drizzled/drizzled");
647
664
 
648
665
    # Use the mysqld found above to find out what features are available
649
666
    collect_mysqld_features();
777
794
  # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
778
795
  $path_vardir_trace=~ s/^\w://;
779
796
 
780
 
  # We make the path absolute, as the server will do a chdir() before usage
781
 
  unless ( $opt_vardir =~ m,^/,)
782
 
  {
783
 
    # Make absolute path, relative test dir
784
 
    $opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
785
 
  }
 
797
  $opt_vardir= collapse_path($opt_vardir);
786
798
 
787
799
  # --------------------------------------------------------------------------
788
800
  # Set tmpdir
1060
1072
 
1061
1073
sub set_mtr_build_thread_ports($) {
1062
1074
  my $mtr_build_thread= shift;
 
1075
  $mtr_build_thread= ($mtr_build_thread % 200) - 100;
1063
1076
 
1064
1077
  if ( lc($mtr_build_thread) eq 'auto' ) {
1065
1078
    print "Requesting build thread... ";
1232
1245
  $exe_my_print_defaults=
1233
1246
    mtr_exe_exists(
1234
1247
        "$path_client_bindir/my_print_defaults",
1235
 
        "$glob_basedir/extra/my_print_defaults");
 
1248
        "$glob_basedir/extra/my_print_defaults",
 
1249
        "$glob_builddir/extra/my_print_defaults");
1236
1250
 
1237
1251
# Look for perror
1238
1252
  $exe_perror= "perror";
1409
1423
  
1410
1424
  $ENV{'LC_COLLATE'}=         "C";
1411
1425
  $ENV{'USE_RUNNING_SERVER'}= $opt_extern;
1412
 
  $ENV{'DRIZZLE_TEST_DIR'}=     $glob_mysql_test_dir;
 
1426
  $ENV{'DRIZZLE_TEST_DIR'}=     collapse_path($glob_mysql_test_dir);
1413
1427
  $ENV{'MYSQLTEST_VARDIR'}=   $opt_vardir;
1414
1428
  $ENV{'DRIZZLE_TMP_DIR'}=      $opt_tmpdir;
1415
1429
  $ENV{'MASTER_MYSOCK'}=      $master->[0]->{'path_sock'};
1422
1436
  $ENV{'SLAVE_MYPORT2'}=      $slave->[2]->{'port'};
1423
1437
  $ENV{'DRIZZLE_TCP_PORT'}=     $mysqld_variables{'port'};
1424
1438
 
1425
 
  $ENV{MTR_BUILD_THREAD}=      $opt_mtr_build_thread;
 
1439
  $ENV{'MTR_BUILD_THREAD'}=      $opt_mtr_build_thread;
1426
1440
 
1427
1441
  $ENV{'EXE_MYSQL'}=          $exe_drizzle;
1428
1442
 
1768
1782
  }
1769
1783
 
1770
1784
  # Make a link std_data_ln in var/ that points to std_data
1771
 
  symlink("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
 
1785
  symlink(collapse_path("$glob_mysql_test_dir/std_data"),
 
1786
          "$opt_vardir/std_data_ln");
1772
1787
 
1773
1788
  # Remove old log files
1774
1789
  foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
2467
2482
 
2468
2483
  mtr_add_arg($args, "%s--no-defaults", $prefix);
2469
2484
 
 
2485
  $path_my_basedir= collapse_path($path_my_basedir);
2470
2486
  mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
2471
2487
 
2472
2488
  if ($opt_engine)
3075
3091
    mtr_add_arg($args, "--record");
3076
3092
  }
3077
3093
 
 
3094
  if ( $opt_testdir )
 
3095
  {
 
3096
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3097
  }
 
3098
 
3078
3099
  my $res = mtr_run_test($exe_drizzletest,$args,
3079
3100
                "include/check-testcase.test", "", "", "");
3080
3101
 
3181
3202
                $path_vardir_trace);
3182
3203
  }
3183
3204
 
 
3205
  if ( $opt_testdir )
 
3206
  {
 
3207
    mtr_add_arg($args, "--testdir=%s", $opt_testdir);
 
3208
  }
 
3209
 
 
3210
 
3184
3211
  # ----------------------------------------------------------------------
3185
3212
  # export DRIZZLE_TEST variable containing <path>/drizzletest <args>
3186
3213
  # ----------------------------------------------------------------------
3483
3510
  return 0;
3484
3511
}
3485
3512
 
 
3513
sub collapse_path ($) {
 
3514
 
 
3515
    my $c_path= rel2abs(shift);
 
3516
    my $updir  = updir($c_path);
 
3517
    my $curdir = curdir($c_path);
 
3518
 
 
3519
    my($vol, $dirs, $file) = splitpath($c_path);
 
3520
    my @dirs = splitdir($dirs);
 
3521
 
 
3522
    my @collapsed;
 
3523
    foreach my $dir (@dirs) {
 
3524
        if( $dir eq $updir              and   # if we have an updir
 
3525
            @collapsed                  and   # and something to collapse
 
3526
            length $collapsed[-1]       and   # and its not the rootdir
 
3527
            $collapsed[-1] ne $updir    and   # nor another updir
 
3528
            $collapsed[-1] ne $curdir         # nor the curdir
 
3529
          )
 
3530
        {                                     # then
 
3531
            pop @collapsed;                   # collapse
 
3532
        }
 
3533
        else {                                # else
 
3534
            push @collapsed, $dir;            # just hang onto it
 
3535
        }
 
3536
    }
 
3537
 
 
3538
    return catpath($vol, catdir(@collapsed), $file);
 
3539
}
3486
3540
 
3487
3541
##############################################################################
3488
3542
#