core-legacy/tests/run_tests.sh

64 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env sh
source_dir=$PWD
working_dir=$PWD/testing_tmp
working_bak=$PWD/testing_bak
alias valgrind_emgauwa="valgrind --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--log-file=$working_dir/valgrind.log"
rm -rf $working_dir
mkdir -p $working_dir
cd $working_dir
target_branch=$(git rev-parse --abbrev-ref HEAD)
git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git controller || exit
pushd ./controller > /dev/null
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
cmake -DWIRING_PI_DEBUG=on .. >/dev/null
cp $source_dir/controller.testing.ini ./controller.ini
make >/dev/null
./controller start >$working_dir/controller.log 2>&1 &
controller_id=$!
popd > /dev/null
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=$!
sleep 2;
export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils
tavern-ci --disable-warnings $source_dir/tavern_tests
test_result=$?
kill $core_id
kill $controller_id
rm -rf $working_bak
mv $working_dir $working_bak
rm -rf $working_dir
exit $test_result