Skip to content

Commit 1f432c8

Browse files
authored
Merge pull request #7235 from FirebirdSQL/work/boost-test
Unit tests (start) with Boost.Test and build improvements
2 parents 1ecb9d7 + 30ff90b commit 1f432c8

File tree

2,679 files changed

+600494
-1517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,679 files changed

+600494
-1517
lines changed

.github/workflows/main.yml

Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
run: |
5959
CC=clang CXX=clang++ ./autogen.sh --enable-binreloc --prefix=/opt/firebird
6060
make -j4
61+
make tests -j4
62+
make run_tests
6163
make dist
6264
tar xzvf gen/Firebird-[0-9]*.tar.gz
6365
(cd Firebird-[0-9]*; sudo ./install.sh -silent)
@@ -82,54 +84,114 @@ jobs:
8284
run: |
8385
./autogen.sh --enable-binreloc-threads --with-builtin-tommath --with-builtin-tomcrypt --prefix=/opt/firebird
8486
make -j4
87+
make tests -j4
88+
make run_tests
8589
make dist
8690
tar xzvf gen/Firebird-[0-9]*.tar.gz
8791
88-
- name: Prepare (MacOS)
92+
- name: Prepare - Install tools (MacOS)
8993
if: matrix.os == 'macOS-latest'
9094
run: |
91-
brew install automake libtool
92-
export LIBTOOLIZE=glibtoolize
93-
export LIBTOOL=glibtool
95+
brew install automake libtool ninja
96+
97+
- name: Cache - libc++ install (MacOS)
98+
id: cache-libcxx-install-macos
99+
if: matrix.os == 'macOS-latest'
100+
uses: actions/cache@v3
101+
with:
102+
key: ${{ runner.os }}-libcxx-install-13.0.1
103+
path: |
104+
extern/libcxx-macos-install
105+
106+
- name: Download libc++ sources (MacOS)
107+
if: matrix.os == 'macOS-latest' && steps.cache-libcxx-install-macos.outputs.cache-hit != 'true'
108+
run: |
109+
mkdir extern/libcxx-macos
110+
pushd extern/libcxx-macos
111+
curl -OL https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/llvm-project-13.0.1.src.tar.xz
112+
tar xJf llvm-project-13.0.1.src.tar.xz
113+
popd
114+
115+
- name: Build libc++ (MacOS)
116+
if: matrix.os == 'macOS-latest' && steps.cache-libcxx-install-macos.outputs.cache-hit != 'true'
117+
run: |
118+
LIBCXX_BUILD_PATH=`pwd`/extern/libcxx-macos-build
119+
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
120+
mkdir $LIBCXX_BUILD_PATH
121+
pushd extern/libcxx-macos/llvm-project-13.0.1.src
122+
export MACOSX_DEPLOYMENT_TARGET=10.9
123+
cmake -G Ninja -S llvm -B $LIBCXX_BUILD_PATH \
124+
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
125+
-DCMAKE_INSTALL_PREFIX=$LIBCXX_INSTALL_PATH \
126+
-DCMAKE_BUILD_TYPE=Release \
127+
-DLIBCXX_ENABLE_SHARED=false \
128+
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=true
129+
ninja -C $LIBCXX_BUILD_PATH cxx cxxabi
130+
ninja -C $LIBCXX_BUILD_PATH install-cxx install-cxxabi
131+
popd
132+
133+
- name: Cache - libicu install (MacOS)
134+
id: cache-libicu-install-macos
135+
if: matrix.os == 'macOS-latest'
136+
uses: actions/cache@v3
137+
with:
138+
key: ${{ runner.os }}-libicu-install-63.2
139+
path: |
140+
extern/libicu-macos-install
94141
95-
mkdir extern/icu-macos
96-
pushd extern/icu-macos
142+
- name: Download and patch libicu sources (MacOS)
143+
if: matrix.os == 'macOS-latest' && steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
144+
run: |
145+
mkdir extern/libicu-macos
146+
pushd extern/libicu-macos
97147
curl -OL https://github.com/unicode-org/icu/releases/download/release-63-2/icu4c-63_2-src.tgz
98148
curl -OL https://github.com/unicode-org/icu/commit/24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
99149
tar xzf icu4c-63_2-src.tgz
100-
ICU_INSTALL_PATH=`pwd`/install
101150
cd icu/source
102151
patch -p3 < ../../24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
103-
./runConfigureICU MacOSX --prefix=$ICU_INSTALL_PATH
152+
popd
153+
154+
- name: Build libicu (MacOS)
155+
if: matrix.os == 'macOS-latest' && steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
156+
run: |
157+
export LIBTOOLIZE=glibtoolize
158+
export LIBTOOL=glibtool
159+
160+
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
161+
pushd extern/libicu-macos/icu/source
162+
./runConfigureICU MacOSX --prefix=$LIBICU_INSTALL_PATH
104163
make -j4
105164
make install
106-
install_name_tool -id @rpath/lib/libicuuc.dylib $ICU_INSTALL_PATH/lib/libicuuc.dylib
107-
install_name_tool -id @rpath/lib/libicui18n.dylib $ICU_INSTALL_PATH/lib/libicui18n.dylib
108-
install_name_tool -id @rpath/lib/libicudata.dylib $ICU_INSTALL_PATH/lib/libicudata.dylib
109-
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $ICU_INSTALL_PATH/lib/libicuuc.63.dylib
110-
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $ICU_INSTALL_PATH/lib/libicui18n.63.dylib
111-
install_name_tool -change libicuuc.63.dylib @loader_path/libicuuc.63.dylib $ICU_INSTALL_PATH/lib/libicui18n.63.dylib
165+
install_name_tool -id @rpath/lib/libicuuc.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.dylib
166+
install_name_tool -id @rpath/lib/libicui18n.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.dylib
167+
install_name_tool -id @rpath/lib/libicudata.dylib $LIBICU_INSTALL_PATH/lib/libicudata.dylib
168+
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.63.dylib
169+
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
170+
install_name_tool -change libicuuc.63.dylib @loader_path/libicuuc.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
112171
popd
113-
mkdir -p gen/Release/firebird/lib
114-
mkdir -p gen/Debug/firebird/lib
115-
cp -R $ICU_INSTALL_PATH/lib/libicu{data,i18n,uc}.*dylib gen/Release/firebird/lib/
116-
cp -R $ICU_INSTALL_PATH/lib/libicu{data,i18n,uc}.*dylib gen/Debug/firebird/lib/
117172
118173
- name: Build (MacOS)
119174
if: matrix.os == 'macOS-latest'
120175
run: |
121176
export LIBTOOLIZE=glibtoolize
122177
export LIBTOOL=glibtool
123178
124-
ICU_INSTALL_PATH=`pwd`/extern/icu-macos/install
179+
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
180+
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
181+
182+
mkdir -p gen/Release/firebird/lib
183+
cp -R $LIBICU_INSTALL_PATH/lib/libicu{data,i18n,uc}.*dylib gen/Release/firebird/lib/
125184
126-
export C_INCLUDE_PATH="$ICU_INSTALL_PATH/include:$C_INCLUDE_PATH"
127-
export CPLUS_INCLUDE_PATH="$ICU_INSTALL_PATH/include:$CPLUS_INCLUDE_PATH"
185+
export C_INCLUDE_PATH="$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
186+
export CPLUS_INCLUDE_PATH="$LIBCXX_INSTALL_PATH/include/c++/v1:$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
187+
export LIBRARY_PATH="$LIBCXX_INSTALL_PATH/lib:$LIBICU_INSTALL_PATH/lib:$LIBRARY_PATH"
128188
129-
LIBRARY_PATH="$ICU_INSTALL_PATH/lib:$LIBRARY_PATH" ./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt
189+
./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt
130190
make -j4
191+
make tests -j4
192+
make run_tests
131193
132-
(cd gen; make -B -f make.platform.postfix ICU_LOC="$ICU_INSTALL_PATH/lib/")
194+
(cd gen; make -B -f make.platform.postfix ICU_LOC="$LIBICU_INSTALL_PATH/lib/")
133195
(cd gen; make -B -f Makefile.install)
134196
135197
# Rename directory to make sure the build is relocatable.
@@ -166,7 +228,8 @@ jobs:
166228
if "%PLATFORM%" == "x86" set FB_OUTPUT_SUFFIX=win32
167229
call "%VS_SCRIPT%" -arch=%FB_VS_ARCH%
168230
cd builds\win32
169-
run_all.bat JUSTBUILD
231+
call run_all.bat JUSTBUILD
232+
call run_tests.bat
170233
171234
- name: Build (Windows, Docker)
172235
if: startsWith(matrix.os, 'windows-') && matrix.docker

