Skip to content

Commit 2a30650

Browse files
committed
Run unittests
Signed-off-by: yubiuser <[email protected]>
1 parent dbcf245 commit 2a30650

File tree

2 files changed

+104
-9
lines changed

2 files changed

+104
-9
lines changed

Diff for: .github/workflows/cibuild.yml

+103-9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
ENABLE_DUKTAPE: NO
3838
NO_CACHING: NO
3939
ALLOW_WARNINGS: YES
40+
RUN_UNITTEST: 1
4041

4142
- os: ubuntu-latest
4243
compiler: clang
@@ -62,6 +63,7 @@ jobs:
6263
ENABLE_DUKTAPE: NO
6364
NO_CACHING: NO
6465
ALLOW_WARNINGS: YES
66+
RUN_UNITTEST: 1
6567

6668
- os: ubuntu-latest
6769
compiler: gcc
@@ -139,6 +141,7 @@ jobs:
139141
ENABLE_DUKTAPE: NO
140142
NO_CACHING: NO
141143
ALLOW_WARNINGS: YES
144+
RUN_UNITTEST: 1
142145

143146
- os: ubuntu-latest
144147
compiler: gcc
@@ -163,6 +166,7 @@ jobs:
163166
ENABLE_DUKTAPE: NO
164167
NO_CACHING: NO
165168
ALLOW_WARNINGS: YES
169+
RUN_UNITTEST: 1
166170

167171
- os: ubuntu-latest
168172
compiler: gcc
@@ -187,6 +191,7 @@ jobs:
187191
ENABLE_DUKTAPE: NO
188192
NO_CACHING: NO
189193
ALLOW_WARNINGS: YES
194+
RUN_UNITTEST: 1
190195

191196
- os: ubuntu-latest
192197
compiler: gcc
@@ -211,6 +216,7 @@ jobs:
211216
ENABLE_DUKTAPE: NO
212217
NO_CACHING: NO
213218
ALLOW_WARNINGS: YES
219+
RUN_UNITTEST: 1
214220

215221
- os: ubuntu-latest
216222
compiler: gcc
@@ -235,6 +241,7 @@ jobs:
235241
ENABLE_DUKTAPE: NO
236242
NO_CACHING: NO
237243
ALLOW_WARNINGS: YES
244+
RUN_UNITTEST: 1
238245

239246
- os: ubuntu-latest
240247
compiler: gcc
@@ -261,8 +268,9 @@ jobs:
261268
ALLOW_WARNINGS: YES
262269
RUN_UNITTEST: 1
263270

264-
# Remove Lua build, until someone knows how to fix the CMake files
265-
# - os: ubuntu-latest
271+
# Disable Lua build, until someone knows how to fix the CMake files
272+
# see https://github.com/civetweb/civetweb/issues/543
273+
# - os: ubuntu-lastest
266274
# compiler: clang
267275
# env:
268276
# idx: 99
@@ -286,6 +294,7 @@ jobs:
286294
# ENABLE_DUKTAPE: NO
287295
# NO_CACHING: YES
288296
# ALLOW_WARNINGS: YES
297+
# RUN_UNITTEST: 1
289298

290299
- os: macos-latest
291300
compiler: clang
@@ -313,7 +322,10 @@ jobs:
313322
ALLOW_WARNINGS: YES
314323
RUN_UNITTEST: 1
315324

316-
- os: macos-latest
325+
# mac-os 13 is the last version of MacOS runner using x86_64 architecture
326+
# mac-os 14 and later are using arm64 architecture
327+
# but OpenSSL 1.0 can't compile on arm64, so we set it fixed to mac-os 13
328+
- os: macos-13
317329
compiler: clang
318330
env:
319331
idx: 11
@@ -338,6 +350,7 @@ jobs:
338350
NO_CACHING: NO
339351
ALLOW_WARNINGS: YES
340352
MACOSX_PACKAGE: 1
353+
RUN_UNITTEST: 1
341354

342355

