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 30, 2023
1 parent 8ade3a6 commit 0a16a9c
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 69 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.
10 changes: 10 additions & 0 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,6 +116,9 @@ 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
Expand Down
6 changes: 5 additions & 1 deletion test/tap/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,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
124 changes: 56 additions & 68 deletions test/tap/tests_with_deps/deprecate_eof_support/Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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: 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

0 comments on commit 0a16a9c

Please sign in to comment.