builds/docker/linux/i586-x86_64/scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ sed -i 's/AC_CHECK_LIB(atomic, main)/AC_CHECK_LIB(:libatomic.a, main)/g' configu
55

66
./autogen.sh --build=$BUILD_ARCH --prefix=/opt/firebird --enable-binreloc --with-builtin-tomcrypt --with-termlib=:libncurses.a
77
make -j${CPUCOUNT}
8+
make tests -j${CPUCOUNT}
9+
make run_tests
810
make dist

builds/docker/windows/scripts/build-x64.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ cd /d C:\firebird-build\builds\win32
1111
REM call run_all.bat
1212
call run_all.bat JUSTBUILD
1313

14+
call run_tests.bat
15+
1416
xcopy /h /e /i /q C:\firebird-build\output_%FB_OUTPUT_SUFFIX%\* C:\firebird-out

builds/docker/windows/scripts/build-x86.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ cd /d C:\firebird-build\builds\win32
1111
REM call run_all.bat
1212
call run_all.bat JUSTBUILD
1313

14+
call run_tests.bat
15+
1416
xcopy /h /e /i /q C:\firebird-build\output_%FB_OUTPUT_SUFFIX%\* C:\firebird-out

builds/posix/Makefile.in

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ $(COMMON_LIB): $(Common_Objects)
361361
-$(RM) $@
362362
$(STATICLIB_LINK) $@ $^
363363