343356
steps:
@@ -350,12 +363,38 @@ jobs:
350363
sudo apt-get install --no-install-recommends -y clang
351364
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
352365
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
366+
367+
- name: Install OpenSSL 1.0 on modern MacOS
368+
# Needed for recent versions of MacOS as they ship with OpenSSL 1.1 by default
369+
if: matrix.os == 'macos-13' && matrix.env.OPENSSL_1_0 == 'YES'
370+
run: |
371+
curl -O -L https://openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
372+
tar -xzf openssl-1.0.2u.tar.gz
373+
cd openssl-1.0.2u
374+
./Configure --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared shared darwin64-x86_64-cc
375+
#make depend
376+
make -j $(nproc)
377+
sudo make install_sw -j $(nproc)
378+
379+
OPENSSL_ROOT_DIR=/usr/local/ssl
380+
LDFLAGS=-L${OPENSSL_ROOT_DIR}/lib
381+
CFLAGS=-I${OPENSSL_ROOT_DIR}/include
382+
ADDITIONAL_CMAKE_ARGS="-DCMAKE_SHARED_LINKER_FLAGS=${LDFLAGS} -DMAKE_C_FLAGS=${CFLAGS}"
383+
PKG_CONFIG_PATH=${OPENSSL_ROOT_DIR}/lib/pkgconfig
384+
385+
echo "LDFLAGS=${LDFLAGS}" >> $GITHUB_ENV
386+
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
387+
echo "${OPENSSL_ROOT_DIR}/bin" >> $GITHUB_PATH
388+
echo "ADDITIONAL_CMAKE_ARGS=${ADDITIONAL_CMAKE_ARGS}" >> $GITHUB_ENV
389+
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV
390+
echo "DYLD_LIBRARY_PATH=${OPENSSL_ROOT_DIR}/lib" >> $GITHUB_ENV
353391
354-
- name: Set up OpenSSL 1.1 on MacOS
392+
- name: Set up OpenSSL 1.1 on modern MacOS
393+
# OpenSSL 1.1 is installed by default, so we just need to set the paths
355394
if: matrix.os == 'macos-latest' && matrix.env.OPENSSL_1_1 == 'YES'
356395
run: |
357396
OPENSSL_ROOT_DIR=$(brew --prefix [email protected])
358-
LDFLAGS=-L{$OPENSSL_ROOT_DIR}/lib
397+
LDFLAGS=-L${OPENSSL_ROOT_DIR}/lib
359398
CFLAGS=-I${OPENSSL_ROOT_DIR}/include
360399
ADDITIONAL_CMAKE_ARGS="-DCMAKE_SHARED_LINKER_FLAGS=${LDFLAGS} -DMAKE_C_FLAGS=${CFLAGS}"
361400
PKG_CONFIG_PATH=${OPENSSL_ROOT_DIR}/lib/pkgconfig
@@ -365,6 +404,44 @@ jobs:
365404
echo "${OPENSSL_ROOT_DIR}/bin" >> $GITHUB_PATH
366405
echo "ADDITIONAL_CMAKE_ARGS=${ADDITIONAL_CMAKE_ARGS}" >> $GITHUB_ENV
367406
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV
407+
408+
- name: Install OpenSSL 1.0 on modern Linux
409+
# Needed for recent versions of Linux as they ship with OpenSSL 3.0 by default
410+
if: matrix.os == 'ubuntu-latest' && matrix.env.OPENSSL_1_0 == 'YES'
411+
run: |
412+
curl -O -L https://openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
413+
tar -xzf openssl-1.0.2u.tar.gz
414+
cd openssl-1.0.2u
415+
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared
416+
make depend
417+
make -j $(nproc)
418+
sudo make install_sw -j $(nproc)
419+
sudo ldconfig
420+
421+
OPENSSL_ROOT_DIR=/usr/local/ssl
422+
LDFLAGS=-L${OPENSSL_ROOT_DIR}/lib
423+
CFLAGS=-I${OPENSSL_ROOT_DIR}/include
424+
ADDITIONAL_CMAKE_ARGS="-DCMAKE_SHARED_LINKER_FLAGS=${LDFLAGS} -DMAKE_C_FLAGS=${CFLAGS}"
425+
PKG_CONFIG_PATH=${OPENSSL_ROOT_DIR}/lib/pkgconfig
426+
427+
echo "LDFLAGS=${LDFLAGS}" >> $GITHUB_ENV
428+
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
429+
echo "${OPENSSL_ROOT_DIR}/bin" >> $GITHUB_PATH
430+
echo "ADDITIONAL_CMAKE_ARGS=${ADDITIONAL_CMAKE_ARGS}" >> $GITHUB_ENV
431+
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> $GITHUB_ENV
432+
echo "LD_LIBRARY_PATH=${OPENSSL_ROOT_DIR}/lib" >> $GITHUB_ENV
433+
434+
- name: Install OpenSSL 1.1 on modern Linux
435+
# Needed for recent versions of Linux as they ship with OpenSSL 3.0 by default
436+
if: matrix.os == 'ubuntu-latest' && matrix.env.OPENSSL_1_1 == 'YES'
437+
run: |
438+
curl -O -L https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
439+
tar -xzf openssl-1.1.1w.tar.gz
440+
cd openssl-1.1.1w
441+
./config
442+
make -j $(nproc)
443+
sudo make install_sw -j $(nproc)
444+
sudo ldconfig
368445
369446
- name: Print tool version information
370447
run: |
@@ -375,7 +452,7 @@ jobs:
375452
376453
- name: Run CMake
377454
run: |
378-
cmake -S . -B CMakeFiles\
455+
cmake -S . -B output\
379456
-DCMAKE_BUILD_TYPE=${{ matrix.env.BUILD_TYPE }}\
380457
-DBUILD_SHARED_LIBS=${{ matrix.env.BUILD_SHARED }}\
381458
-DCIVETWEB_THIRD_PARTY_DIR=../src/third-party\
@@ -403,12 +480,29 @@ jobs:
403480
- name: Build MacOS Package
404481
if: matrix.env.MACOSX_PACKAGE == 1
405482
run: |
406-
make -f Makefile.osx package
483+
make -f Makefile.osx package -j $(nproc)
407484
408485
- name: Build executable
409486
run: |
410-
cmake --build CMakeFiles -- -j $(nproc)
487+
cmake --build output -- -j $(nproc)
411488
412489
- name: Check executable
413490
run: |
414-
./CMakeFiles/src/civetweb -I
491+
./output/src/civetweb -I
492+
493+
- name: Run unit tests
494+
if: matrix.env.RUN_UNITTEST == 1
495+
run: |
496+
# kill processes that are using port 8084, which is used in the unit tests
497+
# Currently, this affects linux only, where 'mono' is using this port
498+
pid_8084=$(sudo lsof -t -i:8084 || true;)
499+
500+
if [[ -n ${pid_8084} ]]; then
501+
echo "Killing process using port 8084: ${pid_8084}"
502+
sudo kill -9 ${pid_8084}
503+
fi
504+
505+
# Run unit tests
506+
gcc unittest/cgi_test.c -o output/cgi_test.cgi
507+
cd output
508+
CTEST_OUTPUT_ON_FAILURE=1 CK_FORK=yes make all test -j $(nproc)

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ log.out
2727
/CMakeCache.txt
2828
/CMakeFiles
2929
/mingw-builds
30+
/output
3031

3132
#################
3233
## Eclipse

0 commit comments

Comments
 (0)