1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MWL#55 : cherrypick MySQL 5.5 CMake/build improvements in order

to be able to build MSI based installer
This commit is contained in:
Vladislav Vaintroub
2011-01-29 18:51:12 +01:00
parent 3edf4dcd5a
commit b19e99865c
46 changed files with 1908 additions and 407 deletions

137
mysql-test/CMakeLists.txt Normal file
View File

@ -0,0 +1,137 @@
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
IF(INSTALL_MYSQLTESTDIR)
INSTALL(
DIRECTORY .
DESTINATION ${INSTALL_MYSQLTESTDIR}
USE_SOURCE_PERMISSIONS
COMPONENT Test
PATTERN "var/" EXCLUDE
PATTERN "lib/My/SafeProcess" EXCLUDE
PATTERN "lib/t*" EXCLUDE
PATTERN "CPack" EXCLUDE
PATTERN "CMake*" EXCLUDE
PATTERN "mtr.out*" EXCLUDE
PATTERN ".cvsignore" EXCLUDE
PATTERN "*.am" EXCLUDE
PATTERN "*.in" EXCLUDE
PATTERN "*.vcproj" EXCLUDE
PATTERN "*.vcxproj" EXCLUDE
PATTERN "*.vcxproj.*" EXCLUDE
)
ENDIF()
IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Enable running mtr from build directory
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source
${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl
@ONLY
)
ENDIF()
IF(UNIX)
EXECUTE_PROCESS(
COMMAND chmod +x mysql-test-run.pl
COMMAND ${CMAKE_COMMAND} -E create_symlink
./mysql-test-run.pl mtr
COMMAND ${CMAKE_COMMAND} -E create_symlink
./mysql-test-run.pl mysql-test-run
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
IF(INSTALL_MYSQLTESTDIR)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr
${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run
DESTINATION ${INSTALL_MYSQLTESTDIR}
COMPONENT Test)
ENDIF()
ENDIF()
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(SETCONFIG_COMMAND set MTR_VS_CONFIG=${CMAKE_CFG_INTDIR})
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(SETCONFIG_COMMAND export MTR_VS_CONFIG=${CMAKE_CFG_INTDIR})
ELSE()
SET(SETCONFIG_COMMAND echo Running tests)
ENDIF()
IF(CYGWIN)
# On cygwin, pretend to be "Unix" system
SET(SETOS_COMMAND export MTR_CYGWIN_IS_UNIX=1)
ELSE()
SET(SETOS_COMMAND echo OS=${CMAKE_SYSTEM_NAME})
ENDIF()
SET(EXP --experimental=collections/default.experimental)
IF(WIN32)
SET(SET_ENV set)
ELSE()
SET(SET_ENV export)
ENDIF()
SET(MTR_FORCE perl ./mysql-test-run.pl --force)
IF(EXISTS ${CMAKE_SOURCE_DIR}/mysql-test/suite/nist)
SET(TEST_NIST ${MTR_FORCE} --comment=nist suite=nist ${EXP} &&
${MTR_FORCE} --comment=nist --force --suite=nist+ps ${EXP})
ELSE()
SET(TEST_NIST echo "NIST tests not found")
ENDIF()
IF(WITH_EMBEDDED_SERVER)
SET(TEST_EMBEDDED ${MTR_FORCE} --comment=embedded --timer --embedded-server
--skip-rpl --skip-ndbcluster $(EXP))
ELSE()
SET(TEST_EMBEDDED echo "Can not test embedded, not compiled in")
ENDIF()
SET(TEST_BT_START
COMMAND ${SETCONFIG_COMMAND}
COMMAND ${SETOS_COMMAND}
COMMAND ${SET_ENV} MTR_BUILD_THREAD=auto
)
ADD_CUSTOM_TARGET(test-force
${TEST_BT_START}
COMMAND ${MTR_FORCE}
)
ADD_CUSTOM_TARGET(test-bt
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=normal --timer --skip-ndbcluster --report-features ${EXP}
COMMAND ${MTR_FORCE} --comment=ps --timer --skip-ndbcluster --ps-protocol ${EXP}
COMMAND ${MTR_FORCE} --comment=funcs1+ps --ps-protocol --reorder --suite=funcs_1 ${EXP}
COMMAND ${MTR_FORCE} --comment=funcs2 --suite=funcs_2 ${EXP}
COMMAND ${MTR_FORCE} --comment=partitions --suite=parts ${EXP}
COMMAND ${MTR_FORCE} --comment=stress --suite=stress ${EXP}
COMMAND ${MTR_FORCE} --force --comment=jp --suite=jp ${EXP}
COMMAND ${TEST_NIST}
COMMAND ${TEST_EMBEDDED}
)
ADD_CUSTOM_TARGET(test-bt-fast
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=ps --timer --skip-ndbcluster --ps-protocol --report-features ${EXP}
COMMAND ${MTR_FORCE} --comment=stress --suite=stress ${EXP}
)
ADD_CUSTOM_TARGET(test-bt-debug
${TEST_BT_START}
COMMAND ${MTR_FORCE} --comment=debug --timer --skip-ndbcluster --skip-rpl --report-features ${EXP}
)

View File

@ -72,7 +72,9 @@ SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README README.suites \
$(test_SCRIPTS) \
$(nobase_test_DATA)
$(nobase_test_DATA) \
CMakeLists.txt \
mtr.out-of-source
# List of directories containing test + result files and the
# related test data files that should be copied
@ -109,7 +111,7 @@ TEST_DIRS = t r include std_data std_data/parts collections \
suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \
suite/innodb_plugin suite/innodb_plugin/t suite/innodb_plugin/r \
suite/innodb_plugin/include \
suite/handler \
suite/percona suite/handler \
suite/engines suite/engines/funcs suite/engines/iuds suite/engines/rr_trx \
suite/engines/funcs/r suite/engines/funcs/t suite/engines/iuds/r \
suite/engines/iuds/t suite/engines/rr_trx/include suite/engines/rr_trx/r \

View File

@ -37,6 +37,15 @@ sub get_testdir {
return $testdir;
}
# Retrive build directory (which is different from basedir in out-of-source build)
sub get_bindir {
if (defined $ENV{MTR_BINDIR})
{
return $ENV{MTR_BINDIR};
}
my ($self, $group)= @_;
return $self->get_basedir($group);
}
sub fix_charset_dir {
my ($self, $config, $group_name, $group)= @_;
@ -46,7 +55,7 @@ sub fix_charset_dir {
sub fix_language {
my ($self, $config, $group_name, $group)= @_;
return my_find_dir($self->get_basedir($group),
return my_find_dir($self->get_bindir($group),
\@share_locations, "english");
}
@ -339,6 +348,7 @@ my @mysql_upgrade_rules=
sub post_check_client_group {
my ($self, $config, $client_group_name, $mysqld_group_name)= @_;
# Settings needed for client, copied from its "mysqld"
my %client_needs=
(
@ -348,7 +358,6 @@ sub post_check_client_group {
user => '#user',
password => '#password',
);
my $group_to_copy_from= $config->group($mysqld_group_name);
while (my ($name_to, $name_from)= each( %client_needs )) {
my $option= $group_to_copy_from->option($name_from);

View File

@ -84,23 +84,34 @@ sub is_child {
my @safe_process_cmd;
my $safe_kill;
my $bindir;
if(defined $ENV{MTR_BINDIR})
{
# This is an out-of-source build. Build directory
# is given in MTR_BINDIR env.variable
$bindir = $ENV{MTR_BINDIR}."/mysql-test";
}
else
{
$bindir = ".";
}
# Find the safe process binary or script
sub find_bin {
if (IS_WIN32PERL or IS_CYGWIN)
{
# Use my_safe_process.exe
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
$safe_kill= my_find_bin($bindir, "lib/My/SafeProcess", "my_safe_kill");
}
else
{
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}

View File

@ -1,4 +1,4 @@
# Copyright (C) 2006 MySQL AB
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -11,7 +11,18 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
SET(INSTALL_ARGS
DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess"
COMPONENT Test
)
IF (WIN32)
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process_win.cc ${INSTALL_ARGS})
MYSQL_ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc ${INSTALL_ARGS})
ELSE()
MYSQL_ADD_EXECUTABLE(my_safe_process safe_process.cc ${INSTALL_ARGS})
ENDIF()
INSTALL(FILES safe_process.pl Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test)

View File

@ -0,0 +1,5 @@
#!/usr/bin/perl
# Call mtr in out-of-source build
$ENV{MTR_BINDIR} = "@CMAKE_BINARY_DIR@";
chdir("@CMAKE_SOURCE_DIR@/mysql-test");
exit(system($^X, "@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl", @ARGV) >> 8);

View File

@ -95,6 +95,7 @@ $SIG{INT}= sub { mtr_error("Got ^C signal"); };
our $mysql_version_id;
our $glob_mysql_test_dir;
our $basedir;
our $bindir;
our $path_charsetsdir;
our $path_client_bindir;
@ -513,7 +514,7 @@ sub run_test_server ($$$) {
my $completed= [];
my %running;
my $result;
my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump
my $exe_mysqld= find_mysqld($bindir) || ""; # Used as hint to CoreDump
my $suite_timeout= start_timer(suite_timeout());
@ -855,7 +856,7 @@ sub run_worker ($) {
stop_all_servers($opt_shutdown_timeout);
}
if ( $opt_gprof ) {
gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
gprof_collect (find_mysqld($bindir), keys %gprof_dirs);
}
exit(0);
}
@ -1092,6 +1093,10 @@ sub command_line_setup {
$basedir= dirname($basedir);
}
# Respect MTR_BINDIR variable, which is typically set in to the
# build directory in out-of-source builds.
$bindir=$ENV{MTR_BINDIR}||$basedir;
fix_vs_config_dir();
# Look for the client binaries directory
@ -1102,21 +1107,25 @@ sub command_line_setup {
}
else
{
$path_client_bindir= mtr_path_exists("$basedir/client_release",
"$basedir/client_debug",
"$basedir/client$opt_vs_config",
"$basedir/client",
"$basedir/bin");
$path_client_bindir= mtr_path_exists("$bindir/client_release",
"$bindir/client_debug",
"$bindir/client$opt_vs_config",
"$bindir/client",
"$bindir/bin");
}
# Look for language files and charsetsdir, use same share
$path_language= mtr_path_exists("$basedir/share/mariadb/english",
"$basedir/share/mysql/english",
"$basedir/sql/share/english",
"$basedir/share/english");
$path_language= mtr_path_exists("$bindir/share/mariadb/english",
"$bindir/share/mysql/english",
"$bindir/sql/share/english",
"$bindir/share/english");
my $path_share= dirname($path_language);
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
$path_charsetsdir= mtr_path_exists("$basedir/share/charsets",
"$basedir/share/mysql/charsets",
"$basedir/sql/share/charsets",
"$basedir/share/charsets");
if ( $opt_comment )
{
@ -1268,7 +1277,15 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Set the "var/" directory, the base for everything else
# --------------------------------------------------------------------------
$default_vardir= "$glob_mysql_test_dir/var";
if(defined $ENV{MTR_BINDIR})
{
$default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var";
}
else
{
$default_vardir= "$glob_mysql_test_dir/var";
}
if ( ! $opt_vardir )
{
$opt_vardir= $default_vardir;
@ -1339,19 +1356,6 @@ sub command_line_setup {
# --------------------------------------------------------------------------
if ( $opt_embedded_server )
{
if ( IS_WINDOWS )
{
# Add the location for libmysqld.dll to the path.
my $separator= ";";
my $lib_mysqld=
mtr_path_exists("$basedir/libmysqld$opt_vs_config");
if ( IS_CYGWIN )
{
$lib_mysqld= posix_path($lib_mysqld);
$separator= ":";
}
$ENV{'PATH'}= "$ENV{'PATH'}".$separator.$lib_mysqld;
}
$opt_skip_ndbcluster= 1; # Turn off use of NDB cluster
$opt_skip_ssl= 1; # Turn off use of SSL
@ -1645,7 +1649,7 @@ sub collect_mysqld_features {
mtr_add_arg($args, "--user=root");
}
my $exe_mysqld= find_mysqld($basedir);
my $exe_mysqld= find_mysqld($bindir);
my $cmd= join(" ", $exe_mysqld, @$args);
my $list= `$cmd`;
@ -1770,7 +1774,7 @@ sub find_mysqld {
unshift(@mysqld_names, "mysqld-debug");
}
return my_find_bin($mysqld_basedir,
return my_find_bin($bindir,
["sql", "libexec", "sbin", "bin"],
[@mysqld_names]);
}
@ -1820,7 +1824,7 @@ sub executable_setup () {
if ( $opt_embedded_server )
{
$exe_mysqltest=
mtr_exe_exists("$basedir/libmysqld/examples$opt_vs_config/mysqltest_embedded",
mtr_exe_exists("$bindir/libmysqld/examples$opt_vs_config/mysqltest_embedded",
"$path_client_bindir/mysqltest_embedded");
}
else
@ -1930,11 +1934,11 @@ sub mysql_client_test_arguments(){
# mysql_client_test executable may _not_ exist
if ( $opt_embedded_server ) {
$exe= mtr_exe_maybe_exists(
"$basedir/libmysqld/examples$opt_vs_config/mysql_client_test_embedded",
"$basedir/bin/mysql_client_test_embedded");
"$bindir/libmysqld/examples$opt_vs_config/mysql_client_test_embedded",
"$bindir/bin/mysql_client_test_embedded");
} else {
$exe= mtr_exe_maybe_exists("$basedir/tests$opt_vs_config/mysql_client_test",
"$basedir/bin/mysql_client_test");
$exe= mtr_exe_maybe_exists("$bindir/tests$opt_vs_config/mysql_client_test",
"$bindir/bin/mysql_client_test");
}
my $args;
@ -1946,13 +1950,13 @@ sub mysql_client_test_arguments(){
mtr_add_arg($args, "--testcase");
mtr_add_arg($args, "--vardir=$opt_vardir");
client_debug_arg($args,"mysql_client_test");
return mtr_args2str($exe, @$args);
my $ret=mtr_args2str($exe, @$args);
return $ret;
}
sub tool_arguments ($$) {
my($sedir, $tool_name) = @_;
my $exe= my_find_bin($basedir,
my $exe= my_find_bin($bindir,
[$sedir, "bin"],
$tool_name);
@ -1966,7 +1970,7 @@ sub tool_arguments ($$) {
# scripts to run the mysqld binary to test invalid server startup options.
sub mysqld_client_arguments () {
my $default_mysqld= default_mysqld();
my $exe = find_mysqld($basedir);
my $exe = find_mysqld($bindir);
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
@ -2147,24 +2151,24 @@ sub environment_setup {
# some versions, test using it should be skipped
# ----------------------------------------------------
my $exe_bug25714=
mtr_exe_maybe_exists("$basedir/tests$opt_vs_config/bug25714");
mtr_exe_maybe_exists("$bindir/tests$opt_vs_config/bug25714");
$ENV{'MYSQL_BUG25714'}= native_path($exe_bug25714);
# ----------------------------------------------------
# mysql_fix_privilege_tables.sql
# ----------------------------------------------------
my $file_mysql_fix_privilege_tables=
mtr_file_exists("$basedir/scripts/mysql_fix_privilege_tables.sql",
"$basedir/share/mysql_fix_privilege_tables.sql",
"$basedir/share/mariadb/mysql_fix_privilege_tables.sql",
"$basedir/share/mysql/mysql_fix_privilege_tables.sql");
mtr_file_exists("$bindir/scripts/mysql_fix_privilege_tables.sql",
"$bindir/share/mysql_fix_privilege_tables.sql",
"$bindir/share/mariadb/mysql_fix_privilege_tables.sql",
"$bindir/share/mysql/mysql_fix_privilege_tables.sql");
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
# ----------------------------------------------------
# my_print_defaults
# ----------------------------------------------------
my $exe_my_print_defaults=
mtr_exe_exists("$basedir/extra$opt_vs_config/my_print_defaults",
mtr_exe_exists("$bindir/extra$opt_vs_config/my_print_defaults",
"$path_client_bindir/my_print_defaults");
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults);
@ -2189,7 +2193,7 @@ sub environment_setup {
# mysqlhotcopy
# ----------------------------------------------------
my $mysqlhotcopy=
mtr_pl_maybe_exists("$basedir/scripts/mysqlhotcopy");
mtr_pl_maybe_exists("$bindir/scripts/mysqlhotcopy");
# Since mysqltest interprets the real path as "false" in an if,
# use 1 ("true") to indicate "not exists" so it can be tested for
$ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy || 1;
@ -2197,7 +2201,7 @@ sub environment_setup {
# ----------------------------------------------------
# perror
# ----------------------------------------------------
my $exe_perror= mtr_exe_exists("$basedir/extra$opt_vs_config/perror",
my $exe_perror= mtr_exe_exists("$bindir/extra$opt_vs_config/perror",
"$path_client_bindir/perror");
$ENV{'MY_PERROR'}= native_path($exe_perror);
@ -2378,9 +2382,9 @@ sub setup_vardir() {
mkpath($plugindir);
if (IS_WINDOWS)
{
for (<../storage/*$opt_vs_config/*.dll>,
<../plugin/*$opt_vs_config/*.dll>,
<../sql$opt_vs_config/*.dll>)
for (<$bindir/storage/*$opt_vs_config/*.dll>,
<$bindir/plugin/*$opt_vs_config/*.dll>,
<$bindir/sql$opt_vs_config/*.dll>)
{
my $pname=basename($_);
copy rel2abs($_), "$plugindir/$pname";
@ -2389,7 +2393,7 @@ sub setup_vardir() {
}
else
{
for (<../storage/*/.libs/*.so>,<../plugin/*/.libs/*.so>,<../sql/.libs/*.so>)
for (<$bindir/storage/*/.libs/*.so>,<$bindir/plugin/*/.libs/*.so>,<$bindir/sql/.libs/*.so>)
{
my $pname=basename($_);
symlink rel2abs($_), "$plugindir/$pname";
@ -2400,8 +2404,8 @@ sub setup_vardir() {
else
{
# hm, what paths work for debs and for rpms ?
for (<$basedir/lib/mysql/plugin/*.so>,
<$basedir/lib/plugin/*.dll>)
for (<$bindir/lib/mysql/plugin/*.so>,
<$bindir/lib/plugin/*.dll>)
{
my $pname=basename($_);
set_plugin_var($pname);
@ -2516,7 +2520,7 @@ sub fix_vs_config_dir () {
$opt_vs_config="";
for (<$basedir/sql/*/mysqld.exe>) {
for (<$bindir/sql/*/mysqld.exe>) {
if (-M $_ < $modified)
{
$modified = -M _;

View File

@ -138,6 +138,7 @@ Tables_in_test
DROP TABLE `@`;
CREATE TABLE `я` (a INT);
SET NAMES DEFAULT;
call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
mysqlcheck --default-character-set="latin1" --databases test
test.?
Error : Table doesn't exist

View File

@ -136,6 +136,7 @@ DROP TABLE `@`;
CREATE TABLE `я` (a INT);
SET NAMES DEFAULT;
call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
--echo mysqlcheck --default-character-set="latin1" --databases test
# Error returned depends on platform, replace it with "Table doesn't exist"
--replace_result "Can't find file: './test/@003f.frm' (errno: 22)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist"