test.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. . "${CI_DIR}/common/build.sh"
  2. . "${CI_DIR}/common/suite.sh"
  3. submit_coverage() {
  4. if [ -n "${GCOV}" ]; then
  5. "${CI_DIR}/common/submit_coverage.sh" "$@" || echo 'codecov upload failed.'
  6. fi
  7. }
  8. print_core() {
  9. local app="$1"
  10. local core="$2"
  11. if test "$app" = quiet ; then
  12. echo "Found core $core"
  13. return 0
  14. fi
  15. echo "======= Core file $core ======="
  16. if test "${TRAVIS_OS_NAME}" = osx ; then
  17. lldb -Q -o "bt all" -f "${app}" -c "${core}"
  18. else
  19. gdb -n -batch -ex 'thread apply all bt full' "${app}" -c "${core}"
  20. fi
  21. }
  22. check_core_dumps() {
  23. local del=
  24. if test "$1" = "--delete" ; then
  25. del=1
  26. shift
  27. fi
  28. local app="${1:-${BUILD_DIR}/bin/nvim}"
  29. local cores
  30. if test "${TRAVIS_OS_NAME}" = osx ; then
  31. cores="$(find /cores/ -type f -print)"
  32. local _sudo='sudo'
  33. else
  34. cores="$(find ./ -type f -name 'core.*' -print)"
  35. local _sudo=
  36. fi
  37. if test -z "${cores}" ; then
  38. return
  39. fi
  40. local core
  41. for core in $cores; do
  42. if test "$del" = "1" ; then
  43. print_core "$app" "$core" >&2
  44. "$_sudo" rm "$core"
  45. else
  46. print_core "$app" "$core"
  47. fi
  48. done
  49. if test "$app" != quiet ; then
  50. fail 'cores' E 'Core dumps found'
  51. fi
  52. }
  53. check_logs() {
  54. # Iterate through each log to remove an useless warning.
  55. for log in $(find "${1}" -type f -name "${2}"); do
  56. sed -i "${log}" \
  57. -e '/Warning: noted but unhandled ioctl/d' \
  58. -e '/could cause spurious value errors to appear/d' \
  59. -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d'
  60. done
  61. # Now do it again, but only consider files with size > 0.
  62. local err=""
  63. for log in $(find "${1}" -type f -name "${2}" -size +0); do
  64. cat "${log}"
  65. err=1
  66. rm "${log}"
  67. done
  68. if test -n "${err}" ; then
  69. fail 'logs' E 'Runtime errors detected.'
  70. fi
  71. }
  72. valgrind_check() {
  73. check_logs "${1}" "valgrind-*"
  74. }
  75. check_sanitizer() {
  76. if test -n "${CLANG_SANITIZER}"; then
  77. check_logs "${1}" "*san.*"
  78. fi
  79. }
  80. run_unittests() {(
  81. enter_suite unittests
  82. ulimit -c unlimited || true
  83. if ! build_make unittest ; then
  84. fail 'unittests' F 'Unit tests failed'
  85. fi
  86. submit_coverage unittest
  87. check_core_dumps "$(command -v luajit)"
  88. exit_suite
  89. )}
  90. run_functionaltests() {(
  91. enter_suite functionaltests
  92. ulimit -c unlimited || true
  93. if ! build_make ${FUNCTIONALTEST}; then
  94. fail 'functionaltests' F 'Functional tests failed'
  95. fi
  96. submit_coverage functionaltest
  97. check_sanitizer "${LOG_DIR}"
  98. valgrind_check "${LOG_DIR}"
  99. check_core_dumps
  100. exit_suite
  101. )}
  102. run_oldtests() {(
  103. enter_suite oldtests
  104. ulimit -c unlimited || true
  105. if ! make oldtest; then
  106. reset
  107. fail 'oldtests' F 'Legacy tests failed'
  108. fi
  109. submit_coverage oldtest
  110. check_sanitizer "${LOG_DIR}"
  111. valgrind_check "${LOG_DIR}"
  112. check_core_dumps
  113. exit_suite
  114. )}
  115. check_runtime_files() {(
  116. set +x
  117. local test_name="$1" ; shift
  118. local message="$1" ; shift
  119. local tst="$1" ; shift
  120. cd runtime
  121. for file in $(git ls-files "$@") ; do
  122. # Check that test is not trying to work with files with spaces/etc
  123. # Prefer failing the build over using more robust construct because files
  124. # with IFS are not welcome.
  125. if ! test -e "$file" ; then
  126. fail "$test_name" E \
  127. "It appears that $file is only a part of the file name"
  128. fi
  129. if ! test "$tst" "$INSTALL_PREFIX/share/nvim/runtime/$file" ; then
  130. fail "$test_name" F "$(printf "$message" "$file")"
  131. fi
  132. done
  133. )}
  134. install_nvim() {(
  135. enter_suite 'install_nvim'
  136. if ! build_make install ; then
  137. fail 'install' E 'make install failed'
  138. exit_suite
  139. fi
  140. "${INSTALL_PREFIX}/bin/nvim" --version
  141. if ! "${INSTALL_PREFIX}/bin/nvim" -u NONE -e -c ':help' -c ':qall' ; then
  142. echo "Running ':help' in the installed nvim failed."
  143. echo "Maybe the helptags have not been generated properly."
  144. fail 'help' F 'Failed running :help'
  145. fi
  146. # Check that all runtime files were installed
  147. check_runtime_files \
  148. 'runtime-install' \
  149. 'It appears that %s is not installed.' \
  150. -e \
  151. '*.vim' '*.ps' '*.dict' '*.py' '*.tutor'
  152. # Check that some runtime files are installed and are executables
  153. check_runtime_files \
  154. 'not-exe' \
  155. 'It appears that %s is not installed or is not executable.' \
  156. -x \
  157. '*.awk' '*.sh' '*.bat'
  158. # Check that generated syntax file has function names, #5060.
  159. local genvimsynf=syntax/vim/generated.vim
  160. local gpat='syn keyword vimFuncName .*eval'
  161. if ! grep -q "$gpat" "${INSTALL_PREFIX}/share/nvim/runtime/$genvimsynf" ; then
  162. fail 'funcnames' F "It appears that $genvimsynf does not contain $gpat."
  163. fi
  164. exit_suite
  165. )}
  166. csi_clean() {
  167. find "${BUILD_DIR}/bin" -name 'test-includes-*' -delete
  168. find "${BUILD_DIR}" -name '*test-include*.o' -delete
  169. }