364+
$(COMMON_TEST): $(Common_Test_Objects) $(COMMON_LIB)
365+
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
364366

365367
#___________________________________________________________________________
366368
# gpre_boot
@@ -369,7 +371,7 @@ $(COMMON_LIB): $(Common_Objects)
369371
boot: $(GPRE_BOOT)
370372

371373
$(GPRE_BOOT): $(GPRE_Boot_Objects) $(COMMON_LIB)
372-
$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
374+
$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
373375
-$(RM) $(GPRE_CURRENT)
374376
(cd $(@D); $(LN) $(@F) $(notdir $(GPRE_CURRENT)))
375377

@@ -404,6 +406,9 @@ engine: $(ENGINE_SONAME)
404406
$(ENGINE_SONAME): $(Engine_Objects) $(SVC_Objects) $(COMMON_LIB)
405407
$(LINK_ENGINE) -o $@ $^ $(LINK_ENGINE_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/$(EngineSoName))
406408

409+
$(ENGINE_TEST): $(Engine_Objects) $(Engine_Test_Objects) $(SVC_Objects) $(COMMON_LIB)
410+
$(EXE_LINK) -o $@ $^ $(EXE_LINK_OPTIONS) $(LINK_ENGINE_LIBS)
411+
407412

408413
#___________________________________________________________________________
409414
# intl support
@@ -711,6 +716,25 @@ install install-embedded silent_install package packages dist:
711716
$(MAKE) -f Makefile.install $@
712717

713718

719+
#___________________________________________________________________________
720+
# tests
721+
#
722+
723+
.PHONY: tests tests_process run_tests run_tests_process
724+
725+
tests:
726+
$(MAKE) TARGET=$(DefaultTarget) tests_process
727+
728+
tests_process: $(COMMON_TEST) $(ENGINE_TEST)
729+
730+
run_tests:
731+
$(MAKE) TARGET=$(DefaultTarget) run_tests_process
732+
733+
run_tests_process: tests_process
734+
$(COMMON_TEST) --log_level=all
735+
$(ENGINE_TEST) --log_level=all
736+
737+
714738
#___________________________________________________________________________
715739
# various cleaning
716740
#

builds/posix/make.defaults

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ RE2_BUILD_FLG=@RE2_BUILD@
5353
SYSTEM_BOOST_FLG=@SYSTEM_BOOST@
5454

5555
FB_BUILD=$(GEN_ROOT)/$(TARGET)/firebird
56+
5657
ifeq ($(IsCross), Y)
5758
FIREBIRD=$(GEN_ROOT)/Native/firebird
5859
else
@@ -71,6 +72,7 @@ LIB=$(FB_BUILD)/lib
7172
BIN=$(FB_BUILD)/bin
7273
PLUGINS=$(FB_BUILD)/plugins
7374
RBIN=$(FIREBIRD)/bin
75+
FB_TESTS_DIR=$(FB_BUILD)/tests
7476

