fate.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #! /bin/sh
  2. config=$1
  3. die(){
  4. echo "$@"
  5. exit 1
  6. }
  7. test -r "$config" || die "usage: fate.sh <config>"
  8. workdir=$(cd $(dirname $config) && pwd)
  9. make=make
  10. tar='tar c'
  11. . "$config"
  12. test -n "$slot" || die "slot not specified"
  13. test -n "$repo" || die "repo not specified"
  14. test -d "$samples" || die "samples location not specified"
  15. lock(){
  16. lock=$1/fate.lock
  17. (set -C; exec >$lock) 2>/dev/null || return
  18. trap 'rm $lock' EXIT
  19. }
  20. checkout(){
  21. case "$repo" in
  22. file:*|/*) src="${repo#file:}" ;;
  23. git:*) git clone "$repo" "$src" ;;
  24. esac
  25. }
  26. update()(
  27. cd ${src} || return
  28. case "$repo" in
  29. git:*) git pull --quiet ;;
  30. esac
  31. )
  32. configure()(
  33. cd ${build} || return
  34. ${shell} ${src}/configure \
  35. --prefix="${inst}" \
  36. --samples="${samples}" \
  37. --enable-gpl \
  38. --enable-memory-poisoning \
  39. ${arch:+--arch=$arch} \
  40. ${cpu:+--cpu="$cpu"} \
  41. ${cross_prefix:+--cross-prefix="$cross_prefix"} \
  42. ${cc:+--cc="$cc"} \
  43. ${ld:+--ld="$ld"} \
  44. ${target_os:+--target-os="$target_os"} \
  45. ${sysroot:+--sysroot="$sysroot"} \
  46. ${target_exec:+--target-exec="$target_exec"} \
  47. ${target_path:+--target-path="$target_path"} \
  48. ${extra_cflags:+--extra-cflags="$extra_cflags"} \
  49. ${extra_ldflags:+--extra-ldflags="$extra_ldflags"} \
  50. ${extra_libs:+--extra-libs="$extra_libs"} \
  51. ${extra_conf}
  52. )
  53. compile()(
  54. cd ${build} || return
  55. ${make} ${makeopts} && ${make} install
  56. )
  57. fate()(
  58. cd ${build} || return
  59. ${make} ${makeopts} -k fate
  60. )
  61. clean(){
  62. rm -rf ${build} ${inst}
  63. }
  64. report(){
  65. date=$(date -u +%Y%m%d%H%M%S)
  66. echo "fate:0:${date}:${slot}:${version}:$1:$2:${comment}" >report
  67. cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report
  68. test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
  69. }
  70. fail(){
  71. report "$@"
  72. clean
  73. exit
  74. }
  75. mkdir -p ${workdir} || die "Error creating ${workdir}"
  76. lock ${workdir} || die "${workdir} locked"
  77. cd ${workdir} || die "cd ${workdir} failed"
  78. src=${workdir}/src
  79. : ${build:=${workdir}/build}
  80. : ${inst:=${workdir}/install}
  81. test -d "$src" && update || checkout || die "Error fetching source"
  82. cd ${workdir}
  83. version=$(${src}/version.sh ${src})
  84. test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
  85. echo ${version} >version-$slot
  86. rm -rf "${build}" *.log
  87. mkdir -p ${build}
  88. configure >configure.log 2>&1 || fail $? "error configuring"
  89. compile >compile.log 2>&1 || fail $? "error compiling"
  90. fate >test.log 2>&1 || fail $? "error testing"
  91. report 0 success
  92. clean