regression.sh.in 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. #
  3. # StarPU
  4. # Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. #
  17. WORKDIR=`mktemp -d`
  18. SRCDIR=@STARPU_SRC_DIR@
  19. MAKE="${MAKE:-make -j3}"
  20. ##################################################
  21. # arg: returned status from the previous command
  22. check_exec()
  23. {
  24. PROFILE=$PROFILE_NUM
  25. if [ $SUBPROFILE_NUM -ne 0 ] ; then
  26. PROFILE="${PROFILE}.${SUBPROFILE_NUM}"
  27. fi
  28. if [ $1 -eq 0 ]; then
  29. echo "PASS: Profile $PROFILE"
  30. else
  31. echo "FAIL: Profile $PROFILE"
  32. if [ ${ABORT_ON_ERROR} -eq 1 ]; then
  33. echo "Aborting ..."
  34. exit 1;
  35. fi
  36. fi
  37. }
  38. do_build()
  39. {
  40. PROFILE_NUM=`expr ${PROFILE_NUM} + 1`
  41. echo ">>> Build configuration ${PROFILE_NUM}: <$@>"
  42. rm -rf ${WORKDIR}/build/*
  43. cd ${WORKDIR}/build
  44. ${SRCDIR}/configure "$@" > $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  45. cd -
  46. code_build=$?
  47. if [ $code_build -ne 0 ]; then
  48. check_exec $code_build
  49. else
  50. ${MAKE} -C ${WORKDIR}/build >> $WORKDIR/logs/profile.${PROFILE_NUM} 2>&1
  51. code_build=$?
  52. check_exec $code_build
  53. fi
  54. }
  55. do_test()
  56. {
  57. SUBPROFILE_NUM=`expr ${SUBPROFILE_NUM} + 1`
  58. echo ">>>> Execution configuration ${PROFILE_NUM}.${SUBPROFILE_NUM} : <$@>"
  59. ${MAKE} -C ${WORKDIR}/build check > $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  60. code_check=?
  61. check_exec $code_check
  62. if [ $code_check -ne 0 ] ; then
  63. grep FAIL: $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM}
  64. fi
  65. coverage=$(find ${WORKDIR}/build -name "*.gcda" 2>/dev/null)
  66. if [ -n "$coverage" ] ; then
  67. lcov -c -d ${WORKDIR}/build -o ${WORKDIR}/cov/profile_${PROFILE_NUM}.${SUBPROFILE_NUM}.lcov >> $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  68. fi
  69. }
  70. ##################################################
  71. ABORT_ON_ERROR=0
  72. while [ $# -ne 0 ]; do
  73. case $1 in
  74. --abort-on-error)
  75. ABORT_ON_ERROR=1
  76. shift ;;
  77. --help)
  78. echo
  79. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  80. echo
  81. exit 0 ;;
  82. *)
  83. break ;;
  84. esac
  85. done
  86. if [ -z "$1" ] ; then
  87. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  88. exit 0
  89. fi
  90. #################################################
  91. ## Create and jump to the workdir
  92. mkdir ${WORKDIR}/build ; mkdir ${WORKDIR}/cov ; mkdir ${WORKDIR}/html ; mkdir ${WORKDIR}/logs
  93. PROFILE_NUM=0
  94. code_build=1
  95. for file in $* ; do
  96. (
  97. while read line ; do
  98. if [ "$line" == "# Build configuration" ] ; then
  99. read line
  100. SUBPROFILE_NUM=0
  101. do_build $line
  102. elif [ "$line" == "# Execution configuration" ] ; then
  103. read line
  104. if [ $code_build -eq 0 ] ; then
  105. do_test $line
  106. fi
  107. fi
  108. done
  109. ) < $file
  110. done
  111. echo $WORKDIR
  112. ### End of script
  113. coverage=$(ls ${WORKDIR}/cov/*.lcov 2>/dev/null)
  114. if [ -n "${coverage}" ] ; then
  115. genhtml --function-coverage --legend ${WORKDIR}/cov/*.lcov -o ${WORKDIR}/html -t "StarPU coverage test results" > ${WORKDIR}/logs/genhtml.log
  116. echo "The coverage report is located at : ${WORKDIR}/html"
  117. fi
  118. echo "Tests done"