mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Run unit tests with sanitizers (fixes #6205)
Also fix memory leak in Net.Ipv4AndIpv6Work Rust tests fail to link when building in san directory, works in source directory.
This commit is contained in:
parent
2847d0f6d0
commit
6691be1d90
15
.github/workflows/clang-sanitizer.yml
vendored
15
.github/workflows/clang-sanitizer.yml
vendored
|
@ -23,20 +23,17 @@ jobs:
|
|||
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev libvulkan-dev glslang-tools spirv-tools -y
|
||||
- name: Build with ASan and UBSan
|
||||
run: |
|
||||
mkdir san
|
||||
cd san
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer"
|
||||
export CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer"
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DHEADLESS_CLIENT=ON ..
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DHEADLESS_CLIENT=ON -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. .
|
||||
make -j"$(nproc)"
|
||||
- name: Run server and headless client with ASan and UBSan
|
||||
run: |
|
||||
cd san
|
||||
export UBSAN_OPTIONS=suppressions=../ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
|
||||
export UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
|
||||
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0
|
||||
export LSAN_OPTIONS=suppressions=../lsan.supp
|
||||
export LSAN_OPTIONS=suppressions=./lsan.supp
|
||||
./DDNet "cl_download_skins 0;quit" || true
|
||||
./DDNet-Server shutdown || true
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
|
@ -44,7 +41,11 @@ jobs:
|
|||
cat ./SAN.*
|
||||
exit 1
|
||||
fi
|
||||
- name: Run unit tests with ASan and UBSan
|
||||
run: |
|
||||
export UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
|
||||
cmake --build . --config Debug --target run_cxx_tests
|
||||
# Rust tests work locally, but still not in CI, even with the same directory
|
||||
- name: Run integration tests with ASan and UBSan
|
||||
run: |
|
||||
cd san
|
||||
make run_integration_tests
|
||||
|
|
|
@ -44,4 +44,7 @@ TEST(Net, Ipv4AndIpv6Work)
|
|||
Addr.port = 0;
|
||||
EXPECT_EQ(Addr, LocalhostV6);
|
||||
EXPECT_EQ(mem_comp(pData, "def", 3), 0);
|
||||
|
||||
net_udp_close(Socket1);
|
||||
net_udp_close(Socket2);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue