Skip to content

Commit

Permalink
add external test deps to the main repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mirostauder committed Oct 31, 2023
1 parent 8ade3a6 commit 01586df
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 84 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
48 changes: 48 additions & 0 deletions test/deps/Makefile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/deps/mariadb-connector-c/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions test/deps/mariadb-connector-c/ConnectorName.cmake.patch
Original file line number Diff line number Diff line change
@@ -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}")
1 change: 1 addition & 0 deletions test/deps/mariadb-connector-c/mariadb-connector-c
Binary file not shown.
16 changes: 16 additions & 0 deletions test/deps/mysql-connector-c/CMakeLists.txt.patch
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions test/deps/mysql-connector-c/install_macros.cmake.patch
Original file line number Diff line number Diff line change
@@ -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()

1 change: 1 addition & 0 deletions test/deps/mysql-connector-c/mysql-connector-c
Binary file not shown.
17 changes: 14 additions & 3 deletions test/tap/tap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ endif
OPT := $(STDCPP) -O2 -ggdb -Wl,--no-as-needed


### main targets

.PHONY: default
default: all

Expand 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)

Expand All @@ -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* .

Expand Down Expand Up @@ -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
36 changes: 25 additions & 11 deletions test/tap/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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 $@
Expand All @@ -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
Loading

0 comments on commit 01586df

Please sign in to comment.