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