Update run_tests.sh

This commit is contained in:
Tobias Reisinger 2022-07-20 00:31:28 +02:00
parent 467a98af43
commit 07aca5293e
2 changed files with 40 additions and 42 deletions

6
.gitignore vendored
View file

@ -1,6 +1,8 @@
target/ /target/
tests/testing/ /tests/testing/
/tests/testing_bak/
/tests/testing_latest/
emgauwa-core.conf.d emgauwa-core.conf.d
emgauwa-core.sqlite emgauwa-core.sqlite

View file

@ -1,54 +1,50 @@
#!/usr/bin/env sh #!/usr/bin/env sh
source_dir=$PWD source_dir=$PWD/tests
working_dir=$PWD/testing_latest working_dir=$source_dir/testing_latest
working_bak=$PWD/testing_bak working_bak=$source_dir/testing_bak
alias valgrind_emgauwa="valgrind $2 --log-file=$working_dir/valgrind.log" rm -rf "$working_bak"
[ -d "$working_dir" ] && mv "$working_dir" "$working_bak"
mkdir -p "$working_dir"
rm -rf $working_bak cp "${1:-"target/debug/emgauwa-core"}" "$working_dir/core"
[ -d $working_dir ] && mv $working_dir $working_bak
mkdir -p $working_dir cd "$working_dir" || exit
cd $working_dir
target_branch=$(git rev-parse --abbrev-ref HEAD) #target_branch=$(git rev-parse --abbrev-ref HEAD)
if [ -z "$EMGAUWA_CONTROLLER_EXE" ] #if [ -z "$EMGAUWA_CONTROLLER_EXE" ]
then #then
git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git controller || exit # git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git controller || exit
cd ./controller # cd ./controller || exit
#
# git checkout dev >/dev/null 2>&1
# git checkout "$target_branch" >/dev/null 2>&1
# git checkout "$2" >/dev/null 2>&1
#
# echo "Building controller on branch $(git rev-parse --abbrev-ref HEAD)"
# mkdir build
# cd build || exit
#
# cmake -DWIRING_PI_DEBUG=on .. >/dev/null
# make >/dev/null
# EMGAUWA_CONTROLLER_EXE=./controller
#fi
git checkout dev >/dev/null 2>&1 #echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)"
git checkout $target_branch >/dev/null 2>&1
git checkout $2 >/dev/null 2>&1
echo "Building controller on branch $(git rev-parse --abbrev-ref HEAD)" #$EMGAUWA_CONTROLLER_EXE start -c "$source_dir/controller.testing.ini" >"$working_dir/controller.log" 2>&1 &
mkdir build #controller_id=$!
cd build
cmake -DWIRING_PI_DEBUG=on .. >/dev/null cd "$working_dir" || exit
make >/dev/null
EMGAUWA_CONTROLLER_EXE=./controller
fi
echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)" EMGAUWA_CORE_EXE="$working_dir/core"
cp "$source_dir/core.testing.ini" "$working_dir/core.ini"
$EMGAUWA_CONTROLLER_EXE start -c $source_dir/controller.testing.ini >$working_dir/controller.log 2>&1 & $EMGAUWA_CORE_EXE start >>"$working_dir/core.log" 2>&1 &
controller_id=$!
cd $working_dir
cp $1 $working_dir/core
cp $source_dir/core.testing.ini $working_dir/core.ini
echo "=== invalids start (must exit) ===" >$working_dir/core.log
$working_dir/core >>$working_dir/core.log 2>&1
$working_dir/core INVALID_ACTION >>$working_dir/core.log 2>&1
echo "=== valid start ===" >>$working_dir/core.log
valgrind_emgauwa $working_dir/core start >>$working_dir/core.log 2>&1 &
core_id=$! core_id=$!
@ -62,10 +58,10 @@ else
fi fi
export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils
tavern-ci --disable-warnings $source_dir/tavern_tests tavern-ci --disable-warnings "$source_dir/tavern_tests"
test_result=$? test_result=$?
#kill $controller_id
kill $core_id kill $core_id
kill $controller_id
exit $test_result exit $test_result