diff --git a/.gitignore b/.gitignore index 3647d93615..59fa167ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,10 @@ heaptrack.* #vscode .vscode/ +# test deps +test/deps/mariadb-connector-c/mariadb-connector-c-*/ +test/deps/mysql-connector-c/mysql-connector-c-*src/ + #tap tests test/tap/tap/cpp-dotenv/cpp-dotenv-* test/tap/tap/cpp-dotenv/static/cpp-dotenv-* diff --git a/Makefile b/Makefile index 25b018815e..ba7ec9fcc8 100644 --- a/Makefile +++ b/Makefile @@ -297,6 +297,7 @@ clean: cd lib && ${MAKE} clean cd src && ${MAKE} clean cd test/tap && ${MAKE} clean + rm -f pkgroot || true .PHONY: cleanall cleanall: @@ -307,6 +308,7 @@ cleanall: rm -f binaries/*deb || true rm -f binaries/*rpm || true rm -f binaries/*id-hash || true + rm -rf pkgroot || true .PHONY: cleanbuild cleanbuild: diff --git a/test/deps/Makefile b/test/deps/Makefile new file mode 100644 index 0000000000..188f37fe58 --- /dev/null +++ b/test/deps/Makefile @@ -0,0 +1,48 @@ +#!/bin/make -f + + +targets := mariadb_client mysql_client + +.PHONY: default +default: $(targets) + + +### test deps targets + +mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a: + cd mariadb-connector-c && rm -rf mariadb-connector-c-*/ || true + cd mariadb-connector-c && tar -zxf mariadb-connector-c-*.tar.gz + cd mariadb-connector-c/mariadb-connector-c && patch -p0 < ../CMakeLists.txt.patch + cd mariadb-connector-c/mariadb-connector-c && patch -p0 < ../ConnectorName.cmake.patch + cd mariadb-connector-c/mariadb-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl/ + cd mariadb-connector-c/mariadb-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mariadbclient + +mariadb_client: mariadb-connector-c/mariadb-connector-c/libmariadb/libmariadbclient.a + + +mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a: + cd mysql-connector-c && rm -rf mysql-connector-c-*-src/ || true + cd mysql-connector-c && tar -zxf mysql-connector-c-*-src.tar.gz + cd mysql-connector-c/mysql-connector-c && patch -p0 < ../CMakeLists.txt.patch + cd mysql-connector-c/mysql-connector-c && patch -p0 < ../install_macros.cmake.patch + cd mysql-connector-c/mysql-connector-c && cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(DEPS_PATH)/libssl/openssl + cd mysql-connector-c/mysql-connector-c && CC=${CC} CXX=${CXX} ${MAKE} mysqlclient + +mysql_client: mysql-connector-c/mysql-connector-c/libmysql/libmysqlclient.a + + +### clean targets + +.SILENT: cleanall +.PHONY: cleanall +cleanall: + cd mariadb-connector-c && rm -rf mariadb-connector-c-*/ || true + cd mysql-connector-c && rm -rf mysql-connector-c-*-src/ || true + +.SILENT: clean +.PHONY: clean +clean: + cd mariadb-connector-c/mariadb-connector-c && $(MAKE) clean || true + cd mariadb-connector-c/mariadb-connector-c && rm -f CMakeCache.txt + cd mysql-connector-c/mysql-connector-c && $(MAKE) clean || true + cd mysql-connector-c/mysql-connector-c && rm -f CMakeCache.txt diff --git a/test/deps/mariadb-connector-c/CMakeLists.txt.patch b/test/deps/mariadb-connector-c/CMakeLists.txt.patch new file mode 100644 index 0000000000..de55d09ad8 --- /dev/null +++ b/test/deps/mariadb-connector-c/CMakeLists.txt.patch @@ -0,0 +1,13 @@ +--- ./CMakeLists.txt 2020-02-27 15:01:10.993225716 +0100 ++++ ./CMakeLists.txt 2020-02-27 15:00:57.705257256 +0100 +@@ -132,8 +132,8 @@ + # Disable dbug information for release builds + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") +-SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") +-SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") ++SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF -ggdb -O0") ++SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF -ggdb -O0") + + IF(CMAKE_COMPILER_IS_GNUCC) + INCLUDE(CheckCCompilerFlag) diff --git a/test/deps/mariadb-connector-c/ConnectorName.cmake.patch b/test/deps/mariadb-connector-c/ConnectorName.cmake.patch new file mode 100644 index 0000000000..5aa3e9666d --- /dev/null +++ b/test/deps/mariadb-connector-c/ConnectorName.cmake.patch @@ -0,0 +1,11 @@ +--- cmake/ConnectorName.cmake 2020-10-29 22:16:20.000000000 +0000 ++++ cmake/ConnectorName.cmake 2022-11-06 08:31:22.615513943 +0000 +@@ -22,7 +22,7 @@ + SET(MACHINE_NAME "x64") + ELSE() + SET(MACHINE_NAME "32") +- END() ++ ENDIF() + ENDIF() + + SET(product_name "mysql-connector-c-${CPACK_PACKAGE_VERSION}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}") diff --git a/test/deps/mariadb-connector-c/mariadb-connector-c b/test/deps/mariadb-connector-c/mariadb-connector-c new file mode 120000 index 0000000000..a92e60f909 --- /dev/null +++ b/test/deps/mariadb-connector-c/mariadb-connector-c @@ -0,0 +1 @@ +mariadb-connector-c-3.1.9 \ No newline at end of file diff --git a/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz b/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz new file mode 100644 index 0000000000..6af78adefc Binary files /dev/null and b/test/deps/mariadb-connector-c/mariadb-connector-c-3.1.9.tar.gz differ diff --git a/test/deps/mysql-connector-c/CMakeLists.txt.patch b/test/deps/mysql-connector-c/CMakeLists.txt.patch new file mode 100644 index 0000000000..e1e614370c --- /dev/null +++ b/test/deps/mysql-connector-c/CMakeLists.txt.patch @@ -0,0 +1,16 @@ +--- ./CMakeLists.txt 2017-07-13 06:55:32.000000000 +0000 ++++ ./CMakeLists.txt 2023-10-30 15:24:21.614898571 +0000 +@@ -262,11 +262,11 @@ + SET(CMAKE_C_FLAGS_DEBUG + "${CMAKE_C_FLAGS_DEBUG} ${SAN_OPT} -O1 -Wno-error -fPIC") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO +- "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${SAN_OPT} -fPIC") ++ "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${SAN_OPT} -O0 -ggdb -fPIC") + SET(CMAKE_CXX_FLAGS_DEBUG + "${CMAKE_CXX_FLAGS_DEBUG} ${SAN_OPT} -O1 -Wno-error -fPIC") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO +- "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SAN_OPT} -fPIC") ++ "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SAN_OPT} -O0 -ggdb -fPIC") + SET(${RESULT} 1) + ELSE() + SET(${RESULT} 0) diff --git a/test/deps/mysql-connector-c/install_macros.cmake.patch b/test/deps/mysql-connector-c/install_macros.cmake.patch new file mode 100644 index 0000000000..f6712d89f0 --- /dev/null +++ b/test/deps/mysql-connector-c/install_macros.cmake.patch @@ -0,0 +1,13 @@ +--- cmake/install_macros.cmake 2017-07-13 06:55:32.000000000 +0000 ++++ cmake/install_macros.cmake 2023-10-30 14:41:22.788965914 +0000 +@@ -362,8 +362,8 @@ + CONFIGURATIONS Release RelWithDebInfo + COMPONENT ${ARG_COMPONENT} + OPTIONAL) +- ENDIF() +- ENDFOREACH() ++ ENDFOREACH() ++ ENDIF() + + ENDFUNCTION() + diff --git a/test/deps/mysql-connector-c/mysql-connector-c b/test/deps/mysql-connector-c/mysql-connector-c new file mode 120000 index 0000000000..22d58ed556 --- /dev/null +++ b/test/deps/mysql-connector-c/mysql-connector-c @@ -0,0 +1 @@ +mysql-connector-c-6.1.11-src \ No newline at end of file diff --git a/test/deps/mysql-connector-c/mysql-connector-c-6.1.11-src.tar.gz b/test/deps/mysql-connector-c/mysql-connector-c-6.1.11-src.tar.gz new file mode 100644 index 0000000000..acac56280a Binary files /dev/null and b/test/deps/mysql-connector-c/mysql-connector-c-6.1.11-src.tar.gz differ diff --git a/test/tap/tap/Makefile b/test/tap/tap/Makefile index 4d51e0332f..2d2f1af58d 100644 --- a/test/tap/tap/Makefile +++ b/test/tap/tap/Makefile @@ -55,6 +55,8 @@ endif OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed +### main targets + .PHONY: default default: all @@ -65,6 +67,8 @@ debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WASAN) debug: libtap.a libtap.so +### helper targets + command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so g++ -fPIC -c command_line.cpp $(IDIRS) $(OPT) @@ -80,6 +84,9 @@ libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h tap.o libtap.so: libtap.a cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so gcc -shared -o libtap.so -Wl,--whole-archive libtap.a ../../../deps/curl/curl/lib/.libs/libcurl.a ../../../deps/libssl/openssl/libcrypto.a ../../../deps/libssl/openssl/libssl.a -Wl,--no-whole-archive + +### tap deps targets + libssl.so.3: $(DEPS_PATH)/libssl/openssl/libssl.so.3 cp -a $(DEPS_PATH)/libssl/openssl/libssl.so* . @@ -109,8 +116,12 @@ cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so: cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE} +### clean targets + +.SILENT: clean .PHONY: clean clean: - rm -f *.o libtap.a libtap.so || true - find cpp-dotenv/dynamic -name '*.o' -or -name '*.a' -delete || true - find cpp-dotenv/static -name '*.o' -or -name '*.a' -delete || true + find . -name '*.a' -delete || true + find . -name '*.o' -delete || true + find . -name '*.so' -delete || true + find . -name '*.so.*' -delete || true diff --git a/test/tap/tests/Makefile b/test/tap/tests/Makefile index 2df12e4d4b..3e3226b304 100644 --- a/test/tap/tests/Makefile +++ b/test/tap/tests/Makefile @@ -82,11 +82,21 @@ TAP_PATH := ../tap TAP_IDIR := ../tap TAP_LDIR := ../tap -DOTENV_DYN_DIR := ../tap/cpp-dotenv/dynamic/cpp-dotenv -DOTENV_DYN_IDIR := $(DOTENV_DYN_DIR)/include -#DOTENV_DYN_LDIR := $(DOTENV_DYN_DIR) +DOTENV_DYN_PATH := $(TAP_LDIR)/cpp-dotenv/dynamic/cpp-dotenv +DOTENV_DYN_IDIR := $(DOTENV_DYN_PATH)/include +#DOTENV_DYN_LDIR := $(DOTENV_DYN_PATH) DOTENV_DYN_LDIR := $(TAP_LDIR) +TEST_DEPS_PATH := $(PROXYSQL_PATH)/test/deps + +TEST_MARIADB_PATH := $(TEST_DEPS_PATH)/mariadb-connector-c/mariadb-connector-c +TEST_MARIADB_IDIR := $(TEST_MARIADB_PATH)/include +TEST_MARIADB_LDIR := $(TEST_MARIADB_PATH)/libmariadb + +TEST_MYSQL_PATH := $(TEST_DEPS_PATH)/mysql-connector-c/mysql-connector-c +TEST_MYSQL_IDIR := $(TEST_MYSQL_PATH)/include +TEST_MYSQL_LDIR := $(TEST_MYSQL_PATH)/libmysql + LIBPROXYSQLAR := $(PROXYSQL_LDIR)/libproxysql.a ODIR := $(PROXYSQL_PATH)//obj @@ -139,7 +149,7 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address -DTEST_WITHASAN endif -OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WGCOV) -DGITVERSION=\"$(GIT_VERSION)\" +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) -DGITVERSION=\"$(GIT_VERSION)\" ### main targets @@ -150,7 +160,7 @@ default: all .PHONY: all all: tests -debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) -DGITVERSION=\"$(GIT_VERSION)\" debug: tests tests: tests-cpp tests-php tests-py \ @@ -242,22 +252,22 @@ reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cp $(CXX) $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp $(TAP_LDIR)/libtap.so - $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + $(CXX) -DLIBMYSQL_HELPER $< -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp $(TAP_LDIR)/libtap.so - $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + $(CXX) -DLIBMYSQL_HELPER $< -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp $(TAP_LDIR)/libtap.so - $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + $(CXX) -DLIBMYSQL_HELPER $< -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so - $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + $(CXX) -DLIBMYSQL_HELPER $< -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LDIR)/libtap.so $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so - $(CXX) -DLIBMYSQL_HELPER $< -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o $@ + $(CXX) -DLIBMYSQL_HELPER $< -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(CUSTOMARGS) -o $@ prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LDIR)/libtap.so $(CXX) -DASYNC_API $< $(IDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@ @@ -268,6 +278,10 @@ test_wexecvp_syscall_failures-t: test_wexecvp_syscall_failures-t.cpp $(TAP_LDIR) ### clean targets +.SILENT: clean .PHONY: clean clean: - rm -f *-t galera_1_timeout_count galera_2_timeout_no_count aurora generate_set_session_csv set_testing-240.csv clickhouse_php_conn-t reg_test_3992_fast_forward_malformed_packet-pymysql-t || true + rm -f *-t || true + rm -f galera_1_timeout_count galera_2_timeout_no_count aurora || true + rm -f generate_set_session_csv set_testing-240.csv || true + rm -f *.gcda *.gcno || true diff --git a/test/tap/tests_with_deps/deprecate_eof_support/Makefile b/test/tap/tests_with_deps/deprecate_eof_support/Makefile index 638fc9d6fb..13138a1360 100644 --- a/test/tap/tests_with_deps/deprecate_eof_support/Makefile +++ b/test/tap/tests_with_deps/deprecate_eof_support/Makefile @@ -1,22 +1,6 @@ #!/bin/make -f -TEST_DEPS_PATH ?= /var/lib/jenkins/scripts/test-scripts/deps - -MARIADB_BASE_FOLDER := $(TEST_DEPS_PATH)/mariadb-client-library-3.1.9/ -MARIADB_TEST_DEP := $(TEST_DEPS_PATH)/mariadb-client-library-3.1.9/mariadb-connector-c - -BASE_DIR_EXIST := $(shell if [ -d $(MARIADB_BASE_FOLDER) ]; then echo 1; else echo 0; fi) -DEP_FOLDER_EMPTY := $(shell if [ -f $(MARIADB_TEST_DEP)/CMakeLists.txt ]; then echo 1; else echo 0; fi) - - -ifeq ($(BASE_DIR_EXIST),1) - -ifeq ($(DEP_FOLDER_EMPTY),0) -$(error "Dependency folder '$(MARIADB_TEST_DEP)' is empty. Make sure folder is initialized.") -endif - - GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION $(error GIT_VERSION is not set) @@ -36,6 +20,16 @@ TAP_PATH := ../../tap TAP_IDIR := $(TAP_PATH) TAP_LDIR := $(TAP_PATH) +TEST_DEPS_PATH := $(PROXYSQL_PATH)/test/deps + +TEST_MARIADB_PATH := $(TEST_DEPS_PATH)/mariadb-connector-c/mariadb-connector-c +TEST_MARIADB_IDIR := $(TEST_MARIADB_PATH)/include +TEST_MARIADB_LDIR := $(TEST_MARIADB_PATH)/libmariadb + +TEST_MYSQL_PATH := $(TEST_DEPS_PATH)/mysql-connector-c/mysql-connector-c +TEST_MYSQL_IDIR := $(TEST_MYSQL_PATH)/include +TEST_MYSQL_LDIR := $(TEST_MYSQL_PATH)/libmysql + ### detect compiler support for c++11/17 CPLUSPLUS := $(shell ${CC} -std=c++17 -dM -E -x c++ /dev/null 2>/dev/null | grep -F __cplusplus | grep -Po '\d\d\d\d\d\dL') ifneq ($(CPLUSPLUS),201703L) @@ -56,7 +50,7 @@ ifeq ($(WITHASAN),1) WASAN := -fsanitize=address endif -OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed $(WGCOV) +OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) IDIRS := -I$(PROXYSQL_PATH)/include IDIRS += -I$(DEPS_PATH)/sqlite3/sqlite3 @@ -69,91 +63,85 @@ IDIRS += -I$(DEPS_PATH)/libhttpserver/libhttpserver/src IDIRS += -I$(DEPS_PATH)/libmicrohttpd/libmicrohttpd/src/include/ IDIRS += -I$(DEPS_PATH)/re2/re2 IDIRS += -I$(DEPS_PATH)/libev/libev -IDIRS += -I$(MARIADB_TEST_DEP)/include +IDIRS += -I$(DEPS_PATH)/curl/curl/include -TESTS_DEPS := $(TAP_LDIR)/libtap.so $(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a +### main targets .PHONY: default default: all .PHONY: all -all: build_deps tests +all: build_test_deps tests .PHONY: debug debug: DEBUG := -DDEBUG -debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed $(WGCOV) $(WASAN) -debug: build_deps tests +debug: OPT := $(STDCPP) -O0 -DDEBUG -ggdb -Wl,--no-as-needed -Wl,-rpath,$(TAP_LDIR) $(WGCOV) $(WASAN) +debug: build_test_deps tests -$(MARIADB_TEST_DEP)/libmariadb/libmariadbclient.a: - cd $(MARIADB_BASE_FOLDER) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client +### test deps targets -.PHONY: build_deps -build_deps: $(TESTS_DEPS) +build_test_deps: $(TAP_LDIR)/libtap.so $(TEST_MARIADB_LDIR)/libmariadbclient.a $(TEST_MYSQL_LDIR)/libmysqlclient.a +$(TAP_LDIR)/libtap.so: + cd $(TAP_PATH) && CC=${CC} CXX=${CXX} ${MAKE} -tests: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) fwd_eof_query fwd_eof_ok_query +$(TEST_MARIADB_LDIR)/libmariadbclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mariadb_client +$(TEST_MYSQL_LDIR)/libmysqlclient.a: + cd $(TEST_DEPS_PATH) && CC=${CC} CXX=${CXX} ${MAKE} mysql_client -COMMONARGS := $(OPT) -I$(TAP_IDIR) -L$(TAP_LDIR) -ltap -lcpp_dotenv -Wl,--no-as-needed -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" -ok_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) $(COMMONARGS) -o $@ +### test and helper targets -eof_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp $(TESTS_DEPS) - $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +tests: $(patsubst %.cpp,%,$(wildcard *-t.cpp)) fwd_eof_query fwd_eof_ok_query -fwd_eof_query: fwd_eof_query.cpp $(TESTS_DEPS) - $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +COMMONARGS := $(OPT) -I$(TAP_IDIR) -L$(TAP_LDIR) -ltap -lcpp_dotenv -lz -ldl -lpthread -DGITVERSION=\"$(GIT_VERSION)\" -# NOTE: Compilation with 'libmysql' instead of 'libmariadb' client to confirm packet sequence id isn't check by 'libmariadb' -fwd_eof_ok_query: fwd_eof_query.cpp $(TAP_LDIR)/libtap.so - $(CXX) $< $(IDIRS) -I$(MARIADB_IDIR) -I/usr/include/mysql/ -lmysqlclient -L/usr/lib/x86_64-linux-gnu/ $(COMMONARGS) -o $@ -# NOTE end +ok_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -deprecate_eof_cache-t: deprecate_eof_cache-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient -L$(PROXYSQL_LDIR) -lproxysql $(COMMONARGS) -o $@ +eof_packet_mixed_queries-t: eof_packet_mixed_queries-t.cpp build_test_deps + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_cache_mixed_flags-t: eof_cache_mixed_flags-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +fwd_eof_query: fwd_eof_query.cpp build_test_deps + $(CXX) -DNON_EOF_SUPPORT $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -eof_mixed_flags_queries-t: eof_mixed_flags_queries-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +# NOTE: Compilation with 'libmysql' instead of 'libmariadb' client to confirm packet sequence id isn't check by 'libmariadb' +fwd_eof_ok_query: fwd_eof_query.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(MARIADB_IDIR) -I$(TEST_MYSQL_IDIR) -L$(TEST_MYSQL_LDIR) -lmysqlclient $(COMMONARGS) -o $@ +# NOTE end -eof_conn_options_check-t: eof_conn_options_check-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +deprecate_eof_cache-t: deprecate_eof_cache-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient -L$(PROXYSQL_LDIR) -lproxysql $(COMMONARGS) -o $@ -eof_fast_forward-t: eof_fast_forward-t.cpp $(TESTS_DEPS) - $(CXX) $< $(IDIRS) -L$(MARIADB_TEST_DEP)/libmariadb -lmariadbclient $(COMMONARGS) -o $@ +eof_cache_mixed_flags-t: eof_cache_mixed_flags-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ +eof_mixed_flags_queries-t: eof_mixed_flags_queries-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -$(TAP_LIBDIR)/libtap.a: - cd ../../tap && CC=${CC} CXX=${CXX} ${MAKE} +eof_conn_options_check-t: eof_conn_options_check-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ +eof_fast_forward-t: eof_fast_forward-t.cpp build_test_deps + $(CXX) $< $(IDIRS) -I$(TEST_MARIADB_IDIR) -L$(TEST_MARIADB_LDIR) -lmariadbclient $(COMMONARGS) -o $@ -.PHONY: clean -clean: - rm -f *-t - rm -f fwd_eof_query - rm -f fwd_eof_ok_query - rm -f *.a *.o - cd $(MARIADB_BASE_FOLDER) && ${MAKE} clean +### clean targets -else -.PHONY: all -all: -$(warning The required deps were not found. Tests 'deprecate_eof_support' wont be build) - -.PHONY: debug -debug: -$(warning The required deps were not found. Tests 'deprecate_eof_support' wont be build) +.SILENT: cleanall +.PHONY: cleanall +cleanall: clean + cd $(TEST_DEPS_PATH) && ${MAKE} cleanall +.SILENT: clean .PHONY: clean clean: - rm -f *-t - rm -f fwd_eof_query - rm -f fwd_eof_ok_query - rm -f *.a *.o -endif + rm -f *-t || true + rm -f fwd_eof_query || true + rm -f fwd_eof_ok_query || true + rm -f *.a *.o || true + rm -f *.gcda *.gcno || true