regression.sh.in 3.8 KB

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