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
|
|
|
|
|
2016-08-05 16:29:49 -03:00
|
|
|
if [ "$#" -lt 1 ]
|
2016-04-20 11:51:58 -03:00
|
|
|
then
|
2016-08-05 16:29:49 -03:00
|
|
|
echo usage: run_tests.bash firmware_src_dir
|
|
|
|
echo ""
|
|
|
|
exit 1
|
2016-04-20 11:51:58 -03:00
|
|
|
fi
|
|
|
|
|
2016-08-05 16:29:49 -03:00
|
|
|
SRC_DIR=$1
|
|
|
|
JOB_DIR=$SRC_DIR/..
|
|
|
|
BUILD=posix_sitl_default
|
|
|
|
# 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
|
|
|
|
# BAGS=/root/.ros
|
|
|
|
# CHARTS=/root/.ros/charts
|
|
|
|
# EXPORT_CHARTS=/sitl/testing/export_charts.py
|
2016-08-05 07:23:59 -03:00
|
|
|
|
2016-08-05 16:29:49 -03:00
|
|
|
# source ROS env
|
2016-08-03 18:17:07 -03:00
|
|
|
if [ -f /opt/ros/indigo/setup.bash ]
|
|
|
|
then
|
|
|
|
source /opt/ros/indigo/setup.bash
|
2016-08-03 19:46:25 -03:00
|
|
|
elif [ -f /opt/ros/kinetic/setup.bash ]
|
|
|
|
then
|
2016-08-03 18:17:07 -03:00
|
|
|
source /opt/ros/kinetic/setup.bash
|
2016-08-03 19:46:25 -03:00
|
|
|
else
|
|
|
|
echo "could not find /opt/ros/{ros-distro}/setup.bash"
|
|
|
|
exit 1
|
2016-08-03 18:17:07 -03:00
|
|
|
fi
|
2016-08-05 16:29:49 -03:00
|
|
|
source $SRC_DIR/integrationtests/setup_gazebo_ros.bash $SRC_DIR
|
2016-03-04 18:39:10 -04:00
|
|
|
|
2016-08-05 16:29:49 -03:00
|
|
|
echo "deleting previous test results ($TEST_RESULT_TARGET_DIR)"
|
|
|
|
if [ -d ${TEST_RESULT_TARGET_DIR} ]; then
|
|
|
|
rm -r ${TEST_RESULT_TARGET_DIR}
|
|
|
|
fi
|
2016-08-05 07:23:59 -03:00
|
|
|
|
2016-08-05 16:29:49 -03:00
|
|
|
# FIXME: Firmware compilation seems to CD into this directory (/root/Firmware)
|
|
|
|
# when run from "run_container.bash". Why?
|
|
|
|
if [ -d /root/Firmware ]; then
|
|
|
|
rm /root/Firmware
|
2016-03-04 18:39:10 -04:00
|
|
|
fi
|
2016-08-05 16:29:49 -03:00
|
|
|
ln -s ${SRC_DIR} /root/Firmware
|
2016-03-04 18:39:10 -04:00
|
|
|
|
2016-04-20 11:51:58 -03:00
|
|
|
echo "=====> compile ($SRC_DIR)"
|
2016-08-05 16:29:49 -03:00
|
|
|
cd $SRC_DIR
|
|
|
|
make ${BUILD}
|
|
|
|
make --no-print-directory gazebo_build
|
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"
|
2016-04-20 11:51:58 -03:00
|
|
|
rostest px4 mavros_posix_tests_iris.launch
|
2016-06-27 19:01:53 -03:00
|
|
|
rostest px4 mavros_posix_tests_standard_vtol.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"
|
2016-08-05 16:29:49 -03:00
|
|
|
mkdir -p ${TEST_RESULT_TARGET_DIR}
|
2016-03-04 20:32:03 -04:00
|
|
|
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
|