diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index b8344606448..e2b5931c2eb 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -386,18 +386,18 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l cp= strmake(result, root, len); if (cp[-1] != FN_LIBCHAR) - *cp= FN_LIBCHAR; + *cp++= FN_LIBCHAR; ret= 1; va_start(va, len); subdir= (!(flags & MY_SEARCH_SELF)) ? va_arg(va, char *) : ""; - while (ret && subdir) + while (subdir) { MY_DIR *dir; FILEINFO *match; char *cp1; - cp1= strnmov(cp + 1, subdir, len - (cp - result) - 1); + cp1= strnmov(cp, subdir, len - (cp - result) - 1); dir= my_dir(result, (flags & MY_ISDIR) ? MY_WANT_STAT : MYF(0)); if (dir) @@ -406,25 +406,20 @@ find_file(const char *name, const char *root, uint flags, char *result, size_t l sizeof(FILEINFO), (qsort_cmp)comp_names); if (match) { - if (!(flags & MY_PARENT)) - { - if (cp1[-1] != FN_LIBCHAR) + ret= (flags & MY_ISDIR) ? !MY_S_ISDIR(match->mystat->st_mode) : 0; + if (!ret) + { + if (cp1[-1] != FN_LIBCHAR) *cp1++= FN_LIBCHAR; - strnmov(cp1, name, len - (cp1 - result)); + + if (!(flags & MY_PARENT)) + strnmov(cp1, name, len - (cp1 - result)); + else + *cp1= '\0'; + + my_dirend(dir); + break; } - else - { - if (cp1[-1] == FN_LIBCHAR) - --cp1; - while (*--cp1 == FN_LIBCHAR) - {} - *++cp1= FN_LIBCHAR; - *++cp1= '\0'; - } - if (flags & MY_ISDIR) - ret= !MY_S_ISDIR(match->mystat->st_mode); - else - ret= 0; } my_dirend(dir); } @@ -484,7 +479,7 @@ int main(int argc, char **argv) || find_file(mysqld_name, basedir, MYF(0), path, sizeof(path), "bin", "libexec", NullS)) { - my_strdup((gptr)basedir, MYF(0)); + my_free((gptr)basedir, MYF(0)); basedir= (char *)DEFAULT_MYSQL_HOME; } } diff --git a/mysql-test/include/report-features.test b/mysql-test/include/report-features.test new file mode 100644 index 00000000000..df395f6e3f0 --- /dev/null +++ b/mysql-test/include/report-features.test @@ -0,0 +1,11 @@ +# +# show server variables +# + +--disable_query_log +--echo ===== ENGINES ===== +show engines; +--echo ===== VARIABLES ===== +show variables; +--echo ===== STOP ===== +--enable_query_log diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh index 4554b92857e..c30583503dc 100644 --- a/mysql-test/install_test_db.sh +++ b/mysql-test/install_test_db.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 1997-2002 MySQL AB +# Copyright (C) 1997-2006 MySQL AB # For a more info consult the file COPYRIGHT distributed with this file # This scripts creates the privilege tables db, host, user, tables_priv, @@ -7,19 +7,26 @@ if [ x$1 = x"--bin" ]; then shift 1 + BINARY_DIST=1 + + bindir=../bin + scriptdir=../bin + libexecdir=../libexec # Check if it's a binary distribution or a 'make install' if test -x ../libexec/mysqld then execdir=../libexec + elif test -x ../../sbin/mysqld # RPM installation + then + execdir=../../sbin + bindir=../../bin + scriptdir=../../bin + libexecdir=../../libexec else execdir=../bin fi - bindir=../bin - BINARY_DIST=1 fix_bin=mysql-test - scriptdir=../bin - libexecdir=../libexec else execdir=../sql bindir=../client diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ba9f788494a..74ec2a02c12 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -220,6 +220,7 @@ our $opt_ndbconnectstring_slave; our $opt_record; our $opt_check_testcases; +my $opt_report_features; our $opt_skip; our $opt_skip_rpl; @@ -426,10 +427,14 @@ sub main () { if ( ! $need_im ) { $opt_skip_im= 1; - } + } initialize_servers(); + if ( $opt_report_features ) { + run_report_features(); + } + run_suite($opt_suite, $tests); } @@ -594,6 +599,7 @@ sub command_line_setup () { 'mem:s' => \$opt_mem, # Misc + 'report-features' => \$opt_report_features, 'comment=s' => \$opt_comment, 'debug' => \$opt_debug, 'fast' => \$opt_fast, @@ -637,7 +643,7 @@ sub command_line_setup () { $glob_hostname= mtr_short_hostname(); - # 'basedir' is always parent of "mysql-test" directory + # Find the absolute path to the test directory $glob_mysql_test_dir= cwd(); if ( $glob_cygwin_perl ) { @@ -645,11 +651,27 @@ sub command_line_setup () { $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`; chomp($glob_mysql_test_dir); } - $glob_basedir= dirname($glob_mysql_test_dir); + + # In most cases, the base directory we find everything relative to, + # is the parent directory of the "mysql-test" directory. For source + # distributions, TAR binary distributions and some other packages. + $glob_basedir= dirname($glob_mysql_test_dir); + + # In the RPM case, binaries and libraries are installed in the + # default system locations, instead of having our own private base + # directory. And we install "/usr/share/mysql-test". Moving up one + # more directory relative to "mysql-test" gives us a usable base + # directory for RPM installs. + if ( ! $opt_source_dist and ! -d "$glob_basedir/bin" ) + { + $glob_basedir= dirname($glob_basedir); + } # Expect mysql-bench to be located adjacent to the source tree, by default $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench" unless defined $glob_mysql_bench_dir; + $glob_mysql_bench_dir= undef + unless -d $glob_mysql_bench_dir; $path_my_basedir= $opt_source_dist ? $glob_mysql_test_dir : $glob_basedir; @@ -677,7 +699,8 @@ sub command_line_setup () { "$path_client_bindir/mysqld-debug", "$path_client_bindir/mysqld-max", "$glob_basedir/libexec/mysqld", - "$glob_basedir/bin/mysqld"); + "$glob_basedir/bin/mysqld", + "$glob_basedir/sbin/mysqld"); # Use the mysqld found above to find out what features are available collect_mysqld_features(); @@ -794,6 +817,13 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; } + # Ensure a proper error message + mkpath("$opt_vardir"); + unless ( -d $opt_vardir and -w $opt_vardir ) + { + mtr_error("Writable 'var' directory is needed, use the '--vardir' option"); + } + # -------------------------------------------------------------------------- # Set tmpdir # -------------------------------------------------------------------------- @@ -1315,7 +1345,9 @@ sub executable_setup_im () { $exe_im= mtr_exe_maybe_exists( "$glob_basedir/server-tools/instance-manager/mysqlmanager", - "$glob_basedir/libexec/mysqlmanager"); + "$glob_basedir/libexec/mysqlmanager", + "$glob_basedir/bin/mysqlmanager", + "$glob_basedir/sbin/mysqlmanager"); return ($exe_im eq ""); } @@ -4210,6 +4242,43 @@ sub run_check_testcase ($$) { return $res; } +############################################################################## +# +# Report the features that were compiled in +# +############################################################################## + +sub run_report_features () { + my $args; + + if ( ! $glob_use_embedded_server ) + { + mysqld_start($master->[0],[],[]); + if ( ! $master->[0]->{'pid'} ) + { + mtr_error("Can't start the mysqld server"); + } + mysqld_wait_started($master->[0]); + } + + my $tinfo = {}; + $tinfo->{'name'} = 'report features'; + $tinfo->{'result_file'} = undef; + $tinfo->{'component_id'} = 'mysqld'; + $tinfo->{'path'} = 'include/report-features.test'; + $tinfo->{'timezone'}= "GMT-3"; + $tinfo->{'slave_num'} = 0; + $tinfo->{'master_opt'} = []; + $tinfo->{'slave_opt'} = []; + $tinfo->{'slave_mi'} = []; + $tinfo->{'comment'} = 'report server features'; + run_mysqltest($tinfo); + + if ( ! $glob_use_embedded_server ) + { + stop_all_servers(); + } +} sub run_mysqltest ($) { @@ -4347,8 +4416,10 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--test-file"); mtr_add_arg($args, $tinfo->{'path'}); - mtr_add_arg($args, "--result-file"); - mtr_add_arg($args, $tinfo->{'result_file'}); + if ( defined $tinfo->{'result_file'} ) { + mtr_add_arg($args, "--result-file"); + mtr_add_arg($args, $tinfo->{'result_file'}); + } if ( $opt_record ) { @@ -4762,3 +4833,4 @@ HERE mtr_exit(1); } + diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 9e19a8cad7e..52e98304aca 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -174,18 +174,29 @@ fi # Misc. Definitions #-- -if [ -d ../sql ] ; then +# BASEDIR is always above mysql-test directory ... +MYSQL_TEST_DIR=`pwd` +cd .. + +if [ -d ./sql ] ; then SOURCE_DIST=1 else BINARY_DIST=1 fi -#BASEDIR is always one above mysql-test directory -CWD=`pwd` -cd .. -BASEDIR=`pwd` -cd $CWD -MYSQL_TEST_DIR=$BASEDIR/mysql-test +# ... one level for tar.gz, two levels for a RPM installation +if [ -d ./bin ] ; then + # this is not perfect: we have + # /usr/share/mysql/ # mysql-test-run is here, so this is "$MYSQL_TEST_DIR" + # /usr/bin/ # with MySQL client programs + # so the existence of "/usr/share/bin/" would make this test fail. + BASEDIR=`pwd` +else + cd .. + BASEDIR=`pwd` +fi + +cd $MYSQL_TEST_DIR MYSQL_TEST_WINDIR=$MYSQL_TEST_DIR MYSQLTEST_VARDIR=$MYSQL_TEST_DIR/var export MYSQL_TEST_DIR MYSQL_TEST_WINDIR MYSQLTEST_VARDIR @@ -744,8 +755,15 @@ else if test -x "$BASEDIR/libexec/mysqld" then MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld" - else + elif test -x "$BASEDIR/bin/mysqld" + then MYSQLD="$VALGRIND $BASEDIR/bin/mysqld" + elif test -x "$BASEDIR/sbin/mysqld" + then + MYSQLD="$VALGRIND $BASEDIR/sbin/mysqld" + else + $ECHO "Fatal error: Cannot find program mysqld in $BASEDIR/{libexec,bin,sbin}" 1>&2 + exit 1 fi CLIENT_BINDIR="$BASEDIR/bin" if test -d "$BASEDIR/tests" @@ -1390,7 +1408,7 @@ start_master() then $ECHO "set args $master_args" > $GDB_MASTER_INIT$1 $ECHO "To start gdb for the master , type in another window:" - $ECHO "cd $CWD ; gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD" + $ECHO "cd $MYSQL_TEST_DIR ; gdb -x $GDB_MASTER_INIT$1 $MASTER_MYSQLD" wait_for_master=1500 else ( $ECHO set args $master_args; @@ -1508,7 +1526,7 @@ start_slave() then $ECHO "set args $slave_args" > $GDB_SLAVE_INIT echo "To start gdb for the slave, type in another window:" - echo "cd $CWD ; gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD" + echo "cd $MYSQL_TEST_DIR ; gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD" wait_for_slave=1500 else ( $ECHO set args $slave_args;