diff --git a/.travis.yml b/.travis.yml index e102881a4b6..1dd864313ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,8 @@ install: - time sudo apt-get install -qq libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-test-dev libcairo2-dev libfribidi-dev libpango1.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev - if [ "$CXX" = "g++" ]; then time sudo apt-get install g++-4.8; fi - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi + - if [ "$WML_TESTS" = true]; then sudo apt-get install gdb; fi +# gdb is used to generate a backtrace if a wml test crashes, this is -g option to run_wml_tests - if [ "$CHECK_UTF8" = true ]; then time sudo apt-get install -qq moreutils; fi script: - if [ "$CHECK_UTF8" = true ]; then time ./utils/travis/check_utf8.sh; fi @@ -37,7 +39,7 @@ script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" - time if [[ "$CPP_TESTS" = true ]]; then ./test; export TEST_ERROR_CODE=$?; ./utils/travis/exit_wrapper.sh $TEST_ERROR_CODE; fi - - if [[ "$WML_TESTS" = true ]]; then time ./run_wml_tests -v -t "$WML_TEST_TIME"; fi + - if [[ "$WML_TESTS" = true ]]; then time ./run_wml_tests -g -v -t "$WML_TEST_TIME"; fi after_failure: - if [ -f "errors.log" ]; then echo -e "\n*** \n*\n* Errors reported in wml unit tests, here is errors.log...\n*\n*** \n"; cat errors.log; fi - if [ "$TEST_ERROR_CODE" = 200 ]; then echo -e "\n***\n*\n* Encountered a segfault in the c++ unit test executable, attempting to get a backtrace in the remaining time...\n*\n***\n"; fi diff --git a/run_wml_tests b/run_wml_tests index 713e0d17601..fc360178566 100755 --- a/run_wml_tests +++ b/run_wml_tests @@ -16,6 +16,7 @@ usage() echo -e "\t-s\tDisable strict mode. By default, we run wesnoth with option" echo -e "\t \t'--log-strict=warning' to ensure errors result in a failed test." echo -e "\t-d\tRun wesnoth-debug binary instead of wesnoth." + echo -e "\t-g\tIf we encounter a crash, generate a backtrace using gdb. Must have gdb installed for this option." echo -e "\t-p arg\tPath to wesnoth binary. By default assume it is with this script." echo -e "\t-l arg\tLoads list of tests from the given file." echo -e "\t \tBy default, the file is wml_test_schedule." @@ -164,11 +165,18 @@ run_test() echo "$command" "2> error.log" fi $command 2> error.log - if check_errs $2 $? $1; then + error_code="$?" + if check_errs $2 $error_code $1; then FirstTest=0 #Only start using validcache flag when at least one test has passed without error handle_error_log 0 return 0 else + # If we got a code of value at least 128, and it wasn't KILL timeout, it means we segfaulted / failed assertion etc. most likely, so run gdb to get a backtrace + if [ "$GdbBacktraceMode" -eq 1 -a "$error_code" -ge 128 -a "$error_code" -ne 137 ]; then + echo -e "\n* Launching gdb for a backtrace...\n" >>error.log + gdb -q -batch -ex start -ex continue -ex bt -ex quit --args $binary $opts $extra_opts >>error.log + fi + handle_error_log 1 return 1 fi @@ -183,10 +191,11 @@ LoadFile="wml_test_schedule" BinPath="./" StrictMode=1 DebugMode=0 +GdbBacktraceMode=0 extra_opts="" basetimer=10 -while getopts ":hvwusdp:l:a:t:" Option +while getopts ":hvwusdgp:l:a:t:" Option do case $Option in h ) @@ -212,6 +221,9 @@ do d ) DebugMode=1 ;; + g ) + GdbBacktraceMode=1 + ;; p ) BinPath="$OPTARG" ;;