Skip to content

Commit

Permalink
ci: run with more emu types (#316)
Browse files Browse the repository at this point in the history
* test: improve prop_stateful_server_conn

* refactor: tools/run scripts

* chore: add log dirs to .gitignore

* ci: run more checks

- valgrind-check
- debug-check
- sanitizer-check

[no ci]
  • Loading branch information
qzhuyan authored Oct 24, 2024
1 parent 6760a88 commit 646a206
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 110 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ jobs:
asan:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
fail-fast: false
matrix:
check:
- valgrind-check
- debug-check
- sanitizer-check
scope:
- all
- proper
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -32,10 +40,10 @@ jobs:
run: |
export PATH=$PATH:$HOME/bin/
. /home/runner/OTP/default/activate
tools/run/bin/sanitizer-check all
- name: Archive asan logs
tools/run/bin/${{ matrix.check }} ${{ matrix.scope }}
- name: Archive logs
uses: actions/upload-artifact@v3
with:
name: asan_logs
path: asan_logs
retention-days: 7
name: logs
path: *_logs
retention-days: 3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ _packages/

# test logs
asan_logs/
valgrind_logs/
coverage/
12 changes: 10 additions & 2 deletions test/prop_stateful_server_conn.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ postcondition(accepted, {call, quicer, shutdown_connection, _Args}, {error, time
true;
postcondition(accepted, {call, quicer, close_connection, _Args}, {error, closed}) ->
true;
postcondition(_, {call, quicer, shutdown_connection, [_, _, Tout]}, {error, timeout}) when
Tout < 200
->
true;
postcondition(_, {call, quicer, close_connection, [_, _, Tout]}, {error, timeout}) when
Tout < 200
->
true;
postcondition(accepted, {call, quicer, shutdown_connection, _Args}, {error, closed}) ->
true;
postcondition(
Expand Down Expand Up @@ -286,10 +294,10 @@ postcondition(_State, {call, _Mod, _Fun, _Args} = _Call, _Res) ->
next_state(State, Res, Call) ->
step_calls(do_next_state(State, Res, Call)).

do_next_state(#{state := accepted} = State, {error, _}, {call, quicer, handshake, _Args}) ->
State;
do_next_state(#{state := _} = State, {error, closed}, {call, quicer, _, _Args}) ->
State#{state := closed};
do_next_state(#{state := accepted} = State, {error, _}, {call, quicer, handshake, _Args}) ->
State;
do_next_state(#{state := accepted} = State, _Res, {call, quicer, handshake, _Args}) ->
State#{state := connected};
do_next_state(#{state := accepted} = State, _Res, {call, quicer, close_connection, _Args}) ->
Expand Down
37 changes: 2 additions & 35 deletions tools/run/bin/debug-check
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,9 @@
#
#
lib_dir=$(dirname "$(realpath "$0")")

# for compiler flag
#export QUICER_USE_SANITIZERS=1
source ${lib_dir}/lib.sh

# for using asan emulator
export ESCRIPT_EMULATOR="${lib_dir}/erl-debug"

# Since cerl returns different code:root_dir(), we need to override it here
# Erlang_OTP_ROOT_DIR will be picked up by CMakeLists.txt
export Erlang_OTP_ROOT_DIR=$(dirname $(dirname $(which erl)))

# Set ERL_TOP for Suppressions list
export ERL_TOP=$(cerl -noshell -eval "io:format(\"~s\", [code:root_dir()])" -s erlang halt)

export QUICER_USE_SNK=1

REBAR3=$(command -v rebar3)

if [ $# -eq 1 ]; then
case $1 in
all)
escript "$REBAR3" ct
;;
one_by_one)
AllTCs=$(erl -pa _build/test/lib/quicer/test/ -noshell \
-eval 'io:format("~p", [lists:flatten( string:join(lists:map(fun erlang:atom_to_list/1, quicer_SUITE:all()), " ") )]), halt()')
for tc in ${AllTCs};
do
echo "running tc $tc";
escript "$REBAR3" do ct --suite=test/quicer_SUITE --case="$tc";
done
;;
proper)
escript "$REBAR3" as test proper
;;
esac
else
escript "$REBAR3" $@
fi
do_run $@
38 changes: 38 additions & 0 deletions tools/run/bin/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env sh
export QUICER_USE_SNK=1
REBAR3=$(command -v rebar3)

# Since cerl returns different code:root_dir(), we need to override it here
# Erlang_OTP_ROOT_DIR will be picked up by CMakeLists.txt
export Erlang_OTP_ROOT_DIR=$(dirname $(dirname $(which erl)))

# Set ERL_TOP for Suppressions list
export ERL_TOP=$(cerl -noshell -eval "io:format(\"~s\", [code:root_dir()])" -s erlang halt)

do_run() {
if [ $# -lt 1 ]; then
echo "Usage: $0 <all|one_by_one|proper|...>"
exit 1
fi

case $1 in
all)
escript "$REBAR3" ct
;;
one_by_one)
AllTCs=$(erl -pa _build/test/lib/quicer/test/ -noshell \
-eval 'io:format("~p", [lists:flatten( string:join(lists:map(fun erlang:atom_to_list/1, quicer_SUITE:all()), " ") )]), halt()')
for tc in ${AllTCs};
do
echo "running tc $tc";
escript "$REBAR3" do ct --suite=test/quicer_SUITE --case="$tc";
done
;;
proper)
escript "$REBAR3" as test proper
;;
*)
escript "$REBAR3" $@
;;
esac
}
34 changes: 2 additions & 32 deletions tools/run/bin/sanitizer-check
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,19 @@
#
#
lib_dir=$(dirname "$(realpath "$0")")
source ${lib_dir}/lib.sh

# for compiler flag
export QUICER_USE_SANITIZERS=1

# for using asan emulator
export ESCRIPT_EMULATOR="${lib_dir}/erl-asan"

# Since cerl returns different code:root_dir(), we need to override it here
# Erlang_OTP_ROOT_DIR will be picked up by CMakeLists.txt
export Erlang_OTP_ROOT_DIR=$(dirname $(dirname $(which erl)))

# Set ERL_TOP for Suppressions list
export ERL_TOP=$(cerl -noshell -eval "io:format(\"~s\", [code:root_dir()])" -s erlang halt)

export QUICER_USE_SNK=1

# For asan log output
if [ -z "${ASAN_LOG_DIR}" ]; then
export ASAN_LOG_DIR=${PWD}/asan_logs
fi

mkdir -p "${ASAN_LOG_DIR}"

REBAR3=$(command -v rebar3)

if [ $# -eq 1 ]; then
case $1 in
all)
escript "$REBAR3" ct
;;
one_by_one)
AllTCs=$(erl -pa _build/test/lib/quicer/test/ -noshell \
-eval 'io:format("~p", [lists:flatten( string:join(lists:map(fun erlang:atom_to_list/1, quicer_SUITE:all()), " ") )]), halt()')
for tc in ${AllTCs};
do
echo "running tc $tc";
escript "$REBAR3" do ct --suite=test/quicer_SUITE --case="$tc";
done
;;
proper)
escript "$REBAR3" as test proper
;;
esac
else
escript "$REBAR3" $@
fi
do_run $@
37 changes: 2 additions & 35 deletions tools/run/bin/valgrind-check
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,16 @@
#
#
lib_dir=$(dirname "$(realpath "$0")")

# for compiler flag
export QUICER_USE_SANITIZERS=1
source "${lib_dir}/lib.sh"

# for using asan emulator
export ESCRIPT_EMULATOR="${lib_dir}/erl-valgrind"

# Since cerl returns different code:root_dir(), we need to override it here
# Erlang_OTP_ROOT_DIR will be picked up by CMakeLists.txt
export Erlang_OTP_ROOT_DIR=$(dirname $(dirname $(which erl)))

# Set ERL_TOP for Suppressions list
export ERL_TOP=$(cerl -noshell -eval "io:format(\"~s\", [code:root_dir()])" -s erlang halt)

#export QUICER_USE_SNK=1

# For log output
if [ -z "${VALGRIND_LOG_DIR}" ]; then
export VALGRIND_LOG_DIR=${PWD}/valgrind_logs
fi

mkdir -p "${VALGRIND_LOG_DIR}"

REBAR3=$(command -v rebar3)

if [ $# -eq 1 ]; then
case $1 in
all)
escript "$REBAR3" ct
;;
one_by_one)
AllTCs=$(erl -pa _build/test/lib/quicer/test/ -noshell \
-eval 'io:format("~p", [lists:flatten( string:join(lists:map(fun erlang:atom_to_list/1, quicer_SUITE:all()), " ") )]), halt()')
for tc in ${AllTCs};
do
echo "running tc $tc";
escript "$REBAR3" do ct --suite=test/quicer_SUITE --case="$tc";
done
;;
proper)
escript "$REBAR3" as test proper
;;
esac
else
escript "$REBAR3" $@
fi
do_run $@

0 comments on commit 646a206

Please sign in to comment.