mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Add valgrind to integration test
This commit is contained in:
parent
0648f22d7a
commit
b3d8e05e00
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
|
@ -58,7 +58,7 @@ jobs:
|
|||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get upgrade -y
|
||||
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libvulkan-dev glslang-tools spirv-tools libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev -y
|
||||
sudo apt-get install pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libvulkan-dev glslang-tools spirv-tools libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev valgrind -y
|
||||
|
||||
- name: Prepare Linux (non-fancy)
|
||||
if: ${{ contains(matrix.os, 'ubuntu') && !matrix.fancy }}
|
||||
|
@ -165,6 +165,7 @@ jobs:
|
|||
run: |
|
||||
cd fancy
|
||||
${{ matrix.cmake-path }}cmake --build . --config RelWithDebInfo --target run_tests ${{ matrix.build-args }}
|
||||
|
||||
- name: Run fancy server
|
||||
if: matrix.fancy
|
||||
env: ${{ matrix.env }}
|
||||
|
@ -172,6 +173,11 @@ jobs:
|
|||
cd fancy
|
||||
./DDNet-Server shutdown
|
||||
|
||||
- name: Run integration tests with Valgrind's Memcheck
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
scripts/integration_test.sh --valgrind-memcheck headless
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
cd release
|
||||
|
|
2
.github/workflows/clang-sanitizer.yml
vendored
2
.github/workflows/clang-sanitizer.yml
vendored
|
@ -45,4 +45,4 @@ jobs:
|
|||
fi
|
||||
- name: Run integration tests with ASan and UBSan
|
||||
run: |
|
||||
./scripts/integration_test.sh san
|
||||
scripts/integration_test.sh san
|
||||
|
|
20
memcheck.supp
Normal file
20
memcheck.supp
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
Motd
|
||||
Memcheck:Cond
|
||||
fun:_ZN7IServer11SendPackMsgI15CNetMsg_Sv_MotdLi0EEEiPT_ii
|
||||
fun:_ZN12CGameContext8SendMotdEi
|
||||
fun:_ZN12CGameContext25ConchainSpecialMotdupdateEPN8IConsole7IResultEPvPFvS2_S3_ES3_
|
||||
fun:_ZN8CConsole9Con_ChainEPN8IConsole7IResultEPv
|
||||
fun:_ZN8CConsole18ExecuteLineStrokedEiPKcib
|
||||
fun:_ZN8CConsole11ExecuteLineEPKcib
|
||||
fun:_ZN8CConsole11ExecuteFileEPKcibi
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
DemoRecorderWrite
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
...
|
||||
fun:_ZN13CDemoRecorder5WriteEiPKvi
|
||||
...
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -f ./scripts/integration_test.sh ] || [ ! -f CMakeLists.txt ]
|
||||
if [ ! -f scripts/integration_test.sh ] || [ ! -f CMakeLists.txt ]
|
||||
then
|
||||
echo "Error: make sure your are in the root of the repo"
|
||||
exit 1
|
||||
|
@ -9,6 +9,7 @@ fi
|
|||
arg_build_dir="build"
|
||||
arg_end_args=0
|
||||
arg_verbose=0
|
||||
arg_valgrind_memcheck=0
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
|
@ -26,6 +27,9 @@ do
|
|||
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
|
||||
then
|
||||
arg_verbose=1
|
||||
elif [ "$arg" == "--valgrind-memcheck" ]
|
||||
then
|
||||
arg_valgrind_memcheck=1
|
||||
elif [ "$arg" == "--" ]
|
||||
then
|
||||
arg_end_args=1
|
||||
|
@ -58,26 +62,28 @@ cp "$arg_build_dir"/DDNet* integration_test
|
|||
|
||||
cd integration_test || exit 1
|
||||
|
||||
got_killed=0
|
||||
|
||||
function kill_all() {
|
||||
# needed to fix hang fifo with additional ctrl+c
|
||||
if [ "$got_killed" == "1" ]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
got_killed=1
|
||||
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
echo "[*] shutting down test clients and server ..."
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
echo "shutdown" > server.fifo
|
||||
echo "quit" > client1.fifo
|
||||
echo "quit" > client2.fifo
|
||||
}
|
||||
|
||||
got_cleanup=0
|
||||
|
||||
function cleanup() {
|
||||
# needed to fix hang fifo with additional ctrl+c
|
||||
if [ "$got_cleanup" == "1" ]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
got_cleanup=1
|
||||
kill_all
|
||||
}
|
||||
|
||||
|
@ -108,7 +114,7 @@ then
|
|||
fi
|
||||
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"
|
||||
then
|
||||
rm ./fail_*
|
||||
rm fail_*
|
||||
fi
|
||||
if [ -f ddnet-server.sqlite ]
|
||||
then
|
||||
|
@ -119,67 +125,97 @@ fi
|
|||
port=17822
|
||||
|
||||
cp ../ubsan.supp .
|
||||
cp ../memcheck.supp .
|
||||
|
||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||
DETECT_LEAKS=0
|
||||
DETECT_LEAKS=0
|
||||
else
|
||||
DETECT_LEAKS=1
|
||||
DETECT_LEAKS=1
|
||||
fi
|
||||
|
||||
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=$DETECT_LEAKS:halt_on_errors=0
|
||||
|
||||
function print_san() {
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
then
|
||||
cat ./SAN.*
|
||||
return 1
|
||||
function print_results() {
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
if grep "ERROR SUMMARY" server.log client1.log client2.log | grep -q -v "ERROR SUMMARY: 0"; then
|
||||
grep "^==" server.log client1.log client2.log
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
then
|
||||
cat SAN.*
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
tool="valgrind --tool=memcheck --gen-suppressions=all --suppressions=memcheck.supp"
|
||||
client_args="cl_menu_map \"\";"
|
||||
else
|
||||
tool=""
|
||||
client_args=""
|
||||
fi
|
||||
|
||||
./DDNet-Server \
|
||||
$tool ./DDNet-Server \
|
||||
"sv_input_fifo server.fifo;
|
||||
sv_map coverage;
|
||||
sv_sqlite_file ddnet-server.sqlite;
|
||||
sv_port $port" &> server.log || fail server "$?" &
|
||||
|
||||
./DDNet \
|
||||
$tool ./DDNet \
|
||||
"cl_input_fifo client1.fifo;
|
||||
player_name client1;
|
||||
cl_download_skins 0;
|
||||
$client_args
|
||||
connect localhost:$port" &> client1.log || fail client1 "$?" &
|
||||
|
||||
sleep 0.5
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
sleep 10
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
./DDNet \
|
||||
$tool ./DDNet \
|
||||
"cl_input_fifo client2.fifo;
|
||||
player_name client2;
|
||||
cl_download_skins 0;
|
||||
$client_args
|
||||
connect localhost:$port" &> client2.log || fail client2 "$?" &
|
||||
|
||||
fails=0
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
tries=120
|
||||
else
|
||||
tries=2
|
||||
fi
|
||||
# give the client time to launch and create the fifo file
|
||||
# but assume after 3 secs that the client crashed before
|
||||
# but assume after X secs that the client crashed before
|
||||
# being able to create the file
|
||||
while [[ ! -p client1.fifo ]]
|
||||
while [[ ! -p client1.fifo || ! -p client2.fifo ]]
|
||||
do
|
||||
fails="$((fails+1))"
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
echo "[!] client fifo not found (attempts $fails/3)"
|
||||
echo "[!] client fifos not found (attempts $fails/$tries)"
|
||||
fi
|
||||
if [ "$fails" -gt "2" ]
|
||||
if [ "$fails" -gt "$tries" ]
|
||||
then
|
||||
print_san
|
||||
print_results
|
||||
echo "[-] Error: client possibly crashed on launch"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 2
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
sleep 20
|
||||
else
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
kill_all
|
||||
wait
|
||||
|
@ -207,16 +243,16 @@ if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"
|
|||
then
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
for fail in ./fail_*
|
||||
for fail in fail_*
|
||||
do
|
||||
cat "$fail"
|
||||
done
|
||||
fi
|
||||
print_san
|
||||
print_results
|
||||
echo "[-] Test failed. See errors above."
|
||||
exit 1
|
||||
else
|
||||
echo "[*] all tests passed"
|
||||
fi
|
||||
|
||||
print_san || exit 1
|
||||
print_results || exit 1
|
||||
|
|
Loading…
Reference in a new issue