7577
# This picks up the current directory and maps it to the equivalent module
7678
# in the src and gen area.
@@ -198,7 +200,6 @@ EXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) -static-libstdc++
198200
endif
199201

200202
STATICLIB_LINK = $(AR) crus
201-
STATICEXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) -static-libstdc++
202203

203204
LINK_LIBS = @LIBS@ $(DECLIB) $(RE2LIB) $(I128LIB)
204205
SO_LINK_LIBS = @LIBS@ $(DECLIB) $(RE2LIB) $(I128LIB)
@@ -253,6 +254,7 @@ LIBFIREBIRD_BASENAME = $(LIB)/$(LibrarySoName)
253254
EngineFileName=libEngine${OdsVersion}
254255
EngineSoName=$(EngineFileName).${SHRLIB_EXT}
255256
ENGINE_SONAME = $(PLUGINS)/$(EngineSoName)
257+
ENGINE_TEST = $(FB_TESTS_DIR)/$(EngineFileName)_test$(EXEC_EXT)
256258

257259
# intl will load dynamically, and having the whole soname set with version
258260
# confuses the dynamic load process. So we only have the .$(SHRLIB_EXT) file
@@ -386,6 +388,7 @@ LINK_PLUG_LIBS = -L$(LIB) $(SO_LINK_LIBS)
386388
# Pay attention - we place common library into obj, not lib dir
387389
# It's just a set of object files, prepared to be used by ld, not an output library
388390
COMMON_LIB = $(OBJ)/common.a
391+
COMMON_TEST = $(FB_TESTS_DIR)/common_test$(EXEC_EXT)
389392

390393
# From utilities
391394
CREATE_DB = $(RBIN)/create_db$(EXEC_EXT)

builds/posix/make.rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
# Please don't use compiler/platform specific flags here - nmcc 02-Nov-2002
3535
WFLAGS =-I$(SRC_ROOT)/include/gen -I$(SRC_ROOT)/include $(CPPFLAGS) $(LTCSOURCE)
3636

37+
ifneq ($(SYSTEM_BOOST_FLG),Y)
38+
WFLAGS += -I$(ROOT)/extern/boost
39+
endif
40+
3741
ifeq ($(TOMMATH_BUILD_FLG),Y)
3842
WFLAGS += -I$(TOMMATH_INC)
3943
endif

builds/posix/make.shared.variables

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ Common_Objects:= $(CO1) $(CO2) $(CO3) $(CO4)
3636

3737
AllObjects += $(Common_Objects)
3838

39+
# Common test files
40+
COT1:= $(call dirObjects,common/tests)
41+
COT2:= $(call dirObjects,common/classes/tests)
42+
Common_Test_Objects:= $(COT1) $(COT2) $(call makeObjects,yvalve,gds.cpp)
43+
44+
AllObjects += $(Common_Test_Objects)
45+
3946

