regression.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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=$PWD
  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. check_exec $?
  61. coverage=$(find ${WORKDIR}/build -name "*.gcda" 2>/dev/null)
  62. if [ -n "$coverage" ] ; then
  63. lcov -c -d ${WORKDIR}/build -o ${WORKDIR}/cov/profile_${PROFILE_NUM}.${SUBPROFILE_NUM}.lcov >> $WORKDIR/logs/profile.${PROFILE_NUM}.${SUBPROFILE_NUM} 2>&1
  64. fi
  65. }
  66. ##################################################
  67. ABORT_ON_ERROR=0
  68. while [ $# -ne 0 ]; do
  69. case $1 in
  70. --abort-on-error)
  71. ABORT_ON_ERROR=1
  72. shift ;;
  73. --help)
  74. echo
  75. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  76. echo
  77. exit 0 ;;
  78. *)
  79. break ;;
  80. esac
  81. done
  82. if [ -z "$1" ] ; then
  83. echo "Error. Syntax $0 [ --abort-on-error ] <profile files>"
  84. exit 0
  85. fi
  86. #################################################
  87. ## Create and jump to the workdir
  88. mkdir ${WORKDIR}/build ; mkdir ${WORKDIR}/cov ; mkdir ${WORKDIR}/html ; mkdir ${WORKDIR}/logs
  89. PROFILE_NUM=0
  90. code_build=1
  91. for file in $* ; do
  92. (
  93. while read line ; do
  94. if [ "$line" == "# Build configuration" ] ; then
  95. read line
  96. SUBPROFILE_NUM=0
  97. do_build $line
  98. elif [ "$line" == "# Execution configuration" ] ; then
  99. read line
  100. if [ $code_build -eq 0 ] ; then
  101. do_test $line
  102. fi
  103. fi
  104. done
  105. ) < $file
  106. done
  107. echo $WORKDIR
  108. ### End of script
  109. coverage=$(ls ${WORKDIR}/cov/*.lcov 2>/dev/null)
  110. if [ -n "${coverage}" ] ; then
  111. genhtml --function-coverage --legend ${WORKDIR}/cov/*.lcov -o ${WORKDIR}/html -t "StarPU coverage test results" > ${WORKDIR}/logs/genhtml.log
  112. echo "The coverage report is located at : ${WORKDIR}/html"
  113. fi
  114. echo "Tests done"