#!/usr/bin/env sh source_dir=$PWD working_dir=$PWD/testing alias valgrind_emgauwa="valgrind -s $2 --log-file=$working_dir/valgrind.log" mkdir -p $working_dir cd $working_dir target_branch=$(git rev-parse --abbrev-ref HEAD) if [ -z "$EMGAUWA_CONTROLLER_EXE" ] then mkdir -p controller cd controller echo "Trying to pull or clone controller" git clone --quiet ssh://git@git.serguzim.me:3022/emgauwa/controller.git . >/dev/null 2>&1 || git pull >/dev/null || 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 -p build cd build cmake -DWIRING_PI_DEBUG=on .. >/dev/null make >/dev/null EMGAUWA_CONTROLLER_EXE=./controller fi echo "Emgauwa controller: $($EMGAUWA_CONTROLLER_EXE --version)" $EMGAUWA_CONTROLLER_EXE -c $source_dir/emgauwa-controller-testing.conf >$working_dir/controller.log 2>&1 & controller_id=$! cd $working_dir touch $working_dir/index.html cp $1 $working_dir/core valgrind_emgauwa $working_dir/core -c $source_dir/emgauwa-core-testing.conf >>$working_dir/core.log 2>&1 & core_id=$! # wait for start 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 export PYTHONPATH=$PYTHONPATH:$source_dir/tavern_utils tavern-ci --disable-warnings $source_dir/tavern_tests test_result=$? kill $core_id kill $controller_id timestamp=$(date -Iseconds) for backup_file in core.log controller.log valgrind.log emgauwa-core.sqlite; do mv $backup_file $timestamp.$backup_file ln -sf $timestamp.$backup_file latest.$backup_file done cat latest.valgrind.log exit $test_result