diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:04:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:04:16 +0000 |
commit | a68fb2d8219f6bccc573009600e9f23e89226a5e (patch) | |
tree | d742d35d14ae816e99293d2b01face30e9f3a46b /storage/mroonga/test | |
parent | Initial commit. (diff) | |
download | mariadb-10.6-a68fb2d8219f6bccc573009600e9f23e89226a5e.tar.xz mariadb-10.6-a68fb2d8219f6bccc573009600e9f23e89226a5e.zip |
Adding upstream version 1:10.6.11.upstream/1%10.6.11upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/mroonga/test')
-rw-r--r-- | storage/mroonga/test/Makefile.am | 14 | ||||
-rwxr-xr-x | storage/mroonga/test/run-sql-test.sh | 244 | ||||
-rwxr-xr-x | storage/mroonga/test/run-unit-test.sh | 49 | ||||
-rw-r--r-- | storage/mroonga/test/unit/Makefile.am | 27 | ||||
-rw-r--r-- | storage/mroonga/test/unit/test_mrn_path_mapper.cpp | 134 |
5 files changed, 468 insertions, 0 deletions
diff --git a/storage/mroonga/test/Makefile.am b/storage/mroonga/test/Makefile.am new file mode 100644 index 00000000..ce75011b --- /dev/null +++ b/storage/mroonga/test/Makefile.am @@ -0,0 +1,14 @@ +SUBDIRS = unit + +TESTS = run-sql-test.sh +TESTS_ENVIRONMENT = \ + NO_MAKE="yes" + +if WITH_CUTTER +TESTS += run-unit-test.sh +TESTS_ENVIRONMENT += CUTTER="$(CUTTER)" +endif + +EXTRA_DIST = \ + run-unit-test.sh \ + run-sql-test.sh diff --git a/storage/mroonga/test/run-sql-test.sh b/storage/mroonga/test/run-sql-test.sh new file mode 100755 index 00000000..589de478 --- /dev/null +++ b/storage/mroonga/test/run-sql-test.sh @@ -0,0 +1,244 @@ +#!/bin/sh +# +# Copyright(C) 2010 Tetsuro IKEDA +# Copyright(C) 2010-2017 Kouhei Sutou <kou@clear-code.com> +# Copyright(C) 2011 Kazuhiko +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +export BASE_DIR="$(cd $(dirname $0); pwd)" +top_dir="$BASE_DIR/.." +mroonga_test_dir="${top_dir}/mysql-test/mroonga" + +n_processors=1 +case `uname` in + Linux) + n_processors="$(grep '^processor' /proc/cpuinfo | wc -l)" + ;; + Darwin) + n_processors="$(/usr/sbin/sysctl -n hw.ncpu)" + ;; + *) + : + ;; +esac + +if [ "$NO_MAKE" != "yes" ]; then + MAKE_ARGS= + if [ -n "$n_processors" ]; then + MAKE_ARGS="-j${n_processors}" + fi + make $MAKE_ARGS -C $top_dir > /dev/null || exit 1 +fi + +. "${top_dir}/config.sh" + +bundled_groonga_normalizer_mysql_dir="${top_dir}/vendor/groonga/vendor/plugins/groonga-normalizer-mysql" +if [ -d "${bundled_groonga_normalizer_mysql_dir}" ]; then + GRN_PLUGINS_DIR="${bundled_groonga_normalizer_mysql_dir}" + export GRN_PLUGINS_DIR +fi + +maria_storage_dir="${MYSQL_SOURCE_DIR}/storage/maria" +if [ -d "${maria_storage_dir}" ]; then + mariadb="yes" +else + mariadb="no" +fi +percona_udf_dir="${MYSQL_SOURCE_DIR}/plugin/percona-udf" +if [ -d "${percona_udf_dir}" ]; then + percona="yes" +else + percona="no" +fi + +source_mysql_test_dir="${MYSQL_SOURCE_DIR}/mysql-test" +build_mysql_test_dir="${MYSQL_BUILD_DIR}/mysql-test" +source_test_suites_dir="${source_mysql_test_dir}/suite" +source_test_include_dir="${source_mysql_test_dir}/include" +build_test_suites_dir="${build_mysql_test_dir}/suite" +build_test_include_dir="${build_mysql_test_dir}/include" +case "${MYSQL_VERSION}" in + 5.1.*) + plugins_dir="${MYSQL_BUILD_DIR}/lib/mysql/plugin" + if [ ! -d "${build_test_suites_dir}" ]; then + mkdir -p "${build_test_suites_dir}" + fi + ;; + *) + if [ ! -d "${build_test_suites_dir}" ]; then + ln -s "${source_test_suites_dir}" "${build_test_suites_dir}" + fi + if [ "${mariadb}" = "yes" ]; then + if [ "${MRN_BUNDLED}" != "TRUE" ]; then + mariadb_mroonga_plugin_dir="${MYSQL_BUILD_DIR}/plugin/mroonga" + if [ ! -e "${mariadb_mroonga_plugin_dir}" ]; then + ln -s "${top_dir}" "${mariadb_mroonga_plugin_dir}" + fi + fi + plugins_dir= + elif [ "${percona}" = "yes" ]; then + plugins_dir="${MYSQL_SOURCE_DIR}/lib/mysql/plugin" + else + plugins_dir="${MYSQL_SOURCE_DIR}/lib/plugin" + fi + ;; +esac + +same_link_p() +{ + src=$1 + dest=$2 + if [ -L "$dest" -a "$(readlink "$dest")" = "$src" ]; then + return 0 + else + return 1 + fi +} + +mroonga_mysql_test_suite_dir="${build_test_suites_dir}/mroonga" +if ! same_link_p "${mroonga_test_dir}" "${mroonga_mysql_test_suite_dir}"; then + rm -rf "${mroonga_mysql_test_suite_dir}" + ln -s "${mroonga_test_dir}" "${mroonga_mysql_test_suite_dir}" +fi + +innodb_test_suite_dir="${build_test_suites_dir}/innodb" +mroonga_wrapper_innodb_test_suite_name="mroonga_wrapper_innodb" +mroonga_wrapper_innodb_test_suite_dir="${build_test_suites_dir}/${mroonga_wrapper_innodb_test_suite_name}" +mroonga_wrapper_innodb_include_dir="${mroonga_wrapper_innodb_test_suite_dir}/include/" +if [ "$0" -nt "$(dirname "${mroonga_wrapper_innodb_test_suite_dir}")" ]; then + rm -rf "${mroonga_wrapper_innodb_test_suite_dir}" +fi +if [ ! -d "${mroonga_wrapper_innodb_test_suite_dir}" ]; then + cp -rp "${innodb_test_suite_dir}" "${mroonga_wrapper_innodb_test_suite_dir}" + mkdir -p "${mroonga_wrapper_innodb_include_dir}" + cp -rp "${source_test_include_dir}"/innodb[-_]*.inc \ + "${mroonga_wrapper_innodb_include_dir}" + ruby -i'' \ + -pe "\$_.gsub!(/\\bengine\\s*=\\s*innodb\\b([^;\\n]*)/i, + \"ENGINE=mroonga\\\1 COMMENT='ENGINE \\\"InnoDB\\\"'\") + \$_.gsub!(/\\b(storage_engine\\s*=\\s*)innodb\\b([^;\\n]*)/i, + \"\\\1mroonga\") + \$_.gsub!(/^(--\\s*source\\s+)(include\\/innodb)/i, + \"\\\1suite/mroonga_wrapper_innodb/\\\2\") + " \ + ${mroonga_wrapper_innodb_test_suite_dir}/r/*.result \ + ${mroonga_wrapper_innodb_test_suite_dir}/t/*.test \ + ${mroonga_wrapper_innodb_test_suite_dir}/include/*.inc + sed -i'' \ + -e '1 i --source ../mroonga/include/mroonga/have_mroonga.inc' \ + ${mroonga_wrapper_innodb_test_suite_dir}/t/*.test +fi + +all_test_suite_names="" +suite_dir="${mroonga_test_dir}/.." +cd "${suite_dir}" +suite_dir="$(pwd)" +for test_suite_name in \ + $(find mroonga -type d -name 'include' '!' -prune -o \ + -type d '!' -name 'mroonga' \ + '!' -name 'include' \ + '!' -name '[tr]'); do + if [ -n "${all_test_suite_names}" ]; then + all_test_suite_names="${all_test_suite_names}," + fi + all_test_suite_names="${all_test_suite_names}${test_suite_name}" +done +cd - + +if [ -n "${plugins_dir}" ]; then + if [ -d "${top_dir}/.libs" ]; then + make -C ${top_dir} \ + install-pluginLTLIBRARIES \ + plugindir=${plugins_dir} > /dev/null || \ + exit 1 + else + mkdir -p "${plugins_dir}" + cp "${top_dir}/ha_mroonga.so" "${plugins_dir}" || exit 1 + fi +fi + +mysql_test_run_options="" +test_suite_names="" +test_names="" +while [ $# -gt 0 ]; do + arg="$1" + shift + case "$arg" in + --manual-gdb|--gdb|--client-gdb|--boot-gdb|--debug|--valgrind) + n_processors=1 + mysql_test_run_options="${mysql_test_run_options} ${arg}" + ;; + --*) + mysql_test_run_options="${mysql_test_run_options} ${arg}" + ;; + *) + case "$arg" in + */t/*.test) + test_suite_name=$(echo "$arg" | sed -e 's,/t/.*\.test,,g') + test_suite_name=$(cd "$test_suite_name" && pwd) + test_name=$(echo "$arg" | sed -e 's,.*/t/\(.*\)\.test,\1,g') + ;; + *) + if [ -d "$arg" ]; then + test_suite_name=$(cd "$arg" && pwd) + else + test_suite_name="$arg" + fi + test_name="" + ;; + esac + + if [ -n "${test_name}" ]; then + if [ -n "${test_names}" ]; then + test_names="${test_names}|" + fi + test_names="${test_names}${test_name}" + fi + + test_suite_name=$(echo "$test_suite_name" | sed -e "s,^${suite_dir}/,,") + if echo "${test_suite_names}" | grep --quiet "${test_suite_name}"; then + continue + fi + if [ -n "${test_suite_names}" ]; then + test_suite_names="${test_suite_names}," + fi + test_suite_names="${test_suite_names}${test_suite_name}" + ;; + esac +done + +if [ -z "$test_suite_names" ]; then + test_suite_names="${all_test_suite_names}" +fi + +mysql_test_run_args="" +if [ "${percona}" != "yes" ]; then + mysql_test_run_args="${mysql_test_run_args} --mem" +fi +mysql_test_run_args="${mysql_test_run_args} --parallel=${n_processors}" +mysql_test_run_args="${mysql_test_run_args} --retry=1" +mysql_test_run_args="${mysql_test_run_args} --suite=${test_suite_names}" +mysql_test_run_args="${mysql_test_run_args} --force" +mysql_test_run_args="${mysql_test_run_args} --mysqld=--loose-plugin-load-add=ha_mroonga.so" +mysql_test_run_args="${mysql_test_run_args} --mysqld=--loose-plugin-mroonga=ON" +if [ -n "$test_names" ]; then + mysql_test_run_args="${mysql_test_run_args} --do-test=${test_names}" +fi + +(cd "$build_mysql_test_dir" && \ + perl -I . ./mysql-test-run.pl \ + ${mysql_test_run_args} \ + ${mysql_test_run_options}) diff --git a/storage/mroonga/test/run-unit-test.sh b/storage/mroonga/test/run-unit-test.sh new file mode 100755 index 00000000..6d995131 --- /dev/null +++ b/storage/mroonga/test/run-unit-test.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +export BASE_DIR="`dirname $0`" +top_dir="$BASE_DIR/.." + +if test -z "$NO_MAKE"; then + MAKE_ARGS= + case `uname` in + Linux) + MAKE_ARGS="-j$(grep '^processor' /proc/cpuinfo | wc -l)" + ;; + Darwin) + MAKE_ARGS="-j$(/usr/sbin/sysctl -n hw.ncpu)" + ;; + *) + : + ;; + esac + make $MAKE_ARGS -C $top_dir > /dev/null || exit 1 +fi + +if test -z "$CUTTER"; then + CUTTER="`make -s -C $top_dir echo-cutter`" +fi +export CUTTER + +CUTTER_ARGS= +CUTTER_WRAPPER= +if test x"$STOP" = x"yes"; then + CUTTER_ARGS="-v v --fatal-failures" +else + CUTTER_ARGS="-v v" +fi + +if test x"$CUTTER_DEBUG" = x"yes"; then + if test x"$TUI_DEBUG" = x"yes"; then + CUTTER_WRAPPER="$top_dir/libtool --mode=execute gdb --tui --args" + else + CUTTER_WRAPPER="$top_dir/libtool --mode=execute gdb --args" + fi + CUTTER_ARGS="--keep-opening-modules" +elif test x"$CUTTER_CHECK_LEAK" = x"yes"; then + CUTTER_WRAPPER="$top_dir/libtool --mode=execute valgrind " + CUTTER_WRAPPER="$CUTTER_WRAPPER --leak-check=full --show-reachable=yes -v" + CUTTER_ARGS="--keep-opening-modules" +fi + +CUTTER_ARGS="$CUTTER_ARGS -s $BASE_DIR" +$CUTTER_WRAPPER $CUTTER $CUTTER_ARGS "$@" $BASE_DIR diff --git a/storage/mroonga/test/unit/Makefile.am b/storage/mroonga/test/unit/Makefile.am new file mode 100644 index 00000000..3950ce0d --- /dev/null +++ b/storage/mroonga/test/unit/Makefile.am @@ -0,0 +1,27 @@ +if WITH_CUTTER +noinst_LTLIBRARIES = \ + test_mrn_path_mapper.la +endif + +AM_CPPFLAGS = \ + $(GROONGA_CFLAGS) \ + $(CPPCUTTER_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lib + +AM_LDFLAGS = \ + -module \ + -rpath $(libdir) \ + -avoid-version \ + -no-undefined + +LIBS = \ + $(CPPCUTTER_LIBS) \ + $(GROONGA_LIBS) \ + $(MECAB_LIBS) + +test_mrn_path_mapper_la_SOURCES = \ + test_mrn_path_mapper.cpp + +test_mrn_path_mapper_la_LIBADD = \ + $(top_builddir)/lib/libmrn_no_mysql.la diff --git a/storage/mroonga/test/unit/test_mrn_path_mapper.cpp b/storage/mroonga/test/unit/test_mrn_path_mapper.cpp new file mode 100644 index 00000000..3ede8726 --- /dev/null +++ b/storage/mroonga/test/unit/test_mrn_path_mapper.cpp @@ -0,0 +1,134 @@ +/* -*- c-basic-offset: 2 -*- */ +/* + Copyright(C) 2012-2015 Kouhei Sutou <kou@clear-code.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA +*/ + +#include <string.h> +#include <cppcutter.h> + +#include <mrn_path_mapper.hpp> + +namespace test_mrn_path_mapper { + namespace db_path { + namespace without_prefix { + void test_normal_db() { + mrn::PathMapper mapper("./db/", NULL); + cppcut_assert_equal("db.mrn", mapper.db_path()); + } + + void test_normal_table() { + mrn::PathMapper mapper("./db/table", NULL); + cppcut_assert_equal("db.mrn", mapper.db_path()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); + cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0.mrn", + mapper.db_path()); + } + } + + namespace with_prefix { + void test_normal_db() { + mrn::PathMapper mapper("./db/", "mroonga.data/"); + cppcut_assert_equal("mroonga.data/db.mrn", mapper.db_path()); + } + + void test_normal_table() { + mrn::PathMapper mapper("./db/table", "mroonga.data/"); + cppcut_assert_equal("mroonga.data/db.mrn", mapper.db_path()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", "mroonga.data/"); + cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0.mrn", + mapper.db_path()); + } + } + } + + namespace db_name { + void test_normal_db() { + mrn::PathMapper mapper("./db/", NULL); + cppcut_assert_equal("db", mapper.db_name()); + } + + void test_normal_table() { + mrn::PathMapper mapper("./db/table", NULL); + cppcut_assert_equal("db", mapper.db_name()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); + cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0", + mapper.db_name()); + } + } + + namespace table_name { + void test_normal_table() { + mrn::PathMapper mapper("./db/table", NULL); + cppcut_assert_equal("table", mapper.table_name()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); + cppcut_assert_equal("#sql27c5_1_0", mapper.table_name()); + } + + void test_underscore_start_table() { + mrn::PathMapper mapper("./db/_table", NULL); + cppcut_assert_equal("@005ftable", mapper.table_name()); + } + } + + namespace mysql_table_name { + void test_normal_table() { + mrn::PathMapper mapper("./db/table", NULL); + cppcut_assert_equal("table", mapper.mysql_table_name()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0", NULL); + cppcut_assert_equal("#sql27c5_1_0", mapper.mysql_table_name()); + } + + void test_underscore_start_table() { + mrn::PathMapper mapper("./db/_table", NULL); + cppcut_assert_equal("_table", mapper.mysql_table_name()); + } + } + + namespace mysql_path { + void test_normal_table() { + mrn::PathMapper mapper("./db/table"); + cppcut_assert_equal("./db/table", mapper.mysql_path()); + } + + void test_temporary_table() { + mrn::PathMapper mapper("/tmp/mysqld.1/#sql27c5_1_0"); + cppcut_assert_equal("/tmp/mysqld.1/#sql27c5_1_0", + mapper.mysql_path()); + } + + void test_partition_table_path() { + mrn::PathMapper mapper("./db/table#P#p1"); + cppcut_assert_equal("./db/table", mapper.mysql_path()); + } + } +} + |