Skip to content

Commit

Permalink
refactor: tools/run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Oct 23, 2024
1 parent c409b22 commit 1781a67
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 100 deletions.
36 changes: 2 additions & 34 deletions tools/run/bin/debug-check
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,10 @@
#
#
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: 3 additions & 34 deletions tools/run/bin/valgrind-check
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@
#
#
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
export QUICER_USE_SNK=1

# For log output
if [ -z "${VALGRIND_LOG_DIR}" ]; then
Expand All @@ -35,26 +26,4 @@ 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 1781a67

Please sign in to comment.