2020-05-05 20:29:04 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2020-05-10 20:37:55 +00:00
|
|
|
source_dir=$PWD
|
2020-11-11 21:55:58 +00:00
|
|
|
working_dir=$PWD/testing
|
2020-05-05 20:29:04 +00:00
|
|
|
|
2020-09-03 22:28:49 +00:00
|
|
|
alias valgrind_emgauwa="valgrind -s $2 --log-file=$working_dir/valgrind.log"
|
2020-08-14 21:18:22 +00:00
|
|
|
|
2020-05-10 20:37:55 +00:00
|
|
|
mkdir -p $working_dir
|
|
|
|
cd $working_dir
|
2020-05-05 20:29:04 +00:00
|
|
|
|
2020-06-25 23:43:08 +00:00
|
|
|
target_branch=$(git rev-parse --abbrev-ref HEAD)
|
2020-05-31 22:45:08 +00:00
|
|
|
|
2020-06-29 22:26:36 +00:00
|
|
|
if [ -z "$EMGAUWA_CONTROLLER_EXE" ]
|
|
|
|
then
|
2020-11-11 21:55:58 +00:00
|
|
|
mkdir -p controller
|
|
|
|
cd controller
|
|
|
|
|
|
|
|
git pull >/dev/null || git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git . || exit
|
2020-06-25 23:36:30 +00:00
|
|
|
|
2020-06-29 22:26:36 +00:00
|
|
|
git checkout dev >/dev/null 2>&1
|
|
|
|
git checkout $target_branch >/dev/null 2>&1
|
|
|
|
git checkout $2 >/dev/null 2>&1
|
2020-06-25 23:36:30 +00:00
|
|
|
|
2020-06-29 22:26:36 +00:00
|
|
|
echo "Building controller on branch $(git rev-parse --abbrev-ref HEAD)"
|
2020-11-11 21:55:58 +00:00
|
|
|
mkdir -p build
|
2020-06-29 22:26:36 +00:00
|
|
|
cd build
|
2020-05-10 20:37:55 +00:00
|
|
|
|
2020-06-29 22:26:36 +00:00
|
|
|
cmake -DWIRING_PI_DEBUG=on .. >/dev/null
|
|
|
|
make >/dev/null
|
|
|
|
EMGAUWA_CONTROLLER_EXE=./controller
|
|
|
|
fi
|
2020-05-31 22:45:08 +00:00
|
|
|
|
2020-06-29 23:25:20 +00:00
|
|
|
echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)"
|
|
|
|
|
2020-11-04 22:03:05 +00:00
|
|
|
$EMGAUWA_CONTROLLER_EXE start -c $source_dir/emgauwa-controller-testing.ini >$working_dir/controller.log 2>&1 &
|
2020-05-10 20:37:55 +00:00
|
|
|
controller_id=$!
|
|
|
|
|
2020-06-29 22:26:36 +00:00
|
|
|
cd $working_dir
|
2020-05-31 22:45:08 +00:00
|
|
|
|
2020-08-29 07:52:49 +00:00
|
|
|
touch $working_dir/index.html
|
|
|
|
|
2020-05-10 20:37:55 +00:00
|
|
|
cp $1 $working_dir/core
|
|
|
|
|
2020-11-18 23:59:26 +00:00
|
|
|
valgrind_emgauwa $working_dir/core -c $source_dir/emgauwa-core-testing.conf >>$working_dir/core.log 2>&1 &
|
2020-05-05 20:29:04 +00:00
|
|
|
core_id=$!
|
|
|
|
|
2020-05-31 22:45:08 +00:00
|
|
|
|
2020-08-14 22:00:04 +00:00
|
|
|
# wait for start
|
2020-08-21 16:38:57 +00:00
|
|
|
if [ -x "$(command -v wait-for-it)" ]
|
|
|
|
then
|
|
|
|
wait-for-it localhost:5000 -t 15
|
|
|
|
else
|
|
|
|
echo "waiting 5 seconds for server"
|
|
|
|
sleep 5;
|
|
|
|
fi
|
2020-05-31 22:45:08 +00:00
|
|
|
|
2020-05-27 22:06:03 +00:00
|
|
|
export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils
|
|
|
|
tavern-ci --disable-warnings $source_dir/tavern_tests
|
2020-05-10 20:37:55 +00:00
|
|
|
test_result=$?
|
|
|
|
|
2020-05-05 20:29:04 +00:00
|
|
|
kill $core_id
|
2020-05-10 20:37:55 +00:00
|
|
|
kill $controller_id
|
|
|
|
|
2020-11-11 21:55:58 +00:00
|
|
|
timestamp=$(date -Iseconds)
|
2020-11-17 22:13:01 +00:00
|
|
|
for backup_file in core.log controller.log valgrind.log emgauwa-core.sqlite; do
|
2020-11-11 21:55:58 +00:00
|
|
|
mv $backup_file $timestamp.$backup_file
|
|
|
|
ln -sf $timestamp.$backup_file latest.$backup_file
|
|
|
|
done
|
|
|
|
|
2020-05-10 20:37:55 +00:00
|
|
|
exit $test_result
|