mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6207
6207: Run C++ unit tests with sanitizers (fixes #6205) r=Chairn a=def- <!-- What is the motivation for the changes of this pull request? --> <!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
21b3b3b098
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
|
||||
|
|
|
@ -2842,7 +2842,7 @@ int str_comp_filenames(const char *a, const char *b)
|
|||
return 1;
|
||||
else if(*b >= '0' && *b <= '9')
|
||||
return -1;
|
||||
else if(!(!result && *a && *b))
|
||||
else if(result || *a == '\0' || *b == '\0')
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -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