test.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. fail() {
  2. local test_name="$1"
  3. local message="$2"
  4. : "${message:=Test $test_name failed}"
  5. local full_msg="$test_name :: $message"
  6. echo "Failed: $full_msg"
  7. export FAILED=1
  8. }
  9. print_core() {
  10. local app="$1"
  11. local core="$2"
  12. if test "$app" = quiet ; then
  13. echo "Found core $core"
  14. return 0
  15. fi
  16. echo "======= Core file $core ======="
  17. if test "${CI_OS_NAME}" = osx ; then
  18. lldb -Q -o "bt all" -f "${app}" -c "${core}"
  19. else
  20. gdb -n -batch -ex 'thread apply all bt full' "${app}" -c "${core}"
  21. fi
  22. }
  23. check_core_dumps() {
  24. local del=
  25. if test "$1" = "--delete" ; then
  26. del=1
  27. shift
  28. fi
  29. local app="${1:-${BUILD_DIR}/bin/nvim}"
  30. local cores
  31. if test "${CI_OS_NAME}" = osx ; then
  32. cores="$(find /cores/ -type f -print)"
  33. local _sudo='sudo'
  34. else
  35. cores="$(find ./ -type f \( -name 'core.*' -o -name core -o -name nvim.core \) -print)"
  36. local _sudo=
  37. fi
  38. if test -z "${cores}" ; then
  39. return
  40. fi
  41. local core
  42. for core in $cores; do
  43. if test "$del" = "1" ; then
  44. print_core "$app" "$core" >&2
  45. "$_sudo" rm "$core"
  46. else
  47. print_core "$app" "$core"
  48. fi
  49. done
  50. if test "$app" != quiet ; then
  51. fail 'cores' 'Core dumps found'
  52. fi
  53. }
  54. check_logs() {
  55. # Iterate through each log to remove a useless warning.
  56. # shellcheck disable=SC2044
  57. for log in $(find "${1}" -type f -name "${2}"); do
  58. sed -i "${log}" \
  59. -e '/Warning: noted but unhandled ioctl/d' \
  60. -e '/could cause spurious value errors to appear/d' \
  61. -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d'
  62. done
  63. # Now do it again, but only consider files with size > 0.
  64. local err=""
  65. # shellcheck disable=SC2044
  66. for log in $(find "${1}" -type f -name "${2}" -size +0); do
  67. cat "${log}"
  68. err=1
  69. rm "${log}"
  70. done
  71. if test -n "${err}" ; then
  72. fail 'logs' 'Runtime errors detected.'
  73. fi
  74. }
  75. valgrind_check() {
  76. check_logs "${1}" "valgrind-*"
  77. }
  78. check_sanitizer() {
  79. check_logs "${1}" "*san.*"
  80. }