1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
# Copyright (c) 2009, 2025, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is designed to work with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have either included with
# the program or referenced in the documentation.
#
# 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, version 2.0, 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
INCLUDE(ProcessorCount)
# Skip -- Up-to-date messages in case of multiple 'make install'.
# This works for CMAKE 3.1.3 and up
SET(CMAKE_INSTALL_MESSAGE LAZY)
IF(INSTALL_MYSQLTESTDIR)
INSTALL(
DIRECTORY .
DESTINATION ${INSTALL_MYSQLTESTDIR}
USE_SOURCE_PERMISSIONS
COMPONENT Test
PATTERN "var" EXCLUDE
PATTERN "var/" EXCLUDE
PATTERN "lib/My/SafeProcess" EXCLUDE
PATTERN "CPack" EXCLUDE
PATTERN "CMake*" EXCLUDE
PATTERN "Makefile" EXCLUDE
PATTERN "mtr.out*" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "*.in" EXCLUDE
)
IF(NOT INSTALL_LAYOUT MATCHES "RPM" AND
NOT INSTALL_LAYOUT MATCHES "DEB")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE
DESTINATION ${INSTALL_DOCREADMEDIR}
COMPONENT TestReadme
RENAME LICENSE-test
)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/README
DESTINATION ${INSTALL_DOCREADMEDIR}
COMPONENT TestReadme
RENAME README-test
)
ENDIF()
ENDIF()
IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# Enable running mtr from build directory
FIND_PROGRAM(PERL_EXECUTABLE perl
/usr/bin /usr/local/bin
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH)
# If not found in hard-coded list above, look in PATH as well.
FIND_PROGRAM(PERL_EXECUTABLE perl)
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()
SET(EXP --experimental=collections/default.experimental)
SET(DEBUG_SERVER "")
SET(VS_CONFIG "")
IF(DEBUG_EXTNAME)
SET(DEBUG_SERVER "--debug-server")
ENDIF()
IF(CMAKE_BUILD_TYPE)
IF(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
SET(DEBUG_SERVER "--debug-server")
ELSE()
SET(DEBUG_SERVER "")
IF(NOT BUILD_IS_SINGLE_CONFIG)
SET(VS_CONFIG "--vs-config=${CMAKE_CFG_INTDIR}")
ENDIF()
ENDIF()
ENDIF()
# On windows do: 'cmake --build . --config debug --target test-mtr'
# On unix do: 'make test-mtr'
ADD_CUSTOM_TARGET(test-mtr
COMMAND perl ./mysql-test-run.pl --force --parallel=4 --suite=main
${VS_CONFIG} ${DEBUG_SERVER} ${EXP}
)
SET(MTR_TESTS_FOR_PROFILING
auth_sec
binlog
connection_control
encryption
gcol
gis
innodb
json
main
sysschema
thread_pool
x
)
STRING(REPLACE ";" "," MTR_SUITE_STRING "${MTR_TESTS_FOR_PROFILING}")
PROCESSORCOUNT(NPROC)
IF(NPROC EQUAL 0)
SET(NPROC 8)
ENDIF()
# Use env var MTR_MAX_PARALLEL if found.
# Note that this must be set permanently in the environment.
# MTR_MAX_PARALLEL=42 make run-profile-suite will not catch the new value.
IF(DEFINED ENV{MTR_MAX_PARALLEL})
SET(NPROC $ENV{MTR_MAX_PARALLEL})
ENDIF()
IF(DEFINED MTR_MAX_PARALLEL)
SET(NPROC ${MTR_MAX_PARALLEL})
ENDIF()
ADD_CUSTOM_TARGET(run-profile-suite
COMMAND perl ./mysql-test-run.pl
--accept-test-fail
--clean-vardir
--force
--max-test-fail=10
--mem
--mysqld=--binlog-format=row
--parallel=${NPROC}
--retry=0
--skip-rpl
--suite=${MTR_SUITE_STRING}
USES_TERMINAL # So that Ninja will show progress, rather than buffer output.
COMMENT "Running mtr with --parallel=${NPROC}"
VERBATIM
)
## We could do something like this, but the 'test' target generated
## by cmake is really for unit testing: all output is muted by default,
## even in case of test failure.
## ADD_EXECUTABLE(perl IMPORTED)
## ADD_TEST(xxx perl ./mysql-test-run.pl --force
## ${VS_CONFIG} ${DEBUG_SERVER} ${EXP})
# With different MAX_INDEXES values, server might behave differently in
# certain cases. 'max_indexes.inc' file should be updated accordingly to
# reflect the current MAX_INDEXES value. This file helps MTR to decide on
# which tests should be skipped.
# NOTE: While committing a patch please make sure that the file is unmodified
# and should show the default MAX_INDEXES (i.e. 64U).
IF (MAX_INDEXES)
IF(NOT (${MAX_INDEXES} EQUAL 64U))
FILE(WRITE include/max_indexes.inc
"# Warning: This is an auto-generated file. Please do not modify it.
--let $max_indexes = ${MAX_INDEXES}\n")
MESSAGE(STATUS "mysql-test/include/max_indexes.inc adjusted")
ENDIF()
ENDIF()
|