px4-firmware/integrationtests/run_tests.bash

80 lines
2.0 KiB
Bash
Raw Normal View History

2016-03-04 18:39:10 -04:00
#!/bin/bash
#
# Starts tests from within the container
#
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
set -e
if [ "$#" -lt 1 ]
then
echo usage: run_tests.bash firmware_src_dir
echo ""
exit 1
fi
SRC_DIR=$1
2016-04-20 12:00:22 -03:00
JOB_DIR=$SRC_DIR/..
BUILD=posix_sitl_default
2016-03-04 18:39:10 -04:00
# TODO
ROS_TEST_RESULT_DIR=/root/.ros/test_results/px4
ROS_LOG_DIR=/root/.ros/log
PX4_LOG_DIR=${SRC_DIR}/build_${BUILD}/src/firmware/posix/rootfs/fs/microsd/log
TEST_RESULT_TARGET_DIR=$JOB_DIR/test_results
2016-03-04 18:39:10 -04:00
# BAGS=/root/.ros
# CHARTS=/root/.ros/charts
# EXPORT_CHARTS=/sitl/testing/export_charts.py
# source ROS env
2016-03-04 18:39:10 -04:00
source /opt/ros/indigo/setup.bash
source $SRC_DIR/integrationtests/setup_gazebo_ros.bash $SRC_DIR
2016-03-04 18:39:10 -04:00
2016-04-20 12:00:22 -03:00
echo "deleting previous test results ($TEST_RESULT_TARGET_DIR)"
2016-03-04 19:34:26 -04:00
if [ -d ${TEST_RESULT_TARGET_DIR} ]; then
rm -r ${TEST_RESULT_TARGET_DIR}
2016-03-04 18:39:10 -04:00
fi
# FIXME: Firmware compilation seems to CD into this directory (/root/Firmware)
2016-04-20 12:00:22 -03:00
# when run from "run_container.bash". Why?
if [ -d /root/Firmware ]; then
rm /root/Firmware
2016-03-04 18:39:10 -04:00
fi
ln -s ${SRC_DIR} /root/Firmware
2016-03-04 18:39:10 -04:00
echo "=====> compile ($SRC_DIR)"
2016-03-04 18:39:10 -04:00
cd $SRC_DIR
make ${BUILD}
2016-03-04 18:39:10 -04:00
mkdir -p Tools/sitl_gazebo/Build
cd Tools/sitl_gazebo/Build
cmake -Wno-dev ..
make -j4
make sdf
2016-03-04 18:39:10 -04:00
echo "<====="
# don't exit on error anymore from here on (because single tests or exports might fail)
set +e
echo "=====> run tests"
rostest px4 mavros_posix_tests_iris.launch
2016-03-04 18:39:10 -04:00
TEST_RESULT=$?
echo "<====="
# TODO
2016-03-04 19:34:26 -04:00
echo "=====> process test results"
2016-03-04 18:39:10 -04:00
# cd $BAGS
# for bag in `ls *.bag`
# do
# echo "processing bag: $bag"
# python $EXPORT_CHARTS $CHARTS $bag
# done
2016-03-04 19:34:26 -04:00
echo "copy build test results to job directory"
mkdir -p ${TEST_RESULT_TARGET_DIR}
cp -r $ROS_TEST_RESULT_DIR/* ${TEST_RESULT_TARGET_DIR}
cp -r $ROS_LOG_DIR/* ${TEST_RESULT_TARGET_DIR}
cp -r $PX4_LOG_DIR/* ${TEST_RESULT_TARGET_DIR}
2016-03-04 19:34:26 -04:00
# cp $BAGS/*.bag ${TEST_RESULT_TARGET_DIR}/
# cp -r $CHARTS ${TEST_RESULT_TARGET_DIR}/
echo "<====="
2016-03-04 18:39:10 -04:00
# need to return error if tests failed, else Jenkins won't notice the failure
exit $TEST_RESULT