From 8d99de5eb52f4b830d434d4cb28bf2d4e9561a84 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Mar 2014 07:06:45 +1100 Subject: [PATCH] autotest: use xterm by default and only use make clean if needed --- Tools/autotest/run_in_terminal_window.sh | 25 +++++++++++ Tools/autotest/sim_arduplane.sh | 56 ++++++++++++++---------- 2 files changed, 57 insertions(+), 24 deletions(-) create mode 100755 Tools/autotest/run_in_terminal_window.sh diff --git a/Tools/autotest/run_in_terminal_window.sh b/Tools/autotest/run_in_terminal_window.sh new file mode 100755 index 0000000000..625551427a --- /dev/null +++ b/Tools/autotest/run_in_terminal_window.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Try to run a command in an appropriate type of terminal window +# depending on whats available +# Sigh: theres no common way of handling command line args :-( +function run_in_terminal_window() +{ + name="$1" + shift + echo "Starting $name : $*" + # default to xterm as it has the most consistent options and can start minimised + if [ -x /usr/bin/xterm ]; then + /usr/bin/xterm -iconic -n "$name" -name "$name" -T "$name" -hold -e $* & + elif [ -x /usr/bin/konsole ]; then + /usr/bin/konsole --hold -e $* + elif [ -x /usr/bin/gnome-terminal ]; then + /usr/bin/gnome-terminal -e "$*" + else + echo "ERROR: Please install xterm" + exit 1 + fi +} + +run_in_terminal_window $* +exit 0 diff --git a/Tools/autotest/sim_arduplane.sh b/Tools/autotest/sim_arduplane.sh index 5ac2345088..0594b4c52a 100755 --- a/Tools/autotest/sim_arduplane.sh +++ b/Tools/autotest/sim_arduplane.sh @@ -5,23 +5,9 @@ SIMHOME="-35.363261,149.165230,584,353" # check the instance number to allow for multiple copies of the sim running at once INSTANCE=0 - -# Try to run a command in an appropriate type of terminal window -# depending on whats available -# Sigh: theres no common way of handling command line args :-( -function run_in_terminal_window() -{ - if [ -x /usr/bin/konsole ]; then - /usr/bin/konsole --hold -e $* - elif [ -x /usr/bin/gnome-terminal ]; then - /usr/bin/gnome-terminal -e "$*" - elif [ -x /usr/bin/xterm ]; then - /usr/bin/xterm -hold -e $* & - else - # out of options: run in the background - $* & - fi -} +USE_VALGRIND=0 +USE_GDB=0 +CLEAN_BUILD=0 # parse options. Thanks to http://wiki.bash-hackers.org/howto/getopts_tutorial while getopts ":I:" opt; do @@ -29,6 +15,15 @@ while getopts ":I:" opt; do I) INSTANCE=$OPTARG ;; + V) + USE_VALGRIND=1 + ;; + G) + USE_GDB=1 + ;; + c) + CLEAN_BUILD=1 + ;; \?) # allow other args to pass on to mavproxy break @@ -58,16 +53,29 @@ set -x autotest=$(dirname $(readlink -e $0)) pushd $autotest/../../ArduPlane -make clean sitl +if [ $CLEAN_BUILD == 1 ]; then + make clean +fi +make sitl -j4 || { + make clean + make sitl -j4 +} + +cmd="/tmp/ArduPlane.build/ArduPlane.elf -I$INSTANCE" + +if [ $USE_VALGRIND == 1 ]; then + $autotest/run_in_terminal_window.sh "ardupilot (valgrind)" valgrind -q $cmd || exit 1 +elif [ $USE_GDB == 1 ]; then + tfile=$(mktemp) + echo r > $tfile + $autotest/run_in_terminal_window.sh "ardupilot (gdb)" gdb -x $tfile --args $cmd || exit 1 +else + $autotest/run_in_terminal_window.sh "ardupilot" $cmd || exit 1 +fi -tfile=$(mktemp) -echo r > $tfile -#run_in_terminal_window gdb -x $tfile --args /tmp/ArduPlane.build/ArduPlane.elf -run_in_terminal_window /tmp/ArduPlane.build/ArduPlane.elf -I$INSTANCE -#run_in_terminal_window valgrind -q /tmp/ArduPlane.build/ArduPlane.elf sleep 2 rm -f $tfile -run_in_terminal_window ../Tools/autotest/jsbsim/runsim.py --home=$SIMHOME --simin=$SIMIN_PORT --simout=$SIMOUT_PORT --fgout=$FG_PORT +$autotest/run_in_terminal_window.sh "JSBSim" ../Tools/autotest/jsbsim/runsim.py --home=$SIMHOME --simin=$SIMIN_PORT --simout=$SIMOUT_PORT --fgout=$FG_PORT || exit 1 sleep 2 popd