mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Use shfmt as formatter for shell scripts
This commit is contained in:
parent
1e11fffb03
commit
c75584406a
2
.editorconfig
Normal file
2
.editorconfig
Normal file
|
@ -0,0 +1,2 @@
|
|||
[*.sh]
|
||||
space_redirects = true
|
4
.github/workflows/style.yml
vendored
4
.github/workflows/style.yml
vendored
|
@ -23,6 +23,8 @@ jobs:
|
|||
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck 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 python3-clang libvulkan-dev glslang-tools spirv-tools -y
|
||||
rustup default stable
|
||||
pip3 install pylint
|
||||
wget -O ~/.local/bin/shfmt https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64
|
||||
chmod +x ~/.local/bin/shfmt
|
||||
git clone https://gitlab.com/Patiga/twmap.git/
|
||||
cd twmap/twmap-tools
|
||||
cargo install --locked --path=.
|
||||
|
@ -60,6 +62,8 @@ jobs:
|
|||
# fi
|
||||
- name: Shellcheck
|
||||
run: find . -type f -name '*.sh' -print0 | xargs -0 shellcheck
|
||||
- name: Shell format (shfmt)
|
||||
run: find . -type f -name '*.sh' -print0 | xargs -0 shfmt -d
|
||||
- name: Check log error case
|
||||
run: |
|
||||
if grep -Eqr '(msg|Print).*\(.*"[Ee]rror:' src/;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
command -v a2x > /dev/null 2>&1 || {
|
||||
echo >&2 "You need asciidoc installed";
|
||||
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc";
|
||||
echo >&2 "http://asciidoc.org/";
|
||||
exit 1;
|
||||
echo >&2 "You need asciidoc installed"
|
||||
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc"
|
||||
echo >&2 "http://asciidoc.org/"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -ex
|
||||
|
@ -20,4 +20,3 @@ EOF
|
|||
|
||||
a2x --doctype manpage --format manpage DDNet.adoc
|
||||
a2x --doctype manpage --format manpage DDNetServer.adoc
|
||||
|
||||
|
|
|
@ -5,18 +5,21 @@ case "$(uname -s)" in
|
|||
explorer "$APPDATA/DDNet/"
|
||||
else
|
||||
explorer "$APPDATA/Teeworlds/"
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
Darwin*)
|
||||
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
|
||||
open "$HOME/Library/Application Support/DDNet/"
|
||||
else
|
||||
open "$HOME/Library/Application Support/Teeworlds/"
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
if [ -d "$DATA_HOME/ddnet/" ]; then
|
||||
xdg-open "$DATA_HOME/ddnet/"
|
||||
else
|
||||
xdg-open "$HOME/.teeworlds/"
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -78,7 +78,6 @@ if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
|
|||
fi
|
||||
cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".apk "$_APK_BASENAME".apk
|
||||
|
||||
|
||||
if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
|
||||
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ c_headers=(assert complex ctype errno fenv float inttypes iso646 limits locale m
|
|||
c_headers_map=(cassert complex cctype cerrno cfenv cfloat cinttypes ciso646 climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctgmath ctime cwchar cwctype)
|
||||
|
||||
# Create regex dynamically from the array to match any C header
|
||||
c_headers_regex=$(IFS="|"; echo "${c_headers[*]}")
|
||||
c_headers_regex=$(printf "%s" "${c_headers[*]}" | tr ' ' '|')
|
||||
|
||||
# Find all C++ source and header files
|
||||
files=$(find ./src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) ! -path "./src/engine/external/*")
|
||||
|
|
|
@ -77,4 +77,3 @@ function compile_all_opusfile() {
|
|||
}
|
||||
|
||||
compile_all_opusfile "$1" "$2"
|
||||
|
||||
|
|
|
@ -62,4 +62,3 @@ function compile_all_sqlite3() {
|
|||
}
|
||||
|
||||
compile_all_sqlite3 "$1" "$2"
|
||||
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
arg_verbose=0
|
||||
arg_valgrind_memcheck=0
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]
|
||||
then
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]; then
|
||||
echo "usage: $(basename "$0") [OPTION..]"
|
||||
echo "description:"
|
||||
echo " Runs a simple integration test of the client and server"
|
||||
|
@ -16,11 +14,9 @@ do
|
|||
echo " --verbose|-v verbose output"
|
||||
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
|
||||
exit 0
|
||||
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
|
||||
then
|
||||
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]; then
|
||||
arg_verbose=1
|
||||
elif [ "$arg" == "--valgrind-memcheck" ]
|
||||
then
|
||||
elif [ "$arg" == "--valgrind-memcheck" ]; then
|
||||
arg_valgrind_memcheck=1
|
||||
else
|
||||
echo "Error: unknown argument '$arg'"
|
||||
|
@ -28,13 +24,11 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
if [ ! -f DDNet ]
|
||||
then
|
||||
if [ ! -f DDNet ]; then
|
||||
echo "[-] Error: client binary 'DDNet' not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f DDNet-Server ]
|
||||
then
|
||||
if [ ! -f DDNet-Server ]; then
|
||||
echo "[-] Error: server binary 'DDNet-Server' not found"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -44,30 +38,25 @@ got_killed=0
|
|||
|
||||
function kill_all() {
|
||||
# needed to fix hang fifo with additional ctrl+c
|
||||
if [ "$got_killed" == "1" ]
|
||||
then
|
||||
if [ "$got_killed" == "1" ]; then
|
||||
exit
|
||||
fi
|
||||
got_killed=1
|
||||
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
if [ "$arg_verbose" == "1" ]; then
|
||||
echo "[*] Shutting down test clients and server"
|
||||
fi
|
||||
sleep 1
|
||||
|
||||
if [[ ! -f fail_server.txt ]]
|
||||
then
|
||||
if [[ ! -f fail_server.txt ]]; then
|
||||
echo "[*] Shutting down server"
|
||||
echo "shutdown" > server.fifo
|
||||
fi
|
||||
sleep 1
|
||||
|
||||
local i
|
||||
for ((i=1;i<3;i++))
|
||||
do
|
||||
if [[ ! -f fail_client$i.txt ]]
|
||||
then
|
||||
for ((i = 1; i < 3; i++)); do
|
||||
if [[ ! -f fail_client$i.txt ]]; then
|
||||
echo "[*] Shutting down client$i"
|
||||
echo "quit" > "client$i.fifo"
|
||||
fi
|
||||
|
@ -81,8 +70,7 @@ function cleanup() {
|
|||
|
||||
trap cleanup EXIT
|
||||
|
||||
function fail()
|
||||
{
|
||||
function fail() {
|
||||
sleep 1
|
||||
tail -n2 "$1".log > fail_"$1".txt
|
||||
echo "$1 exited with code $2" >> fail_"$1".txt
|
||||
|
@ -90,7 +78,7 @@ function fail()
|
|||
}
|
||||
|
||||
# Get unused port from the system by binding to port 0 and immediately closing the socket again
|
||||
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
|
||||
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
|
||||
|
||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||
DETECT_LEAKS=0
|
||||
|
@ -113,8 +101,7 @@ function print_results() {
|
|||
return 1
|
||||
fi
|
||||
else
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
then
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"; then
|
||||
echo "[-] Error: ASAN has detected the following errors:"
|
||||
cat SAN.*
|
||||
return 1
|
||||
|
@ -153,15 +140,12 @@ function wait_for_fifo() {
|
|||
# give the server/client time to launch and create the fifo file
|
||||
# but assume after X secs that the server/client crashed before
|
||||
# being able to create the file
|
||||
while [[ ! -p "$fifo" ]]
|
||||
do
|
||||
while [[ ! -p "$fifo" ]]; do
|
||||
fails="$((fails + 1))"
|
||||
if [ "$arg_verbose" == "1" ]
|
||||
then
|
||||
if [ "$arg_verbose" == "1" ]; then
|
||||
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
|
||||
fi
|
||||
if [ "$fails" -gt "$tries" ]
|
||||
then
|
||||
if [ "$fails" -gt "$tries" ]; then
|
||||
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
|
||||
kill_all
|
||||
print_results
|
||||
|
@ -282,34 +266,29 @@ fi
|
|||
# Kill all processes first so all outputs are fully written
|
||||
kill_all
|
||||
|
||||
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log
|
||||
then
|
||||
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log; then
|
||||
touch fail_chat.txt
|
||||
echo "[-] Error: chat message not found in server log"
|
||||
fi
|
||||
|
||||
if ! grep -q 'cmdlist' client1.log || \
|
||||
! grep -q 'pause' client1.log || \
|
||||
! grep -q 'rank' client1.log || \
|
||||
! grep -q 'points' client1.log
|
||||
then
|
||||
if ! grep -q 'cmdlist' client1.log ||
|
||||
! grep -q 'pause' client1.log ||
|
||||
! grep -q 'rank' client1.log ||
|
||||
! grep -q 'points' client1.log; then
|
||||
touch fail_chatcommand.txt
|
||||
echo "[-] Error: did not find output of /cmdlist command"
|
||||
fi
|
||||
|
||||
if ! grep -q "hello from admin" server.log
|
||||
then
|
||||
if ! grep -q "hello from admin" server.log; then
|
||||
touch fail_rcon.txt
|
||||
echo "[-] Error: admin message not found in server log"
|
||||
fi
|
||||
|
||||
if ! grep -q "demo_player: Stopped playback" client1.log
|
||||
then
|
||||
if ! grep -q "demo_player: Stopped playback" client1.log; then
|
||||
touch fail_demo_server.txt
|
||||
echo "[-] Error: demo playback of server demo in client 1 was not started/finished"
|
||||
fi
|
||||
if ! grep -q "demo_player: Stopped playback" client2.log
|
||||
then
|
||||
if ! grep -q "demo_player: Stopped playback" client2.log; then
|
||||
touch fail_demo_client.txt
|
||||
echo "[-] Error: demo playback of client demo in client 2 was not started/finished"
|
||||
fi
|
||||
|
@ -324,33 +303,27 @@ player: client1 time: 168300.5 cps: 0.02 0.06 0.12 15300.14 15300.18 30600.2 306
|
|||
player: client2 time: 302.02 cps: 0.42 0.5 0.0 0.66 0.92 0.02 300.18 300.46 300.76 300.88 300.98 301.16 301.24 301.28 301.3 301.86 301.96 0.0 0.0 0.0 0.0 0.0 0.0"
|
||||
|
||||
# require at least one rank in all cases. Exact finishes only with valgrind disabled
|
||||
if [ "$ranks" == "" ]
|
||||
then
|
||||
if [ "$ranks" == "" ]; then
|
||||
touch fail_ranks.txt
|
||||
echo "[-] Error: no ranks found in database"
|
||||
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]
|
||||
then
|
||||
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]; then
|
||||
touch fail_ranks.txt
|
||||
echo "[-] Error: unexpected finish time"
|
||||
echo " expected: $expected_times"
|
||||
echo " got: $rank_time"
|
||||
fi
|
||||
|
||||
for logfile in client1.log client2.log server.log
|
||||
do
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]
|
||||
then
|
||||
for logfile in client1.log client2.log server.log; do
|
||||
if [ "$arg_valgrind_memcheck" == "1" ]; then
|
||||
break
|
||||
fi
|
||||
if [ ! -f "$logfile" ]
|
||||
then
|
||||
if [ ! -f "$logfile" ]; then
|
||||
echo "[-] Error: logfile '$logfile' not found"
|
||||
touch fail_logs.txt
|
||||
continue
|
||||
fi
|
||||
logdiff="$(diff -u <(grep -v "console: .* access for .* is now .*abled" "$logfile" | sort) <(sort "stdout_$(basename "$logfile" .log).txt"))"
|
||||
if [ "$logdiff" != "" ]
|
||||
then
|
||||
if [ "$logdiff" != "" ]; then
|
||||
echo "[-] Error: logfile '$logfile' differs from stdout"
|
||||
echo "$logdiff"
|
||||
echo "[-] Error: logfile '$logfile' differs from stdout" >> fail_logs.txt
|
||||
|
@ -358,24 +331,19 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
for stderr in ./stderr_*.txt
|
||||
do
|
||||
if [ ! -f "$stderr" ]
|
||||
then
|
||||
for stderr in ./stderr_*.txt; do
|
||||
if [ ! -f "$stderr" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "$(cat "$stderr")" == "" ]
|
||||
then
|
||||
if [ "$(cat "$stderr")" == "" ]; then
|
||||
continue
|
||||
fi
|
||||
echo "[!] Warning: $stderr"
|
||||
cat "$stderr"
|
||||
done
|
||||
|
||||
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"
|
||||
then
|
||||
for fail in fail_*
|
||||
do
|
||||
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"; then
|
||||
for fail in fail_*; do
|
||||
cat "$fail"
|
||||
done
|
||||
print_results
|
||||
|
|
|
@ -46,8 +46,7 @@ function prine_line_for_address() {
|
|||
}
|
||||
|
||||
ADDR_PC_REGEX='[0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+'
|
||||
while read -r line
|
||||
do
|
||||
while read -r line; do
|
||||
if [[ $line =~ $ADDR_PC_REGEX ]]; then
|
||||
# Check for main executable file with address information
|
||||
EXE_FILE_RELATIVE_ADDR=$(echo "$line" | grep -E -o -m 1 "\s${EXE_FILE_FILENAME_REGEX}!.*0x[0-9A-Fa-f]+" | grep -E -o "0x[0-9A-Fa-f]+" | head -1)
|
||||
|
|
Loading…
Reference in a new issue