4047
# gpre
4148
GPRE_Common_Objects:= $(call dirObjects,gpre) $(call makeObjects,gpre/languages,@GPRE_LANGUAGE_MODULES@)
@@ -80,7 +87,9 @@ Engine_Objects:= $(call dirObjects,jrd) $(call dirObjects,dsql) $(call dirObject
8087
$(call dirObjects,jrd/optimizer) $(call dirObjects,jrd/recsrc) $(call dirObjects,jrd/replication) $(call dirObjects,jrd/trace) \
8188
$(call makeObjects,lock,lock.cpp)
8289

83-
AllObjects += $(Engine_Objects)
90+
Engine_Test_Objects:= $(call dirObjects,jrd/tests)
91+
92+
AllObjects += $(Engine_Objects) $(Engine_Test_Objects)
8493

8594

8695
# services

builds/win32/make_all.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if errorlevel 1 call :ERROR build failed - see make_all_%FB_TARGET_PLATFORM%.log
5252
@mkdir %FB_OUTPUT_DIR%\plugins\udr 2>nul
5353

5454
@copy %FB_ROOT_PATH%\temp\%FB_OBJ_DIR%\firebird\* %FB_OUTPUT_DIR% >nul
55+
@del %FB_OUTPUT_DIR%\*_test.exe >nul
5556
@copy %FB_ROOT_PATH%\temp\%FB_OBJ_DIR%\firebird\intl\* %FB_OUTPUT_DIR%\intl >nul
5657
@copy %FB_ROOT_PATH%\temp\%FB_OBJ_DIR%\firebird\tzdata\* %FB_OUTPUT_DIR%\tzdata >nul
5758
@copy %FB_ROOT_PATH%\temp\%FB_OBJ_DIR%\firebird\system32\* %FB_OUTPUT_DIR%\system32 >nul

builds/win32/make_boot.bat

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ if "%ERRLEV%"=="1" goto :END
105105
@call :msgs
106106
if "%ERRLEV%"=="1" goto :END
107107

108-
@call :codes
109-
if "%ERRLEV%"=="1" goto :END
110-
111108
::=======
112109
@call create_msgs.bat msg
113110
::=======
@@ -231,8 +228,8 @@ goto :EOF
231228
:engine
232229
@echo.
233230
@echo Building engine (%FB_OBJ_DIR%)...
234-
@call compile.bat builds\win32\%VS_VER%\Firebird engine_%FB_TARGET_PLATFORM%.log engine
235-
@call compile.bat builds\win32\%VS_VER%\Firebird engine_%FB_TARGET_PLATFORM%.log ib_util
231+
@call compile.bat builds\win32\%VS_VER%\Firebird engine_%FB_TARGET_PLATFORM%.log DLLs\engine
232+
@call compile.bat builds\win32\%VS_VER%\Firebird engine_%FB_TARGET_PLATFORM%.log DLLs\ib_util
236233
if errorlevel 1 call :boot2 engine
237234
@goto :EOF
238235

@@ -241,7 +238,7 @@ if errorlevel 1 call :boot2 engine
241238
:gbak
242239
@echo.
243240
@echo Building gbak (%FB_OBJ_DIR%)...
244-
@call compile.bat builds\win32\%VS_VER%\Firebird gbak_%FB_TARGET_PLATFORM%.log gbak
241+
@call compile.bat builds\win32\%VS_VER%\Firebird gbak_%FB_TARGET_PLATFORM%.log EXEs\gbak
245242
if errorlevel 1 call :boot2 gbak
246243
@goto :EOF
247244

@@ -250,7 +247,7 @@ if errorlevel 1 call :boot2 gbak
250247
:gpre
251248
@echo.
252249
@echo Building gpre (%FB_OBJ_DIR%)...
253-
@call compile.bat builds\win32\%VS_VER%\Firebird gpre_%FB_TARGET_PLATFORM%.log gpre
250+
@call compile.bat builds\win32\%VS_VER%\Firebird gpre_%FB_TARGET_PLATFORM%.log EXEs\gpre
254251
if errorlevel 1 call :boot2 gpre
255252
@goto :EOF
256253

@@ -259,7 +256,7 @@ if errorlevel 1 call :boot2 gpre
259256
:isql
260257
@echo.
261258
@echo Building isql (%FB_OBJ_DIR%)...
262-
@call compile.bat builds\win32\%VS_VER%\Firebird isql_%FB_TARGET_PLATFORM%.log isql
259+
@call compile.bat builds\win32\%VS_VER%\Firebird isql_%FB_TARGET_PLATFORM%.log EXEs\isql
263260
if errorlevel 1 call :boot2 isql
264261
@goto :EOF
265262

@@ -299,10 +296,6 @@ goto :EOF
299296
@"%FB_BIN_DIR%\isql" -q %FB_GEN_DB_DIR%/dbs/security5.fdb -i %FB_ROOT_PATH%\src\dbs\security.sql
300297
@copy %FB_GEN_DIR%\dbs\security5.fdb %FB_GEN_DIR%\dbs\security.fdb > nul
301298

302-
@echo Creating metadata.fdb...
303-
@echo create database '%FB_GEN_DB_DIR%/dbs/metadata.fdb'; | "%FB_BIN_DIR%\isql" -q -sqldialect 1
304-
@copy %FB_GEN_DIR%\dbs\metadata.fdb %FB_GEN_DIR%\dbs\yachts.lnk > nul
305-
306299
@call create_msgs.bat db
307300

308301
@goto :EOF

0 commit comments

Comments
 (0)